@telia-ace/widget-components-tab-stop 1.0.13 → 1.0.14
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/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/tab-stop.403c4dee.js +53 -0
- package/dist/tab-stop.403c4dee.js.map +1 -0
- package/package.json +8 -5
- package/dist/tab-stop.js +0 -85
- package/dist/tab-stop.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createReactComponent } from "@telia-ace/widget-ui";
|
|
2
|
-
const
|
|
3
|
-
|
|
1
|
+
import { createReactComponent as o } from "@telia-ace/widget-ui";
|
|
2
|
+
const p = (t) => o(t, "tab-stop", import("./tab-stop.403c4dee.js"));
|
|
3
|
+
export {
|
|
4
|
+
p as default
|
|
4
5
|
};
|
|
5
|
-
export { TabStopComponent as default };
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/tab-stop-component.ts"],"sourcesContent":["import { createReactComponent } from '@telia-ace/widget-ui';\r\nimport { Container } from '@webprovisions/platform';\r\n\r\nexport type TabStopComponentProps = {\r\n position: 'start' | 'end';\r\n};\r\n\r\nconst TabStopComponent = (container: Container) => {\r\n return createReactComponent(container, 'tab-stop', import('./tab-stop'));\r\n};\r\n\r\nexport default TabStopComponent;\r\n"],"names":[],"mappings":";AAOM,MAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/tab-stop-component.ts"],"sourcesContent":["import { createReactComponent } from '@telia-ace/widget-ui';\r\nimport { Container } from '@webprovisions/platform';\r\n\r\nexport type TabStopComponentProps = {\r\n position: 'start' | 'end';\r\n};\r\n\r\nconst TabStopComponent = (container: Container) => {\r\n return createReactComponent(container, 'tab-stop', import('./tab-stop'));\r\n};\r\n\r\nexport default TabStopComponent;\r\n"],"names":[],"mappings":";AAOM,MAAA,IAAmB,CAAC,MACf,EAAqB,GAAW,YAAY,OAAO,yBAAa;"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var D = Object.defineProperty, M = Object.defineProperties;
|
|
2
|
+
var O = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var s = Object.getOwnPropertySymbols;
|
|
4
|
+
var g = Object.prototype.hasOwnProperty, y = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var m = (e, t, n) => t in e ? D(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, b = (e, t) => {
|
|
6
|
+
for (var n in t || (t = {}))
|
|
7
|
+
g.call(t, n) && m(e, n, t[n]);
|
|
8
|
+
if (s)
|
|
9
|
+
for (var n of s(t))
|
|
10
|
+
y.call(t, n) && m(e, n, t[n]);
|
|
11
|
+
return e;
|
|
12
|
+
}, w = (e, t) => M(e, O(t));
|
|
13
|
+
var E = (e, t) => {
|
|
14
|
+
var n = {};
|
|
15
|
+
for (var o in e)
|
|
16
|
+
g.call(e, o) && t.indexOf(o) < 0 && (n[o] = e[o]);
|
|
17
|
+
if (e != null && s)
|
|
18
|
+
for (var o of s(e))
|
|
19
|
+
t.indexOf(o) < 0 && y.call(e, o) && (n[o] = e[o]);
|
|
20
|
+
return n;
|
|
21
|
+
};
|
|
22
|
+
import { useContainer as C, useProperties as R } from "@telia-ace/widget-ui";
|
|
23
|
+
import { appendClassNames as S } from "@telia-ace/widget-utilities";
|
|
24
|
+
import H, { useRef as h, useEffect as x } from "react";
|
|
25
|
+
import L from "styled-components";
|
|
26
|
+
const j = (n) => {
|
|
27
|
+
var o = n, { className: e } = o, t = E(o, ["className"]);
|
|
28
|
+
const r = h(), f = C(), { position: i = "end" } = R(), d = h(i);
|
|
29
|
+
x(() => {
|
|
30
|
+
d.current = i;
|
|
31
|
+
}, [i]);
|
|
32
|
+
const l = () => {
|
|
33
|
+
const [c] = f.get("widgetDOMElements"), v = c.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"]):not(.humany-tab-stop)'), a = [].filter.call(v, (u) => typeof window == "undefined" ? !0 : !(window.getComputedStyle(u).display === "none" || u.offsetWidth <= 0 && u.offsetHeight <= 0)), p = d.current === "end" ? a[0] : a[a.length - 1];
|
|
34
|
+
p && p.focus();
|
|
35
|
+
};
|
|
36
|
+
return x(() => {
|
|
37
|
+
const [c] = f.get("widgetDOMElements");
|
|
38
|
+
return r.current && c && r.current.addEventListener("focus", l), () => {
|
|
39
|
+
r.current && r.current.removeEventListener("focus", l);
|
|
40
|
+
};
|
|
41
|
+
}, []), /* @__PURE__ */ H.createElement(N, w(b({}, t), {
|
|
42
|
+
tabIndex: 0,
|
|
43
|
+
ref: r,
|
|
44
|
+
className: S(e, "humany-tab-stop")
|
|
45
|
+
}));
|
|
46
|
+
}, N = L.div`
|
|
47
|
+
opacity: 0;
|
|
48
|
+
position: absolute;
|
|
49
|
+
`;
|
|
50
|
+
export {
|
|
51
|
+
j as default
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=tab-stop.403c4dee.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tab-stop.403c4dee.js","sources":["../src/tab-stop.tsx"],"sourcesContent":["import { useContainer, useProperties } from '@telia-ace/widget-ui';\r\nimport { appendClassNames } from '@telia-ace/widget-utilities';\r\nimport React, { useEffect, useRef } from 'react';\r\nimport styled from 'styled-components';\r\nimport { TabStopComponentProps } from './tab-stop-component';\r\n\r\ntype Props = {\r\n className: string;\r\n};\r\n\r\nconst TabStop: React.SFC<Props> = ({ className, ...other }) => {\r\n const node = useRef() as React.MutableRefObject<HTMLDivElement>;\r\n const container = useContainer();\r\n const { position = 'end' } = useProperties<TabStopComponentProps>();\r\n const positionRef = useRef(position) as React.MutableRefObject<'start' | 'end'>;\r\n\r\n useEffect(() => {\r\n positionRef.current = position;\r\n }, [position]);\r\n\r\n const focusHandler = () => {\r\n const [widgetDOMElement] = container.get('widgetDOMElements') as HTMLElement[];\r\n\r\n const focusable = widgetDOMElement.querySelectorAll(\r\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"]):not(.humany-tab-stop)'\r\n );\r\n\r\n // ensure that elements is visible\r\n const filtered = [].filter.call(focusable, (el: HTMLElement) => {\r\n if (typeof window === 'undefined') {\r\n return true;\r\n }\r\n\r\n const style = window.getComputedStyle(el);\r\n if (style.display === 'none' || (el.offsetWidth <= 0 && el.offsetHeight <= 0)) {\r\n return false;\r\n }\r\n return true;\r\n }) as HTMLElement[];\r\n\r\n const target = positionRef.current === 'end' ? filtered[0] : filtered[filtered.length - 1];\r\n\r\n if (target) {\r\n target.focus();\r\n }\r\n };\r\n\r\n useEffect(() => {\r\n const [widgetDOMElement] = container.get('widgetDOMElements');\r\n\r\n if (node.current && widgetDOMElement) {\r\n node.current.addEventListener('focus', focusHandler);\r\n }\r\n\r\n return () => {\r\n if (node.current) {\r\n node.current.removeEventListener('focus', focusHandler);\r\n }\r\n };\r\n }, []);\r\n\r\n return (\r\n <Wrapper\r\n {...other}\r\n tabIndex={0}\r\n ref={node}\r\n className={appendClassNames(className, 'humany-tab-stop')}\r\n />\r\n );\r\n};\r\n\r\nexport default TabStop;\r\n\r\nconst Wrapper = styled.div`\r\n opacity: 0;\r\n position: absolute;\r\n`;\r\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAUA,MAAM,IAA4B,CAAC,MAA4B;AAA5B,aAAE,mBAAF,GAAgB,MAAhB,GAAgB,CAAd;AACjC,QAAM,IAAO,KACP,IAAY,KACZ,EAAE,cAAW,UAAU,EAAqC,GAC5D,IAAc,EAAO,CAAQ;AAEnC,IAAU,MAAM;AACZ,MAAY,UAAU;AAAA,EAAA,GACvB,CAAC,CAAQ,CAAC;AAEb,QAAM,IAAe,MAAM;AACvB,UAAM,CAAC,KAAoB,EAAU,IAAI,mBAAmB,GAEtD,IAAY,EAAiB,iBAC/B,gGACJ,GAGM,IAAW,CAAA,EAAG,OAAO,KAAK,GAAW,CAAC,MACpC,OAAO,UAAW,cACX,KAIP,EADU,OAAO,iBAAiB,CAAE,EAC9B,YAAY,UAAW,EAAG,eAAe,KAAK,EAAG,gBAAgB,EAI9E,GAEK,IAAS,EAAY,YAAY,QAAQ,EAAS,KAAK,EAAS,EAAS,SAAS;AAExF,IAAI,KACA,EAAO,MAAM;AAAA,EACjB;AAGJ,WAAU,MAAM;AACZ,UAAM,CAAC,KAAoB,EAAU,IAAI,mBAAmB;AAExD,WAAA,EAAK,WAAW,KACX,EAAA,QAAQ,iBAAiB,SAAS,CAAY,GAGhD,MAAM;AACT,MAAI,EAAK,WACA,EAAA,QAAQ,oBAAoB,SAAS,CAAY;AAAA,IAC1D;AAAA,EAER,GAAG,CAAE,CAAA,GAGA,kBAAA,cAAA,GAAA,QACO,IADP;AAAA,IAEG,UAAU;AAAA,IACV,KAAK;AAAA,IACL,WAAW,EAAiB,GAAW,iBAAiB;AAAA,EAAA,EAC5D;AAER,GAIM,IAAU,EAAO;AAAA;AAAA;AAAA;"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telia-ace/widget-components-tab-stop",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "Tab stop component for ACE Widgets.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"author": "Telia Company AB",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"telia"
|
|
9
9
|
],
|
|
10
|
-
"
|
|
11
|
-
|
|
10
|
+
"exports": {
|
|
11
|
+
"development": "./src/index.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
12
15
|
"types": "dist/index.d.ts",
|
|
13
16
|
"files": [
|
|
14
17
|
"LICENSE.txt",
|
|
@@ -25,7 +28,7 @@
|
|
|
25
28
|
},
|
|
26
29
|
"sideEffects": false,
|
|
27
30
|
"dependencies": {
|
|
28
|
-
"@telia-ace/widget-ui": "^1.0.
|
|
31
|
+
"@telia-ace/widget-ui": "^1.0.18",
|
|
29
32
|
"@telia-ace/widget-utilities": "^1.0.2",
|
|
30
33
|
"@webprovisions/platform": "^1.1.2"
|
|
31
34
|
},
|
|
@@ -39,5 +42,5 @@
|
|
|
39
42
|
"@types/react-dom": "^16.8.0",
|
|
40
43
|
"@types/styled-components": "^5.1.7"
|
|
41
44
|
},
|
|
42
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "4006655a78d8f0379c021e4362536dcdf881b3d0"
|
|
43
46
|
}
|
package/dist/tab-stop.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __objRest = (source, exclude) => {
|
|
21
|
-
var target = {};
|
|
22
|
-
for (var prop in source)
|
|
23
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
-
target[prop] = source[prop];
|
|
25
|
-
if (source != null && __getOwnPropSymbols)
|
|
26
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
}
|
|
30
|
-
return target;
|
|
31
|
-
};
|
|
32
|
-
import { useContainer, useProperties } from "@telia-ace/widget-ui";
|
|
33
|
-
import { appendClassNames } from "@telia-ace/widget-utilities";
|
|
34
|
-
import React, { useRef, useEffect } from "react";
|
|
35
|
-
import styled from "styled-components";
|
|
36
|
-
const TabStop = (_a) => {
|
|
37
|
-
var _b = _a, { className } = _b, other = __objRest(_b, ["className"]);
|
|
38
|
-
const node = useRef();
|
|
39
|
-
const container = useContainer();
|
|
40
|
-
const { position = "end" } = useProperties();
|
|
41
|
-
const positionRef = useRef(position);
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
positionRef.current = position;
|
|
44
|
-
}, [position]);
|
|
45
|
-
const focusHandler = () => {
|
|
46
|
-
const [widgetDOMElement] = container.get("widgetDOMElements");
|
|
47
|
-
const focusable = widgetDOMElement.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"]):not(.humany-tab-stop)');
|
|
48
|
-
const filtered = [].filter.call(focusable, (el) => {
|
|
49
|
-
if (typeof window === "undefined") {
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
const style = window.getComputedStyle(el);
|
|
53
|
-
if (style.display === "none" || el.offsetWidth <= 0 && el.offsetHeight <= 0) {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
return true;
|
|
57
|
-
});
|
|
58
|
-
const target = positionRef.current === "end" ? filtered[0] : filtered[filtered.length - 1];
|
|
59
|
-
if (target) {
|
|
60
|
-
target.focus();
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
const [widgetDOMElement] = container.get("widgetDOMElements");
|
|
65
|
-
if (node.current && widgetDOMElement) {
|
|
66
|
-
node.current.addEventListener("focus", focusHandler);
|
|
67
|
-
}
|
|
68
|
-
return () => {
|
|
69
|
-
if (node.current) {
|
|
70
|
-
node.current.removeEventListener("focus", focusHandler);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
}, []);
|
|
74
|
-
return /* @__PURE__ */ React.createElement(Wrapper, __spreadProps(__spreadValues({}, other), {
|
|
75
|
-
tabIndex: 0,
|
|
76
|
-
ref: node,
|
|
77
|
-
className: appendClassNames(className, "humany-tab-stop")
|
|
78
|
-
}));
|
|
79
|
-
};
|
|
80
|
-
const Wrapper = styled.div`
|
|
81
|
-
opacity: 0;
|
|
82
|
-
position: absolute;
|
|
83
|
-
`;
|
|
84
|
-
export { TabStop as default };
|
|
85
|
-
//# sourceMappingURL=tab-stop.js.map
|
package/dist/tab-stop.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tab-stop.js","sources":["../src/tab-stop.tsx"],"sourcesContent":["import { useContainer, useProperties } from '@telia-ace/widget-ui';\r\nimport { appendClassNames } from '@telia-ace/widget-utilities';\r\nimport React, { useEffect, useRef } from 'react';\r\nimport styled from 'styled-components';\r\nimport { TabStopComponentProps } from './tab-stop-component';\r\n\r\ntype Props = {\r\n className: string;\r\n};\r\n\r\nconst TabStop: React.SFC<Props> = ({ className, ...other }) => {\r\n const node = useRef() as React.MutableRefObject<HTMLDivElement>;\r\n const container = useContainer();\r\n const { position = 'end' } = useProperties<TabStopComponentProps>();\r\n const positionRef = useRef(position) as React.MutableRefObject<'start' | 'end'>;\r\n\r\n useEffect(() => {\r\n positionRef.current = position;\r\n }, [position]);\r\n\r\n const focusHandler = () => {\r\n const [widgetDOMElement] = container.get('widgetDOMElements') as HTMLElement[];\r\n\r\n const focusable = widgetDOMElement.querySelectorAll(\r\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"]):not(.humany-tab-stop)'\r\n );\r\n\r\n // ensure that elements is visible\r\n const filtered = [].filter.call(focusable, (el: HTMLElement) => {\r\n if (typeof window === 'undefined') {\r\n return true;\r\n }\r\n\r\n const style = window.getComputedStyle(el);\r\n if (style.display === 'none' || (el.offsetWidth <= 0 && el.offsetHeight <= 0)) {\r\n return false;\r\n }\r\n return true;\r\n }) as HTMLElement[];\r\n\r\n const target = positionRef.current === 'end' ? filtered[0] : filtered[filtered.length - 1];\r\n\r\n if (target) {\r\n target.focus();\r\n }\r\n };\r\n\r\n useEffect(() => {\r\n const [widgetDOMElement] = container.get('widgetDOMElements');\r\n\r\n if (node.current && widgetDOMElement) {\r\n node.current.addEventListener('focus', focusHandler);\r\n }\r\n\r\n return () => {\r\n if (node.current) {\r\n node.current.removeEventListener('focus', focusHandler);\r\n }\r\n };\r\n }, []);\r\n\r\n return (\r\n <Wrapper\r\n {...other}\r\n tabIndex={0}\r\n ref={node}\r\n className={appendClassNames(className, 'humany-tab-stop')}\r\n />\r\n );\r\n};\r\n\r\nexport default TabStop;\r\n\r\nconst Wrapper = styled.div`\r\n opacity: 0;\r\n position: absolute;\r\n`;\r\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,MAAM,UAA4B,CAAC,OAA4B;AAA5B,eAAE,gBAAF,IAAgB,kBAAhB,IAAgB,CAAd;AACjC,QAAM,OAAO;AACb,QAAM,YAAY;AACZ,QAAA,EAAE,WAAW,UAAU,cAAqC;AAC5D,QAAA,cAAc,OAAO,QAAQ;AAEnC,YAAU,MAAM;AACZ,gBAAY,UAAU;AAAA,EAAA,GACvB,CAAC,QAAQ,CAAC;AAEb,QAAM,eAAe,MAAM;AACvB,UAAM,CAAC,oBAAoB,UAAU,IAAI,mBAAmB;AAEtD,UAAA,YAAY,iBAAiB,iBAC/B,gGACJ;AAGA,UAAM,WAAW,CAAA,EAAG,OAAO,KAAK,WAAW,CAAC,OAAoB;AACxD,UAAA,OAAO,WAAW,aAAa;AACxB,eAAA;AAAA,MACX;AAEM,YAAA,QAAQ,OAAO,iBAAiB,EAAE;AACpC,UAAA,MAAM,YAAY,UAAW,GAAG,eAAe,KAAK,GAAG,gBAAgB,GAAI;AACpE,eAAA;AAAA,MACX;AACO,aAAA;AAAA,IAAA,CACV;AAEK,UAAA,SAAS,YAAY,YAAY,QAAQ,SAAS,KAAK,SAAS,SAAS,SAAS;AAExF,QAAI,QAAQ;AACR,aAAO,MAAM;AAAA,IACjB;AAAA,EAAA;AAGJ,YAAU,MAAM;AACZ,UAAM,CAAC,oBAAoB,UAAU,IAAI,mBAAmB;AAExD,QAAA,KAAK,WAAW,kBAAkB;AAC7B,WAAA,QAAQ,iBAAiB,SAAS,YAAY;AAAA,IACvD;AAEA,WAAO,MAAM;AACT,UAAI,KAAK,SAAS;AACT,aAAA,QAAQ,oBAAoB,SAAS,YAAY;AAAA,MAC1D;AAAA,IAAA;AAAA,EAER,GAAG,CAAE,CAAA;AAEL,SACK,sBAAA,cAAA,SAAA,iCACO,QADP;AAAA,IAEG,UAAU;AAAA,IACV,KAAK;AAAA,IACL,WAAW,iBAAiB,WAAW,iBAAiB;AAAA,EAAA,EAC5D;AAER;AAIA,MAAM,UAAU,OAAO;AAAA;AAAA;AAAA;;"}
|