@blakfy/accessibility-widget-react 2.0.0-alpha.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.
- package/LICENSE +21 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tarık Tunç
|
|
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,54 @@
|
|
|
1
|
+
import { Locale } from '@blakfy/a11y-core';
|
|
2
|
+
import { Position } from '@blakfy/a11y-core';
|
|
3
|
+
import { Preferences } from '@blakfy/a11y-core';
|
|
4
|
+
import { Theme } from '@blakfy/a11y-core';
|
|
5
|
+
import { WidgetOptions } from '@blakfy/a11y-core';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Mounts the Blakfy accessibility widget into the DOM.
|
|
9
|
+
* Renders nothing — the widget manages its own DOM elements.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* // app/App.tsx or main entry
|
|
14
|
+
* import { A11yWidget } from '@blakfy/accessibility-widget-react';
|
|
15
|
+
*
|
|
16
|
+
* export default function App() {
|
|
17
|
+
* return (
|
|
18
|
+
* <>
|
|
19
|
+
* <A11yWidget locale="tr" theme="auto" position="bottom-right" />
|
|
20
|
+
* <RouterOutlet />
|
|
21
|
+
* </>
|
|
22
|
+
* );
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function A11yWidget(props: A11yWidgetProps): null;
|
|
27
|
+
|
|
28
|
+
export declare type A11yWidgetProps = Partial<WidgetOptions>;
|
|
29
|
+
|
|
30
|
+
export { Locale }
|
|
31
|
+
|
|
32
|
+
export { Position }
|
|
33
|
+
|
|
34
|
+
export { Preferences }
|
|
35
|
+
|
|
36
|
+
export { Theme }
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Returns the current accessibility preferences and re-renders whenever
|
|
40
|
+
* the user changes a preference in the widget panel.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* function MyComponent() {
|
|
45
|
+
* const prefs = useA11yPreferences();
|
|
46
|
+
* return <p style={{ fontSize: prefs.fontScale === 125 ? '1.25rem' : '1rem' }}>Hello</p>;
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function useA11yPreferences(): Preferences;
|
|
51
|
+
|
|
52
|
+
export { WidgetOptions }
|
|
53
|
+
|
|
54
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useEffect as o, useState as f } from "react";
|
|
2
|
+
import { mount as i } from "@blakfy/accessibility-widget";
|
|
3
|
+
import { getPreferences as c, EVENT_NAMES as n } from "@blakfy/a11y-core";
|
|
4
|
+
function p(e) {
|
|
5
|
+
return o(() => {
|
|
6
|
+
const { unmount: r } = i(e);
|
|
7
|
+
return r;
|
|
8
|
+
}, []), null;
|
|
9
|
+
}
|
|
10
|
+
function A() {
|
|
11
|
+
const [e, r] = f(c);
|
|
12
|
+
return o(() => {
|
|
13
|
+
function t(s) {
|
|
14
|
+
const u = s.detail;
|
|
15
|
+
r(u.prefs);
|
|
16
|
+
}
|
|
17
|
+
return window.addEventListener(n.CHANGE, t), () => window.removeEventListener(n.CHANGE, t);
|
|
18
|
+
}, []), e;
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
p as A11yWidget,
|
|
22
|
+
A as useA11yPreferences
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/A11yWidget.tsx","../src/useA11yPreferences.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { mount } from '@blakfy/accessibility-widget';\nimport type { WidgetOptions } from '@blakfy/a11y-core';\n\nexport type A11yWidgetProps = Partial<WidgetOptions>;\n\n/**\n * Mounts the Blakfy accessibility widget into the DOM.\n * Renders nothing — the widget manages its own DOM elements.\n *\n * @example\n * ```tsx\n * // app/App.tsx or main entry\n * import { A11yWidget } from '@blakfy/accessibility-widget-react';\n *\n * export default function App() {\n * return (\n * <>\n * <A11yWidget locale=\"tr\" theme=\"auto\" position=\"bottom-right\" />\n * <RouterOutlet />\n * </>\n * );\n * }\n * ```\n */\nexport function A11yWidget(props: A11yWidgetProps) {\n useEffect(() => {\n const { unmount } = mount(props);\n return unmount;\n }, []);\n\n return null;\n}\n","import { useState, useEffect } from 'react';\nimport { getPreferences, EVENT_NAMES } from '@blakfy/a11y-core';\nimport type { Preferences, PreferencesRecord } from '@blakfy/a11y-core';\n\n/**\n * Returns the current accessibility preferences and re-renders whenever\n * the user changes a preference in the widget panel.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const prefs = useA11yPreferences();\n * return <p style={{ fontSize: prefs.fontScale === 125 ? '1.25rem' : '1rem' }}>Hello</p>;\n * }\n * ```\n */\nexport function useA11yPreferences(): Preferences {\n const [prefs, setPrefs] = useState<Preferences>(getPreferences);\n\n useEffect(() => {\n function handler(e: Event) {\n const record = (e as CustomEvent<PreferencesRecord>).detail;\n setPrefs(record.prefs);\n }\n window.addEventListener(EVENT_NAMES.CHANGE, handler);\n return () => window.removeEventListener(EVENT_NAMES.CHANGE, handler);\n }, []);\n\n return prefs;\n}\n"],"names":["A11yWidget","props","useEffect","unmount","mount","useA11yPreferences","prefs","setPrefs","useState","getPreferences","handler","e","record","EVENT_NAMES"],"mappings":";;;AAyBO,SAASA,EAAWC,GAAwB;AACjD,SAAAC,EAAU,MAAM;AACd,UAAM,EAAE,SAAAC,EAAA,IAAYC,EAAMH,CAAK;AAC/B,WAAOE;AAAA,EACT,GAAG,CAAA,CAAE,GAEE;AACT;AChBO,SAASE,IAAkC;AAChD,QAAM,CAACC,GAAOC,CAAQ,IAAIC,EAAsBC,CAAc;AAE9D,SAAAP,EAAU,MAAM;AACd,aAASQ,EAAQC,GAAU;AACzB,YAAMC,IAAUD,EAAqC;AACrD,MAAAJ,EAASK,EAAO,KAAK;AAAA,IACvB;AACA,kBAAO,iBAAiBC,EAAY,QAAQH,CAAO,GAC5C,MAAM,OAAO,oBAAoBG,EAAY,QAAQH,CAAO;AAAA,EACrE,GAAG,CAAA,CAAE,GAEEJ;AACT;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@blakfy/accessibility-widget-react",
|
|
3
|
+
"version": "2.0.0-alpha.10",
|
|
4
|
+
"description": "React wrapper for @blakfy/accessibility-widget — A11yWidget component and useA11yPreferences hook",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"react": ">=18.0.0"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@blakfy/a11y-core": "2.0.0-alpha.10",
|
|
23
|
+
"@blakfy/accessibility-widget": "2.0.0-alpha.10"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@testing-library/react": "^16.0.0",
|
|
27
|
+
"@types/react": "^18.3.12",
|
|
28
|
+
"jsdom": "^25.0.1",
|
|
29
|
+
"react": "^18.3.1",
|
|
30
|
+
"vite": "^5.4.10",
|
|
31
|
+
"vite-plugin-dts": "^4.3.0",
|
|
32
|
+
"vitest": "^2.1.4"
|
|
33
|
+
},
|
|
34
|
+
"keywords": [
|
|
35
|
+
"accessibility",
|
|
36
|
+
"a11y",
|
|
37
|
+
"wcag",
|
|
38
|
+
"react",
|
|
39
|
+
"hook",
|
|
40
|
+
"blakfy"
|
|
41
|
+
],
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public",
|
|
44
|
+
"provenance": true
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "vite build",
|
|
48
|
+
"dev": "vite build --watch",
|
|
49
|
+
"test": "vitest run",
|
|
50
|
+
"typecheck": "tsc --noEmit",
|
|
51
|
+
"api:check": "api-extractor run",
|
|
52
|
+
"api:update": "api-extractor run --local"
|
|
53
|
+
}
|
|
54
|
+
}
|