@epilot/spark-ui 0.30.0 → 0.30.1
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/components/autocomplete.cjs +9 -2
- package/dist/components/autocomplete.cjs.map +1 -1
- package/dist/components/autocomplete.js +10 -3
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/bubble.d.cts +1 -1
- package/dist/components/bubble.d.ts +1 -1
- package/dist/components/button.d.cts +2 -2
- package/dist/components/button.d.ts +2 -2
- package/dist/components/combobox.cjs +2 -1
- package/dist/components/combobox.cjs.map +1 -1
- package/dist/components/combobox.js +3 -2
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/field.cjs +18 -3
- package/dist/components/field.cjs.map +1 -1
- package/dist/components/field.d.cts +3 -1
- package/dist/components/field.d.ts +3 -1
- package/dist/components/field.js +18 -4
- package/dist/components/field.js.map +1 -1
- package/dist/components/info-block.d.cts +1 -1
- package/dist/components/info-block.d.ts +1 -1
- package/dist/components/input-date.cjs +11 -1
- package/dist/components/input-date.cjs.map +1 -1
- package/dist/components/input-date.js +11 -1
- package/dist/components/input-date.js.map +1 -1
- package/dist/components/input-otp.cjs +1 -0
- package/dist/components/input-otp.cjs.map +1 -1
- package/dist/components/input-otp.js +2 -1
- package/dist/components/input-otp.js.map +1 -1
- package/dist/components/marker.d.cts +1 -1
- package/dist/components/marker.d.ts +1 -1
- package/dist/components/page-header.d.cts +1 -1
- package/dist/components/page-header.d.ts +1 -1
- package/dist/components/theme.cjs +2 -0
- package/dist/components/theme.cjs.map +1 -1
- package/dist/components/theme.js +2 -0
- package/dist/components/theme.js.map +1 -1
- package/dist/hooks/use-focus-modality.cjs +55 -0
- package/dist/hooks/use-focus-modality.cjs.map +1 -0
- package/dist/hooks/use-focus-modality.d.cts +8 -0
- package/dist/hooks/use-focus-modality.d.ts +8 -0
- package/dist/hooks/use-focus-modality.js +53 -0
- package/dist/hooks/use-focus-modality.js.map +1 -0
- package/dist/styles/theme.css +45 -3
- package/package.json +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
let react = require("react");
|
|
4
|
+
//#region src/hooks/use-focus-modality.ts
|
|
5
|
+
const FOCUS_MODALITY_ATTRIBUTE = "data-spark-focus";
|
|
6
|
+
const TEXT_ENTRY_INPUT_TYPES = new Set([
|
|
7
|
+
"text",
|
|
8
|
+
"search",
|
|
9
|
+
"email",
|
|
10
|
+
"url",
|
|
11
|
+
"tel",
|
|
12
|
+
"password",
|
|
13
|
+
"number",
|
|
14
|
+
"date",
|
|
15
|
+
"datetime-local",
|
|
16
|
+
"month",
|
|
17
|
+
"week",
|
|
18
|
+
"time"
|
|
19
|
+
]);
|
|
20
|
+
function isTextEntry(target) {
|
|
21
|
+
if (!(target instanceof HTMLElement)) return false;
|
|
22
|
+
if (target instanceof HTMLTextAreaElement) return true;
|
|
23
|
+
if (target instanceof HTMLInputElement) return TEXT_ENTRY_INPUT_TYPES.has(target.type);
|
|
24
|
+
return target.isContentEditable;
|
|
25
|
+
}
|
|
26
|
+
function onPointerDown() {
|
|
27
|
+
document.documentElement.setAttribute(FOCUS_MODALITY_ATTRIBUTE, "pointer");
|
|
28
|
+
}
|
|
29
|
+
function onKeyDown(event) {
|
|
30
|
+
if (event.metaKey || event.ctrlKey || event.altKey) return;
|
|
31
|
+
if (event.key !== "Tab" && isTextEntry(event.target)) return;
|
|
32
|
+
document.documentElement.removeAttribute(FOCUS_MODALITY_ATTRIBUTE);
|
|
33
|
+
}
|
|
34
|
+
let subscribers = 0;
|
|
35
|
+
function subscribe() {
|
|
36
|
+
if (subscribers++ === 0) {
|
|
37
|
+
document.addEventListener("pointerdown", onPointerDown, true);
|
|
38
|
+
document.addEventListener("keydown", onKeyDown, true);
|
|
39
|
+
}
|
|
40
|
+
return () => {
|
|
41
|
+
if (--subscribers === 0) {
|
|
42
|
+
document.removeEventListener("pointerdown", onPointerDown, true);
|
|
43
|
+
document.removeEventListener("keydown", onKeyDown, true);
|
|
44
|
+
document.documentElement.removeAttribute(FOCUS_MODALITY_ATTRIBUTE);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function useFocusModality() {
|
|
49
|
+
(0, react.useEffect)(subscribe, []);
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
exports.FOCUS_MODALITY_ATTRIBUTE = FOCUS_MODALITY_ATTRIBUTE;
|
|
53
|
+
exports.useFocusModality = useFocusModality;
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=use-focus-modality.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-focus-modality.cjs","names":[],"sources":["../../src/hooks/use-focus-modality.ts"],"sourcesContent":["import { useEffect } from 'react'\n\nexport const FOCUS_MODALITY_ATTRIBUTE = 'data-spark-focus'\n\nconst TEXT_ENTRY_INPUT_TYPES = new Set([\n 'text',\n 'search',\n 'email',\n 'url',\n 'tel',\n 'password',\n 'number',\n 'date',\n 'datetime-local',\n 'month',\n 'week',\n 'time',\n])\n\nfunction isTextEntry(target: EventTarget | null) {\n if (!(target instanceof HTMLElement)) return false\n if (target instanceof HTMLTextAreaElement) return true\n if (target instanceof HTMLInputElement)\n return TEXT_ENTRY_INPUT_TYPES.has(target.type)\n return target.isContentEditable\n}\n\nfunction onPointerDown() {\n document.documentElement.setAttribute(FOCUS_MODALITY_ATTRIBUTE, 'pointer')\n}\n\nfunction onKeyDown(event: KeyboardEvent) {\n if (event.metaKey || event.ctrlKey || event.altKey) return\n if (event.key !== 'Tab' && isTextEntry(event.target)) return\n document.documentElement.removeAttribute(FOCUS_MODALITY_ATTRIBUTE)\n}\n\nlet subscribers = 0\n\nfunction subscribe() {\n if (subscribers++ === 0) {\n document.addEventListener('pointerdown', onPointerDown, true)\n document.addEventListener('keydown', onKeyDown, true)\n }\n return () => {\n if (--subscribers === 0) {\n document.removeEventListener('pointerdown', onPointerDown, true)\n document.removeEventListener('keydown', onKeyDown, true)\n document.documentElement.removeAttribute(FOCUS_MODALITY_ATTRIBUTE)\n }\n }\n}\n\nfunction useFocusModality() {\n useEffect(subscribe, [])\n}\n\nexport { useFocusModality }\n"],"mappings":";;;;AAEA,MAAa,2BAA2B;AAExC,MAAM,yBAAyB,IAAI,IAAI;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,YAAY,QAA4B;CAC/C,IAAI,EAAE,kBAAkB,cAAc,OAAO;CAC7C,IAAI,kBAAkB,qBAAqB,OAAO;CAClD,IAAI,kBAAkB,kBACpB,OAAO,uBAAuB,IAAI,OAAO,IAAI;CAC/C,OAAO,OAAO;AAChB;AAEA,SAAS,gBAAgB;CACvB,SAAS,gBAAgB,aAAa,0BAA0B,SAAS;AAC3E;AAEA,SAAS,UAAU,OAAsB;CACvC,IAAI,MAAM,WAAW,MAAM,WAAW,MAAM,QAAQ;CACpD,IAAI,MAAM,QAAQ,SAAS,YAAY,MAAM,MAAM,GAAG;CACtD,SAAS,gBAAgB,gBAAgB,wBAAwB;AACnE;AAEA,IAAI,cAAc;AAElB,SAAS,YAAY;CACnB,IAAI,kBAAkB,GAAG;EACvB,SAAS,iBAAiB,eAAe,eAAe,IAAI;EAC5D,SAAS,iBAAiB,WAAW,WAAW,IAAI;CACtD;CACA,aAAa;EACX,IAAI,EAAE,gBAAgB,GAAG;GACvB,SAAS,oBAAoB,eAAe,eAAe,IAAI;GAC/D,SAAS,oBAAoB,WAAW,WAAW,IAAI;GACvD,SAAS,gBAAgB,gBAAgB,wBAAwB;EACnE;CACF;AACF;AAEA,SAAS,mBAAmB;CAC1B,CAAA,GAAA,MAAA,WAAU,WAAW,CAAC,CAAC;AACzB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
//#region src/hooks/use-focus-modality.d.ts
|
|
4
|
+
declare const FOCUS_MODALITY_ATTRIBUTE = "data-spark-focus";
|
|
5
|
+
declare function useFocusModality(): void;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { FOCUS_MODALITY_ATTRIBUTE, useFocusModality };
|
|
8
|
+
//# sourceMappingURL=use-focus-modality.d.cts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
//#region src/hooks/use-focus-modality.d.ts
|
|
4
|
+
declare const FOCUS_MODALITY_ATTRIBUTE = "data-spark-focus";
|
|
5
|
+
declare function useFocusModality(): void;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { FOCUS_MODALITY_ATTRIBUTE, useFocusModality };
|
|
8
|
+
//# sourceMappingURL=use-focus-modality.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
//#region src/hooks/use-focus-modality.ts
|
|
4
|
+
const FOCUS_MODALITY_ATTRIBUTE = "data-spark-focus";
|
|
5
|
+
const TEXT_ENTRY_INPUT_TYPES = new Set([
|
|
6
|
+
"text",
|
|
7
|
+
"search",
|
|
8
|
+
"email",
|
|
9
|
+
"url",
|
|
10
|
+
"tel",
|
|
11
|
+
"password",
|
|
12
|
+
"number",
|
|
13
|
+
"date",
|
|
14
|
+
"datetime-local",
|
|
15
|
+
"month",
|
|
16
|
+
"week",
|
|
17
|
+
"time"
|
|
18
|
+
]);
|
|
19
|
+
function isTextEntry(target) {
|
|
20
|
+
if (!(target instanceof HTMLElement)) return false;
|
|
21
|
+
if (target instanceof HTMLTextAreaElement) return true;
|
|
22
|
+
if (target instanceof HTMLInputElement) return TEXT_ENTRY_INPUT_TYPES.has(target.type);
|
|
23
|
+
return target.isContentEditable;
|
|
24
|
+
}
|
|
25
|
+
function onPointerDown() {
|
|
26
|
+
document.documentElement.setAttribute(FOCUS_MODALITY_ATTRIBUTE, "pointer");
|
|
27
|
+
}
|
|
28
|
+
function onKeyDown(event) {
|
|
29
|
+
if (event.metaKey || event.ctrlKey || event.altKey) return;
|
|
30
|
+
if (event.key !== "Tab" && isTextEntry(event.target)) return;
|
|
31
|
+
document.documentElement.removeAttribute(FOCUS_MODALITY_ATTRIBUTE);
|
|
32
|
+
}
|
|
33
|
+
let subscribers = 0;
|
|
34
|
+
function subscribe() {
|
|
35
|
+
if (subscribers++ === 0) {
|
|
36
|
+
document.addEventListener("pointerdown", onPointerDown, true);
|
|
37
|
+
document.addEventListener("keydown", onKeyDown, true);
|
|
38
|
+
}
|
|
39
|
+
return () => {
|
|
40
|
+
if (--subscribers === 0) {
|
|
41
|
+
document.removeEventListener("pointerdown", onPointerDown, true);
|
|
42
|
+
document.removeEventListener("keydown", onKeyDown, true);
|
|
43
|
+
document.documentElement.removeAttribute(FOCUS_MODALITY_ATTRIBUTE);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function useFocusModality() {
|
|
48
|
+
useEffect(subscribe, []);
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { FOCUS_MODALITY_ATTRIBUTE, useFocusModality };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=use-focus-modality.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-focus-modality.js","names":[],"sources":["../../src/hooks/use-focus-modality.ts"],"sourcesContent":["import { useEffect } from 'react'\n\nexport const FOCUS_MODALITY_ATTRIBUTE = 'data-spark-focus'\n\nconst TEXT_ENTRY_INPUT_TYPES = new Set([\n 'text',\n 'search',\n 'email',\n 'url',\n 'tel',\n 'password',\n 'number',\n 'date',\n 'datetime-local',\n 'month',\n 'week',\n 'time',\n])\n\nfunction isTextEntry(target: EventTarget | null) {\n if (!(target instanceof HTMLElement)) return false\n if (target instanceof HTMLTextAreaElement) return true\n if (target instanceof HTMLInputElement)\n return TEXT_ENTRY_INPUT_TYPES.has(target.type)\n return target.isContentEditable\n}\n\nfunction onPointerDown() {\n document.documentElement.setAttribute(FOCUS_MODALITY_ATTRIBUTE, 'pointer')\n}\n\nfunction onKeyDown(event: KeyboardEvent) {\n if (event.metaKey || event.ctrlKey || event.altKey) return\n if (event.key !== 'Tab' && isTextEntry(event.target)) return\n document.documentElement.removeAttribute(FOCUS_MODALITY_ATTRIBUTE)\n}\n\nlet subscribers = 0\n\nfunction subscribe() {\n if (subscribers++ === 0) {\n document.addEventListener('pointerdown', onPointerDown, true)\n document.addEventListener('keydown', onKeyDown, true)\n }\n return () => {\n if (--subscribers === 0) {\n document.removeEventListener('pointerdown', onPointerDown, true)\n document.removeEventListener('keydown', onKeyDown, true)\n document.documentElement.removeAttribute(FOCUS_MODALITY_ATTRIBUTE)\n }\n }\n}\n\nfunction useFocusModality() {\n useEffect(subscribe, [])\n}\n\nexport { useFocusModality }\n"],"mappings":";;;AAEA,MAAa,2BAA2B;AAExC,MAAM,yBAAyB,IAAI,IAAI;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,YAAY,QAA4B;CAC/C,IAAI,EAAE,kBAAkB,cAAc,OAAO;CAC7C,IAAI,kBAAkB,qBAAqB,OAAO;CAClD,IAAI,kBAAkB,kBACpB,OAAO,uBAAuB,IAAI,OAAO,IAAI;CAC/C,OAAO,OAAO;AAChB;AAEA,SAAS,gBAAgB;CACvB,SAAS,gBAAgB,aAAa,0BAA0B,SAAS;AAC3E;AAEA,SAAS,UAAU,OAAsB;CACvC,IAAI,MAAM,WAAW,MAAM,WAAW,MAAM,QAAQ;CACpD,IAAI,MAAM,QAAQ,SAAS,YAAY,MAAM,MAAM,GAAG;CACtD,SAAS,gBAAgB,gBAAgB,wBAAwB;AACnE;AAEA,IAAI,cAAc;AAElB,SAAS,YAAY;CACnB,IAAI,kBAAkB,GAAG;EACvB,SAAS,iBAAiB,eAAe,eAAe,IAAI;EAC5D,SAAS,iBAAiB,WAAW,WAAW,IAAI;CACtD;CACA,aAAa;EACX,IAAI,EAAE,gBAAgB,GAAG;GACvB,SAAS,oBAAoB,eAAe,eAAe,IAAI;GAC/D,SAAS,oBAAoB,WAAW,WAAW,IAAI;GACvD,SAAS,gBAAgB,gBAAgB,wBAAwB;EACnE;CACF;AACF;AAEA,SAAS,mBAAmB;CAC1B,UAAU,WAAW,CAAC,CAAC;AACzB"}
|
package/dist/styles/theme.css
CHANGED
|
@@ -15,11 +15,18 @@
|
|
|
15
15
|
:is([data-slot='input'], [data-slot='textarea']):not(:placeholder-shown)
|
|
16
16
|
),
|
|
17
17
|
:has(
|
|
18
|
-
:is([data-slot='input'], [data-slot='textarea']):not(
|
|
18
|
+
:is([data-slot='input'], [data-slot='textarea']):not(
|
|
19
|
+
[placeholder=' '],
|
|
20
|
+
[data-focus-placeholder]
|
|
21
|
+
)
|
|
19
22
|
),
|
|
20
23
|
:has(:is([data-slot='input'], [data-slot='textarea']):autofill),
|
|
21
|
-
:has(
|
|
22
|
-
|
|
24
|
+
:has(
|
|
25
|
+
:is([data-slot='select-trigger'], [data-slot='combobox-trigger']):not(
|
|
26
|
+
[data-placeholder]
|
|
27
|
+
)
|
|
28
|
+
),
|
|
29
|
+
:has([data-popup-open])
|
|
23
30
|
)
|
|
24
31
|
& {
|
|
25
32
|
@slot;
|
|
@@ -623,6 +630,41 @@
|
|
|
623
630
|
}
|
|
624
631
|
}
|
|
625
632
|
|
|
633
|
+
:root[data-spark-focus='pointer']
|
|
634
|
+
:is(
|
|
635
|
+
input:not(
|
|
636
|
+
[type='checkbox'],
|
|
637
|
+
[type='radio'],
|
|
638
|
+
[type='range'],
|
|
639
|
+
[type='button'],
|
|
640
|
+
[type='submit'],
|
|
641
|
+
[type='reset'],
|
|
642
|
+
[type='color'],
|
|
643
|
+
[type='file']
|
|
644
|
+
),
|
|
645
|
+
textarea,
|
|
646
|
+
[contenteditable]
|
|
647
|
+
):focus-visible,
|
|
648
|
+
:root[data-spark-focus='pointer']
|
|
649
|
+
:is([data-slot='input-group'], [data-slot='field']):has(
|
|
650
|
+
:is(
|
|
651
|
+
input:not(
|
|
652
|
+
[type='checkbox'],
|
|
653
|
+
[type='radio'],
|
|
654
|
+
[type='range'],
|
|
655
|
+
[type='button'],
|
|
656
|
+
[type='submit'],
|
|
657
|
+
[type='reset'],
|
|
658
|
+
[type='color'],
|
|
659
|
+
[type='file']
|
|
660
|
+
),
|
|
661
|
+
textarea,
|
|
662
|
+
[contenteditable]
|
|
663
|
+
):focus-visible
|
|
664
|
+
) {
|
|
665
|
+
outline: none;
|
|
666
|
+
}
|
|
667
|
+
|
|
626
668
|
/* The focus indicator, for wrappers that draw it when focus lands on an inner control (contract §12). */
|
|
627
669
|
@utility focus-outline {
|
|
628
670
|
outline: 2px solid var(--color-focus-root);
|