@bikdotai/bik-component-library 0.0.564-beta.picker.5 → 0.0.564-beta.picker.6

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.
@@ -12,6 +12,7 @@ export type CustomEditorProps = React.TextareaHTMLAttributes<HTMLTextAreaElement
12
12
  * Calls only for editor only error, not for errors coming from outside
13
13
  */
14
14
  onError?: (err: string) => void;
15
+ onClickVariable?: (variable: string) => void;
15
16
  };
16
17
  export type CustomEditorRef = {
17
18
  addTextOrWrap: (textToAdd: string) => {
@@ -37,4 +38,5 @@ export declare const WhatsAppTextEditor: React.ForwardRefExoticComponent<React.T
37
38
  * Calls only for editor only error, not for errors coming from outside
38
39
  */
39
40
  onError?: ((err: string) => void) | undefined;
41
+ onClickVariable?: ((variable: string) => void) | undefined;
40
42
  } & React.RefAttributes<CustomEditorRef>>;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),n=require("../../assets/icons/info.svg.js"),r=require("../../helpers/BaseWhatsappContentLang.helper.js"),l=require("react"),o=require("../../constants/Theme.js"),i=require("../TypographyStyle.js"),u=require("./CustomEditor.styled.js"),s=require("./WhatsAppTextEditorHeader.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=c(l);const d="Character limit reached",v=new r.BaseWhatsappContentLangHelper,h={[s.EditorActionTypes.BOLD]:"*",[s.EditorActionTypes.ITALIC]:"_",[s.EditorActionTypes.STRIKETHROUGH]:"~"},p=a.default.forwardRef(((r,c)=>{var a,p,{onChange:f,text:g,RightComponent:x,error:j,limit:m,onError:C,rows:E,actions:T}=r,O=e.__rest(r,["onChange","text","RightComponent","error","limit","onError","rows","actions"]);const y=l.useRef(null);function L(e){const t=null==y?void 0:y.current;null!=t&&(t.selectionStart?(t.focus(),t.selectionEnd=e):t.focus())}function S(e){var t,n;let r=null!==(n=null===(t=y.current)||void 0===t?void 0:t.value)&&void 0!==n?n:"";if(y.current&&e){const t=y.current.selectionStart,n=y.current.selectionEnd,l=e;if(t===n)return R(l);{r=v.wrappWildcard(t,n,l,r);const e=v.getHTML(r);return y.current.value=r,{text:r,html:e}}}return{text:r,html:r}}function R(e){var t,n;let r=null!==(n=null===(t=y.current)||void 0===t?void 0:t.value)&&void 0!==n?n:"";if(y.current&&e){const t=y.current.selectionStart;if(t===y.current.selectionEnd)return H(e,t)}return{text:r,html:r}}function H(e,t){var n,r;let l=null!==(r=null===(n=y.current)||void 0===n?void 0:n.value)&&void 0!==r?r:"";l=l.slice(0,t)+e+l.slice(t);const o=v.getHTML(l);return y.current.value=l,{text:l,html:o}}return l.useImperativeHandle(c,(()=>({addTextOrWrap:S,addText:R,get(){var e,t;return null!==(t=null===(e=y.current)||void 0===e?void 0:e.value)&&void 0!==t?t:""},setCaretPosition:L}))),l.useEffect((()=>{if(null==y?void 0:y.current){y.current.value=g||"";const e=v.getHTML(g||"");null==f||f(g||"",e)}}),[g]),l.useEffect((()=>{var e,t;(null===(e=null==y?void 0:y.current)||void 0===e?void 0:e.value)&&m&&((null===(t=null==y?void 0:y.current)||void 0===t?void 0:t.value.length)>m?null==C||C(d):null==C||C(null!=j?j:""))}),[null===(a=null==y?void 0:y.current)||void 0===a?void 0:a.value.length]),t.jsxs(u.OuterContainer,{children:[t.jsxs(u.Container,Object.assign({isError:!!j},{children:[t.jsx(s.WhatsAppTextEditorHeader,{actions:T,ref:y,onActionSelect:function(e){if((null==h?void 0:h[e])&&y.current){const t=y.current.selectionStart;if(t===y.current.selectionEnd){H(null==h?void 0:h[e],t);const{text:n,html:r}=H(null==h?void 0:h[e],t);L(t+1),null==f||f(n,r)}else{const{text:t,html:n}=S(null==h?void 0:h[e]);null==f||f(t,n)}}},RightComponent:x,onEmojiClick:function(e){const{text:t,html:n}=R(e);null==f||f(t,n)}}),t.jsx(u.TextSpace,Object.assign({ref:y,onChange:function(e){const t=e.target.value,n=v.getHTML(t);null==f||f(t,n)}},O,{rows:E}))]})),j&&j!==d?t.jsxs("div",Object.assign({style:{display:"flex",gap:6,alignItems:"center"}},{children:[t.jsx(n.default,{width:16,height:16,color:o.COLORS.content.negative}),t.jsx(i.BodyCaption,Object.assign({color:o.COLORS.content.negative},{children:j}))]})):t.jsx(t.Fragment,{children:m&&(null==y?void 0:y.current)?t.jsxs(i.BodyCaption,Object.assign({style:{color:j===d||(null===(p=null==y?void 0:y.current)||void 0===p?void 0:p.value.length)>m?o.COLORS.content.negative:o.COLORS.content.secondary}},{children:[y.current.value.length,"/",m]})):t.jsx(t.Fragment,{})})]})}));p.displayName="WhatsAppTextEditor",exports.WhatsAppTextEditor=p;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),n=require("../../assets/icons/info.svg.js"),r=require("../../helpers/BaseWhatsappContentLang.helper.js"),l=require("react"),o=require("../../constants/Theme.js"),i=require("../TypographyStyle.js"),s=require("./CustomEditor.styled.js"),u=require("./WhatsAppTextEditorHeader.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=c(l);const d="Character limit reached",v=new r.BaseWhatsappContentLangHelper,p={[u.EditorActionTypes.BOLD]:"*",[u.EditorActionTypes.ITALIC]:"_",[u.EditorActionTypes.STRIKETHROUGH]:"~"},h=a.default.forwardRef(((r,c)=>{var a,h,{onChange:g,onClickVariable:x,text:f,RightComponent:j,error:C,limit:m,onError:O,rows:y,actions:E}=r,T=e.__rest(r,["onChange","onClickVariable","text","RightComponent","error","limit","onError","rows","actions"]);const b=l.useRef(null);function S(e){const t=null==b?void 0:b.current;null!=t&&(t.selectionStart?(t.focus(),t.selectionEnd=e):t.focus())}function L(e){var t,n;let r=null!==(n=null===(t=b.current)||void 0===t?void 0:t.value)&&void 0!==n?n:"";if(b.current&&e){const t=b.current.selectionStart,n=b.current.selectionEnd,l=e;if(t===n)return w(l);{r=v.wrappWildcard(t,n,l,r);const e=v.getHTML(r);return b.current.value=r,{text:r,html:e}}}return{text:r,html:r}}function w(e){var t,n;let r=null!==(n=null===(t=b.current)||void 0===t?void 0:t.value)&&void 0!==n?n:"";if(b.current&&e){const t=b.current.selectionStart;if(t===b.current.selectionEnd)return R(e,t)}return{text:r,html:r}}function R(e,t){var n,r;let l=null!==(r=null===(n=b.current)||void 0===n?void 0:n.value)&&void 0!==r?r:"";l=l.slice(0,t)+e+l.slice(t);const o=v.getHTML(l);return b.current.value=l,{text:l,html:o}}l.useImperativeHandle(c,(()=>({addTextOrWrap:L,addText:w,get(){var e,t;return null!==(t=null===(e=b.current)||void 0===e?void 0:e.value)&&void 0!==t?t:""},setCaretPosition:S}))),l.useEffect((()=>{if(null==b?void 0:b.current){b.current.value=f||"";const e=v.getHTML(f||"");null==g||g(f||"",e)}}),[f]),l.useEffect((()=>{var e,t;(null===(e=null==b?void 0:b.current)||void 0===e?void 0:e.value)&&m&&((null===(t=null==b?void 0:b.current)||void 0===t?void 0:t.value.length)>m?null==O||O(d):null==O||O(null!=C?C:""))}),[null===(a=null==b?void 0:b.current)||void 0===a?void 0:a.value.length]);return t.jsxs(s.OuterContainer,{children:[t.jsxs(s.Container,Object.assign({isError:!!C},{children:[t.jsx(u.WhatsAppTextEditorHeader,{actions:E,ref:b,onActionSelect:function(e){if((null==p?void 0:p[e])&&b.current){const t=b.current.selectionStart;if(t===b.current.selectionEnd){R(null==p?void 0:p[e],t);const{text:n,html:r}=R(null==p?void 0:p[e],t);S(t+1),null==g||g(n,r)}else{const{text:t,html:n}=L(null==p?void 0:p[e]);null==g||g(t,n)}}},RightComponent:j,onEmojiClick:function(e){const{text:t,html:n}=w(e);null==g||g(t,n)}}),t.jsxs("div",Object.assign({style:{position:"relative"}},{children:[t.jsx("div",Object.assign({style:{position:"absolute",top:0,left:0,pointerEvents:"none",color:"transparent",zIndex:1,width:"100%",whiteSpace:"pre-wrap",wordWrap:"break-word",padding:"12px 16px"}},{children:(()=>{var e;const n=(null===(e=null==b?void 0:b.current)||void 0===e?void 0:e.value)||"";console.log(n);const r=/(\{\{.*?\}\})/g;return n.split(r).map(((e,n)=>r.test(e)?t.jsx("span",Object.assign({onClick:()=>null==x?void 0:x(e),style:{color:"purple"}},{children:e}),n):e))})()})),t.jsx(s.TextSpace,Object.assign({style:{zIndex:2,background:"none",caretColor:o.COLORS.content.primary},ref:b,onChange:function(e){const t=e.target.value,n=v.getHTML(t);null==g||g(t,n)}},T,{rows:y}))]}))]})),C&&C!==d?t.jsxs("div",Object.assign({style:{display:"flex",gap:6,alignItems:"center"}},{children:[t.jsx(n.default,{width:16,height:16,color:o.COLORS.content.negative}),t.jsx(i.BodyCaption,Object.assign({color:o.COLORS.content.negative},{children:C}))]})):t.jsx(t.Fragment,{children:m&&(null==b?void 0:b.current)?t.jsxs(i.BodyCaption,Object.assign({style:{color:C===d||(null===(h=null==b?void 0:b.current)||void 0===h?void 0:h.value.length)>m?o.COLORS.content.negative:o.COLORS.content.secondary}},{children:[b.current.value.length,"/",m]})):t.jsx(t.Fragment,{})})]})}));h.displayName="WhatsAppTextEditor",exports.WhatsAppTextEditor=h;
@@ -12,6 +12,7 @@ export type CustomEditorProps = React.TextareaHTMLAttributes<HTMLTextAreaElement
12
12
  * Calls only for editor only error, not for errors coming from outside
13
13
  */
14
14
  onError?: (err: string) => void;
15
+ onClickVariable?: (variable: string) => void;
15
16
  };
16
17
  export type CustomEditorRef = {
17
18
  addTextOrWrap: (textToAdd: string) => {
@@ -37,4 +38,5 @@ export declare const WhatsAppTextEditor: React.ForwardRefExoticComponent<React.T
37
38
  * Calls only for editor only error, not for errors coming from outside
38
39
  */
39
40
  onError?: ((err: string) => void) | undefined;
41
+ onClickVariable?: ((variable: string) => void) | undefined;
40
42
  } & React.RefAttributes<CustomEditorRef>>;
@@ -1 +1 @@
1
- import{__rest as t}from"../../_virtual/_tslib.js";import{jsxs as n,jsx as e,Fragment as r}from"react/jsx-runtime";import l from"../../assets/icons/info.svg.js";import{BaseWhatsappContentLangHelper as o}from"../../helpers/BaseWhatsappContentLang.helper.js";import i,{useRef as u,useImperativeHandle as c,useEffect as s}from"react";import{COLORS as a}from"../../constants/Theme.js";import{BodyCaption as d}from"../TypographyStyle.js";import{OuterContainer as v,Container as m,TextSpace as h}from"./CustomEditor.styled.js";import{EditorActionTypes as f,WhatsAppTextEditorHeader as g}from"./WhatsAppTextEditorHeader.js";const p="Character limit reached",x=new o,j={[f.BOLD]:"*",[f.ITALIC]:"_",[f.STRIKETHROUGH]:"~"},T=i.forwardRef(((o,i)=>{var f,T,{onChange:C,text:E,RightComponent:y,error:O,limit:w,onError:H,rows:L,actions:S}=o,b=t(o,["onChange","text","RightComponent","error","limit","onError","rows","actions"]);const R=u(null);function W(t){const n=null==R?void 0:R.current;null!=n&&(n.selectionStart?(n.focus(),n.selectionEnd=t):n.focus())}function A(t){var n,e;let r=null!==(e=null===(n=R.current)||void 0===n?void 0:n.value)&&void 0!==e?e:"";if(R.current&&t){const n=R.current.selectionStart,e=R.current.selectionEnd,l=t;if(n===e)return I(l);{r=x.wrappWildcard(n,e,l,r);const t=x.getHTML(r);return R.current.value=r,{text:r,html:t}}}return{text:r,html:r}}function I(t){var n,e;let r=null!==(e=null===(n=R.current)||void 0===n?void 0:n.value)&&void 0!==e?e:"";if(R.current&&t){const n=R.current.selectionStart;if(n===R.current.selectionEnd)return M(t,n)}return{text:r,html:r}}function M(t,n){var e,r;let l=null!==(r=null===(e=R.current)||void 0===e?void 0:e.value)&&void 0!==r?r:"";l=l.slice(0,n)+t+l.slice(n);const o=x.getHTML(l);return R.current.value=l,{text:l,html:o}}return c(i,(()=>({addTextOrWrap:A,addText:I,get(){var t,n;return null!==(n=null===(t=R.current)||void 0===t?void 0:t.value)&&void 0!==n?n:""},setCaretPosition:W}))),s((()=>{if(null==R?void 0:R.current){R.current.value=E||"";const t=x.getHTML(E||"");null==C||C(E||"",t)}}),[E]),s((()=>{var t,n;(null===(t=null==R?void 0:R.current)||void 0===t?void 0:t.value)&&w&&((null===(n=null==R?void 0:R.current)||void 0===n?void 0:n.value.length)>w?null==H||H(p):null==H||H(null!=O?O:""))}),[null===(f=null==R?void 0:R.current)||void 0===f?void 0:f.value.length]),n(v,{children:[n(m,Object.assign({isError:!!O},{children:[e(g,{actions:S,ref:R,onActionSelect:function(t){if((null==j?void 0:j[t])&&R.current){const n=R.current.selectionStart;if(n===R.current.selectionEnd){M(null==j?void 0:j[t],n);const{text:e,html:r}=M(null==j?void 0:j[t],n);W(n+1),null==C||C(e,r)}else{const{text:n,html:e}=A(null==j?void 0:j[t]);null==C||C(n,e)}}},RightComponent:y,onEmojiClick:function(t){const{text:n,html:e}=I(t);null==C||C(n,e)}}),e(h,Object.assign({ref:R,onChange:function(t){const n=t.target.value,e=x.getHTML(n);null==C||C(n,e)}},b,{rows:L}))]})),O&&O!==p?n("div",Object.assign({style:{display:"flex",gap:6,alignItems:"center"}},{children:[e(l,{width:16,height:16,color:a.content.negative}),e(d,Object.assign({color:a.content.negative},{children:O}))]})):e(r,{children:w&&(null==R?void 0:R.current)?n(d,Object.assign({style:{color:O===p||(null===(T=null==R?void 0:R.current)||void 0===T?void 0:T.value.length)>w?a.content.negative:a.content.secondary}},{children:[R.current.value.length,"/",w]})):e(r,{})})]})}));T.displayName="WhatsAppTextEditor";export{T as WhatsAppTextEditor};
1
+ import{__rest as t}from"../../_virtual/_tslib.js";import{jsxs as n,jsx as e,Fragment as r}from"react/jsx-runtime";import l from"../../assets/icons/info.svg.js";import{BaseWhatsappContentLangHelper as o}from"../../helpers/BaseWhatsappContentLang.helper.js";import i,{useRef as c,useImperativeHandle as u,useEffect as s}from"react";import{COLORS as a}from"../../constants/Theme.js";import{BodyCaption as d}from"../TypographyStyle.js";import{OuterContainer as v,Container as p,TextSpace as h}from"./CustomEditor.styled.js";import{EditorActionTypes as m,WhatsAppTextEditorHeader as g}from"./WhatsAppTextEditorHeader.js";const f="Character limit reached",x=new o,j={[m.BOLD]:"*",[m.ITALIC]:"_",[m.STRIKETHROUGH]:"~"},C=i.forwardRef(((o,i)=>{var m,C,{onChange:b,onClickVariable:y,text:E,RightComponent:T,error:w,limit:O,onError:S,rows:H,actions:L}=o,k=t(o,["onChange","onClickVariable","text","RightComponent","error","limit","onError","rows","actions"]);const I=c(null);function R(t){const n=null==I?void 0:I.current;null!=n&&(n.selectionStart?(n.focus(),n.selectionEnd=t):n.focus())}function W(t){var n,e;let r=null!==(e=null===(n=I.current)||void 0===n?void 0:n.value)&&void 0!==e?e:"";if(I.current&&t){const n=I.current.selectionStart,e=I.current.selectionEnd,l=t;if(n===e)return A(l);{r=x.wrappWildcard(n,e,l,r);const t=x.getHTML(r);return I.current.value=r,{text:r,html:t}}}return{text:r,html:r}}function A(t){var n,e;let r=null!==(e=null===(n=I.current)||void 0===n?void 0:n.value)&&void 0!==e?e:"";if(I.current&&t){const n=I.current.selectionStart;if(n===I.current.selectionEnd)return M(t,n)}return{text:r,html:r}}function M(t,n){var e,r;let l=null!==(r=null===(e=I.current)||void 0===e?void 0:e.value)&&void 0!==r?r:"";l=l.slice(0,n)+t+l.slice(n);const o=x.getHTML(l);return I.current.value=l,{text:l,html:o}}u(i,(()=>({addTextOrWrap:W,addText:A,get(){var t,n;return null!==(n=null===(t=I.current)||void 0===t?void 0:t.value)&&void 0!==n?n:""},setCaretPosition:R}))),s((()=>{if(null==I?void 0:I.current){I.current.value=E||"";const t=x.getHTML(E||"");null==b||b(E||"",t)}}),[E]),s((()=>{var t,n;(null===(t=null==I?void 0:I.current)||void 0===t?void 0:t.value)&&O&&((null===(n=null==I?void 0:I.current)||void 0===n?void 0:n.value.length)>O?null==S||S(f):null==S||S(null!=w?w:""))}),[null===(m=null==I?void 0:I.current)||void 0===m?void 0:m.value.length]);return n(v,{children:[n(p,Object.assign({isError:!!w},{children:[e(g,{actions:L,ref:I,onActionSelect:function(t){if((null==j?void 0:j[t])&&I.current){const n=I.current.selectionStart;if(n===I.current.selectionEnd){M(null==j?void 0:j[t],n);const{text:e,html:r}=M(null==j?void 0:j[t],n);R(n+1),null==b||b(e,r)}else{const{text:n,html:e}=W(null==j?void 0:j[t]);null==b||b(n,e)}}},RightComponent:T,onEmojiClick:function(t){const{text:n,html:e}=A(t);null==b||b(n,e)}}),n("div",Object.assign({style:{position:"relative"}},{children:[e("div",Object.assign({style:{position:"absolute",top:0,left:0,pointerEvents:"none",color:"transparent",zIndex:1,width:"100%",whiteSpace:"pre-wrap",wordWrap:"break-word",padding:"12px 16px"}},{children:(()=>{var t;const n=(null===(t=null==I?void 0:I.current)||void 0===t?void 0:t.value)||"";console.log(n);const r=/(\{\{.*?\}\})/g;return n.split(r).map(((t,n)=>r.test(t)?e("span",Object.assign({onClick:()=>null==y?void 0:y(t),style:{color:"purple"}},{children:t}),n):t))})()})),e(h,Object.assign({style:{zIndex:2,background:"none",caretColor:a.content.primary},ref:I,onChange:function(t){const n=t.target.value,e=x.getHTML(n);null==b||b(n,e)}},k,{rows:H}))]}))]})),w&&w!==f?n("div",Object.assign({style:{display:"flex",gap:6,alignItems:"center"}},{children:[e(l,{width:16,height:16,color:a.content.negative}),e(d,Object.assign({color:a.content.negative},{children:w}))]})):e(r,{children:O&&(null==I?void 0:I.current)?n(d,Object.assign({style:{color:w===f||(null===(C=null==I?void 0:I.current)||void 0===C?void 0:C.value.length)>O?a.content.negative:a.content.secondary}},{children:[I.current.value.length,"/",O]})):e(r,{})})]})}));C.displayName="WhatsAppTextEditor";export{C as WhatsAppTextEditor};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.564-beta.picker.5",
3
+ "version": "0.0.564-beta.picker.6",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",