@bikdotai/bik-component-library 0.0.646-beta.6 → 0.0.646-beta.8

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.
Files changed (79) hide show
  1. package/dist/cjs/assets/icons/boxV2.svg.js +1 -0
  2. package/dist/cjs/assets/icons/help.svg.js +1 -0
  3. package/dist/cjs/assets/icons/openai.svg.js +1 -0
  4. package/dist/cjs/assets/icons/redirect.svg.js +1 -0
  5. package/dist/cjs/assets/icons/text_t9.svg.js +1 -0
  6. package/dist/cjs/assets/icons/website.svg.js +1 -0
  7. package/dist/cjs/components/analytics-chips-and-dropdowns/chart/Pie/PieChartAnalytics.js +1 -1
  8. package/dist/cjs/components/data-source-panel/DataSourceInfoFooter.d.ts +19 -0
  9. package/dist/cjs/components/data-source-panel/DataSourceInfoFooter.js +1 -0
  10. package/dist/cjs/components/data-source-panel/DataSourcePanel.d.ts +23 -0
  11. package/dist/cjs/components/data-source-panel/DataSourcePanel.js +1 -0
  12. package/dist/cjs/components/data-source-panel/DataSourcePanel.style.d.ts +3 -0
  13. package/dist/cjs/components/data-source-panel/DataSourcePanel.style.js +123 -0
  14. package/dist/cjs/components/data-source-panel/index.d.ts +1 -0
  15. package/dist/cjs/components/data-source-panel/model.d.ts +135 -0
  16. package/dist/cjs/components/data-source-panel/model.js +1 -0
  17. package/dist/cjs/components/dropdown/ChipInput.d.ts +1 -1
  18. package/dist/cjs/components/dropdown/ChipInput.js +1 -1
  19. package/dist/cjs/components/dropdown/Dropdown.d.ts +1 -1
  20. package/dist/cjs/components/dropdown/Dropdown.js +1 -1
  21. package/dist/cjs/components/input/Input.d.ts +1 -1
  22. package/dist/cjs/components/input/Input.js +1 -1
  23. package/dist/cjs/components/input/Input.styled.js +1 -1
  24. package/dist/cjs/components/modals/styledModal.d.ts +0 -1
  25. package/dist/cjs/components/modals/styledModal.js +1 -1
  26. package/dist/cjs/components/product-picker-v2/modal.d.ts +1 -5
  27. package/dist/cjs/components/product-picker-v2/modal.js +1 -1
  28. package/dist/cjs/components/product-picker-v2/utility.d.ts +1 -13
  29. package/dist/cjs/components/product-picker-v2/utility.js +1 -1
  30. package/dist/cjs/components/unsatisfactory-response-list/UnsatisfactoryCountIntentWiseModal.d.ts +14 -0
  31. package/dist/cjs/components/unsatisfactory-response-list/UnsatisfactoryCountIntentWiseModal.js +1 -0
  32. package/dist/cjs/components/unsatisfactory-response-list/UnsatisfactoryCountIntentWiseModal.style.d.ts +1 -0
  33. package/dist/cjs/components/unsatisfactory-response-list/UnsatisfactoryCountIntentWiseModal.style.js +42 -0
  34. package/dist/cjs/components/unsatisfactory-response-list/UnsatisfactoryResponseList.d.ts +15 -0
  35. package/dist/cjs/components/unsatisfactory-response-list/UnsatisfactoryResponseList.js +1 -0
  36. package/dist/cjs/components/unsatisfactory-response-list/UnsatisfactoryResponseList.style.d.ts +1 -0
  37. package/dist/cjs/components/unsatisfactory-response-list/UnsatisfactoryResponseList.style.js +38 -0
  38. package/dist/cjs/index.d.ts +3 -0
  39. package/dist/cjs/index.js +1 -1
  40. package/dist/esm/assets/icons/boxV2.svg.js +1 -0
  41. package/dist/esm/assets/icons/help.svg.js +1 -0
  42. package/dist/esm/assets/icons/openai.svg.js +1 -0
  43. package/dist/esm/assets/icons/redirect.svg.js +1 -0
  44. package/dist/esm/assets/icons/text_t9.svg.js +1 -0
  45. package/dist/esm/assets/icons/website.svg.js +1 -0
  46. package/dist/esm/components/analytics-chips-and-dropdowns/chart/Pie/PieChartAnalytics.js +1 -1
  47. package/dist/esm/components/data-source-panel/DataSourceInfoFooter.d.ts +19 -0
  48. package/dist/esm/components/data-source-panel/DataSourceInfoFooter.js +1 -0
  49. package/dist/esm/components/data-source-panel/DataSourcePanel.d.ts +23 -0
  50. package/dist/esm/components/data-source-panel/DataSourcePanel.js +1 -0
  51. package/dist/esm/components/data-source-panel/DataSourcePanel.style.d.ts +3 -0
  52. package/dist/esm/components/data-source-panel/DataSourcePanel.style.js +123 -0
  53. package/dist/esm/components/data-source-panel/index.d.ts +1 -0
  54. package/dist/esm/components/data-source-panel/model.d.ts +135 -0
  55. package/dist/esm/components/data-source-panel/model.js +1 -0
  56. package/dist/esm/components/dropdown/ChipInput.d.ts +1 -1
  57. package/dist/esm/components/dropdown/ChipInput.js +1 -1
  58. package/dist/esm/components/dropdown/Dropdown.d.ts +1 -1
  59. package/dist/esm/components/dropdown/Dropdown.js +1 -1
  60. package/dist/esm/components/input/Input.d.ts +1 -1
  61. package/dist/esm/components/input/Input.js +1 -1
  62. package/dist/esm/components/input/Input.styled.js +1 -1
  63. package/dist/esm/components/modals/styledModal.d.ts +0 -1
  64. package/dist/esm/components/modals/styledModal.js +1 -1
  65. package/dist/esm/components/product-picker-v2/modal.d.ts +1 -5
  66. package/dist/esm/components/product-picker-v2/modal.js +1 -1
  67. package/dist/esm/components/product-picker-v2/utility.d.ts +1 -13
  68. package/dist/esm/components/product-picker-v2/utility.js +1 -1
  69. package/dist/esm/components/unsatisfactory-response-list/UnsatisfactoryCountIntentWiseModal.d.ts +14 -0
  70. package/dist/esm/components/unsatisfactory-response-list/UnsatisfactoryCountIntentWiseModal.js +1 -0
  71. package/dist/esm/components/unsatisfactory-response-list/UnsatisfactoryCountIntentWiseModal.style.d.ts +1 -0
  72. package/dist/esm/components/unsatisfactory-response-list/UnsatisfactoryCountIntentWiseModal.style.js +42 -0
  73. package/dist/esm/components/unsatisfactory-response-list/UnsatisfactoryResponseList.d.ts +15 -0
  74. package/dist/esm/components/unsatisfactory-response-list/UnsatisfactoryResponseList.js +1 -0
  75. package/dist/esm/components/unsatisfactory-response-list/UnsatisfactoryResponseList.style.d.ts +1 -0
  76. package/dist/esm/components/unsatisfactory-response-list/UnsatisfactoryResponseList.style.js +38 -0
  77. package/dist/esm/index.d.ts +3 -0
  78. package/dist/esm/index.js +1 -1
  79. package/package.json +1 -1
@@ -0,0 +1,135 @@
1
+ /// <reference types="react" />
2
+ export interface MessageSource {
3
+ sources: InfoContent[];
4
+ intent: string;
5
+ messageId: string;
6
+ output_message_id?: string;
7
+ isUnsatisfactoryAnswer?: boolean;
8
+ isEditable?: boolean;
9
+ }
10
+ export interface InfoContent {
11
+ title: string;
12
+ docId?: string;
13
+ subTitle?: string;
14
+ link?: string | string[];
15
+ type?: string;
16
+ intent?: string;
17
+ productId?: string;
18
+ variantId?: string;
19
+ imageUrl?: string;
20
+ isTrainable?: boolean;
21
+ subIntent?: string;
22
+ insights?: string;
23
+ }
24
+ export interface DataSourcePanelZeroState {
25
+ title: string;
26
+ leadingIcon: React.FunctionComponent<React.SVGAttributes<SVGElement>>;
27
+ onClick: () => void;
28
+ }
29
+ export interface AllSourceInfoDetailsCustomDataModel {
30
+ [keys: string]: SourceInfoDetailsCustomDataModel;
31
+ }
32
+ export interface SourceInfoDetailsCustomDataModel {
33
+ storeId: string;
34
+ type: CustomDataType;
35
+ data: FileMetaData | CustomDataDocument | CustomDataFaqModel;
36
+ content?: string;
37
+ docId: string;
38
+ onEditClick: (item: FileMetaData | CustomDataDocument | CustomDataFaqModel, type: string) => void;
39
+ redirect?: (source: InfoContent) => void;
40
+ }
41
+ export declare enum CustomDataCategories {
42
+ PAGE = "page",
43
+ POLICY = "policy",
44
+ ARTICLE = "article",
45
+ UPLOADED = "uploaded",
46
+ TEXT = "text"
47
+ }
48
+ export type CustomDataCategory = keyof typeof CustomDataCategories;
49
+ export declare enum CustomDataType {
50
+ FAQ = "FAQ",
51
+ FILES = "FILES",
52
+ WEBSITE_LINKS = "WEBSITE_LINKS",
53
+ TEXTS = "TEXTS",
54
+ FETCHED_LINKS = "FETCHED_LINKS",
55
+ URL = "URL",
56
+ TRAINING_TEMPLATE = "TRAINING_TEMPLATE"
57
+ }
58
+ export interface FileMetaData {
59
+ fileId: string;
60
+ fileName: string;
61
+ fileSize: string;
62
+ fileType: string;
63
+ fileUrl: string;
64
+ uploadType: 'URL' | 'FileUpload';
65
+ uploadDate: Date;
66
+ characterCount?: number;
67
+ intent?: string;
68
+ fileContent?: string;
69
+ fileContentPath?: string;
70
+ fileContentText?: string;
71
+ isActive?: boolean;
72
+ }
73
+ export interface CustomDataDocument {
74
+ category: CustomDataCategory;
75
+ id: string;
76
+ handle?: string;
77
+ title?: string;
78
+ createdAt?: Date;
79
+ updatedAt?: Date;
80
+ url?: string;
81
+ isActive?: boolean;
82
+ characterCount?: number;
83
+ intent?: string;
84
+ wasManualLinkAdded?: boolean;
85
+ fileContent?: string;
86
+ fileContentText?: string;
87
+ fileId?: string;
88
+ fileContentPath?: string;
89
+ fileName?: string;
90
+ lastEditedAt?: number;
91
+ }
92
+ export interface CustomDataFaqModel {
93
+ id: string;
94
+ question: string;
95
+ answer: string;
96
+ createdAt: Date;
97
+ updatedAt?: Date;
98
+ questionSpecificProducts?: Array<FaqProductModel>;
99
+ products?: Array<FaqProductModel>;
100
+ cta?: Array<LiveChatCTA>;
101
+ intent?: string;
102
+ crmNoteMeta?: CRMNoteMeta;
103
+ fromEditResponse?: boolean;
104
+ isTemplateFAQ?: boolean;
105
+ isSatisfactoryAnswer?: boolean;
106
+ }
107
+ export interface FaqProductModel {
108
+ id: string;
109
+ variantId: string;
110
+ name: string;
111
+ imageUrl: string;
112
+ }
113
+ export interface CRMNoteMeta {
114
+ createdAt: Date;
115
+ sessionId: string;
116
+ userId: number;
117
+ messageId: string;
118
+ customerId: string;
119
+ updatedAt: Date;
120
+ }
121
+ export interface LiveChatCTA {
122
+ url: string;
123
+ cta: string;
124
+ buttonType: string;
125
+ }
126
+ export interface footerButtonOptionModel {
127
+ title?: string;
128
+ subtitle?: string;
129
+ buttonTitle: string;
130
+ addFaqProps?: any;
131
+ redirectUrl?: string;
132
+ hideAddDataButton?: boolean;
133
+ navigate?: (pagePathKey: Record<string, string>, params?: object, queryParam?: object, openInNewTab?: boolean) => void;
134
+ onClick: () => void;
135
+ }
@@ -0,0 +1 @@
1
+ var E,T;!function(E){E.PAGE="page",E.POLICY="policy",E.ARTICLE="article",E.UPLOADED="uploaded",E.TEXT="text"}(E||(E={})),function(E){E.FAQ="FAQ",E.FILES="FILES",E.WEBSITE_LINKS="WEBSITE_LINKS",E.TEXTS="TEXTS",E.FETCHED_LINKS="FETCHED_LINKS",E.URL="URL",E.TRAINING_TEMPLATE="TRAINING_TEMPLATE"}(T||(T={}));export{E as CustomDataCategories,T as CustomDataType};
@@ -6,7 +6,7 @@ interface ChipInputProps {
6
6
  onDeleteChip: (chip: SingleOption) => void;
7
7
  containerStyle?: React.CSSProperties;
8
8
  isDropdownOpened?: boolean;
9
- sizeToUse?: 'default' | 'small' | 'x-small';
9
+ sizeToUse?: 'default' | 'small';
10
10
  }
11
11
  declare const ChipInput: React.FC<ChipInputProps>;
12
12
  export default ChipInput;
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as l,useEffect as s}from"react";import r from"../../utils/StringUtils.js";import{COLORS as o}from"../../constants/Theme.js";import n from"../../assets/icons/chevronDown.svg.js";import i from"../../assets/icons/cross.svg.js";import{Tag as c}from"../tag/Tag.js";import{BodyCaption as a}from"../TypographyStyle.js";import{ChipInputWrapper as m}from"./Common.styled.js";const h=h=>{let{chips:d,onDeleteChip:g,containerStyle:p={},sizeToUse:j="default",isDropdownOpened:f,placeholder:b="Select.."}=h;const[y,u]=l(),[v,O]=l(0);return s((()=>{if(!d)return;let e=0;const t=(e=>1===e.length?100:2===e.length?40:34)(d);let l=d.filter((l=>(e+=l.label.length,e<=t)));0===l.length&&d.length>0&&(l=[d[0]]),u(l),O(d.length-l.length)}),[d]),e(m,Object.assign({style:Object.assign({},p)},{children:[e("div",Object.assign({className:"chips-container"},{children:[null==y?void 0:y.map(((e,l)=>t("div",Object.assign({style:{zIndex:2}},{children:t(c,Object.assign({tagText:r.truncateText(e.selectedLabel||e.label,40),TrailingIcon:()=>t(i,{width:12,height:12,style:{cursor:"pointer"},onClick:()=>{g(e)}})},{children:e.selectedLabel||e.label}))}),l))),!!v&&t(a,Object.assign({color:o.content.placeholder},{children:`+${v} more`})),0===d.length&&t("div",Object.assign({style:{color:o.content.placeholder}},{children:b}))]})),t("div",{children:t(n,{style:{transform:f?"rotate(180deg)":"rotate(0deg)"},width:"x-small"===j?16:"small"===j?20:24,height:"x-small"===j?16:"small"===j?20:24,color:o.content.primary})})]}))};export{h as default};
1
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as l,useEffect as s}from"react";import r from"../../utils/StringUtils.js";import{COLORS as o}from"../../constants/Theme.js";import n from"../../assets/icons/chevronDown.svg.js";import i from"../../assets/icons/cross.svg.js";import{Tag as c}from"../tag/Tag.js";import{BodyCaption as a}from"../TypographyStyle.js";import{ChipInputWrapper as h}from"./Common.styled.js";const m=m=>{let{chips:d,onDeleteChip:g,containerStyle:p={},sizeToUse:j="default",isDropdownOpened:f,placeholder:b="Select.."}=m;const[y,u]=l(),[v,O]=l(0);return s((()=>{if(!d)return;let e=0;const t=(e=>1===e.length?100:2===e.length?40:34)(d);let l=d.filter((l=>(e+=l.label.length,e<=t)));0===l.length&&d.length>0&&(l=[d[0]]),u(l),O(d.length-l.length)}),[d]),e(h,Object.assign({style:Object.assign({},p)},{children:[e("div",Object.assign({className:"chips-container"},{children:[null==y?void 0:y.map(((e,l)=>t("div",Object.assign({style:{zIndex:2}},{children:t(c,Object.assign({tagText:r.truncateText(e.selectedLabel||e.label,40),TrailingIcon:()=>t(i,{width:12,height:12,style:{cursor:"pointer"},onClick:()=>{g(e)}})},{children:e.selectedLabel||e.label}))}),l))),!!v&&t(a,Object.assign({color:o.content.placeholder},{children:`+${v} more`})),0===d.length&&t("div",Object.assign({style:{color:o.content.placeholder}},{children:b}))]})),t("div",{children:t(n,{style:{transform:f?"rotate(180deg)":"rotate(0deg)"},width:"small"===j?20:24,height:"small"===j?20:24,color:o.content.primary})})]}))};export{m as default};
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { OpenDropdownProps, SingleOption } from './type';
3
3
  export type DropdownProps = OpenDropdownProps & {
4
4
  placeHolder?: string;
5
- size?: 'default' | 'small' | 'x-small';
5
+ size?: 'default' | 'small';
6
6
  disabled?: boolean;
7
7
  noErrorHint?: boolean;
8
8
  buttonWidth?: string;
@@ -1 +1 @@
1
- import{__rest as e}from"../../_virtual/_tslib.js";import{jsx as o,jsxs as t,Fragment as n}from"react/jsx-runtime";import{useState as l,useRef as i,useEffect as r}from"react";import{COLORS as s}from"../../constants/Theme.js";import a from"../../assets/icons/chevronDown.svg.js";import{Input as d}from"../input/Input.js";import{InputStyleContext as p}from"../input/context/InputStyleProvider.js";import c from"./ChipInput.js";import{DropdownPopover as u}from"./DropdownPopover/index.js";import{getSelectedOptionsAsText as h}from"./OpenedDropdown/utils/iterationOnOptions.js";function m(){}const v=v=>{var f,g,w,x,b,{placeHolder:j,size:I,onSelect:y,defaultOptions:O,disabled:S,noErrorHint:H,placeHolderHeight:D,showPlaceholderWhenSelected:T=!1,inputStyle:C={},inputType:P="default",onDeleteChip:E,truncatedText:z,showLeadingIconInPlaceholder:W=!1}=v,A=e(v,["placeHolder","size","onSelect","defaultOptions","disabled","noErrorHint","placeHolderHeight","showPlaceholderWhenSelected","inputStyle","inputType","onDeleteChip","truncatedText","showLeadingIconInPlaceholder"]);const[L,_]=l(!1),k=null!=I?I:"default",M=i(),[N,U]=l(null!=O?O:[]);r((()=>{var e;const o=[];null===(e=null==A?void 0:A.options)||void 0===e||e.forEach((e=>{e.options?e.options.forEach((e=>{e.selected&&o.push(Object.assign(Object.assign({},e),{label:e.label}))})):e.selected&&o.push(e)})),U([...o])}),[A.options]),r((()=>{O&&U([...O])}),[O]);const V=h(N);return o(p.Provider,Object.assign({value:{InputWrapper:Object.assign({height:D||("x-small"===k?24:"small"===k?32:48),width:null!==(g=null!==(f=A.buttonWidth)&&void 0!==f?f:A.width)&&void 0!==g?g:"100%",zIndex:1,cursor:"pointer",padding:"x-small"===k?"4px 8px":"6px 8px"},C),input:{minHeight:"100%"}}},{children:t(u,Object.assign({"data-test":A["data-test"],ref:M,onSelect:function(e){Array.isArray(e)?U([...e]):U([e]),null==y||y(e)},disabled:S,onDropdownVisbilityChange:e=>_(e)},A,{children:["default"==P&&o(d,{version:A.version,noErrorHint:H,state:S?"disabled":"none",value:T?j:null!=V?V:"",errorMessage:A.error,variant:k,placeholder:null!=j?j:"Select an option",width:null!==(w=A.width)&&void 0!==w?w:"100%",onChangeText:m,leftIcon:W&&(null===(x=N[0])||void 0===x?void 0:x.leadingIcon)?{icon:()=>{var e;return o(n,{children:null===(e=N[0])||void 0===e?void 0:e.leadingIcon})}}:void 0,rightIcon:{icon:()=>o(a,{style:{transform:L?"rotate(180deg)":"rotate(0deg)"},onClick:m,width:"x-small"===k?16:"small"===k?20:24,height:"x-small"===k?16:"small"===k?20:24,color:s.content.primary})},truncateText:null==z||z}),"chip"==P&&o(c,{placeholder:null!=j?j:"Select options",chips:N,onDeleteChip:e=>{null==E||E(e)},isDropdownOpened:L,sizeToUse:k,containerStyle:{width:null!==(b=A.width)&&void 0!==b?b:"100%",cursor:"pointer"}})]}))}))};v.displayName="Dropdown";export{v as Dropdown};
1
+ import{__rest as e}from"../../_virtual/_tslib.js";import{jsx as o,jsxs as t,Fragment as n}from"react/jsx-runtime";import{useState as i,useRef as l,useEffect as r}from"react";import{COLORS as s}from"../../constants/Theme.js";import d from"../../assets/icons/chevronDown.svg.js";import{Input as a}from"../input/Input.js";import{InputStyleContext as p}from"../input/context/InputStyleProvider.js";import c from"./ChipInput.js";import{DropdownPopover as u}from"./DropdownPopover/index.js";import{getSelectedOptionsAsText as h}from"./OpenedDropdown/utils/iterationOnOptions.js";function m(){}const v=v=>{var f,g,w,b,j,{placeHolder:I,size:y,onSelect:x,defaultOptions:O,disabled:S,noErrorHint:H,placeHolderHeight:D,showPlaceholderWhenSelected:T=!1,inputStyle:C={},inputType:P="default",onDeleteChip:E,truncatedText:z,showLeadingIconInPlaceholder:W=!1}=v,A=e(v,["placeHolder","size","onSelect","defaultOptions","disabled","noErrorHint","placeHolderHeight","showPlaceholderWhenSelected","inputStyle","inputType","onDeleteChip","truncatedText","showLeadingIconInPlaceholder"]);const[L,_]=i(!1),k=null!=y?y:"default",M=l(),[N,U]=i(null!=O?O:[]);r((()=>{var e;const o=[];null===(e=null==A?void 0:A.options)||void 0===e||e.forEach((e=>{e.options?e.options.forEach((e=>{e.selected&&o.push(Object.assign(Object.assign({},e),{label:e.label}))})):e.selected&&o.push(e)})),U([...o])}),[A.options]),r((()=>{O&&U([...O])}),[O]);const V=h(N);return o(p.Provider,Object.assign({value:{InputWrapper:Object.assign({height:D||("small"===k?32:48),width:null!==(g=null!==(f=A.buttonWidth)&&void 0!==f?f:A.width)&&void 0!==g?g:"100%",zIndex:1,cursor:"pointer",padding:"6px 8px"},C),input:{minHeight:"100%"}}},{children:t(u,Object.assign({"data-test":A["data-test"],ref:M,onSelect:function(e){Array.isArray(e)?U([...e]):U([e]),null==x||x(e)},disabled:S,onDropdownVisbilityChange:e=>_(e)},A,{children:["default"==P&&o(a,{version:A.version,noErrorHint:H,state:S?"disabled":"none",value:T?I:null!=V?V:"",errorMessage:A.error,variant:k,placeholder:null!=I?I:"Select an option",width:null!==(w=A.width)&&void 0!==w?w:"100%",onChangeText:m,leftIcon:W&&(null===(b=N[0])||void 0===b?void 0:b.leadingIcon)?{icon:()=>{var e;return o(n,{children:null===(e=N[0])||void 0===e?void 0:e.leadingIcon})}}:void 0,rightIcon:{icon:()=>o(d,{style:{transform:L?"rotate(180deg)":"rotate(0deg)"},onClick:m,width:"small"===k?20:24,height:"small"===k?20:24,color:s.content.primary})},truncateText:null==z||z}),"chip"==P&&o(c,{placeholder:null!=I?I:"Select options",chips:N,onDeleteChip:e=>{null==E||E(e)},isDropdownOpened:L,sizeToUse:k,containerStyle:{width:null!==(j=A.width)&&void 0!==j?j:"100%",cursor:"pointer"}})]}))}))};v.displayName="Dropdown";export{v as Dropdown};
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ButtonProps } from '../button/model';
3
- export type InputVariant = 'default' | 'small' | 'x-small';
3
+ export type InputVariant = 'default' | 'small';
4
4
  export type InputStateI = 'invalid' | 'active' | 'read-only' | 'disabled' | 'disabled-invalid' | 'none';
5
5
  export type InputTypeI = 'number' | 'email' | 'text' | 'multiline' | 'url' | 'zip' | 'phonenumber' | 'password';
6
6
  export interface InputProps {
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import i from"../../assets/icons/info.svg.js";import{forwardRef as l,useState as r,useContext as o,useRef as a,useEffect as s}from"react";import{Button as c}from"../button/Button.js";import{isFunction as h,validateInput as u}from"./Input-helper.js";import{Tooltip as d}from"../tooltips/Tooltip.js";import{TitleSmall as v,BodySecondary as p}from"../TypographyStyle.js";import{COLORS as g}from"../../constants/Theme.js";import m from"../../assets/icons/errorInfo.svg.js";import{InputStyleContext as x}from"./context/InputStyleProvider.js";import{RootContainer as b,InputFooter as f,MaxCharStyle as y,InputWrapper as j,IconHolder as C,PrefixHolder as O,InputContainer as T,InputContainerSmall as w,SuffixHolder as I,InputHeader as k}from"./Input.styled.js";const L=l(((l,L)=>{var H,B,E,M,P,D,S;const{placeholder:z,leftIcon:A,rightIcon:F,labelText:K,maxCharLimit:N,isRequired:R,hintText:G,type:_,state:q,validate:V,variant:W,button:$,suffixText:J,prefixText:Q,onChangeText:U,value:X,noErrorHint:Y,reset:Z,rangeValidation:ee,noKeyDownChange:te,version:ne,noMaxCharCheck:ie,labelElement:le,autoGrow:re,minHeight:oe,maxHeight:ae,labelTextBold:se,truncateText:ce,maxCharLimitPosition:he,hightlightInputColor:ue,onKeyDownEvent:de,hideInputHeader:ve}=Object.assign({maxCharLimit:0,type:"text",variant:"default",maxCharLimitPosition:"TOP"},l),pe=null==A?void 0:A.icon,ge=null==F?void 0:F.icon,[me,xe]=r(!1),[be,fe]=r(!1),[ye,je]=r(),Ce="x-small"===W?"12px":"small"===W?"18px":"22px",Oe=o(x),[Te,we]=r(),Ie=a(null),ke=null!=L?L:Ie;s((()=>{we(X),!X&&re&&(ke.current.style.height=oe||"48px")}),[X]),s((()=>{var e;ke.current&&(null===(e=l.onReferenceInit)||void 0===e||e.call(l,ke.current))}),[ke]),s((()=>{const e=ke.current;if(e&&["phonenumber","zip","number"].includes(_))return e.addEventListener("wheel",Ee,{passive:!1}),()=>{e.removeEventListener("wheel",Ee)}}),[]),s((()=>{Z&&we("")}),[Z]),s((()=>{var e;fe(!!l.isActive),l.isActive&&(null===(e=ke.current)||void 0===e||e.focus())}),[l.isActive]),s((()=>{je(l.errorMessage)}),[l.errorMessage]),s((()=>{var e;xe(!1),("invalid"===l.state||ye||"disabled-invalid"===l.state)&&xe(!0),"active"===l.state&&(null===(e=ke.current)||void 0===e||e.focus())}),[l.state,ye]),s((()=>{xe(!!ye||"invalid"===l.state)}),[ye,l.state]);const Le=function(e){if(h(e)){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];e(...n)}},He=()=>"zip"===_?6:2e3,Be=e=>{const t=0!==N?N:He();if(de&&de(e),te||U(X||"",e),ie)return;const n=e.target.value;![8].includes(e.which)&&t>0&&n.length>=t&&e.preventDefault()},Ee=e=>{e.preventDefault()},Me=e=>{let t=e.target.value;const n=0!==N?N+1:He();!ie&&n>0&&t.length>=n&&(t=t.substring(0,n-1)),U(t,e),l.textControl||we(t),re&&(ke.current.style.height=`${ke.current.scrollHeight}px`,t||(ke.current.style.height=oe||"48px"));const i=V||u;if(!i||!h(i))return;const[r,o]=i(t,_,ee);xe(!r),je(l.errorMessage?l.errorMessage:o)},Pe=e=>{var t;l.skipFocus||fe(!0),Le(null===(t=l.onFocus)||void 0===t?void 0:t.call(l,e))},De=e=>{var t;l.skipFocus||fe(!1),Le(null===(t=l.onBlur)||void 0===t?void 0:t.call(l,e))},Se=()=>{var i;return e(n,{children:["multiline"!==_&&t("input",{className:ce?"truncate-class":"","data-test":l["data-test"],id:l.id,style:null!==(i=null==Oe?void 0:Oe.input)&&void 0!==i?i:{},ref:ke,type:["phonenumber","zip","number"].includes(_)?"number":_,value:Te,onFocus:e=>Pe(e),onBlur:e=>De(e),placeholder:z||"Enter here",onChange:Me,onClick:e=>Le(l.onClick),onKeyDown:e=>Be(e)}),"multiline"===_&&t("textarea",{"data-test":l["data-test"],value:Te,ref:ke,onFocus:e=>Pe(e),onBlur:e=>De(e),onClick:e=>Le(l.onClick),placeholder:z||"Enter here",onChange:Me,onKeyDown:e=>Be(e),maxLength:N>0?N:void 0})]})};return e(b,Object.assign({width:l.width,height:l.height,state:q,type:_,style:null!==(H=null==Oe?void 0:Oe.RootContainer)&&void 0!==H?H:{}},{children:[e("div",Object.assign({className:"flex-align-center"},{children:[!Y&&(!!G||!!ye)&&e(f,Object.assign({invalid:!!ye},{children:[!!ye&&t(m,{width:16,height:16}),ye||G]})),N>0&&"BOTTOM"===he&&e(y,Object.assign({position:"BOTTOM"},{children:[null!==(E=null===(B=(null!=X?X:"").toString())||void 0===B?void 0:B.length)&&void 0!==E?E:0,"/",N]}))]})),e(j,Object.assign({variant:W,state:q,width:l.width,isActive:"active"===q||be,isInvalid:me,style:null!==(M=null==Oe?void 0:Oe.InputWrapper)&&void 0!==M?M:{},version:ne,height:l.height,hightlightInputColor:ue},{children:[!!pe&&t(C,Object.assign({variant:W,iconSize:Ce,onClick:()=>Le(null==A?void 0:A.callback),isLeft:!0,style:null!==(P=null==Oe?void 0:Oe.IconHolder)&&void 0!==P?P:{}},{children:t(pe,{})})),!!Q&&t(O,Object.assign({variant:W},{children:Q})),"default"===W&&t(T,Object.assign({height:l.height,type:l.type,minHeight:oe,maxHeight:ae,autoGrow:re},{children:Se()})),["x-small","small"].includes(W)&&t(w,Object.assign({height:l.height,type:l.type},{children:Se()})),!!ge&&t(C,Object.assign({variant:W,iconSize:Ce,onClick:()=>Le(null==F?void 0:F.callback),isLeft:!1},{children:t(ge,{})})),!!J&&t(I,Object.assign({variant:W},{children:J})),$&&$.text&&t(c,{buttonText:$.text,onClick:()=>Le(null==$?void 0:$.onClick)}),$&&$.buttonProps&&t(c,Object.assign({},$.buttonProps))]})),!ve&&(!!K||!!N)&&e(k,Object.assign({invalid:me},{children:[le&&le,e("div",Object.assign({className:"label__container"},{children:[e(se?v:p,{children:[K,R?t("span",{children:"*"}):""]}),l.tooltipText&&t(d,Object.assign({body:l.tooltipText,placement:"top"},{children:t("span",{children:t(i,{style:{marginTop:-3},width:18,height:18,color:me?g.content.negative:g.content.primary})})}))]})),N>0&&"TOP"===he&&e(y,{children:[null!==(S=null===(D=(null!=X?X:"").toString())||void 0===D?void 0:D.length)&&void 0!==S?S:0,"/",N]})]}))]}))}));L.displayName="Input";export{L as Input};
1
+ import{jsxs as t,jsx as e,Fragment as n}from"react/jsx-runtime";import i from"../../assets/icons/info.svg.js";import{forwardRef as l,useState as r,useContext as o,useRef as a,useEffect as s}from"react";import{Button as c}from"../button/Button.js";import{isFunction as h,validateInput as u}from"./Input-helper.js";import{Tooltip as d}from"../tooltips/Tooltip.js";import{TitleSmall as v,BodySecondary as p}from"../TypographyStyle.js";import{COLORS as g}from"../../constants/Theme.js";import m from"../../assets/icons/errorInfo.svg.js";import{InputStyleContext as b}from"./context/InputStyleProvider.js";import{RootContainer as f,InputFooter as x,MaxCharStyle as y,InputWrapper as j,IconHolder as C,PrefixHolder as O,InputContainer as T,InputContainerSmall as w,SuffixHolder as I,InputHeader as k}from"./Input.styled.js";const L=l(((l,L)=>{var H,B,E,M,P,D,S;const{placeholder:z,leftIcon:A,rightIcon:F,labelText:K,maxCharLimit:N,isRequired:R,hintText:G,type:_,state:q,validate:V,variant:W,button:$,suffixText:J,prefixText:Q,onChangeText:U,value:X,noErrorHint:Y,reset:Z,rangeValidation:tt,noKeyDownChange:et,version:nt,noMaxCharCheck:it,labelElement:lt,autoGrow:rt,minHeight:ot,maxHeight:at,labelTextBold:st,truncateText:ct,maxCharLimitPosition:ht,hightlightInputColor:ut,onKeyDownEvent:dt,hideInputHeader:vt}=Object.assign({maxCharLimit:0,type:"text",variant:"default",maxCharLimitPosition:"TOP"},l),pt=null==A?void 0:A.icon,gt=null==F?void 0:F.icon,[mt,bt]=r(!1),[ft,xt]=r(!1),[yt,jt]=r(),Ct="small"===W?"18px":"22px",Ot=o(b),[Tt,wt]=r(),It=a(null),kt=null!=L?L:It;s((()=>{wt(X),!X&&rt&&(kt.current.style.height=ot||"48px")}),[X]),s((()=>{var t;kt.current&&(null===(t=l.onReferenceInit)||void 0===t||t.call(l,kt.current))}),[kt]),s((()=>{const t=kt.current;if(t&&["phonenumber","zip","number"].includes(_))return t.addEventListener("wheel",Et,{passive:!1}),()=>{t.removeEventListener("wheel",Et)}}),[]),s((()=>{Z&&wt("")}),[Z]),s((()=>{var t;xt(!!l.isActive),l.isActive&&(null===(t=kt.current)||void 0===t||t.focus())}),[l.isActive]),s((()=>{jt(l.errorMessage)}),[l.errorMessage]),s((()=>{var t;bt(!1),("invalid"===l.state||yt||"disabled-invalid"===l.state)&&bt(!0),"active"===l.state&&(null===(t=kt.current)||void 0===t||t.focus())}),[l.state,yt]),s((()=>{bt(!!yt||"invalid"===l.state)}),[yt,l.state]);const Lt=function(t){if(h(t)){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];t(...n)}},Ht=()=>"zip"===_?6:2e3,Bt=t=>{const e=0!==N?N:Ht();if(dt&&dt(t),et||U(X||"",t),it)return;const n=t.target.value;![8].includes(t.which)&&e>0&&n.length>=e&&t.preventDefault()},Et=t=>{t.preventDefault()},Mt=t=>{let e=t.target.value;const n=0!==N?N+1:Ht();!it&&n>0&&e.length>=n&&(e=e.substring(0,n-1)),U(e,t),l.textControl||wt(e),rt&&(kt.current.style.height=`${kt.current.scrollHeight}px`,e||(kt.current.style.height=ot||"48px"));const i=V||u;if(!i||!h(i))return;const[r,o]=i(e,_,tt);bt(!r),jt(l.errorMessage?l.errorMessage:o)},Pt=t=>{var e;l.skipFocus||xt(!0),Lt(null===(e=l.onFocus)||void 0===e?void 0:e.call(l,t))},Dt=t=>{var e;l.skipFocus||xt(!1),Lt(null===(e=l.onBlur)||void 0===e?void 0:e.call(l,t))},St=()=>{var i;return t(n,{children:["multiline"!==_&&e("input",{className:ct?"truncate-class":"","data-test":l["data-test"],id:l.id,style:null!==(i=null==Ot?void 0:Ot.input)&&void 0!==i?i:{},ref:kt,type:["phonenumber","zip","number"].includes(_)?"number":_,value:Tt,onFocus:t=>Pt(t),onBlur:t=>Dt(t),placeholder:z||"Enter here",onChange:Mt,onClick:t=>Lt(l.onClick),onKeyDown:t=>Bt(t)}),"multiline"===_&&e("textarea",{"data-test":l["data-test"],value:Tt,ref:kt,onFocus:t=>Pt(t),onBlur:t=>Dt(t),onClick:t=>Lt(l.onClick),placeholder:z||"Enter here",onChange:Mt,onKeyDown:t=>Bt(t),maxLength:N>0?N:void 0})]})};return t(f,Object.assign({width:l.width,height:l.height,state:q,type:_,style:null!==(H=null==Ot?void 0:Ot.RootContainer)&&void 0!==H?H:{}},{children:[t("div",Object.assign({className:"flex-align-center"},{children:[!Y&&(!!G||!!yt)&&t(x,Object.assign({invalid:!!yt},{children:[!!yt&&e(m,{width:16,height:16}),yt||G]})),N>0&&"BOTTOM"===ht&&t(y,Object.assign({position:"BOTTOM"},{children:[null!==(E=null===(B=(null!=X?X:"").toString())||void 0===B?void 0:B.length)&&void 0!==E?E:0,"/",N]}))]})),t(j,Object.assign({variant:W,state:q,width:l.width,isActive:"active"===q||ft,isInvalid:mt,style:null!==(M=null==Ot?void 0:Ot.InputWrapper)&&void 0!==M?M:{},version:nt,height:l.height,hightlightInputColor:ut},{children:[!!pt&&e(C,Object.assign({variant:W,iconSize:Ct,onClick:()=>Lt(null==A?void 0:A.callback),isLeft:!0,style:null!==(P=null==Ot?void 0:Ot.IconHolder)&&void 0!==P?P:{}},{children:e(pt,{})})),!!Q&&e(O,Object.assign({variant:W},{children:Q})),"default"===W&&e(T,Object.assign({height:l.height,type:l.type,minHeight:ot,maxHeight:at,autoGrow:rt},{children:St()})),"small"===W&&e(w,Object.assign({height:l.height,type:l.type},{children:St()})),!!gt&&e(C,Object.assign({variant:W,iconSize:Ct,onClick:()=>Lt(null==F?void 0:F.callback),isLeft:!1},{children:e(gt,{})})),!!J&&e(I,Object.assign({variant:W},{children:J})),$&&$.text&&e(c,{buttonText:$.text,onClick:()=>Lt(null==$?void 0:$.onClick)}),$&&$.buttonProps&&e(c,Object.assign({},$.buttonProps))]})),!vt&&(!!K||!!N)&&t(k,Object.assign({invalid:mt},{children:[lt&&lt,t("div",Object.assign({className:"label__container"},{children:[t(st?v:p,{children:[K,R?e("span",{children:"*"}):""]}),l.tooltipText&&e(d,Object.assign({body:l.tooltipText,placement:"top"},{children:e("span",{children:e(i,{style:{marginTop:-3},width:18,height:18,color:mt?g.content.negative:g.content.primary})})}))]})),N>0&&"TOP"===ht&&t(y,{children:[null!==(S=null===(D=(null!=X?X:"").toString())||void 0===D?void 0:D.length)&&void 0!==S?S:0,"/",N]})]}))]}))}));L.displayName="Input";export{L as Input};