@purpurds/visually-hidden 6.3.0 → 6.4.0

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 d(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=d(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():d(e[i],null)}}}}var p=l.forwardRef((e,t)=>{const{children:n,...r}=e,i=l.Children.toArray(n),o=i.find(v);if(o){const s=o.props.children,u=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(c,{...r,ref:t,children:l.isValidElement(s)?l.cloneElement(s,void 0,u):null})}return a.jsx(c,{...r,ref:t,children:n})});p.displayName="Slot";var c=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});c.displayName="SlotClone";var b=({children:e})=>a.jsx(a.Fragment,{children:e});function v(e){return l.isValidElement(e)&&e.type===b}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]=(...u)=>{o(...u),i(...u)}: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,u=o?p:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),a.jsx(u,{...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;
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 f, Fragment as y } from "react/jsx-runtime";
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 p(e, n) {
4
+ function u(e, r) {
5
5
  if (typeof e == "function")
6
- return e(n);
7
- e != null && (e.current = n);
6
+ return e(r);
7
+ e != null && (e.current = r);
8
8
  }
9
9
  function h(...e) {
10
- return (n) => {
11
- let r = !1;
10
+ return (r) => {
11
+ let n = !1;
12
12
  const t = e.map((i) => {
13
- const o = p(i, n);
14
- return !r && typeof o == "function" && (r = !0), o;
13
+ const o = u(i, r);
14
+ return !n && typeof o == "function" && (n = !0), o;
15
15
  });
16
- if (r)
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() : p(e[i], null);
20
+ typeof o == "function" ? o() : u(e[i], null);
21
21
  }
22
22
  };
23
23
  };
24
24
  }
25
- var d = l.forwardRef((e, n) => {
26
- const { children: r, ...t } = e, i = l.Children.toArray(r), o = i.find(v);
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((c) => c === o ? l.Children.count(s) > 1 ? l.Children.only(null) : l.isValidElement(s) ? s.props.children : null : c);
29
- return /* @__PURE__ */ f(u, { ...t, ref: n, children: l.isValidElement(s) ? l.cloneElement(s, void 0, a) : null });
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(u, { ...t, ref: n, children: r });
31
+ return /* @__PURE__ */ c(f, { ...t, ref: r, children: n });
32
32
  });
33
33
  d.displayName = "Slot";
34
- var u = l.forwardRef((e, n) => {
35
- const { children: r, ...t } = e;
36
- if (l.isValidElement(r)) {
37
- const i = R(r), o = w(t, r.props);
38
- return r.type !== l.Fragment && (o.ref = n ? h(n, i) : i), l.cloneElement(r, o);
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(r) > 1 ? l.Children.only(null) : null;
40
+ return l.Children.count(n) > 1 ? l.Children.only(null) : null;
41
41
  });
42
- u.displayName = "SlotClone";
43
- var g = ({ children: e }) => /* @__PURE__ */ f(y, { children: e });
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, n) {
48
- const r = { ...n };
49
- for (const t in n) {
50
- const i = e[t], o = n[t];
51
- /^on[A-Z]/.test(t) ? i && o ? r[t] = (...a) => {
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 && (r[t] = i) : t === "style" ? r[t] = { ...i, ...o } : t === "className" && (r[t] = [i, o].filter(Boolean).join(" "));
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, ...r };
55
+ return { ...e, ...n };
56
56
  }
57
57
  function R(e) {
58
58
  var t, i;
59
- let n = (t = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : t.get, r = n && "isReactWarning" in n && n.isReactWarning;
60
- return r ? e.ref : (n = (i = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : i.get, r = n && "isReactWarning" in n && n.isReactWarning, r ? e.props.ref : e.props.ref || e.ref);
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, n) => {
80
- const r = l.forwardRef((t, i) => {
81
- const { asChild: o, ...s } = t, a = o ? d : n;
82
- return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ f(a, { ...s, ref: i });
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 r.displayName = `Primitive.${n}`, { ...e, [n]: r };
84
+ return n.displayName = `Primitive.${r}`, { ...e, [r]: n };
85
85
  }, {}), E = "VisuallyHidden", m = l.forwardRef(
86
- (e, n) => /* @__PURE__ */ f(
86
+ (e, r) => /* @__PURE__ */ c(
87
87
  b.span,
88
88
  {
89
89
  ...e,
90
- ref: n,
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: n,
113
- className: r = "",
112
+ children: r,
113
+ className: n = "",
114
114
  ["data-testid"]: t
115
- }) => /* @__PURE__ */ f(N, { asChild: e, "data-testid": t, className: r, children: n });
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.0",
3
+ "version": "6.4.0",
4
4
  "license": "AGPL-3.0-only",
5
5
  "main": "./dist/visually-hidden.cjs.js",
6
6
  "types": "./dist/visually-hidden.d.ts",
@@ -17,13 +17,13 @@
17
17
  },
18
18
  "devDependencies": {
19
19
  "@rushstack/eslint-patch": "~1.10.0",
20
- "@storybook/react": "^8.3.5",
21
- "storybook": "^8.3.5",
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",
25
25
  "@testing-library/jest-dom": "~6.4.0",
26
- "@testing-library/react": "~ 16.2.0",
26
+ "@testing-library/react": "~16.2.0",
27
27
  "@types/node": "20.12.12",
28
28
  "@types/react-dom": "^19.0.4",
29
29
  "@types/react": "^19.0.10",
@@ -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": "5.4.8",
38
+ "vite": "^6.2.1",
39
39
  "vitest": "^2.1.2",
40
40
  "@purpurds/component-rig": "1.0.0"
41
41
  },