@purpurds/visually-hidden 6.3.0 → 6.3.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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),y=require("react");require("react-dom");function g(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const l=g(y);function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),y=require("react");require("react-dom");function g(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const l=g(y);function p(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function h(...e){return t=>{let n=!1;const r=e.map(i=>{const o=p(i,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<r.length;i++){const o=r[i];typeof o=="function"?o():p(e[i],null)}}}}var d=l.forwardRef((e,t)=>{const{children:n,...r}=e,i=l.Children.toArray(n),o=i.find(b);if(o){const s=o.props.children,c=i.map(f=>f===o?l.Children.count(s)>1?l.Children.only(null):l.isValidElement(s)?s.props.children:null:f);return a.jsx(u,{...r,ref:t,children:l.isValidElement(s)?l.cloneElement(s,void 0,c):null})}return a.jsx(u,{...r,ref:t,children:n})});d.displayName="Slot";var u=l.forwardRef((e,t)=>{const{children:n,...r}=e;if(l.isValidElement(n)){const i=j(n),o=w(r,n.props);return n.type!==l.Fragment&&(o.ref=t?h(t,i):i),l.cloneElement(n,o)}return l.Children.count(n)>1?l.Children.only(null):null});u.displayName="SlotClone";var v=({children:e})=>a.jsx(a.Fragment,{children:e});function b(e){return l.isValidElement(e)&&e.type===v}function w(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...c)=>{o(...c),i(...c)}:i&&(n[r]=i):r==="style"?n[r]={...i,...o}:r==="className"&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}function j(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var R=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],S=R.reduce((e,t)=>{const n=l.forwardRef((r,i)=>{const{asChild:o,...s}=r,c=o?d:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),a.jsx(c,{...s,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),C="VisuallyHidden",m=l.forwardRef((e,t)=>a.jsx(S.span,{...e,ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));m.displayName=C;var O=m;const P=({asChild:e,children:t,className:n="",["data-testid"]:r})=>a.jsx(O,{asChild:e,"data-testid":r,className:n,children:t});exports.VisuallyHidden=P;
|
|
2
2
|
//# sourceMappingURL=visually-hidden.cjs.js.map
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as c, Fragment as y } from "react/jsx-runtime";
|
|
2
2
|
import * as l from "react";
|
|
3
3
|
import "react-dom";
|
|
4
|
-
function
|
|
4
|
+
function u(e, r) {
|
|
5
5
|
if (typeof e == "function")
|
|
6
|
-
return e(
|
|
7
|
-
e != null && (e.current =
|
|
6
|
+
return e(r);
|
|
7
|
+
e != null && (e.current = r);
|
|
8
8
|
}
|
|
9
9
|
function h(...e) {
|
|
10
|
-
return (
|
|
11
|
-
let
|
|
10
|
+
return (r) => {
|
|
11
|
+
let n = !1;
|
|
12
12
|
const t = e.map((i) => {
|
|
13
|
-
const o =
|
|
14
|
-
return !
|
|
13
|
+
const o = u(i, r);
|
|
14
|
+
return !n && typeof o == "function" && (n = !0), o;
|
|
15
15
|
});
|
|
16
|
-
if (
|
|
16
|
+
if (n)
|
|
17
17
|
return () => {
|
|
18
18
|
for (let i = 0; i < t.length; i++) {
|
|
19
19
|
const o = t[i];
|
|
20
|
-
typeof o == "function" ? o() :
|
|
20
|
+
typeof o == "function" ? o() : u(e[i], null);
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
var d = l.forwardRef((e,
|
|
26
|
-
const { children:
|
|
25
|
+
var d = l.forwardRef((e, r) => {
|
|
26
|
+
const { children: n, ...t } = e, i = l.Children.toArray(n), o = i.find(v);
|
|
27
27
|
if (o) {
|
|
28
|
-
const s = o.props.children, a = i.map((
|
|
29
|
-
return /* @__PURE__ */ f
|
|
28
|
+
const s = o.props.children, a = i.map((p) => p === o ? l.Children.count(s) > 1 ? l.Children.only(null) : l.isValidElement(s) ? s.props.children : null : p);
|
|
29
|
+
return /* @__PURE__ */ c(f, { ...t, ref: r, children: l.isValidElement(s) ? l.cloneElement(s, void 0, a) : null });
|
|
30
30
|
}
|
|
31
|
-
return /* @__PURE__ */ f
|
|
31
|
+
return /* @__PURE__ */ c(f, { ...t, ref: r, children: n });
|
|
32
32
|
});
|
|
33
33
|
d.displayName = "Slot";
|
|
34
|
-
var
|
|
35
|
-
const { children:
|
|
36
|
-
if (l.isValidElement(
|
|
37
|
-
const i = R(
|
|
38
|
-
return
|
|
34
|
+
var f = l.forwardRef((e, r) => {
|
|
35
|
+
const { children: n, ...t } = e;
|
|
36
|
+
if (l.isValidElement(n)) {
|
|
37
|
+
const i = R(n), o = w(t, n.props);
|
|
38
|
+
return n.type !== l.Fragment && (o.ref = r ? h(r, i) : i), l.cloneElement(n, o);
|
|
39
39
|
}
|
|
40
|
-
return l.Children.count(
|
|
40
|
+
return l.Children.count(n) > 1 ? l.Children.only(null) : null;
|
|
41
41
|
});
|
|
42
|
-
|
|
43
|
-
var g = ({ children: e }) => /* @__PURE__ */
|
|
42
|
+
f.displayName = "SlotClone";
|
|
43
|
+
var g = ({ children: e }) => /* @__PURE__ */ c(y, { children: e });
|
|
44
44
|
function v(e) {
|
|
45
45
|
return l.isValidElement(e) && e.type === g;
|
|
46
46
|
}
|
|
47
|
-
function w(e,
|
|
48
|
-
const
|
|
49
|
-
for (const t in
|
|
50
|
-
const i = e[t], o =
|
|
51
|
-
/^on[A-Z]/.test(t) ? i && o ?
|
|
47
|
+
function w(e, r) {
|
|
48
|
+
const n = { ...r };
|
|
49
|
+
for (const t in r) {
|
|
50
|
+
const i = e[t], o = r[t];
|
|
51
|
+
/^on[A-Z]/.test(t) ? i && o ? n[t] = (...a) => {
|
|
52
52
|
o(...a), i(...a);
|
|
53
|
-
} : i && (
|
|
53
|
+
} : i && (n[t] = i) : t === "style" ? n[t] = { ...i, ...o } : t === "className" && (n[t] = [i, o].filter(Boolean).join(" "));
|
|
54
54
|
}
|
|
55
|
-
return { ...e, ...
|
|
55
|
+
return { ...e, ...n };
|
|
56
56
|
}
|
|
57
57
|
function R(e) {
|
|
58
58
|
var t, i;
|
|
59
|
-
let
|
|
60
|
-
return
|
|
59
|
+
let r = (t = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : t.get, n = r && "isReactWarning" in r && r.isReactWarning;
|
|
60
|
+
return n ? e.ref : (r = (i = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : i.get, n = r && "isReactWarning" in r && r.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
|
|
61
61
|
}
|
|
62
62
|
var C = [
|
|
63
63
|
"a",
|
|
@@ -76,18 +76,18 @@ var C = [
|
|
|
76
76
|
"span",
|
|
77
77
|
"svg",
|
|
78
78
|
"ul"
|
|
79
|
-
], b = C.reduce((e,
|
|
80
|
-
const
|
|
81
|
-
const { asChild: o, ...s } = t, a = o ? d :
|
|
82
|
-
return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */
|
|
79
|
+
], b = C.reduce((e, r) => {
|
|
80
|
+
const n = l.forwardRef((t, i) => {
|
|
81
|
+
const { asChild: o, ...s } = t, a = o ? d : r;
|
|
82
|
+
return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ c(a, { ...s, ref: i });
|
|
83
83
|
});
|
|
84
|
-
return
|
|
84
|
+
return n.displayName = `Primitive.${r}`, { ...e, [r]: n };
|
|
85
85
|
}, {}), E = "VisuallyHidden", m = l.forwardRef(
|
|
86
|
-
(e,
|
|
86
|
+
(e, r) => /* @__PURE__ */ c(
|
|
87
87
|
b.span,
|
|
88
88
|
{
|
|
89
89
|
...e,
|
|
90
|
-
ref:
|
|
90
|
+
ref: r,
|
|
91
91
|
style: {
|
|
92
92
|
// See: https://github.com/twbs/bootstrap/blob/main/scss/mixins/_visually-hidden.scss
|
|
93
93
|
position: "absolute",
|
|
@@ -109,10 +109,10 @@ m.displayName = E;
|
|
|
109
109
|
var N = m;
|
|
110
110
|
const P = ({
|
|
111
111
|
asChild: e,
|
|
112
|
-
children:
|
|
113
|
-
className:
|
|
112
|
+
children: r,
|
|
113
|
+
className: n = "",
|
|
114
114
|
["data-testid"]: t
|
|
115
|
-
}) => /* @__PURE__ */
|
|
115
|
+
}) => /* @__PURE__ */ c(N, { asChild: e, "data-testid": t, className: n, children: r });
|
|
116
116
|
export {
|
|
117
117
|
P as VisuallyHidden
|
|
118
118
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@purpurds/visually-hidden",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.1",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"main": "./dist/visually-hidden.cjs.js",
|
|
6
6
|
"types": "./dist/visually-hidden.d.ts",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@rushstack/eslint-patch": "~1.10.0",
|
|
20
|
-
"@storybook/react": "^8.
|
|
21
|
-
"storybook": "^8.
|
|
20
|
+
"@storybook/react": "^8.6.4",
|
|
21
|
+
"storybook": "^8.6.4",
|
|
22
22
|
"@telia/base-rig": "~8.2.0",
|
|
23
23
|
"@telia/react-rig": "~3.2.0",
|
|
24
24
|
"@testing-library/dom": "~10.4.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"react-dom": "^19.0.0",
|
|
36
36
|
"react": "^19.0.0",
|
|
37
37
|
"typescript": "^5.6.3",
|
|
38
|
-
"vite": "
|
|
38
|
+
"vite": "^6.2.1",
|
|
39
39
|
"vitest": "^2.1.2",
|
|
40
40
|
"@purpurds/component-rig": "1.0.0"
|
|
41
41
|
},
|