@forgedevstack/bear 1.1.0 → 1.1.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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react/jsx-runtime"),t=require("react"),R=require("../../utils/cn.cjs"),r=require("./Typewriter.const.cjs"),X=b=>{const{text:f,speed:i=r.DEFAULT_SPEED,startDelay:N=r.DEFAULT_START_DELAY,deleteDelay:x=r.DEFAULT_DELETE_DELAY,deleteSpeed:d=r.DEFAULT_DELETE_SPEED,loop:_=!1,cursor:I=!0,cursorChar:h=r.DEFAULT_CURSOR_CHAR,cursorBlinkSpeed:A=r.DEFAULT_CURSOR_BLINK_SPEED,onComplete:n,onWordComplete:o,as:g="span",className:U,style:j,testId:w}=b,u=Array.isArray(f)?f:[f],[F,m]=t.useState(""),[a,p]=t.useState(r.INITIAL_TEXT_INDEX),[l,S]=t.useState(r.INITIAL_CHAR_INDEX),[E,L]=t.useState(!1),[v,B]=t.useState(!0),e=t.useRef(),D=t.useRef(!1);t.useEffect(()=>{if(!I)return;const T=setInterval(()=>B(s=>!s),A);return()=>clearInterval(T)},[I,A]);const c=t.useCallback(()=>{const T=u[a];if(E)if(l>0)S(s=>s-1),m(T.slice(0,l-1)),e.current=setTimeout(c,d);else{L(!1);const s=a+1;s>=u.length?_?(p(r.INITIAL_TEXT_INDEX),e.current=setTimeout(c,i)):n==null||n():(p(s),e.current=setTimeout(c,i))}else if(l<T.length)m(T.slice(0,l+1)),S(s=>s+1),e.current=setTimeout(c,i);else{if(o==null||o(a),u.length===1&&!_){n==null||n();return}e.current=setTimeout(()=>{L(!0),c()},x)}},[u,a,l,E,i,d,x,_,n,o]);return t.useEffect(()=>{if(!D.current)return D.current=!0,e.current=setTimeout(c,N),()=>{e.current&&clearTimeout(e.current)}},[]),t.useEffect(()=>{if(D.current)return e.current&&clearTimeout(e.current),e.current=setTimeout(c,E?d:i),()=>{e.current&&clearTimeout(e.current)}},[E,a]),y.jsxs(g,{className:R.cn("Bear-Typewriter","bear-inline",U),style:j,"data-testid":w,"aria-label":u.join(", "),children:[y.jsx("span",{className:"Bear-Typewriter__text",children:F}),I&&y.jsx("span",{className:R.cn("Bear-Typewriter__cursor","bear-inline-block bear-ml-0.5","bear-text-[var(--bear-primary-500)]"),style:{opacity:v?1:0},"aria-hidden":"true",children:h})]})};exports.Typewriter=X;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),t=require("react"),X=require("../../utils/cn.cjs"),e=require("./Typewriter.const.cjs"),k=g=>{const{text:I,speed:T=e.DEFAULT_SPEED,startDelay:C=e.DEFAULT_START_DELAY,deleteDelay:N=e.DEFAULT_DELETE_DELAY,deleteSpeed:R=e.DEFAULT_DELETE_SPEED,loop:d=!1,cursor:f=!0,cursorChar:U=e.DEFAULT_CURSOR_CHAR,cursorBlinkSpeed:y=e.DEFAULT_CURSOR_BLINK_SPEED,onComplete:n,onWordComplete:o,as:j="span",className:w,style:F,testId:H}=g,a=t.useMemo(()=>Array.isArray(I)?I:[I],[I]),[v,L]=t.useState(""),[p,S]=t.useState(e.INITIAL_TEXT_INDEX),[m,E]=t.useState(e.INITIAL_CHAR_INDEX),[b,h]=t.useState(!1),[B,q]=t.useState(!0),s=t.useRef(),_=t.useRef(p),c=t.useRef(m),D=t.useRef(b);_.current=p,c.current=m,D.current=b,t.useEffect(()=>{if(!f)return;const l=setInterval(()=>q(i=>!i),y);return()=>clearInterval(l)},[f,y]);const u=t.useCallback(()=>{const l=_.current,i=c.current,P=D.current,A=a[l];if(P)if(i>0){const r=i-1;E(r),c.current=r,L(A.slice(0,r)),s.current=setTimeout(u,R)}else{h(!1),D.current=!1;const r=l+1;r>=a.length?d?(S(e.INITIAL_TEXT_INDEX),_.current=e.INITIAL_TEXT_INDEX,E(e.INITIAL_CHAR_INDEX),c.current=e.INITIAL_CHAR_INDEX,s.current=setTimeout(u,T)):n==null||n():(S(r),_.current=r,E(e.INITIAL_CHAR_INDEX),c.current=e.INITIAL_CHAR_INDEX,s.current=setTimeout(u,T))}else if(i<A.length){const r=i+1;L(A.slice(0,r)),E(r),c.current=r,s.current=setTimeout(u,T)}else{if(o==null||o(l),a.length===1&&!d){n==null||n();return}s.current=setTimeout(()=>{h(!0),D.current=!0,u()},N)}},[a,T,R,N,d,n,o]);return t.useEffect(()=>(s.current=setTimeout(u,C),()=>{s.current&&clearTimeout(s.current)}),[]),x.jsxs(j,{className:X.cn("Bear-Typewriter","bear-inline",w),style:F,"data-testid":H,"aria-label":a.join(", "),children:[x.jsx("span",{className:"Bear-Typewriter__text",children:v}),f&&x.jsx("span",{className:X.cn("Bear-Typewriter__cursor","bear-inline-block bear-ml-0.5","bear-text-[var(--bear-primary-500)]"),style:{opacity:B?1:0},"aria-hidden":"true",children:U})]})};exports.Typewriter=k;
@@ -1,82 +1,76 @@
1
- import { jsxs as P, jsx as b } from "react/jsx-runtime";
2
- import { useState as l, useRef as h, useEffect as _, useCallback as X } from "react";
3
- import { cn as R } from "../../utils/cn.js";
4
- import { DEFAULT_SPEED as H, DEFAULT_START_DELAY as O, DEFAULT_DELETE_DELAY as V, DEFAULT_DELETE_SPEED as Y, DEFAULT_CURSOR_CHAR as K, DEFAULT_CURSOR_BLINK_SPEED as q, INITIAL_TEXT_INDEX as N, INITIAL_CHAR_INDEX as z } from "./Typewriter.const.js";
5
- const Z = (S) => {
1
+ import { jsxs as K, jsx as U } from "react/jsx-runtime";
2
+ import { useMemo as M, useState as u, useRef as D, useEffect as F, useCallback as q } from "react";
3
+ import { cn as B } from "../../utils/cn.js";
4
+ import { DEFAULT_SPEED as z, DEFAULT_START_DELAY as G, DEFAULT_DELETE_DELAY as J, DEFAULT_DELETE_SPEED as Q, DEFAULT_CURSOR_CHAR as Z, DEFAULT_CURSOR_BLINK_SPEED as $, INITIAL_TEXT_INDEX as p, INITIAL_CHAR_INDEX as l } from "./Typewriter.const.js";
5
+ const se = (v) => {
6
6
  const {
7
- text: f,
8
- speed: n = H,
9
- startDelay: U = O,
10
- deleteDelay: I = V,
11
- deleteSpeed: E = Y,
12
- loop: d = !1,
13
- cursor: m = !0,
14
- cursorChar: g = K,
15
- cursorBlinkSpeed: p = q,
16
- onComplete: t,
17
- onWordComplete: o,
18
- as: F = "span",
19
- className: B,
20
- style: v,
21
- testId: w
22
- } = S, i = Array.isArray(f) ? f : [f], [C, x] = l(""), [a, y] = l(N), [c, A] = l(z), [T, L] = l(!1), [j, k] = l(!0), e = h(), D = h(!1);
23
- _(() => {
24
- if (!m) return;
25
- const u = setInterval(() => k((r) => !r), p);
26
- return () => clearInterval(u);
27
- }, [m, p]);
28
- const s = X(() => {
29
- const u = i[a];
30
- if (T)
31
- if (c > 0)
32
- A((r) => r - 1), x(u.slice(0, c - 1)), e.current = setTimeout(s, E);
33
- else {
34
- L(!1);
35
- const r = a + 1;
36
- r >= i.length ? d ? (y(N), e.current = setTimeout(s, n)) : t == null || t() : (y(r), e.current = setTimeout(s, n));
7
+ text: o,
8
+ speed: T = z,
9
+ startDelay: w = G,
10
+ deleteDelay: y = J,
11
+ deleteSpeed: A = Q,
12
+ loop: I = !1,
13
+ cursor: _ = !0,
14
+ cursorChar: C = Z,
15
+ cursorBlinkSpeed: L = $,
16
+ onComplete: r,
17
+ onWordComplete: E,
18
+ as: j = "span",
19
+ className: k,
20
+ style: P,
21
+ testId: X
22
+ } = v, i = M(() => Array.isArray(o) ? o : [o], [o]), [H, R] = u(""), [h, b] = u(p), [N, d] = u(l), [S, g] = u(!1), [O, V] = u(!0), t = D(), f = D(h), s = D(N), x = D(S);
23
+ f.current = h, s.current = N, x.current = S, F(() => {
24
+ if (!_) return;
25
+ const a = setInterval(() => V((c) => !c), L);
26
+ return () => clearInterval(a);
27
+ }, [_, L]);
28
+ const n = q(() => {
29
+ const a = f.current, c = s.current, Y = x.current, m = i[a];
30
+ if (Y)
31
+ if (c > 0) {
32
+ const e = c - 1;
33
+ d(e), s.current = e, R(m.slice(0, e)), t.current = setTimeout(n, A);
34
+ } else {
35
+ g(!1), x.current = !1;
36
+ const e = a + 1;
37
+ e >= i.length ? I ? (b(p), f.current = p, d(l), s.current = l, t.current = setTimeout(n, T)) : r == null || r() : (b(e), f.current = e, d(l), s.current = l, t.current = setTimeout(n, T));
37
38
  }
38
- else if (c < u.length)
39
- x(u.slice(0, c + 1)), A((r) => r + 1), e.current = setTimeout(s, n);
40
- else {
41
- if (o == null || o(a), i.length === 1 && !d) {
42
- t == null || t();
39
+ else if (c < m.length) {
40
+ const e = c + 1;
41
+ R(m.slice(0, e)), d(e), s.current = e, t.current = setTimeout(n, T);
42
+ } else {
43
+ if (E == null || E(a), i.length === 1 && !I) {
44
+ r == null || r();
43
45
  return;
44
46
  }
45
- e.current = setTimeout(() => {
46
- L(!0), s();
47
- }, I);
47
+ t.current = setTimeout(() => {
48
+ g(!0), x.current = !0, n();
49
+ }, y);
48
50
  }
49
- }, [i, a, c, T, n, E, I, d, t, o]);
50
- return _(() => {
51
- if (!D.current)
52
- return D.current = !0, e.current = setTimeout(s, U), () => {
53
- e.current && clearTimeout(e.current);
54
- };
55
- }, []), _(() => {
56
- if (D.current)
57
- return e.current && clearTimeout(e.current), e.current = setTimeout(s, T ? E : n), () => {
58
- e.current && clearTimeout(e.current);
59
- };
60
- }, [T, a]), /* @__PURE__ */ P(
61
- F,
51
+ }, [i, T, A, y, I, r, E]);
52
+ return F(() => (t.current = setTimeout(n, w), () => {
53
+ t.current && clearTimeout(t.current);
54
+ }), []), /* @__PURE__ */ K(
55
+ j,
62
56
  {
63
- className: R("Bear-Typewriter", "bear-inline", B),
64
- style: v,
65
- "data-testid": w,
57
+ className: B("Bear-Typewriter", "bear-inline", k),
58
+ style: P,
59
+ "data-testid": X,
66
60
  "aria-label": i.join(", "),
67
61
  children: [
68
- /* @__PURE__ */ b("span", { className: "Bear-Typewriter__text", children: C }),
69
- m && /* @__PURE__ */ b(
62
+ /* @__PURE__ */ U("span", { className: "Bear-Typewriter__text", children: H }),
63
+ _ && /* @__PURE__ */ U(
70
64
  "span",
71
65
  {
72
- className: R(
66
+ className: B(
73
67
  "Bear-Typewriter__cursor",
74
68
  "bear-inline-block bear-ml-0.5",
75
69
  "bear-text-[var(--bear-primary-500)]"
76
70
  ),
77
- style: { opacity: j ? 1 : 0 },
71
+ style: { opacity: O ? 1 : 0 },
78
72
  "aria-hidden": "true",
79
- children: g
73
+ children: C
80
74
  }
81
75
  )
82
76
  ]
@@ -84,5 +78,5 @@ const Z = (S) => {
84
78
  );
85
79
  };
86
80
  export {
87
- Z as Typewriter
81
+ se as Typewriter
88
82
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forgedevstack/bear",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Strong, reliable React UI components. Tailwind-powered, zero config required. The protective force of ForgeStack.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",