@telia-ace/widget-components-tab-stop 0.0.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/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { default as TabStopComponent } from './tab-stop-component';
2
+
3
+ export default TabStopComponent;
package/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";const t=require("@telia-ace/widget-ui"),o=e=>t.createReactComponent(e,"tab-stop",Promise.resolve().then(()=>require("./tab-stop-7db5c970.js")));module.exports=o;
package/index.mjs ADDED
@@ -0,0 +1,5 @@
1
+ import { createReactComponent as o } from "@telia-ace/widget-ui";
2
+ const p = (t) => o(t, "tab-stop", import("./tab-stop-d7ffaa68.mjs"));
3
+ export {
4
+ p as default
5
+ };
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@telia-ace/widget-components-tab-stop",
3
+ "version": "0.0.1",
4
+ "main": "./index.js",
5
+ "types": "./index.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./index.mjs",
9
+ "require": "./index.js"
10
+ }
11
+ },
12
+ "dependencies": {
13
+ "@telia-ace/widget-core": "*",
14
+ "@telia-ace/widget-ui": "*",
15
+ "@telia-ace/widget-utilities": "*",
16
+ "@webprovisions/platform": "^1.1.4"
17
+ },
18
+ "peerDependencies": {
19
+ "@emotion/react": "11.11.1",
20
+ "@emotion/styled": "11.11.0",
21
+ "react": "18.2.0"
22
+ }
23
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),y=require("@emotion/styled"),f=require("@telia-ace/widget-ui"),w=require("@telia-ace/widget-utilities"),n=require("react"),x=({className:l,...p})=>{const e=n.useRef(),u=f.useContainer(),{position:r="end"}=f.useProperties(),c=n.useRef(r);n.useEffect(()=>{c.current=r},[r]);const a=t=>{const[g]=u.get("widgetDOMElements"),s=Array.from(g.querySelectorAll('.humany-tab-stop, button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"]):not(.humany-tab-stop):not([tabindex=""])')),m=s.indexOf(t.relatedTarget)<s.indexOf(t.target),o=s.filter(i=>typeof window>"u"?!0:!(window.getComputedStyle(i).display==="none"||i.offsetWidth<=0&&i.offsetHeight<=0)),d=c.current==="end"||m?o[0]:o[o.length-1];d&&d.focus()};return n.useEffect(()=>{const[t]=u.get("widgetDOMElements");return e.current&&t&&e.current.addEventListener("focus",a),()=>{e.current&&e.current.removeEventListener("focus",a)}},[]),b.jsx(E,{...p,tabIndex:0,ref:e,className:w.appendClassNames(l,"humany-tab-stop")})},E=y.div`
2
+ opacity: 0;
3
+ position: absolute;
4
+ `;exports.default=x;
@@ -0,0 +1,7 @@
1
+ import { Container } from '@webprovisions/platform';
2
+
3
+ export type TabStopComponentProps = {
4
+ position: 'start' | 'end';
5
+ };
6
+ declare const TabStopComponent: (container: Container) => Promise<void>;
7
+ export default TabStopComponent;
@@ -0,0 +1,41 @@
1
+ import { jsx as g } from "react/jsx-runtime";
2
+ import y from "@emotion/styled";
3
+ import { useContainer as x, useProperties as w } from "@telia-ace/widget-ui";
4
+ import { appendClassNames as h } from "@telia-ace/widget-utilities";
5
+ import { useRef as c, useEffect as d } from "react";
6
+ const A = ({ className: m, ...p }) => {
7
+ const t = c(), i = x(), { position: n = "end" } = w(), a = c(n);
8
+ d(() => {
9
+ a.current = n;
10
+ }, [n]);
11
+ const f = (e) => {
12
+ const [l] = i.get(
13
+ "widgetDOMElements"
14
+ ), o = Array.from(
15
+ l.querySelectorAll(
16
+ '.humany-tab-stop, button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"]):not(.humany-tab-stop):not([tabindex=""])'
17
+ )
18
+ ), b = o.indexOf(e.relatedTarget) < o.indexOf(e.target), r = o.filter((s) => typeof window > "u" ? !0 : !(window.getComputedStyle(s).display === "none" || s.offsetWidth <= 0 && s.offsetHeight <= 0)), u = a.current === "end" || b ? r[0] : r[r.length - 1];
19
+ u && u.focus();
20
+ };
21
+ return d(() => {
22
+ const [e] = i.get("widgetDOMElements");
23
+ return t.current && e && t.current.addEventListener("focus", f), () => {
24
+ t.current && t.current.removeEventListener("focus", f);
25
+ };
26
+ }, []), /* @__PURE__ */ g(
27
+ E,
28
+ {
29
+ ...p,
30
+ tabIndex: 0,
31
+ ref: t,
32
+ className: h(m, "humany-tab-stop")
33
+ }
34
+ );
35
+ }, E = y.div`
36
+ opacity: 0;
37
+ position: absolute;
38
+ `;
39
+ export {
40
+ A as default
41
+ };
package/tab-stop.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+
3
+ type Props = {
4
+ className: string;
5
+ };
6
+ declare const TabStop: React.FC<Props>;
7
+ export default TabStop;