@bikdotai/bik-component-library 0.0.684 → 0.0.685-beta.10
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.
- package/dist/cjs/components/QueryBuilder/Triggers/EVENTS/components/EventsTrigger.d.ts +1 -1
- package/dist/cjs/components/QueryBuilder/Triggers/EVENTS/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
- package/dist/cjs/components/QueryBuilder/Triggers/IG/components/IGTrigger.d.ts +1 -1
- package/dist/cjs/components/QueryBuilder/Triggers/IG/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
- package/dist/cjs/components/QueryBuilder/Triggers/components/BaseTriggerQueryBuilderNode.d.ts +2 -2
- package/dist/cjs/components/SearchFilter/components/DatePickerButton.js +1 -1
- package/dist/cjs/components/SearchFilter/components/DateRangeOnlyButton.js +1 -1
- package/dist/cjs/components/TablePagination/TablePagination.js +1 -1
- package/dist/cjs/components/accordion/Accordion.d.ts +8 -0
- package/dist/cjs/components/accordion/Accordion.js +1 -1
- package/dist/cjs/components/accordion/Accordion.style.d.ts +1 -0
- package/dist/cjs/components/accordion/Accordion.style.js +8 -1
- package/dist/cjs/components/analytics-chips-and-dropdowns/AnalyticsDropdown.js +1 -1
- package/dist/cjs/components/analytics-chips-and-dropdowns/chart/Pie/PieChartAnalytics.js +1 -1
- package/dist/cjs/components/analytics-chips-and-dropdowns/chart/VerticalBarGraph/VerticalGraph.js +1 -1
- package/dist/cjs/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/cjs/components/carousel-secondary/CarouselSecondary.d.ts +2 -4
- package/dist/cjs/components/carousel-secondary/CarouselSecondary.js +1 -1
- package/dist/cjs/components/carousel-secondary/CarouselSecondary.style.d.ts +1 -1
- package/dist/cjs/components/carousel-secondary/CarouselSecondary.style.js +1 -1
- package/dist/cjs/components/carousel-secondary/model.d.ts +4 -0
- package/dist/cjs/components/carousel-secondary/model.js +1 -0
- package/dist/cjs/components/code-block/CodeBlock.d.ts +2 -0
- package/dist/cjs/components/code-block/CodeBlock.js +1 -0
- package/dist/cjs/components/code-block/CodeBlock.styled.d.ts +31 -0
- package/dist/cjs/components/code-block/CodeBlock.styled.js +110 -0
- package/dist/cjs/components/code-block/CodeBlockHelper.d.ts +1 -0
- package/dist/cjs/components/code-block/CodeBlockHelper.js +1 -0
- package/dist/cjs/components/code-block/index.d.ts +2 -0
- package/dist/cjs/components/code-block/languageSpecificFormatting/html.d.ts +1 -0
- package/dist/cjs/components/code-block/types.d.ts +18 -0
- package/dist/cjs/components/code-block/types.js +1 -0
- package/dist/cjs/components/custom-date-time/DateSelector/DateSelector.js +1 -1
- package/dist/cjs/components/datePicker/DatePickerWrapper.d.ts +1 -4
- package/dist/cjs/components/datePicker/DatePickerWrapper.js +1 -1
- package/dist/cjs/components/datePicker/DatePickerWrapper.styled.d.ts +1 -1
- package/dist/cjs/components/datePicker/DatePickerWrapper.styled.js +2 -2
- package/dist/cjs/components/datePicker/model.d.ts +4 -0
- package/dist/cjs/components/datePicker/model.js +1 -0
- package/dist/cjs/components/discount-modal/DynamicCoupon/DynamicCoupon.d.ts +1 -2
- package/dist/cjs/components/discount-modal/DynamicCoupon/DynamicCoupon.js +1 -1
- package/dist/cjs/components/dropdown/ChipDropdown.d.ts +1 -1
- package/dist/cjs/components/dropdown/ChipDropdown.js +3 -3
- package/dist/cjs/components/dropdown/MenuItem/MenuItem.d.ts +1 -1
- package/dist/cjs/components/dropdown/MenuItem/MenuItem.js +5 -5
- package/dist/cjs/components/multi-level-dropdown/MenuItem.js +1 -1
- package/dist/cjs/components/product-picker-v2/modal.d.ts +1 -8
- package/dist/cjs/components/product-picker-v2/modal.js +1 -1
- package/dist/cjs/components/product-picker-v2/style.js +1 -1
- package/dist/cjs/components/product-picker-v2/type.d.ts +7 -0
- package/dist/cjs/components/product-picker-v2/type.js +1 -1
- package/dist/cjs/components/product-picker-v2/variant.js +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/BackTrackComponent.js +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/DiscountCodeComponent.js +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/EditWebpushTemplate.js +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppCarouselTemplateV2.js +1 -1
- package/dist/cjs/components/template-preview/RCS/RCSMediaCard.d.ts +1 -1
- package/dist/cjs/components/template-preview/RCS/RCSMediaCard.js +1 -1
- package/dist/cjs/components/template-preview/WhatsApp/MediaCard.js +1 -1
- package/dist/cjs/components/variable-picker-v3/Content.d.ts +0 -1
- package/dist/cjs/components/variable-picker-v3/Content.js +1 -1
- package/dist/cjs/components/variable-picker-v3/SubHeaderItems.js +1 -1
- package/dist/cjs/components/variable-picker-v3/highlightSearchText.d.ts +1 -0
- package/dist/cjs/components/variable-picker-v3/highlightSearchText.js +1 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/esm/components/QueryBuilder/Triggers/EVENTS/components/EventsTrigger.d.ts +1 -1
- package/dist/esm/components/QueryBuilder/Triggers/EVENTS/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
- package/dist/esm/components/QueryBuilder/Triggers/IG/components/IGTrigger.d.ts +1 -1
- package/dist/esm/components/QueryBuilder/Triggers/IG/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
- package/dist/esm/components/QueryBuilder/Triggers/components/BaseTriggerQueryBuilderNode.d.ts +2 -2
- package/dist/esm/components/SearchFilter/components/DatePickerButton.js +1 -1
- package/dist/esm/components/SearchFilter/components/DateRangeOnlyButton.js +1 -1
- package/dist/esm/components/TablePagination/TablePagination.js +1 -1
- package/dist/esm/components/accordion/Accordion.d.ts +8 -0
- package/dist/esm/components/accordion/Accordion.js +1 -1
- package/dist/esm/components/accordion/Accordion.style.d.ts +1 -0
- package/dist/esm/components/accordion/Accordion.style.js +23 -16
- package/dist/esm/components/analytics-chips-and-dropdowns/AnalyticsDropdown.js +1 -1
- package/dist/esm/components/analytics-chips-and-dropdowns/chart/Pie/PieChartAnalytics.js +1 -1
- package/dist/esm/components/analytics-chips-and-dropdowns/chart/VerticalBarGraph/VerticalGraph.js +1 -1
- package/dist/esm/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/esm/components/carousel-secondary/CarouselSecondary.d.ts +2 -4
- package/dist/esm/components/carousel-secondary/CarouselSecondary.js +1 -1
- package/dist/esm/components/carousel-secondary/CarouselSecondary.style.d.ts +1 -1
- package/dist/esm/components/carousel-secondary/CarouselSecondary.style.js +1 -1
- package/dist/esm/components/carousel-secondary/model.d.ts +4 -0
- package/dist/esm/components/carousel-secondary/model.js +1 -0
- package/dist/esm/components/code-block/CodeBlock.d.ts +2 -0
- package/dist/esm/components/code-block/CodeBlock.js +1 -0
- package/dist/esm/components/code-block/CodeBlock.styled.d.ts +31 -0
- package/dist/esm/components/code-block/CodeBlock.styled.js +110 -0
- package/dist/esm/components/code-block/CodeBlockHelper.d.ts +1 -0
- package/dist/esm/components/code-block/CodeBlockHelper.js +1 -0
- package/dist/esm/components/code-block/index.d.ts +2 -0
- package/dist/esm/components/code-block/languageSpecificFormatting/html.d.ts +1 -0
- package/dist/esm/components/code-block/types.d.ts +18 -0
- package/dist/esm/components/code-block/types.js +1 -0
- package/dist/esm/components/custom-date-time/DateSelector/DateSelector.js +1 -1
- package/dist/esm/components/datePicker/DatePickerWrapper.d.ts +1 -4
- package/dist/esm/components/datePicker/DatePickerWrapper.js +1 -1
- package/dist/esm/components/datePicker/DatePickerWrapper.styled.d.ts +1 -1
- package/dist/esm/components/datePicker/DatePickerWrapper.styled.js +11 -11
- package/dist/esm/components/datePicker/model.d.ts +4 -0
- package/dist/esm/components/datePicker/model.js +1 -0
- package/dist/esm/components/discount-modal/DynamicCoupon/DynamicCoupon.d.ts +1 -2
- package/dist/esm/components/discount-modal/DynamicCoupon/DynamicCoupon.js +1 -1
- package/dist/esm/components/dropdown/ChipDropdown.d.ts +1 -1
- package/dist/esm/components/dropdown/ChipDropdown.js +3 -3
- package/dist/esm/components/dropdown/MenuItem/MenuItem.d.ts +1 -1
- package/dist/esm/components/dropdown/MenuItem/MenuItem.js +5 -5
- package/dist/esm/components/multi-level-dropdown/MenuItem.js +1 -1
- package/dist/esm/components/product-picker-v2/modal.d.ts +1 -8
- package/dist/esm/components/product-picker-v2/modal.js +1 -1
- package/dist/esm/components/product-picker-v2/style.js +4 -4
- package/dist/esm/components/product-picker-v2/type.d.ts +7 -0
- package/dist/esm/components/product-picker-v2/type.js +1 -1
- package/dist/esm/components/product-picker-v2/variant.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/BackTrackComponent.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/DiscountCodeComponent.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/EditWebpushTemplate.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppCarouselTemplateV2.js +1 -1
- package/dist/esm/components/template-preview/RCS/RCSMediaCard.d.ts +1 -1
- package/dist/esm/components/template-preview/RCS/RCSMediaCard.js +1 -1
- package/dist/esm/components/template-preview/WhatsApp/MediaCard.js +1 -1
- package/dist/esm/components/variable-picker-v3/Content.d.ts +0 -1
- package/dist/esm/components/variable-picker-v3/Content.js +1 -1
- package/dist/esm/components/variable-picker-v3/SubHeaderItems.js +1 -1
- package/dist/esm/components/variable-picker-v3/highlightSearchText.d.ts +1 -0
- package/dist/esm/components/variable-picker-v3/highlightSearchText.js +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0});var r=e(require("styled-components"));const t=r.default.div`
|
|
2
|
+
background-color: ${e=>{let{themeMode:r}=e;return"dark"===r?"#0d1117":"#ffffff"}};
|
|
3
|
+
border: 1px solid
|
|
4
|
+
${e=>{let{themeMode:r}=e;return"dark"===r?"#30363d":"#d0d7de"}};
|
|
5
|
+
border-radius: 6px;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
font-family: ui-monospace, SFMono-Regular, 'SF Mono', Consolas,
|
|
8
|
+
'Liberation Mono', Menlo, monospace;
|
|
9
|
+
margin-bottom: 1rem;
|
|
10
|
+
${e=>{let{maxWidth:r}=e;return r&&`max-width: ${r};`}}
|
|
11
|
+
`,o=r.default.div`
|
|
12
|
+
background-color: ${e=>{let{themeMode:r}=e;return"dark"===r?"#161b22":"#f6f8fa"}};
|
|
13
|
+
border-bottom: 1px solid
|
|
14
|
+
${e=>{let{themeMode:r}=e;return"dark"===r?"#30363d":"#d0d7de"}};
|
|
15
|
+
padding: 8px 16px;
|
|
16
|
+
display: flex;
|
|
17
|
+
justify-content: space-between;
|
|
18
|
+
align-items: center;
|
|
19
|
+
`;r.default.div`
|
|
20
|
+
display: flex;
|
|
21
|
+
gap: 6px;
|
|
22
|
+
align-items: center;
|
|
23
|
+
`,r.default.div`
|
|
24
|
+
width: 12px;
|
|
25
|
+
height: 12px;
|
|
26
|
+
border-radius: 50%;
|
|
27
|
+
background-color: ${e=>{let{color:r}=e;return r}};
|
|
28
|
+
`;const d=r.default.div`
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
gap: 8px;
|
|
32
|
+
flex: 1;
|
|
33
|
+
margin-left: 12px;
|
|
34
|
+
`,n=r.default.span`
|
|
35
|
+
color: ${e=>{let{themeMode:r}=e;return"dark"===r?"#f0f6fc":"#24292f"}};
|
|
36
|
+
font-size: 14px;
|
|
37
|
+
font-weight: 500;
|
|
38
|
+
`,a=r.default.div`
|
|
39
|
+
background-color: ${e=>{let{bg:r}=e;return r}};
|
|
40
|
+
color: ${e=>{let{color:r}=e;return r||"#ffffff"}};
|
|
41
|
+
padding: 2px 6px;
|
|
42
|
+
border-radius: 4px;
|
|
43
|
+
font-size: 11px;
|
|
44
|
+
font-weight: 600;
|
|
45
|
+
text-transform: uppercase;
|
|
46
|
+
`,l=r.default.button`
|
|
47
|
+
background-color: transparent;
|
|
48
|
+
border: 1px solid
|
|
49
|
+
${e=>{let{themeMode:r}=e;return"dark"===r?"#30363d":"#d0d7de"}};
|
|
50
|
+
border-radius: 4px;
|
|
51
|
+
padding: 4px 8px;
|
|
52
|
+
color: ${e=>{let{themeMode:r}=e;return"dark"===r?"#f0f6fc":"#24292f"}};
|
|
53
|
+
font-size: 12px;
|
|
54
|
+
cursor: pointer;
|
|
55
|
+
display: flex;
|
|
56
|
+
align-items: center;
|
|
57
|
+
gap: 4px;
|
|
58
|
+
transition: background-color 0.2s ease;
|
|
59
|
+
|
|
60
|
+
&:hover {
|
|
61
|
+
background-color: ${e=>{let{themeMode:r}=e;return"dark"===r?"#21262d":"#f3f4f6"}};
|
|
62
|
+
}
|
|
63
|
+
`,i=r.default.div`
|
|
64
|
+
max-height: ${e=>{let{maxHeight:r}=e;return r}};
|
|
65
|
+
overflow: auto;
|
|
66
|
+
display: flex;
|
|
67
|
+
/* Ensure this is the only scroll container */
|
|
68
|
+
min-width: 0;
|
|
69
|
+
`,f=r.default.div`
|
|
70
|
+
background-color: ${e=>{let{themeMode:r}=e;return"dark"===r?"#0d1117":"#f6f8fa"}};
|
|
71
|
+
color: ${e=>{let{themeMode:r}=e;return"dark"===r?"#6e7681":"#656d76"}};
|
|
72
|
+
padding: 16px 12px;
|
|
73
|
+
font-size: 12px;
|
|
74
|
+
line-height: 20px;
|
|
75
|
+
text-align: right;
|
|
76
|
+
user-select: none;
|
|
77
|
+
border-right: 1px solid
|
|
78
|
+
${e=>{let{themeMode:r}=e;return"dark"===r?"#21262d":"#d0d7de"}};
|
|
79
|
+
min-width: 40px;
|
|
80
|
+
`,p=r.default.pre`
|
|
81
|
+
flex: 1;
|
|
82
|
+
padding: 16px;
|
|
83
|
+
font-size: 12px;
|
|
84
|
+
line-height: 20px;
|
|
85
|
+
color: ${e=>{let{themeMode:r}=e;return"dark"===r?"#f0f6fc":"#24292f"}};
|
|
86
|
+
background-color: transparent;
|
|
87
|
+
margin: 0;
|
|
88
|
+
white-space: pre;
|
|
89
|
+
/* Remove overflow-x from here since parent handles all scrolling */
|
|
90
|
+
overflow: visible;
|
|
91
|
+
min-width: 0; /* Ensures proper shrinking in flex container */
|
|
92
|
+
|
|
93
|
+
.keyword {
|
|
94
|
+
color: ${e=>{let{themeMode:r}=e;return"dark"===r?"#79c0ff":"#0969da"}};
|
|
95
|
+
font-weight: 600;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.string {
|
|
99
|
+
color: ${e=>{let{themeMode:r}=e;return"dark"===r?"#a5d6ff":"#0a3069"}};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.comment {
|
|
103
|
+
color: ${e=>{let{themeMode:r}=e;return"dark"===r?"#8b949e":"#656d76"}};
|
|
104
|
+
font-style: italic;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.number {
|
|
108
|
+
color: ${e=>{let{themeMode:r}=e;return"dark"===r?"#79c0ff":"#0969da"}};
|
|
109
|
+
}
|
|
110
|
+
`;exports.Code=p,exports.CodeContainer=i,exports.Container=t,exports.CopyButton=l,exports.Header=o,exports.LanguageBadge=a,exports.LineNumbers=f,exports.Title=n,exports.TitleSection=d;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const highlightCode: (code: string, lang: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.highlightCode=(e,t)=>{const s={javascript:["function","const","let","var","if","else","for","while","return","class","import","export","from","async","await","try","catch","new","this","console","log","window","document","switch"],python:["def","class","if","else","elif","for","while","import","from","return","try","except","with","as","lambda","and","or","not","in","print"],java:["public","private","protected","static","class","interface","if","else","for","while","return","import","new","this","extends","implements","System","out","println"],css:["color","background","margin","padding","display","position","flex","grid","width","height","border","font"],html:["div","span","p","h1","h2","h3","body","head","html","script","style","link"],json:["true","false","null"]}[t.toLowerCase()]||[],n={};s.forEach((e=>{n[e]=(e=>{let t=0;for(let s=0;s<e.length;s++)t=e.charCodeAt(s)+((t<<5)-t);const s=(16777215&t).toString(16).toUpperCase();return`#${"00000".substring(0,6-s.length)+s}`})(e)}));let r=e;return r=r.replace(/(["'`])(?:\\.|(?!\1).)*\1/g,'<span class="string">$&</span>'),r=r.replace(/\/\/.*$/gm,'<span class="comment">$&</span>'),r=r.replace(/\/\*[\s\S]*?\*\//g,'<span class="comment">$&</span>'),r=r.replace(/#.*$/gm,'<span class="comment">$&</span>'),r=r.replace(/\b\d+\.?\d*\b/g,'<span class="number">$&</span>'),s.forEach((e=>{const t=new RegExp(`\\b(${e})\\b(?![^<]*>)`,"g");r=r.replace(t,`<span style="color: ${n[e]}">$1</span>`)})),r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function format(code: string): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare enum CodeLanguage {
|
|
2
|
+
JAVASCRIPT = "javascript",
|
|
3
|
+
PYTHON = "python",
|
|
4
|
+
JAVA = "java",
|
|
5
|
+
CSS = "css",
|
|
6
|
+
HTML = "html",
|
|
7
|
+
JSON = "json"
|
|
8
|
+
}
|
|
9
|
+
export interface CodeBlockProps {
|
|
10
|
+
code?: string;
|
|
11
|
+
language?: CodeLanguage;
|
|
12
|
+
title?: string;
|
|
13
|
+
showTitle?: boolean;
|
|
14
|
+
showLineNumbers?: boolean;
|
|
15
|
+
maxHeight?: string;
|
|
16
|
+
maxWidth?: string;
|
|
17
|
+
theme?: 'dark' | 'light';
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),exports.CodeLanguage=void 0,(e=exports.CodeLanguage||(exports.CodeLanguage={})).JAVASCRIPT="javascript",e.PYTHON="python",e.JAVA="java",e.CSS="css",e.HTML="html",e.JSON="json";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/calendar.svg.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/calendar.svg.js"),r=require("../../../assets/icons/chevronDown.svg.js"),s=require("react"),a=require("react-popper"),i=require("../../datePicker/DatePicker.js");require("react-calendar");var n=require("../../../hooks/useOutside.js"),u=require("../../../utils/DateUtils.js");require("../../../constants/Theme.js"),require("../../TypographyStyle.js"),require("../../datePicker/DatePickerWrapper.styled.js"),require("../../datePicker/model.js");var o=require("../../dropdown/Common.styled.js"),d=require("../../dropShadow/DropShadow.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=c(s);exports.default=c=>{const[j,p]=s.useState(null),[h,m]=s.useState(null),[y,D]=s.useState(!1),{styles:f,attributes:g}=a.usePopper(j,h,{placement:c.placement}),q=l.default.useRef();return n.useOutside(q,(()=>{D(!1)})),e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"date-preview",ref:p,onClick:()=>{D(!y)}},{children:[e.jsx(t.default,{width:24,height:24}),e.jsx("span",Object.assign({style:{marginLeft:8}},{children:u.default.onlyDateFormat(c.customDate,"dd MMM yyyy")})),e.jsx(r.default,{style:{marginLeft:"auto"},width:22,height:22})]})),y&&e.jsx(o.OpenDropdownContainer,Object.assign({ref:m,style:Object.assign(Object.assign({},f.popper),{zIndex:3})},g.popper,{children:e.jsx("div",Object.assign({ref:q},{children:e.jsx(d.DropShadow,Object.assign({level:"z2",position:"down",style:{borderRadius:4}},{children:e.jsx(i.DatePicker,{selectedDate:c.customDate||new Date,selectRange:!1,onSelectDate:e=>{D(!1),c.setCustomDate(e)},minDate:c.minDate})}))}))}))]})};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CalendarProps } from 'react-calendar';
|
|
3
3
|
import { CSSProperties } from 'styled-components';
|
|
4
|
-
|
|
5
|
-
DEFAULT = "default",
|
|
6
|
-
LARGE = "large"
|
|
7
|
-
}
|
|
4
|
+
import { DateButtonType } from './model';
|
|
8
5
|
export declare const DatePickerWrapper: React.FC<{
|
|
9
6
|
val?: Date | Date[];
|
|
10
7
|
onChange: (val: Date | Date[]) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("react-calendar"),a=require("../../hooks/useOutside.js"),n=require("../../utils/DateUtils.js"),o=require("../../constants/Theme.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("react-calendar"),a=require("../../hooks/useOutside.js"),n=require("../../utils/DateUtils.js"),o=require("../../constants/Theme.js"),i=require("../../assets/icons/calendar.svg.js"),s=require("../TypographyStyle.js"),l=require("./DatePickerWrapper.styled.js"),u=require("./model.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=c(r);exports.DatePickerWrapper=r=>{let{val:c,onChange:O,calendarProps:y,disabled:D,pickerStyles:S,nativeID:g,maxDate:p,minDate:C,dateButtonType:L,dateButtonStyles:j}=r;const[v,b]=t.useState(!1),m=t.useRef(null),R=t.useRef(null);a.useOutside(R,(()=>{b(!1)}));const f=()=>{var e,t,r,a;return c?Array.isArray(c)?(null===(e=null==c?void 0:c[0])||void 0===e?void 0:e.toString())&&(null===(t=null==c?void 0:c[1])||void 0===t?void 0:t.toString())?`${new Date(null===(r=null==c?void 0:c[0])||void 0===r?void 0:r.toString()).toLocaleDateString()}-${new Date(null===(a=null==c?void 0:c[1])||void 0===a?void 0:a.toString()).toLocaleDateString()}`:`${n.default.getPastDate(new Date,30).toLocaleDateString()}-${(new Date).toLocaleDateString()}`:new Date(c.toString()).toLocaleDateString():(new Date).toLocaleDateString()};return e.jsxs(e.Fragment,{children:[e.jsxs(l.DateBtn,Object.assign({id:g,ref:m,bgColor:D?o.COLORS.background.base:o.COLORS.surface.standard,borderColor:o.COLORS.stroke.primary,onClick:()=>b(!v),dateButtonType:L||u.DateButtonType.DEFAULT,style:j},{children:[L===u.DateButtonType.LARGE?e.jsx(s.BodyPrimary,Object.assign({style:{color:D?o.COLORS.content.inactive:o.COLORS.content.primary,flex:1}},{children:f()})):e.jsx(s.BodySecondary,Object.assign({style:{color:D?o.COLORS.content.inactive:o.COLORS.content.primary,flex:1}},{children:f()})),e.jsx(i.default,{width:L===u.DateButtonType.LARGE?24:20,height:L===u.DateButtonType.LARGE?24:20,color:D?o.COLORS.content.inactive:o.COLORS.content.primary})]})),v&&!D&&e.jsx(l.PickerContainer,Object.assign({ref:R,style:Object.assign({},S),contentPrimary:o.COLORS.content.primary,subDued:o.COLORS.surface.subdued,brandColor:o.COLORS.background.brand,bgColor:o.COLORS.surface.standard,borderColor:o.COLORS.stroke.primary},{children:e.jsx(d.default,Object.assign({tileClassName:["custom__tile"],className:["custom__calendar"],onChange:e=>{O(e),b(!1)},maxDate:p,minDate:C,value:c?Array.isArray(c)?2===c.length?[new Date(c[0]),new Date(c[1])]:null:new Date(c):null},y))}))]})};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),r=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),r=require("./model.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=o(e);const a=t.default.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
padding: 5px 8px;
|
|
4
4
|
background: ${e=>e.bgColor};
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
gap: 8px;
|
|
12
12
|
position: relative;
|
|
13
13
|
height: ${e=>e.dateButtonType===r.DateButtonType.LARGE?"48px":"32px"};
|
|
14
|
-
`,n=
|
|
14
|
+
`,n=t.default.div`
|
|
15
15
|
position: absolute;
|
|
16
16
|
top: calc(100% + 8px);
|
|
17
17
|
zindex: 9;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),exports.DateButtonType=void 0,(e=exports.DateButtonType||(exports.DateButtonType={})).DEFAULT="default",e.LARGE="large";
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { DISCOUNT_TYPES } from "..";
|
|
3
2
|
import { COUPON_EXPIRATION, DISCOUNT_APPLIES_TO, ICouponData, IDynamicDiscountValidationError, MIN_PURCHASE_REQUIREMENT, OFFER_APPLIES_TO } from "../type";
|
|
4
3
|
import { SingleOption } from "../../dropdown/type";
|
|
5
4
|
import { Collection, Product } from "../../product-picker/type";
|
|
6
5
|
import { VariableListInterfaceV3 } from '../../variable-picker-v3/model';
|
|
7
|
-
import { ProductVariable } from '../type';
|
|
6
|
+
import { DISCOUNT_TYPES, ProductVariable } from '../type';
|
|
8
7
|
export declare enum DISCOUNT_PRODUCTS {
|
|
9
8
|
ENTITLED = "entitled",
|
|
10
9
|
PREREQUISITE = "prerequisite"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),i=require("react/jsx-runtime"),t=require("../../../assets/icons/info.svg.js"),o=require("../../alerts/Alert.js"),s=require("../../alerts/AlertHelper.js"),n=require("../../button/Button.js"),r=require("../../checkBox/CheckBox.js");require("../../../node_modules/@bikdotai/bik-models/growth/models/bik-store.js"),require("react");var l=require("../type.js");require("../../dropdown/DropdownPopover/index.js");var a=require("../../dropdown/Dropdown.js");require("../../dropdown/ChipDropdown.js"),require("../../zeroState/ZeroState.js");var d=require("../../TypographyStyle.js"),c=require("../../../constants/Theme.js");require("../../dropdown/OpenedDropdown/components/description/Description.styled.js"),require("../../list-item/ListItem.js"),require("../../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js"),require("../../dropdown/OpenedDropdown/components/menu/MenuItem.js"),require("../../dropdown/OpenedDropdown/components/menu/MenuList.styled.js"),require("../../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js"),require("../../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js"),require("../../icon-button/IconButton.js");var u=require("../../input/Input.js"),p=require("../../../assets/icons/cross.svg.js");require("../../dropdown/MenuItem/MenuItem.js"),require("../../modals/styledModal.js"),require("../../../node_modules/lodash.debounce/index.js"),require("../../bik-layout/CommonStyles.js"),require("../../product-picker/ProductPicker.styled.js"),require("../../../utils/DateUtils.js"),require("../../tag/Tag.js"),require("../../tooltips/Tooltip.js"),require("../../product-picker-v2/modal.js"),require("../../variable-picker-v3/model.js"),require("../../modals/modal.styled.js");var T=require("../../../assets/icons/plus.svg.js");require("../../accordion/Accordion.style.js"),require("../../accordion/AccordionArrow.js"),require("../../switch/Switch.js"),require("../../variable-picker-v3/NoResult.js"),require("../../variable-picker-v3/styles.js"),require("lodash");var C,E=require("../DiscountModal.styled.js"),D=require("../CouponExpiration/CouponExpiration.js"),O=require("../../radioButton/RadioButton.js"),S=require("../../../assets/icons/cubeIcon.svg.js"),P=require("../../../assets/icons/delete.svg.js"),I=require("../../../assets/icons/edit.svg.js"),x=require("./DynamicCoupon.styled.js"),v=require("./MinimumRequirementComponent.js"),j=require("./ZeroState.js");exports.DISCOUNT_PRODUCTS=void 0,(C=exports.DISCOUNT_PRODUCTS||(exports.DISCOUNT_PRODUCTS={})).ENTITLED="entitled",C.PREREQUISITE="prerequisite";exports.default=C=>{var _,b,m,g,y,h,U,R;const N=[{selected:C.discountCouponAppliesTo===l.DISCOUNT_APPLIES_TO.ENTIRE_ORDER,label:"Entire Order",value:l.DISCOUNT_APPLIES_TO.ENTIRE_ORDER},{selected:C.discountCouponAppliesTo===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS,label:"Specific Product",value:l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS},{selected:C.discountCouponAppliesTo===l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS,label:"Specific Collections",value:l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS}],V=[{selected:C.offerAppliesToBuy===l.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS,label:"Specific Product",value:l.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS},{selected:C.offerAppliesToBuy===l.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS,label:"Specific Collections",value:l.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS}],A=[{selected:C.offerAppliesToGet===l.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS,label:"Specific Product",value:l.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS},{selected:C.offerAppliesToGet===l.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS,label:"Specific Collections",value:l.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS}],q=(e,r,a)=>{var u,E,D,O,v,j,_,b,m,g,y,h;let U=[],R=[],N={},V={};C.useNewPicker?(N=r===exports.DISCOUNT_PRODUCTS.ENTITLED?C.entitledProducts:C.prerequisiteProducts,V=null!==(u=r===exports.DISCOUNT_PRODUCTS.ENTITLED?C.entitledCollections:C.prerequisiteCollections)&&void 0!==u?u:[],(null==N?void 0:N.isCustom)&&delete N.isCustom,(null==V?void 0:V.isCustom)&&delete V.isCustom,Object.values(N).forEach((e=>{Object.keys(e.products).forEach((i=>{U.push({id:i,name:e.products[i].name,image:e.products[i].image})}))})),Object.keys(V).forEach((e=>{"isCustom"!==e&&R.push({id:e,name:V[e].name,image:V[e].image})}))):(U=r===exports.DISCOUNT_PRODUCTS.ENTITLED?C.entitledProducts:C.prerequisiteProducts,R=null!==(E=r===exports.DISCOUNT_PRODUCTS.ENTITLED?C.entitledCollections:C.prerequisiteCollections)&&void 0!==E?E:[]);const A=[null===(D=C.dynamicDiscountValidationError)||void 0===D?void 0:D.inValidProductSelection,null===(O=C.dynamicDiscountValidationError)||void 0===O?void 0:O.inValidProductVariableSelection,null===(v=C.dynamicDiscountValidationError)||void 0===v?void 0:v.inValidCollectionSelection],q=[null===(j=C.dynamicDiscountValidationError)||void 0===j?void 0:j.inValidBuyXCollectionSelection,null===(_=C.dynamicDiscountValidationError)||void 0===_?void 0:_.inValidBuyXProductSelection,null===(b=C.dynamicDiscountValidationError)||void 0===b?void 0:b.inValidBuyXProductVariableSelection],L=[null===(m=C.dynamicDiscountValidationError)||void 0===m?void 0:m.inValidGetYCollectionSelection,null===(g=C.dynamicDiscountValidationError)||void 0===g?void 0:g.inValidGetYProductSelection,null===(y=C.dynamicDiscountValidationError)||void 0===y?void 0:y.inValidGetYProductVariableSelection];let f=!1;return"couponAppliesTo"===a&&(f=A.some(Boolean)),"buyX"===a&&(f=q.some(Boolean)),"getY"===a&&(f=L.some(Boolean)),i.jsxs(i.Fragment,{children:[i.jsxs("div",Object.assign({style:{display:"flex",gap:18}},{children:[e===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS&&0===U.length&&(r===exports.DISCOUNT_PRODUCTS.ENTITLED&&!C.entitledProductVariable||r===exports.DISCOUNT_PRODUCTS.PREREQUISITE&&!C.preRequisiteProductVariable)&&!(null==R?void 0:R.length)&&i.jsxs(x.AddProductButtonsContainer,{children:[i.jsx("div",Object.assign({style:{width:C.isProductVariableSupported?"284px":"300px",display:"flex"}},{children:i.jsx(n.Button,{buttonText:"Add Product(s)",buttonType:"dashRegular",LeadingIcon:T.default,matchParentWidth:!0,onClick:()=>{C.setIsProductPickerOpen(r)},error:f})})),C.isProductVariableSupported&&C.productVariableList&&i.jsxs(i.Fragment,{children:[i.jsx(d.BodySecondary,Object.assign({color:c.DEFAULT_THEME.colorsV2.content.placeholder},{children:"OR"})),i.jsx(n.Button,{buttonText:"Add Product(s) Variable",buttonType:"dashRegular",LeadingIcon:T.default,matchParentWidth:!0,onClick:()=>{C.setIsProductVariablePickerOpen(r)},error:f})]})]}),e===l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS&&0===R.length&&!(null==U?void 0:U.length)&&i.jsx("div",Object.assign({style:{width:"300px",display:"flex"}},{children:i.jsx(n.Button,{buttonText:"Add collection(s)",buttonType:"dashRegular",LeadingIcon:T.default,matchParentWidth:!0,onClick:()=>{C.setIsCollectionPickerOpen(r)},style:{marginTop:"16px"},error:f})}))]})),f&&i.jsx("div",Object.assign({style:{margin:"8px 0 0"}},{children:i.jsx(o.Alert,{type:s.ALERT_TYPES.NEGATIVE,text:"Required Field",contentPosition:s.CONTENT_POSITION.START,icon:()=>i.jsx(t.default,{width:16,height:16,color:c.DEFAULT_THEME.colorsV2.content.negative})})})),U.length||R.length?i.jsxs("div",{children:[i.jsx(d.BodySecondary,Object.assign({style:{margin:"8px 0"}},{children:e===l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS?"Collection(s)":"Product(s)"})),i.jsxs(x.ProductCollectionCard,{children:[i.jsx(x.CubeIconContainer,{children:i.jsx(S.default,{width:20,height:20,color:c.DEFAULT_THEME.colorsV2.content.secondary})}),i.jsxs(d.TitleSmall,{children:[e===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS?U.length:R.length," ",e===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS?"Product(s)":"Collection(s)"," ","added"]}),i.jsxs("div",Object.assign({style:{display:"flex",gap:4}},{children:[i.jsx(x.IconContainer,Object.assign({onClick:()=>{e===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS?C.setIsProductPickerOpen(r):C.setIsCollectionPickerOpen(r)}},{children:i.jsx(I.default,{width:24,height:24,color:c.DEFAULT_THEME.colorsV2.content.placeholder})})),i.jsx(x.IconContainer,Object.assign({onClick:()=>{e===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS?r===exports.DISCOUNT_PRODUCTS.ENTITLED?C.setEntitledProducts([]):C.setPrerequisiteProducts([]):r===exports.DISCOUNT_PRODUCTS.ENTITLED?C.setEntitledCollections([]):C.setPrerequisiteCollections([])}},{children:i.jsx(P.default,{width:24,height:24,color:c.DEFAULT_THEME.colorsV2.content.placeholder})}))]}))]})]}):r===exports.DISCOUNT_PRODUCTS.ENTITLED&&C.entitledProductVariable?i.jsxs("div",{children:[i.jsx(d.BodySecondary,Object.assign({style:{margin:"16px 0 8px"}},{children:"Product Variable"})),i.jsxs(x.ProductVariableCard,{children:[i.jsx(d.TitleSmall,{children:C.entitledProductVariable.displayName}),i.jsx("div",Object.assign({style:{display:"flex",gap:4}},{children:i.jsx(x.IconContainer,Object.assign({onClick:()=>{C.setEntitledProductVariable(void 0)}},{children:i.jsx(p.default,{width:24,height:24,color:c.DEFAULT_THEME.colorsV2.content.primary})}))}))]})]}):r===exports.DISCOUNT_PRODUCTS.PREREQUISITE&&(null===(h=C.preRequisiteProductVariable)||void 0===h?void 0:h.displayName)?i.jsxs("div",{children:[i.jsx(d.BodySecondary,Object.assign({style:{margin:"16px 0 8px"}},{children:"Product Variable"})),i.jsxs(x.ProductVariableCard,{children:[i.jsx(d.TitleSmall,{children:C.preRequisiteProductVariable.displayName}),i.jsx("div",Object.assign({style:{display:"flex",gap:4}},{children:i.jsx(x.IconContainer,Object.assign({onClick:()=>{C.setPreRequisiteProductVariable(void 0)}},{children:i.jsx(p.default,{width:24,height:24,color:c.DEFAULT_THEME.colorsV2.content.primary})}))}))]})]}):i.jsx(i.Fragment,{children:" "})]})},L=(e,t)=>{var o,s,n,r,c,p,T,E,D,O;let S=[],P=[],I={},x={};C.useNewPicker?(I=e===exports.DISCOUNT_PRODUCTS.ENTITLED?C.entitledProducts:C.prerequisiteProducts,x=null!==(o=e===exports.DISCOUNT_PRODUCTS.ENTITLED?C.entitledCollections:C.prerequisiteCollections)&&void 0!==o?o:[],(null==I?void 0:I.isCustom)&&delete I.isCustom,(null==x?void 0:x.isCustom)&&delete x.isCustom,Object.values(I).forEach((e=>{Object.keys(e.products).forEach((i=>{S.push({id:i,name:e.products[i].name,image:e.products[i].image})}))})),Object.keys(x).forEach((e=>{"isCustom"!==e&&P.push({id:e,name:x[e].name,image:x[e].image})}))):(S=e===exports.DISCOUNT_PRODUCTS.ENTITLED?C.entitledProducts:C.prerequisiteProducts,P=null!==(s=e===exports.DISCOUNT_PRODUCTS.ENTITLED?C.entitledCollections:C.prerequisiteCollections)&&void 0!==s?s:[]);const v=e===exports.DISCOUNT_PRODUCTS.PREREQUISITE?C.offerAppliesToBuy:C.offerAppliesToGet,j=e===exports.DISCOUNT_PRODUCTS.PREREQUISITE?exports.DISCOUNT_PRODUCTS.PREREQUISITE:exports.DISCOUNT_PRODUCTS.ENTITLED,_=v===l.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS?l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS:l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS;return i.jsxs("div",{children:[i.jsx(d.TitleSmall,Object.assign({style:{marginBottom:16}},{children:e===exports.DISCOUNT_PRODUCTS.PREREQUISITE?"Customer buys":"Customer gets"})),i.jsxs("div",Object.assign({style:{display:"flex"}},{children:[!t&&i.jsx("div",{children:i.jsxs("div",Object.assign({className:"input__rows"},{children:[i.jsx("div",Object.assign({className:"input__wrapper"},{children:i.jsx(u.Input,{value:e===exports.DISCOUNT_PRODUCTS.ENTITLED?null!==(r=null===(n=C.discountData.entitledQuantity)||void 0===n?void 0:n.toString())&&void 0!==r?r:"":null!==(p=null===(c=C.discountData.prerequisiteQuantity)||void 0===c?void 0:c.toString())&&void 0!==p?p:"",type:"number",onChangeText:i=>{e===exports.DISCOUNT_PRODUCTS.ENTITLED?C.setDiscountData(Object.assign(Object.assign({},C.discountData),{entitledQuantity:parseInt(i)})):C.setDiscountData(Object.assign(Object.assign({},C.discountData),{prerequisiteQuantity:parseInt(i)}))},labelText:"Quantity of products",placeholder:"Eg. 2",width:"300px",errorMessage:e===exports.DISCOUNT_PRODUCTS.PREREQUISITE&&(null===(T=C.dynamicDiscountValidationError)||void 0===T?void 0:T.inValidBuyXValue)||e===exports.DISCOUNT_PRODUCTS.ENTITLED&&(null===(E=C.dynamicDiscountValidationError)||void 0===E?void 0:E.inValidGetYValue)?"Required Field":"",state:e===exports.DISCOUNT_PRODUCTS.PREREQUISITE&&(null===(D=C.dynamicDiscountValidationError)||void 0===D?void 0:D.inValidBuyXValue)||e===exports.DISCOUNT_PRODUCTS.ENTITLED&&(null===(O=C.dynamicDiscountValidationError)||void 0===O?void 0:O.inValidGetYValue)?"invalid":"none"})})),i.jsx("div",{className:"input__wrapper"})]}))}),i.jsxs("div",{children:[i.jsx(d.BodySecondary,Object.assign({style:{marginBottom:8}},{children:"Any items from"})),e===exports.DISCOUNT_PRODUCTS.PREREQUISITE&&i.jsx(a.Dropdown,{width:"244px",options:V,placement:"bottom-start",onSelect:e=>{var i,t,o;C.setOfferAppliesToBuy(e.value),C.setPrerequisiteProducts([]),C.setPrerequisiteCollections([]),C.setPreRequisiteProductVariable(void 0),C.setDynamicDiscountValidationError((e=>Object.assign(Object.assign({},e),{inValidBuyXCollectionSelection:!1,inValidBuyXProductSelection:!1,inValidBuyXProductVariableSelection:!1}))),C.setDiscountData(Object.assign(Object.assign({},C.discountData),{prerequisiteCollectionIds:[],prerequisiteProductIds:[],collectionsConf:{entitledCollections:null===(i=C.discountData.collectionsConf)||void 0===i?void 0:i.entitledCollections,prerequisiteCollections:{}},productsConf:{entitledProducts:null===(t=C.discountData.productsConf)||void 0===t?void 0:t.entitledProducts,prerequisiteProducts:{}},productVariableConf:{entitledProductVariable:null===(o=C.discountData.productVariableConf)||void 0===o?void 0:o.entitledProductVariable,prerequisiteProductVariable:{}}}))}}),e===exports.DISCOUNT_PRODUCTS.ENTITLED&&i.jsx(a.Dropdown,{width:"244px",options:A,placement:"bottom-start",onSelect:e=>{var i,t,o;C.setOfferAppliesToGet(e.value),C.setEntitledProducts([]),C.setEntitledCollections([]),C.setEntitledProductVariable(void 0),C.setDynamicDiscountValidationError((e=>Object.assign(Object.assign({},e),{inValidGetYCollectionSelection:!1,inValidGetYProductSelection:!1,inValidGetYProductVariableSelection:!1}))),C.setDiscountData(Object.assign(Object.assign({},C.discountData),{entitledCollectionIds:[],entitledProductIds:[],collectionsConf:{entitledCollections:{},prerequisiteCollections:null===(i=C.discountData.collectionsConf)||void 0===i?void 0:i.prerequisiteCollections},productsConf:{entitledProducts:{},prerequisiteProducts:null===(t=C.discountData.productsConf)||void 0===t?void 0:t.prerequisiteProducts},productVariableConf:{entitledProductVariable:{},prerequisiteProductVariable:null===(o=C.discountData.productVariableConf)||void 0===o?void 0:o.prerequisiteProductVariable}}))}})]})]})),q(_,j,e===exports.DISCOUNT_PRODUCTS.PREREQUISITE?"buyX":"getY")]})};return i.jsxs(E.DynamicCouponContainer,{children:[i.jsxs("div",{children:[i.jsxs("div",Object.assign({style:{display:"flex",gap:16}},{children:[i.jsx("div",Object.assign({className:"input__wrapper"},{children:i.jsx(u.Input,{value:null!==(_=C.discountData.title)&&void 0!==_?_:"",onChangeText:e=>{var i;C.setDiscountData(Object.assign(Object.assign({},C.discountData),{title:null!==(i=null==e?void 0:e.trim())&&void 0!==i?i:""}))},maxCharLimit:30,labelText:"Discount Coupon Title",placeholder:`Eg. “Flat ${null!==(b=C.currency)&&void 0!==b?b:""} 15 Off”`,hintText:"Will be same for everyone. Can’t be changed later",width:"300px",isRequired:!0,errorMessage:(null===(m=C.dynamicDiscountValidationError)||void 0===m?void 0:m.invalidCouponTitle)?"Required Field":"",state:(null===(g=C.dynamicDiscountValidationError)||void 0===g?void 0:g.invalidCouponTitle)?"invalid":"none"})})),!C.hideProbability&&i.jsx(u.Input,{value:null!==(h=null===(y=C.discountData.probability)||void 0===y?void 0:y.toString())&&void 0!==h?h:"",type:"number",onChangeText:e=>{C.setDiscountData(Object.assign(Object.assign({},C.discountData),{probability:e.startsWith(".")?parseFloat(parseFloat(`0${e}`).toFixed(2)):parseFloat(parseFloat(e).toFixed(2))}))},labelText:"Probability of getting coupon ",hintText:"Enter a decimal value between 0-1",placeholder:"Eg. 0.5",maxCharLimit:4,width:"300px",isRequired:!0,errorMessage:(null===(U=C.dynamicDiscountValidationError)||void 0===U?void 0:U.inValidProbability)?"Required Field":"",state:(null===(R=C.dynamicDiscountValidationError)||void 0===R?void 0:R.inValidProbability)?"invalid":"none"})]})),i.jsx("div",{style:{height:"1px",width:"100%",background:c.DEFAULT_THEME.colorsV2.stroke.primary,margin:"24px 0 8px"}})]}),C.allowStaticCoupon&&i.jsx((()=>i.jsxs("div",{children:[i.jsx(d.TitleRegular,{children:"Discount Details"}),i.jsx(x.DiscountOptionsContainer,{children:C.discountDetailsOptions.map((t=>{return i.jsxs(x.DiscountDetailsOption,Object.assign({selected:C.selectedDiscountDetails.id===t.id,onClick:()=>(i=>{if(C.selectedDiscountDetails.id!==i.id)if(C.resetValidationErrors(),C.setValidationErrorMessage(""),C.setDiscountCouponAppliesTo(l.DISCOUNT_APPLIES_TO.ENTIRE_ORDER),C.setSelectedDiscountDetails(i),C.setDiscountData(Object.assign(Object.assign({},C.discountData),{value:void 0})),C.setPreRequisiteProductVariable(void 0),C.setEntitledProductVariable(void 0),["percentage","amount"].includes(i.value)){C.onChangeCouponType({label:"Amount off on order",selected:!0,value:l.DISCOUNT_TYPES.AMOUNT_OFF_ORDER});const t=Object.assign(Object.assign({},C.discountData),{valueType:"percentage"===i.value?l.DISCOUNT_VALUE_TYPES.PERCENTAGE:l.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT,value:void 0,targetType:l.DISCOUNT_TARGET_TYPES.LINE_ITEM,targetSelection:l.DISCOUNT_TARGET_SELECTION.ALL,entitledCollectionIds:[],entitledProductIds:[],prerequisiteCollectionIds:[],prerequisiteProductIds:[],collectionsConf:{entitledCollections:{},prerequisiteCollections:{}},productsConf:{entitledProducts:{},prerequisiteProducts:{}},productVariableConf:{entitledProductVariable:{},prerequisiteProductVariable:{}}}),o=e.__rest(t,["entitledQuantity","prerequisiteQuantity"]);C.setDiscountData(o)}else C.onChangeCouponType({label:i.label,selected:!0,value:i.value})})(t)},{children:[t.icon((o=t.id,C.selectedDiscountDetails.id===o?c.DEFAULT_THEME.colorsV2.stroke.brand:c.DEFAULT_THEME.colorsV2.text.secondary)),t.label]}),t.id);var o}))})]})),{}),(C.selectedCouponType===l.DISCOUNT_TYPES.AMOUNT_OFF_ORDER||C.selectedCouponType===l.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS)&&(()=>{var e,t,o,s,n,r;return i.jsxs(i.Fragment,{children:[i.jsx("div",Object.assign({className:"input__rows"},{children:i.jsx("div",Object.assign({className:"input__wrapper"},{children:i.jsx(u.Input,{value:null!==(o=null===(t=null===(e=C.discountData)||void 0===e?void 0:e.value)||void 0===t?void 0:t.toString())&&void 0!==o?o:"",labelText:"Discount amount",type:"number",width:"300px",onChangeText:e=>{C.setDiscountData(Object.assign(Object.assign({},C.discountData),{value:parseInt(e)}))},placeholder:"15",prefixText:C.discountData.valueType===l.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?null!==(s=C.currency)&&void 0!==s?s:"":void 0,suffixText:C.discountData.valueType===l.DISCOUNT_VALUE_TYPES.PERCENTAGE?"%":void 0,errorMessage:(null===(n=C.dynamicDiscountValidationError)||void 0===n?void 0:n.inValidDiscountAmount)?"Required Field":"",state:(null===(r=C.dynamicDiscountValidationError)||void 0===r?void 0:r.inValidDiscountAmount)?"invalid":"none"})}))})),i.jsx("div",Object.assign({style:{paddingTop:"24px",marginTop:16,borderTop:`1px solid ${c.DEFAULT_THEME.colorsV2.stroke.primary}`}},{children:i.jsxs("div",Object.assign({className:"input__wrapper"},{children:[i.jsx(d.TitleRegular,Object.assign({style:{marginBottom:10}},{children:"Applies to"})),i.jsx("div",Object.assign({style:{display:"flex",flexGrow:0,flexShrink:0,flexBasis:"auto"}},{children:i.jsx(a.Dropdown,{width:"300px",options:N,placement:"bottom-start",onSelect:e=>{const i="value"in e&&e.value===l.DISCOUNT_APPLIES_TO.ENTIRE_ORDER?{label:"Amount off on order",selected:!0,value:l.DISCOUNT_TYPES.AMOUNT_OFF_ORDER}:{label:"Amount off on products",selected:!0,value:l.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS};C.onChangeCouponType(i),C.setDiscountCouponAppliesTo(e.value),C.setEntitledProductVariable(void 0),C.setDynamicDiscountValidationError((e=>Object.assign(Object.assign({},e),{inValidProductVariableSelection:!1,inValidProductSelection:!1,inValidCollectionSelection:!1})))}})})),(C.discountCouponAppliesTo===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS||C.discountCouponAppliesTo===l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS)&&q(C.discountCouponAppliesTo,exports.DISCOUNT_PRODUCTS.ENTITLED,"couponAppliesTo")]}))}))]})})(),C.selectedCouponType===l.DISCOUNT_TYPES.BUY_X_GET_Y&&(()=>{var e,t,o,s,n;return i.jsxs(E.DynamicCouponContainer,Object.assign({style:{border:`1px solid ${c.DEFAULT_THEME.colorsV2.stroke.primary}`,padding:"16px",borderRadius:"4px",margin:0}},{children:[L(exports.DISCOUNT_PRODUCTS.PREREQUISITE),i.jsx("div",{style:{width:"100%",height:"1px",backgroundColor:c.DEFAULT_THEME.colorsV2.stroke.primary,margin:"8px 0"}}),L(exports.DISCOUNT_PRODUCTS.ENTITLED),i.jsx(d.BodySecondary,Object.assign({style:{marginTop:"8px"}},{children:"At a discounted value"})),i.jsx("div",{children:i.jsx(O.RadioButton,{label:"Free",isActive:100===C.discountData.value,onValueChange:e=>{e?C.setDiscountData(Object.assign(Object.assign({},C.discountData),{value:100})):C.setDiscountData(Object.assign(Object.assign({},C.discountData),{value:void 0}))}})}),i.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column"}},{children:[i.jsx(O.RadioButton,{label:"Percentage off",isActive:100!==C.discountData.value,onValueChange:()=>{C.setDiscountData(Object.assign(Object.assign({},C.discountData),{value:void 0}))}}),100!==C.discountData.value&&i.jsx("div",Object.assign({style:{marginTop:8}},{children:i.jsx(u.Input,{value:null!==(o=null===(t=null===(e=C.discountData)||void 0===e?void 0:e.value)||void 0===t?void 0:t.toString())&&void 0!==o?o:"",onChangeText:e=>{C.setDiscountData(Object.assign(Object.assign({},C.discountData),{value:parseInt(e)}))},type:"number",placeholder:"Eg. 50",suffixText:"%",width:"300px",errorMessage:(null===(s=C.dynamicDiscountValidationError)||void 0===s?void 0:s.inValidDiscountAmount)?"Required Field":"",state:(null===(n=C.dynamicDiscountValidationError)||void 0===n?void 0:n.inValidDiscountAmount)?"invalid":"none"})}))]}))]}))})(),!C.selectedCouponType&&i.jsx(j.default,{}),C.allowStaticCoupon&&C.selectedCouponType!==l.DISCOUNT_TYPES.BUY_X_GET_Y&&i.jsx("div",Object.assign({style:{padding:"24px 0 16px",marginTop:16,borderTop:`1px solid ${c.DEFAULT_THEME.colorsV2.stroke.primary}`}},{children:i.jsx(v.default,{selectedMinimumRequirement:C.selectedMinimumRequirement,setSelectedMinimumRequirement:C.setSelectedMinimumRequirement,discountData:C.discountData,setDiscountData:C.setDiscountData,currency:C.currency,dynamicDiscountValidationError:C.dynamicDiscountValidationError})})),C.selectedCouponType&&!C.hideExpiration&&i.jsxs("div",Object.assign({style:{padding:C.selectedCouponType!==l.DISCOUNT_TYPES.BUY_X_GET_Y?"24px 0 16px":"8px 0",borderTop:C.selectedCouponType!==l.DISCOUNT_TYPES.BUY_X_GET_Y?`1px solid ${c.DEFAULT_THEME.colorsV2.stroke.primary}`:"none"}},{children:[i.jsx(r.CheckBox,{label:"Add expiration",isDisabled:!!C.makeExpiryMandatory,isChecked:C.isAddExpirationChecked,onValueChange:e=>{C.setIsAddExpirationChecked(e),C.setDiscountData(Object.assign(Object.assign({},C.discountData),{expireAfter:void 0,expireAt:void 0})),C.setSelectedExpiration(l.COUPON_EXPIRATION.DYNAMIC_EXPIRATION)},boldOnChecked:!0,labelSize:"DEFAULT"}),i.jsx(d.BodySecondary,Object.assign({style:{color:c.DEFAULT_THEME.colorsV2.text.secondary,marginLeft:28}},{children:"Make coupon only valid till a certain time"})),C.isAddExpirationChecked&&i.jsx(D.CouponExpiration,{discountData:C.discountData,setDiscountData:C.setDiscountData,isAddExpirationChecked:C.isAddExpirationChecked,inValidCouponExpiry:C.dynamicDiscountValidationError.inValidCouponExpiry,selectedExpiration:C.selectedExpiration,setSelectedExpiration:C.setSelectedExpiration})]}))]})};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),i=require("react/jsx-runtime"),t=require("../../../assets/icons/info.svg.js"),o=require("../../alerts/Alert.js"),s=require("../../alerts/AlertHelper.js"),n=require("../../button/Button.js"),r=require("../../checkBox/CheckBox.js"),l=require("../type.js");require("../../dropdown/DropdownPopover/index.js");var a=require("../../dropdown/Dropdown.js");require("../../dropdown/ChipDropdown.js"),require("react"),require("../../zeroState/ZeroState.js");var d=require("../../TypographyStyle.js"),c=require("../../../constants/Theme.js");require("../../dropdown/OpenedDropdown/components/description/Description.styled.js"),require("../../list-item/ListItem.js"),require("../../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js"),require("../../dropdown/OpenedDropdown/components/menu/MenuItem.js"),require("../../dropdown/OpenedDropdown/components/menu/MenuList.styled.js"),require("../../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js"),require("../../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js"),require("../../icon-button/IconButton.js");var u=require("../../input/Input.js"),p=require("../../../assets/icons/cross.svg.js");require("../../dropdown/MenuItem/MenuItem.js");var T,C=require("../../radioButton/RadioButton.js"),E=require("../../../assets/icons/cubeIcon.svg.js"),D=require("../../../assets/icons/delete.svg.js"),O=require("../../../assets/icons/edit.svg.js"),S=require("../../../assets/icons/plus.svg.js"),P=require("../CouponExpiration/CouponExpiration.js"),I=require("../DiscountModal.styled.js"),x=require("./DynamicCoupon.styled.js"),v=require("./MinimumRequirementComponent.js"),_=require("./ZeroState.js");exports.DISCOUNT_PRODUCTS=void 0,(T=exports.DISCOUNT_PRODUCTS||(exports.DISCOUNT_PRODUCTS={})).ENTITLED="entitled",T.PREREQUISITE="prerequisite";exports.default=T=>{var j,b,g,m,y,U,h,R;const N=[{selected:T.discountCouponAppliesTo===l.DISCOUNT_APPLIES_TO.ENTIRE_ORDER,label:"Entire Order",value:l.DISCOUNT_APPLIES_TO.ENTIRE_ORDER},{selected:T.discountCouponAppliesTo===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS,label:"Specific Product",value:l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS},{selected:T.discountCouponAppliesTo===l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS,label:"Specific Collections",value:l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS}],V=[{selected:T.offerAppliesToBuy===l.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS,label:"Specific Product",value:l.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS},{selected:T.offerAppliesToBuy===l.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS,label:"Specific Collections",value:l.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS}],A=[{selected:T.offerAppliesToGet===l.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS,label:"Specific Product",value:l.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS},{selected:T.offerAppliesToGet===l.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS,label:"Specific Collections",value:l.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS}],L=(e,r,a)=>{var u,C,P,I,v,_,j,b,g,m,y,U;let h=[],R=[],N={},V={};T.useNewPicker?(N=r===exports.DISCOUNT_PRODUCTS.ENTITLED?T.entitledProducts:T.prerequisiteProducts,V=null!==(u=r===exports.DISCOUNT_PRODUCTS.ENTITLED?T.entitledCollections:T.prerequisiteCollections)&&void 0!==u?u:[],(null==N?void 0:N.isCustom)&&delete N.isCustom,(null==V?void 0:V.isCustom)&&delete V.isCustom,Object.values(N).forEach((e=>{Object.keys(e.products).forEach((i=>{h.push({id:i,name:e.products[i].name,image:e.products[i].image})}))})),Object.keys(V).forEach((e=>{"isCustom"!==e&&R.push({id:e,name:V[e].name,image:V[e].image})}))):(h=r===exports.DISCOUNT_PRODUCTS.ENTITLED?T.entitledProducts:T.prerequisiteProducts,R=null!==(C=r===exports.DISCOUNT_PRODUCTS.ENTITLED?T.entitledCollections:T.prerequisiteCollections)&&void 0!==C?C:[]);const A=[null===(P=T.dynamicDiscountValidationError)||void 0===P?void 0:P.inValidProductSelection,null===(I=T.dynamicDiscountValidationError)||void 0===I?void 0:I.inValidProductVariableSelection,null===(v=T.dynamicDiscountValidationError)||void 0===v?void 0:v.inValidCollectionSelection],L=[null===(_=T.dynamicDiscountValidationError)||void 0===_?void 0:_.inValidBuyXCollectionSelection,null===(j=T.dynamicDiscountValidationError)||void 0===j?void 0:j.inValidBuyXProductSelection,null===(b=T.dynamicDiscountValidationError)||void 0===b?void 0:b.inValidBuyXProductVariableSelection],f=[null===(g=T.dynamicDiscountValidationError)||void 0===g?void 0:g.inValidGetYCollectionSelection,null===(m=T.dynamicDiscountValidationError)||void 0===m?void 0:m.inValidGetYProductSelection,null===(y=T.dynamicDiscountValidationError)||void 0===y?void 0:y.inValidGetYProductVariableSelection];let F=!1;return"couponAppliesTo"===a&&(F=A.some(Boolean)),"buyX"===a&&(F=L.some(Boolean)),"getY"===a&&(F=f.some(Boolean)),i.jsxs(i.Fragment,{children:[i.jsxs("div",Object.assign({style:{display:"flex",gap:18}},{children:[e===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS&&0===h.length&&(r===exports.DISCOUNT_PRODUCTS.ENTITLED&&!T.entitledProductVariable||r===exports.DISCOUNT_PRODUCTS.PREREQUISITE&&!T.preRequisiteProductVariable)&&!(null==R?void 0:R.length)&&i.jsxs(x.AddProductButtonsContainer,{children:[i.jsx("div",Object.assign({style:{width:T.isProductVariableSupported?"284px":"300px",display:"flex"}},{children:i.jsx(n.Button,{buttonText:"Add Product(s)",buttonType:"dashRegular",LeadingIcon:S.default,matchParentWidth:!0,onClick:()=>{T.setIsProductPickerOpen(r)},error:F})})),T.isProductVariableSupported&&T.productVariableList&&i.jsxs(i.Fragment,{children:[i.jsx(d.BodySecondary,Object.assign({color:c.DEFAULT_THEME.colorsV2.content.placeholder},{children:"OR"})),i.jsx(n.Button,{buttonText:"Add Product(s) Variable",buttonType:"dashRegular",LeadingIcon:S.default,matchParentWidth:!0,onClick:()=>{T.setIsProductVariablePickerOpen(r)},error:F})]})]}),e===l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS&&0===R.length&&!(null==h?void 0:h.length)&&i.jsx("div",Object.assign({style:{width:"300px",display:"flex"}},{children:i.jsx(n.Button,{buttonText:"Add collection(s)",buttonType:"dashRegular",LeadingIcon:S.default,matchParentWidth:!0,onClick:()=>{T.setIsCollectionPickerOpen(r)},style:{marginTop:"16px"},error:F})}))]})),F&&i.jsx("div",Object.assign({style:{margin:"8px 0 0"}},{children:i.jsx(o.Alert,{type:s.ALERT_TYPES.NEGATIVE,text:"Required Field",contentPosition:s.CONTENT_POSITION.START,icon:()=>i.jsx(t.default,{width:16,height:16,color:c.DEFAULT_THEME.colorsV2.content.negative})})})),h.length||R.length?i.jsxs("div",{children:[i.jsx(d.BodySecondary,Object.assign({style:{margin:"8px 0"}},{children:e===l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS?"Collection(s)":"Product(s)"})),i.jsxs(x.ProductCollectionCard,{children:[i.jsx(x.CubeIconContainer,{children:i.jsx(E.default,{width:20,height:20,color:c.DEFAULT_THEME.colorsV2.content.secondary})}),i.jsxs(d.TitleSmall,{children:[e===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS?h.length:R.length," ",e===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS?"Product(s)":"Collection(s)"," ","added"]}),i.jsxs("div",Object.assign({style:{display:"flex",gap:4}},{children:[i.jsx(x.IconContainer,Object.assign({onClick:()=>{e===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS?T.setIsProductPickerOpen(r):T.setIsCollectionPickerOpen(r)}},{children:i.jsx(O.default,{width:24,height:24,color:c.DEFAULT_THEME.colorsV2.content.placeholder})})),i.jsx(x.IconContainer,Object.assign({onClick:()=>{e===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS?r===exports.DISCOUNT_PRODUCTS.ENTITLED?T.setEntitledProducts([]):T.setPrerequisiteProducts([]):r===exports.DISCOUNT_PRODUCTS.ENTITLED?T.setEntitledCollections([]):T.setPrerequisiteCollections([])}},{children:i.jsx(D.default,{width:24,height:24,color:c.DEFAULT_THEME.colorsV2.content.placeholder})}))]}))]})]}):r===exports.DISCOUNT_PRODUCTS.ENTITLED&&T.entitledProductVariable?i.jsxs("div",{children:[i.jsx(d.BodySecondary,Object.assign({style:{margin:"16px 0 8px"}},{children:"Product Variable"})),i.jsxs(x.ProductVariableCard,{children:[i.jsx(d.TitleSmall,{children:T.entitledProductVariable.displayName}),i.jsx("div",Object.assign({style:{display:"flex",gap:4}},{children:i.jsx(x.IconContainer,Object.assign({onClick:()=>{T.setEntitledProductVariable(void 0)}},{children:i.jsx(p.default,{width:24,height:24,color:c.DEFAULT_THEME.colorsV2.content.primary})}))}))]})]}):r===exports.DISCOUNT_PRODUCTS.PREREQUISITE&&(null===(U=T.preRequisiteProductVariable)||void 0===U?void 0:U.displayName)?i.jsxs("div",{children:[i.jsx(d.BodySecondary,Object.assign({style:{margin:"16px 0 8px"}},{children:"Product Variable"})),i.jsxs(x.ProductVariableCard,{children:[i.jsx(d.TitleSmall,{children:T.preRequisiteProductVariable.displayName}),i.jsx("div",Object.assign({style:{display:"flex",gap:4}},{children:i.jsx(x.IconContainer,Object.assign({onClick:()=>{T.setPreRequisiteProductVariable(void 0)}},{children:i.jsx(p.default,{width:24,height:24,color:c.DEFAULT_THEME.colorsV2.content.primary})}))}))]})]}):i.jsx(i.Fragment,{children:" "})]})},f=(e,t)=>{var o,s,n,r,c,p,C,E,D,O;let S=[],P=[],I={},x={};T.useNewPicker?(I=e===exports.DISCOUNT_PRODUCTS.ENTITLED?T.entitledProducts:T.prerequisiteProducts,x=null!==(o=e===exports.DISCOUNT_PRODUCTS.ENTITLED?T.entitledCollections:T.prerequisiteCollections)&&void 0!==o?o:[],(null==I?void 0:I.isCustom)&&delete I.isCustom,(null==x?void 0:x.isCustom)&&delete x.isCustom,Object.values(I).forEach((e=>{Object.keys(e.products).forEach((i=>{S.push({id:i,name:e.products[i].name,image:e.products[i].image})}))})),Object.keys(x).forEach((e=>{"isCustom"!==e&&P.push({id:e,name:x[e].name,image:x[e].image})}))):(S=e===exports.DISCOUNT_PRODUCTS.ENTITLED?T.entitledProducts:T.prerequisiteProducts,P=null!==(s=e===exports.DISCOUNT_PRODUCTS.ENTITLED?T.entitledCollections:T.prerequisiteCollections)&&void 0!==s?s:[]);const v=e===exports.DISCOUNT_PRODUCTS.PREREQUISITE?T.offerAppliesToBuy:T.offerAppliesToGet,_=e===exports.DISCOUNT_PRODUCTS.PREREQUISITE?exports.DISCOUNT_PRODUCTS.PREREQUISITE:exports.DISCOUNT_PRODUCTS.ENTITLED,j=v===l.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS?l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS:l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS;return i.jsxs("div",{children:[i.jsx(d.TitleSmall,Object.assign({style:{marginBottom:16}},{children:e===exports.DISCOUNT_PRODUCTS.PREREQUISITE?"Customer buys":"Customer gets"})),i.jsxs("div",Object.assign({style:{display:"flex"}},{children:[!t&&i.jsx("div",{children:i.jsxs("div",Object.assign({className:"input__rows"},{children:[i.jsx("div",Object.assign({className:"input__wrapper"},{children:i.jsx(u.Input,{value:e===exports.DISCOUNT_PRODUCTS.ENTITLED?null!==(r=null===(n=T.discountData.entitledQuantity)||void 0===n?void 0:n.toString())&&void 0!==r?r:"":null!==(p=null===(c=T.discountData.prerequisiteQuantity)||void 0===c?void 0:c.toString())&&void 0!==p?p:"",type:"number",onChangeText:i=>{e===exports.DISCOUNT_PRODUCTS.ENTITLED?T.setDiscountData(Object.assign(Object.assign({},T.discountData),{entitledQuantity:parseInt(i)})):T.setDiscountData(Object.assign(Object.assign({},T.discountData),{prerequisiteQuantity:parseInt(i)}))},labelText:"Quantity of products",placeholder:"Eg. 2",width:"300px",errorMessage:e===exports.DISCOUNT_PRODUCTS.PREREQUISITE&&(null===(C=T.dynamicDiscountValidationError)||void 0===C?void 0:C.inValidBuyXValue)||e===exports.DISCOUNT_PRODUCTS.ENTITLED&&(null===(E=T.dynamicDiscountValidationError)||void 0===E?void 0:E.inValidGetYValue)?"Required Field":"",state:e===exports.DISCOUNT_PRODUCTS.PREREQUISITE&&(null===(D=T.dynamicDiscountValidationError)||void 0===D?void 0:D.inValidBuyXValue)||e===exports.DISCOUNT_PRODUCTS.ENTITLED&&(null===(O=T.dynamicDiscountValidationError)||void 0===O?void 0:O.inValidGetYValue)?"invalid":"none"})})),i.jsx("div",{className:"input__wrapper"})]}))}),i.jsxs("div",{children:[i.jsx(d.BodySecondary,Object.assign({style:{marginBottom:8}},{children:"Any items from"})),e===exports.DISCOUNT_PRODUCTS.PREREQUISITE&&i.jsx(a.Dropdown,{width:"244px",options:V,placement:"bottom-start",onSelect:e=>{var i,t,o;T.setOfferAppliesToBuy(e.value),T.setPrerequisiteProducts([]),T.setPrerequisiteCollections([]),T.setPreRequisiteProductVariable(void 0),T.setDynamicDiscountValidationError((e=>Object.assign(Object.assign({},e),{inValidBuyXCollectionSelection:!1,inValidBuyXProductSelection:!1,inValidBuyXProductVariableSelection:!1}))),T.setDiscountData(Object.assign(Object.assign({},T.discountData),{prerequisiteCollectionIds:[],prerequisiteProductIds:[],collectionsConf:{entitledCollections:null===(i=T.discountData.collectionsConf)||void 0===i?void 0:i.entitledCollections,prerequisiteCollections:{}},productsConf:{entitledProducts:null===(t=T.discountData.productsConf)||void 0===t?void 0:t.entitledProducts,prerequisiteProducts:{}},productVariableConf:{entitledProductVariable:null===(o=T.discountData.productVariableConf)||void 0===o?void 0:o.entitledProductVariable,prerequisiteProductVariable:{}}}))}}),e===exports.DISCOUNT_PRODUCTS.ENTITLED&&i.jsx(a.Dropdown,{width:"244px",options:A,placement:"bottom-start",onSelect:e=>{var i,t,o;T.setOfferAppliesToGet(e.value),T.setEntitledProducts([]),T.setEntitledCollections([]),T.setEntitledProductVariable(void 0),T.setDynamicDiscountValidationError((e=>Object.assign(Object.assign({},e),{inValidGetYCollectionSelection:!1,inValidGetYProductSelection:!1,inValidGetYProductVariableSelection:!1}))),T.setDiscountData(Object.assign(Object.assign({},T.discountData),{entitledCollectionIds:[],entitledProductIds:[],collectionsConf:{entitledCollections:{},prerequisiteCollections:null===(i=T.discountData.collectionsConf)||void 0===i?void 0:i.prerequisiteCollections},productsConf:{entitledProducts:{},prerequisiteProducts:null===(t=T.discountData.productsConf)||void 0===t?void 0:t.prerequisiteProducts},productVariableConf:{entitledProductVariable:{},prerequisiteProductVariable:null===(o=T.discountData.productVariableConf)||void 0===o?void 0:o.prerequisiteProductVariable}}))}})]})]})),L(j,_,e===exports.DISCOUNT_PRODUCTS.PREREQUISITE?"buyX":"getY")]})};return i.jsxs(I.DynamicCouponContainer,{children:[i.jsxs("div",{children:[i.jsxs("div",Object.assign({style:{display:"flex",gap:16}},{children:[i.jsx("div",Object.assign({className:"input__wrapper"},{children:i.jsx(u.Input,{value:null!==(j=T.discountData.title)&&void 0!==j?j:"",onChangeText:e=>{var i;T.setDiscountData(Object.assign(Object.assign({},T.discountData),{title:null!==(i=null==e?void 0:e.trim())&&void 0!==i?i:""}))},maxCharLimit:30,labelText:"Discount Coupon Title",placeholder:`Eg. “Flat ${null!==(b=T.currency)&&void 0!==b?b:""} 15 Off”`,hintText:"Will be same for everyone. Can’t be changed later",width:"300px",isRequired:!0,errorMessage:(null===(g=T.dynamicDiscountValidationError)||void 0===g?void 0:g.invalidCouponTitle)?"Required Field":"",state:(null===(m=T.dynamicDiscountValidationError)||void 0===m?void 0:m.invalidCouponTitle)?"invalid":"none"})})),!T.hideProbability&&i.jsx(u.Input,{value:null!==(U=null===(y=T.discountData.probability)||void 0===y?void 0:y.toString())&&void 0!==U?U:"",type:"number",onChangeText:e=>{T.setDiscountData(Object.assign(Object.assign({},T.discountData),{probability:e.startsWith(".")?parseFloat(parseFloat(`0${e}`).toFixed(2)):parseFloat(parseFloat(e).toFixed(2))}))},labelText:"Probability of getting coupon ",hintText:"Enter a decimal value between 0-1",placeholder:"Eg. 0.5",maxCharLimit:4,width:"300px",isRequired:!0,errorMessage:(null===(h=T.dynamicDiscountValidationError)||void 0===h?void 0:h.inValidProbability)?"Required Field":"",state:(null===(R=T.dynamicDiscountValidationError)||void 0===R?void 0:R.inValidProbability)?"invalid":"none"})]})),i.jsx("div",{style:{height:"1px",width:"100%",background:c.DEFAULT_THEME.colorsV2.stroke.primary,margin:"24px 0 8px"}})]}),T.allowStaticCoupon&&i.jsx((()=>i.jsxs("div",{children:[i.jsx(d.TitleRegular,{children:"Discount Details"}),i.jsx(x.DiscountOptionsContainer,{children:T.discountDetailsOptions.map((t=>{return i.jsxs(x.DiscountDetailsOption,Object.assign({selected:T.selectedDiscountDetails.id===t.id,onClick:()=>(i=>{if(T.selectedDiscountDetails.id!==i.id)if(T.resetValidationErrors(),T.setValidationErrorMessage(""),T.setDiscountCouponAppliesTo(l.DISCOUNT_APPLIES_TO.ENTIRE_ORDER),T.setSelectedDiscountDetails(i),T.setDiscountData(Object.assign(Object.assign({},T.discountData),{value:void 0})),T.setPreRequisiteProductVariable(void 0),T.setEntitledProductVariable(void 0),["percentage","amount"].includes(i.value)){T.onChangeCouponType({label:"Amount off on order",selected:!0,value:l.DISCOUNT_TYPES.AMOUNT_OFF_ORDER});const t=Object.assign(Object.assign({},T.discountData),{valueType:"percentage"===i.value?l.DISCOUNT_VALUE_TYPES.PERCENTAGE:l.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT,value:void 0,targetType:l.DISCOUNT_TARGET_TYPES.LINE_ITEM,targetSelection:l.DISCOUNT_TARGET_SELECTION.ALL,entitledCollectionIds:[],entitledProductIds:[],prerequisiteCollectionIds:[],prerequisiteProductIds:[],collectionsConf:{entitledCollections:{},prerequisiteCollections:{}},productsConf:{entitledProducts:{},prerequisiteProducts:{}},productVariableConf:{entitledProductVariable:{},prerequisiteProductVariable:{}}}),o=e.__rest(t,["entitledQuantity","prerequisiteQuantity"]);T.setDiscountData(o)}else T.onChangeCouponType({label:i.label,selected:!0,value:i.value})})(t)},{children:[t.icon((o=t.id,T.selectedDiscountDetails.id===o?c.DEFAULT_THEME.colorsV2.stroke.brand:c.DEFAULT_THEME.colorsV2.text.secondary)),t.label]}),t.id);var o}))})]})),{}),(T.selectedCouponType===l.DISCOUNT_TYPES.AMOUNT_OFF_ORDER||T.selectedCouponType===l.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS)&&(()=>{var e,t,o,s,n,r;return i.jsxs(i.Fragment,{children:[i.jsx("div",Object.assign({className:"input__rows"},{children:i.jsx("div",Object.assign({className:"input__wrapper"},{children:i.jsx(u.Input,{value:null!==(o=null===(t=null===(e=T.discountData)||void 0===e?void 0:e.value)||void 0===t?void 0:t.toString())&&void 0!==o?o:"",labelText:"Discount amount",type:"number",width:"300px",onChangeText:e=>{T.setDiscountData(Object.assign(Object.assign({},T.discountData),{value:parseInt(e)}))},placeholder:"15",prefixText:T.discountData.valueType===l.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?null!==(s=T.currency)&&void 0!==s?s:"":void 0,suffixText:T.discountData.valueType===l.DISCOUNT_VALUE_TYPES.PERCENTAGE?"%":void 0,errorMessage:(null===(n=T.dynamicDiscountValidationError)||void 0===n?void 0:n.inValidDiscountAmount)?"Required Field":"",state:(null===(r=T.dynamicDiscountValidationError)||void 0===r?void 0:r.inValidDiscountAmount)?"invalid":"none"})}))})),i.jsx("div",Object.assign({style:{paddingTop:"24px",marginTop:16,borderTop:`1px solid ${c.DEFAULT_THEME.colorsV2.stroke.primary}`}},{children:i.jsxs("div",Object.assign({className:"input__wrapper"},{children:[i.jsx(d.TitleRegular,Object.assign({style:{marginBottom:10}},{children:"Applies to"})),i.jsx("div",Object.assign({style:{display:"flex",flexGrow:0,flexShrink:0,flexBasis:"auto"}},{children:i.jsx(a.Dropdown,{width:"300px",options:N,placement:"bottom-start",onSelect:e=>{const i="value"in e&&e.value===l.DISCOUNT_APPLIES_TO.ENTIRE_ORDER?{label:"Amount off on order",selected:!0,value:l.DISCOUNT_TYPES.AMOUNT_OFF_ORDER}:{label:"Amount off on products",selected:!0,value:l.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS};T.onChangeCouponType(i),T.setDiscountCouponAppliesTo(e.value),T.setEntitledProductVariable(void 0),T.setDynamicDiscountValidationError((e=>Object.assign(Object.assign({},e),{inValidProductVariableSelection:!1,inValidProductSelection:!1,inValidCollectionSelection:!1})))}})})),(T.discountCouponAppliesTo===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS||T.discountCouponAppliesTo===l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS)&&L(T.discountCouponAppliesTo,exports.DISCOUNT_PRODUCTS.ENTITLED,"couponAppliesTo")]}))}))]})})(),T.selectedCouponType===l.DISCOUNT_TYPES.BUY_X_GET_Y&&(()=>{var e,t,o,s,n;return i.jsxs(I.DynamicCouponContainer,Object.assign({style:{border:`1px solid ${c.DEFAULT_THEME.colorsV2.stroke.primary}`,padding:"16px",borderRadius:"4px",margin:0}},{children:[f(exports.DISCOUNT_PRODUCTS.PREREQUISITE),i.jsx("div",{style:{width:"100%",height:"1px",backgroundColor:c.DEFAULT_THEME.colorsV2.stroke.primary,margin:"8px 0"}}),f(exports.DISCOUNT_PRODUCTS.ENTITLED),i.jsx(d.BodySecondary,Object.assign({style:{marginTop:"8px"}},{children:"At a discounted value"})),i.jsx("div",{children:i.jsx(C.RadioButton,{label:"Free",isActive:100===T.discountData.value,onValueChange:e=>{e?T.setDiscountData(Object.assign(Object.assign({},T.discountData),{value:100})):T.setDiscountData(Object.assign(Object.assign({},T.discountData),{value:void 0}))}})}),i.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column"}},{children:[i.jsx(C.RadioButton,{label:"Percentage off",isActive:100!==T.discountData.value,onValueChange:()=>{T.setDiscountData(Object.assign(Object.assign({},T.discountData),{value:void 0}))}}),100!==T.discountData.value&&i.jsx("div",Object.assign({style:{marginTop:8}},{children:i.jsx(u.Input,{value:null!==(o=null===(t=null===(e=T.discountData)||void 0===e?void 0:e.value)||void 0===t?void 0:t.toString())&&void 0!==o?o:"",onChangeText:e=>{T.setDiscountData(Object.assign(Object.assign({},T.discountData),{value:parseInt(e)}))},type:"number",placeholder:"Eg. 50",suffixText:"%",width:"300px",errorMessage:(null===(s=T.dynamicDiscountValidationError)||void 0===s?void 0:s.inValidDiscountAmount)?"Required Field":"",state:(null===(n=T.dynamicDiscountValidationError)||void 0===n?void 0:n.inValidDiscountAmount)?"invalid":"none"})}))]}))]}))})(),!T.selectedCouponType&&i.jsx(_.default,{}),T.allowStaticCoupon&&T.selectedCouponType!==l.DISCOUNT_TYPES.BUY_X_GET_Y&&i.jsx("div",Object.assign({style:{padding:"24px 0 16px",marginTop:16,borderTop:`1px solid ${c.DEFAULT_THEME.colorsV2.stroke.primary}`}},{children:i.jsx(v.default,{selectedMinimumRequirement:T.selectedMinimumRequirement,setSelectedMinimumRequirement:T.setSelectedMinimumRequirement,discountData:T.discountData,setDiscountData:T.setDiscountData,currency:T.currency,dynamicDiscountValidationError:T.dynamicDiscountValidationError})})),T.selectedCouponType&&!T.hideExpiration&&i.jsxs("div",Object.assign({style:{padding:T.selectedCouponType!==l.DISCOUNT_TYPES.BUY_X_GET_Y?"24px 0 16px":"8px 0",borderTop:T.selectedCouponType!==l.DISCOUNT_TYPES.BUY_X_GET_Y?`1px solid ${c.DEFAULT_THEME.colorsV2.stroke.primary}`:"none"}},{children:[i.jsx(r.CheckBox,{label:"Add expiration",isDisabled:!!T.makeExpiryMandatory,isChecked:T.isAddExpirationChecked,onValueChange:e=>{T.setIsAddExpirationChecked(e),T.setDiscountData(Object.assign(Object.assign({},T.discountData),{expireAfter:void 0,expireAt:void 0})),T.setSelectedExpiration(l.COUPON_EXPIRATION.DYNAMIC_EXPIRATION)},boldOnChecked:!0,labelSize:"DEFAULT"}),i.jsx(d.BodySecondary,Object.assign({style:{color:c.DEFAULT_THEME.colorsV2.text.secondary,marginLeft:28}},{children:"Make coupon only valid till a certain time"})),T.isAddExpirationChecked&&i.jsx(P.CouponExpiration,{discountData:T.discountData,setDiscountData:T.setDiscountData,isAddExpirationChecked:T.isAddExpirationChecked,inValidCouponExpiry:T.dynamicDiscountValidationError.inValidCouponExpiry,selectedExpiration:T.selectedExpiration,setSelectedExpiration:T.setSelectedExpiration})]}))]})};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { DropdownProps } from
|
|
2
|
+
import { DropdownProps } from './Dropdown';
|
|
3
3
|
export declare const ChipDropdown: React.FC<DropdownProps>;
|
|
4
4
|
export declare const ChipDropdownContainer: import("styled-components").StyledComponent<"div", any, {
|
|
5
5
|
width?: string | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),r=require("react"),i=require("styled-components"),o=require("../tag/Tag.js"),n=require("../../constants/Theme.js"),s=require("../../assets/icons/chevronDown.svg.js"),l=require("../../assets/icons/chevronDownOutline.svg.js"),a=require("../../assets/icons/chevronUpOutline.svg.js"),d=require("../TypographyStyle.js"),u=require("./DropdownPopover/index.js");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=p(i);const h=i=>{var{placeHolder:p,onSelect:c}=i,h=e.__rest(i,["placeHolder","onSelect"]);const[j,x]=r.useState(!1),v=r.useRef();return t.jsx(u.DropdownPopover,Object.assign({ref:v,onDropdownVisbilityChange:e=>x(e),onSelect:function(e){null==c||c(e)}},h,{children:"default"==h.inputType?t.jsxs(g,Object.assign({width:null==h?void 0:h.width,height:null==h?void 0:h.height},{children:[t.jsx(d.BodySecondary,Object.assign({color:n.COLORS.content.placeholder},{children:p})),t.jsx(s.default,{style:{transform:j?"rotate(180deg)":"rotate(0deg)"},width:20,height:20,color:n.COLORS.content.primary})]})):t.jsx(o.Tag,{tagText:null!=p?p:"",theme:"light",type:"neutral",variant:"regular",TrailingIcon:j?a.default:l.default})}))};h.displayName="ChipDropdown";const g=c.default.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: row;
|
|
4
4
|
width: ${e=>(null==e?void 0:e.width)?e.width:"240px"};
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
gap: 8px;
|
|
7
7
|
justify-content: space-between;
|
|
8
8
|
align-items: center;
|
|
9
|
-
border: 1px solid ${
|
|
9
|
+
border: 1px solid ${n.COLORS.stroke.primary};
|
|
10
10
|
border-radius: 4px;
|
|
11
11
|
padding-left: 8px;
|
|
12
12
|
padding-right: 8px;
|
|
13
13
|
cursor: pointer;
|
|
14
|
-
`;exports.ChipDropdown=h,exports.ChipDropdownContainer=
|
|
14
|
+
`;exports.ChipDropdown=h,exports.ChipDropdownContainer=g;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("../../../assets/icons/horizontal_dots.svg.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("../../../assets/icons/horizontal_dots.svg.js"),s=require("../../../assets/icons/vertical_dots.svg.js"),o=require("styled-components"),t=require("../../icon-button/IconButton.js"),i=require("../../../constants/Theme.js"),n=require("../DropdownPopover/index.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const a=d(o).default.div`
|
|
2
2
|
:hover {
|
|
3
|
-
background: ${
|
|
3
|
+
background: ${i.COLORS.surface.subdued};
|
|
4
4
|
}
|
|
5
5
|
position: ${e=>e.isNewTag?"relative":""};
|
|
6
6
|
.new--tag {
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
border-radius: 50%;
|
|
12
12
|
width: 14px;
|
|
13
13
|
height: 14px;
|
|
14
|
-
background: ${
|
|
15
|
-
border: 1.25px solid ${
|
|
14
|
+
background: ${i.COLORS.background.negative.vibrant};
|
|
15
|
+
border: 1.25px solid ${i.COLORS.surface.standard};
|
|
16
16
|
display: flex;
|
|
17
17
|
justify-content: center;
|
|
18
18
|
align-items: center;
|
|
19
19
|
}
|
|
20
|
-
`,
|
|
20
|
+
`,u=o=>e.jsx(a,Object.assign({isNewTag:o.isNewTag},{children:e.jsxs(n.DropdownPopover,Object.assign({},o,{children:[e.jsx("div",{children:e.jsx(t.IconButton,{Icon:o.isHorizontal?r.default:s.default,bordered:!(null==o?void 0:o.hideBorder)})}),o.isNewTag?e.jsx("div",{className:"new--tag"}):null]}))}));u.displayName="MenuItemDropdown",exports.MenuItemDropdown=u;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("../../assets/icons/chevronRight2.svg.js"),t=require("react"),i=require("../../constants/Theme.js"),o=require("../TypographyStyle.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("../../assets/icons/chevronRight2.svg.js"),t=require("react"),i=require("../../constants/Theme.js"),o=require("../TypographyStyle.js"),s=require("./MultiLevelDropdown.styled.js");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=r(t);const d=l.default.lazy((()=>Promise.resolve().then((function(){return require("./MenuList.js")})).then((e=>({default:e.MenuList})))));exports.MenuItem=r=>{let{width:a,onDropdownItemClick:c,option:u,parents:p}=r;var h,j,g,v,O,b,C;const[x,f]=l.default.useState(!1),[S,m]=l.default.useState(!1),[L,y]=l.default.useState({top:0,left:0}),M=t.useRef({top:0,left:0});return e.jsxs(s.MenuItemWrapper,Object.assign({onMouseEnter:e=>{f(!0),(e=>{const n=e.currentTarget.getBoundingClientRect();y({top:n.top,left:n.right}),M.current={top:n.top,left:n.right}})(e)},onMouseLeave:()=>{f(!1)},onClick:()=>{var e,n;!c||null!==(e=u.disabled)&&void 0!==e&&e||(null===(n=u.children)||void 0===n?void 0:n.length)||c(u,p)},id:"menuItemWrapper",style:{cursor:null!==(h=u.disabled)&&void 0!==h&&h?"not-allowed":"pointer",backgroundColor:null!==(j=u.disabled)&&void 0!==j&&j?i.COLORS.surface.standard:"transparent"}},{children:[u.customComponent?u.customComponent:e.jsxs(s.MenuItemContainer,Object.assign({isSelected:u.selected,isSubMenuOpen:x,isHovered:S,isDisabled:null!==(g=u.disabled)&&void 0!==g&&g},{children:[e.jsxs(s.ContentContainer,{children:[u.leadingIcon&&e.jsx(s.LeadingIconContainer,{children:u.leadingIcon}),e.jsxs("div",{children:[e.jsx(o.BodyCaption,Object.assign({style:{color:null!==(v=u.disabled)&&void 0!==v&&v?i.COLORS.content.inactive:u.selected||S?i.COLORS.content.positive:i.COLORS.content.primary}},{children:u.label})),u.subText&&e.jsx(o.BodyTiny,Object.assign({style:{color:null!==(O=u.disabled)&&void 0!==O&&O?i.COLORS.content.inactive:u.selected||S?i.COLORS.content.positive:i.COLORS.content.secondary,marginTop:"2px"}},{children:u.subText}))]})]}),u.children&&u.children.length>0?e.jsx(s.TrailingIconContainer,{children:e.jsx(n.default,{width:16,height:16,color:null!==(b=u.disabled)&&void 0!==b&&b?i.COLORS.content.inactive:u.selected||S?i.COLORS.content.positive:i.COLORS.content.primary})}):u.trailingIcon?e.jsx(s.TrailingIconContainer,{children:u.trailingIcon}):e.jsx(e.Fragment,{})]})),!(null!==(C=u.disabled)&&void 0!==C&&C)&&u.children&&u.children.length>0&&x&&e.jsx(s.SubMenuContainer,Object.assign({width:a,className:"submenu",onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1)},{children:e.jsx(s.StyledSubMenuWrapper,Object.assign({width:a,top:L.top,left:L.left},{children:e.jsx(s.SubMenuListContainer,{children:e.jsx(t.Suspense,Object.assign({fallback:e.jsx("div",{children:"Loading..."})},{children:e.jsx(d,{width:a,onDropdownItemClick:c,options:u.children,parents:[...p,u]})}))})}))}))]}))};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
|
|
3
3
|
import { ButtonProps } from '../button/model';
|
|
4
|
-
import { FooterForNonModalI, OUT_OF_STOCK_ACTION } from './type';
|
|
4
|
+
import { FooterForNonModalI, OUT_OF_STOCK_ACTION, ScreenName } from './type';
|
|
5
5
|
export interface ProductVariant {
|
|
6
6
|
name: string;
|
|
7
7
|
price: string;
|
|
@@ -58,13 +58,6 @@ export type FbStatusFetcherReturn = Promise<{
|
|
|
58
58
|
[key: string]: FbProductStatus;
|
|
59
59
|
}>;
|
|
60
60
|
export type FbProductStatus = 'APPROVED' | 'REJECTED';
|
|
61
|
-
export declare enum ScreenName {
|
|
62
|
-
Collections = "collections",
|
|
63
|
-
RearrangeProducts = "rearrange",
|
|
64
|
-
SelectedProducts = "view",
|
|
65
|
-
SearchProducts = "searchProducts",
|
|
66
|
-
Products = "products"
|
|
67
|
-
}
|
|
68
61
|
export type ProductPickerInterface = {
|
|
69
62
|
hideGlobalSearch?: boolean;
|
|
70
63
|
hideInCollectionSearch?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime");require("../../node_modules/@bikdotai/bik-models/growth/models/bik-store.js");var t
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime");require("../../node_modules/@bikdotai/bik-models/growth/models/bik-store.js");var t=require("../../assets/icons/search.svg.js"),o=require("react"),c=require("../../constants/Theme.js"),r=require("../../assets/icons/cross.svg.js"),s=require("../button/Button.js"),n=require("../input/Input.js"),i=require("../modals/styledModal.js"),l=require("../spinner/Spinner.js"),a=require("../tag/Tag.js"),d=require("./collectionScreen.js"),u=require("./productInfoOverlay.js"),h=require("./productScreen.js"),p=require("./rearrangeScreen.js"),S=require("./reducers.js"),C=require("./searchScreen.js"),g=require("./selectedScreen.js"),y=require("./style.js"),j=require("./type.js"),x=require("./utility.js"),b=require("../../_virtual/bik-store.js");exports.ProductPickerModal=m=>{const{storeId:f,selectedItems:v,onClose:k,visible:I,zIndex:O,exactLimit:F,limit:P,hideCollectionCheckbox:T,hideProductCheckbox:R,outOfStockAction:D=j.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:q,selectProductsFromCustomCollection:E,hideSelectionCount:N,title:A,width:B,left:w,renderWithoutModal:L,onClickSave:M,pickerType:V,hideProductVariants:_=!1,startupScreen:z=j.ScreenName.Collections,rearrangeEnabled:$,selectSingleItem:H=!1,showProductDetails:K,containerStyle:W,crossButtonInsideHeader:G=!1,footerForNonModal:U={},primaryButton:Y,secondaryButton:J,subtitle:Q}=m,X=m.appType||b.__exports.ApplicationType.BIK,[Z,ee]=o.useReducer(S.collectionsReducer,{}),[te,oe]=o.useState([j.ScreenName.Collections,j.ScreenName.RearrangeProducts].includes(z)?z:j.ScreenName.Collections),[ce,re]=o.useState("grid"),[se,ne]=o.useState(""),[ie,le]=o.useState(""),[ae,de]=o.useState(0),[ue,he]=o.useState(!1),[pe,Se]=o.useState(0),[Ce,ge]=o.useState(""),[ye,je]=o.useState(!1),[xe,be]=o.useState(!1),[me,fe]=o.useReducer(S.searchReducer,{collections:{},products:{}}),[ve,ke]=o.useReducer(S.selectedColectionsReducer,Object.keys(v).length>0?v:{}),Ie=o.useRef(null),[Oe,Fe]=o.useState(!1),[Pe,Te]=o.useState();o.useEffect((()=>{he(!0),be(!0),m.collectionFetcher(ae,f,X).then((e=>{ee({type:"fetched",data:(null==e?void 0:e.collections)||{}}),he(!1),de((e=>e+1)),be(!1)})).catch()}),[]),o.useEffect((()=>{let e=0;_?Object.keys(ve||[]).forEach((t=>{var o;Object.keys((null===(o=ve[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&ve[-1]&&(null===(c=ve[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(ve||[]).forEach((t=>{var o;Object.keys((null===(o=ve[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=ve[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),Se(e)}),[Z,ve,_]),o.useEffect((()=>{ie&&(he(!0),m.productFetcher(ie,f,X).then((e=>{Object.keys(e).length&&ee({type:"productsFetched",data:{collectionId:ie,products:e}}),he(!1)})).catch())}),[ie]),o.useEffect((()=>{const e=setTimeout((()=>{"rearrange"!==te&&(Ce.length||"collections"!==te)&&(Ce.length?(je(!0),m.searchFetcher(f,Ce,X).then((e=>{"collections"in e&&"products"in e?(fe({type:"set",data:e}),ee({type:"searched",data:e.collections}),ee({type:"searched",data:e.products})):(fe({type:"set",data:{collections:{},products:e}}),ee({type:"searched",data:e})),oe("searchProducts"),he(!1),je(!1)}))):oe("collections"))}),800);return()=>clearTimeout(e)}),[Ce]),o.useEffect((()=>{M&&(m.onAdd(ve,pe),Re())}),[M]),o.useEffect((()=>{H&&Object.keys(ve||{}).length&&pe&&(m.onAdd(ve,pe),Re())}),[H,ve,pe]);const Re=()=>{ke({type:"reset",data:{}})},De=()=>F&&pe>F?e.jsx(a.Tag,{tagText:`You can only select ${F} products`,type:"negative"}):P&&pe>P?e.jsx(a.Tag,{tagText:`You can only select ${P} products`,type:"negative"}):pe>0?e.jsx(s.Button,{onClick:()=>{oe($?j.ScreenName.RearrangeProducts:j.ScreenName.SelectedProducts)},buttonText:F?`${pe}/${F} products selected`:`${pe} products selected`,buttonType:["rearrange","view"].includes(te)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(te)}):e.jsx(s.Button,{disabled:!0,buttonText:F?`${pe}/${F} products selected`:`${pe} products selected`,buttonType:"tertiaryGray"}),qe=e=>ue?"Loading...":te===j.ScreenName.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",Ee=e.jsxs(y.ContainerStyle,Object.assign({style:null!=W?W:{}},{children:[m.postHeader&&e.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:m.postHeader})),!m.hideGlobalSearch&&e.jsx(e.Fragment,{children:("collections"===te||"searchProducts"===te)&&e.jsx("div",Object.assign({style:{padding:L?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(n.Input,{placeholder:"Search using ID, Name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ye?e.jsx(l.Spinner,{size:"small",color:c.COLORS.content.primary}):e.jsx(t.default,{})},id:"listInput",height:"24px",type:"text",value:Ce,onChangeText:e=>{e.length&&e.trim().length?ge(e):ge("")}})}))}),e.jsxs(y.ScrollContainerStyle,Object.assign({ref:Ie,screenName:te},{children:["collections"===te&&e.jsx(d.CollectionsScreen,{customCollectionRestriction:m.customCollectionRestriction,dataLoading:xe,collections:Z,selectedCollectionsDispatch:ke,setCollectionId:ne,setSelectedCollectionId:le,setScreen:oe,selectedCollections:ve,collectionFetcher:m.collectionFetcher,storeId:f,appType:X,collectionsDispatch:ee,setSaveDisabled:he,pagingControls:{curPage:ae,setCurPage:de},hideCollectionCheckbox:T,renderWithoutModal:L,pickerType:V,scrollContainerRef:Ie}),"products"===te&&se&&e.jsx(S.CollectionIdContext.Provider,Object.assign({value:se},{children:e.jsx(h.ProductsScreen,{hideInCollectionSearch:m.hideInCollectionSearch,customCollectionRestriction:m.customCollectionRestriction,productFetcher:m.productFetcher,setScreen:oe,storeId:f,appType:X,data:Z[se],collectionsDispatch:ee,selectedCollectionsDispatch:ke,selectedData:ve,setSaveDisabled:he,searchInCollectionFetcher:m.searchInCollectionFetcher,hideProductCheckbox:R,outOfStockAction:D,hideVariantCheckbox:q,selectProductsFromCustomCollection:E,renderWithoutModal:L,pickerType:V,hideProductVariants:_,fbStatusFetcher:m.fbStatusFetcher,onProductDetailClick:e=>{Fe(!0),Te(e)},showProductDetailInfoIcon:K,scrollContainerRef:Ie})})),"view"===te&&e.jsx(g.SelectedScreen,{selectedCollections:ve||{},selectedCollectionsDispatch:ke,setScreen:oe,collections:Z,hideProductVariants:_,outOfStockAction:D,storeId:f,appType:X,fbStatusFetcher:m.fbStatusFetcher}),"rearrange"===te&&e.jsx(p.RearrangeScreen,{selectedCollections:ve||{},selectedCollectionsDispatch:ke,setScreen:oe,outOfStockAction:D,rearrangeViewType:"grid"===ce?"list":"grid",scrollContainerRef:Ie,storeId:f,appType:X,fbStatusFetcher:m.fbStatusFetcher}),"searchProducts"===te&&e.jsx(C.SearchScreen,{customCollectionRestriction:m.customCollectionRestriction,selectedCollections:ve||{},searchedCollections:me||{},searchedCollectionsDispatch:fe,selectedCollectionsDispatch:ke,setScreen:oe,collections:Z,onBackPress:()=>{ge(""),fe({type:"set",data:{collections:{},products:{}}})},pickerType:V,hideProductCheckbox:R,hideProductVariants:_,hideVariantCheckbox:q,storeId:f,appType:X,fbStatusFetcher:m.fbStatusFetcher,setCollectionId:ne,setSelectedCollectionId:le,renderWithoutModal:L,hideCollectionCheckbox:T,outOfStockAction:D})]}))]}));return e.jsx(e.Fragment,{children:L?e.jsxs(e.Fragment,{children:[Ee,U.renderFooter?e.jsxs(y.StyledFooterForNonModal,{children:[De(),e.jsx(s.Button,{buttonText:qe(U.primaryButtonText),disabled:!U.isLoading&&(ue||pe<1||F&&pe<F||!F&&P&&pe>P)||U.primaryButtonDisabled,isLoading:U.isLoading,onClick:()=>{m.onAdd(ve,pe),Re(),oe([j.ScreenName.Collections,j.ScreenName.RearrangeProducts].includes(z)?z:j.ScreenName.Collections)}})]}):e.jsx(e.Fragment,{}),Oe&&Pe?e.jsx(u.ProductInfoOverlay,{productData:Pe,outOfStockAction:D,useDynamicInfoImageSize:m.useDynamicInfoImageSize,onClose:()=>{Fe(!1)}}):e.jsx(e.Fragment,{})]}):e.jsxs(i.StyledModal,Object.assign({zIndex:O,open:I,onClose:()=>{null==k||k(),Re()},headingTitle:A||("collections"===te||"products"===te?"Select Products":"view"===te?"Selected Products":"searchProducts"===te?"Searched Results":"rearrange"===te?"Rearrange Products":void 0),headingSubtitle:Q,footerShadow:!0,centralContainerStyles:{width:B||"600px",left:w||"auto"},headerRightCustomElement:G?e.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:k},{children:e.jsx(r.default,{width:20,height:20,color:c.COLORS.content.secondary})})):e.jsx(e.Fragment,{}),footerContainerStyle:m.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:c.COLORS.surface.standard}:void 0,primaryButton:Y?(e=>Object.assign(Object.assign({},e),{disabled:!e.isLoading&&(ue||pe<1||F&&pe<F||!F&&P&&pe>P)||e.disabled,onClick:()=>{m.onAdd(ve,pe),Re(),oe([j.ScreenName.Collections,j.ScreenName.RearrangeProducts].includes(z)?z:j.ScreenName.Collections)}}))(Y):{buttonText:qe(),disabled:ue||pe<1||F&&pe<F||!F&&P&&pe>P||!1,onClick:()=>{m.onAdd(ve,pe),Re()}},secondaryButton:J?(e=>Object.assign(Object.assign({},e),{disabled:ue||pe<1||F&&pe<F||!F&&P&&pe>P||!1,onClick:()=>{const e=x.updateAllVariantsForSelectedProducts(ve,Z,me);m.onAdd(e,pe,!0)}}))(J):void 0,wrapperStyle:m.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:N?e.jsx(e.Fragment,{}):De(),hideCrossButton:Oe||G},{children:[Ee,Oe&&Pe?e.jsx(u.ProductInfoOverlay,{productData:Pe,useDynamicInfoImageSize:m.useDynamicInfoImageSize,outOfStockAction:D,onClose:()=>{Fe(!1)}}):e.jsx(e.Fragment,{})]}))})};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),t=require("../../constants/Theme.js"),i=require("../TypographyStyle.js"),o=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),t=require("../../constants/Theme.js"),i=require("../TypographyStyle.js"),o=require("./type.js");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=r(e);const d=l.default.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
background-color: white;
|
|
4
4
|
height: ${e=>e.renderWithoutModal?"90%":"75vh"};
|
|
@@ -10,3 +10,10 @@ export interface FooterForNonModalI {
|
|
|
10
10
|
primaryButtonDisabled?: boolean;
|
|
11
11
|
isLoading?: boolean;
|
|
12
12
|
}
|
|
13
|
+
export declare enum ScreenName {
|
|
14
|
+
Collections = "collections",
|
|
15
|
+
RearrangeProducts = "rearrange",
|
|
16
|
+
SelectedProducts = "view",
|
|
17
|
+
SearchProducts = "searchProducts",
|
|
18
|
+
Products = "products"
|
|
19
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var e,r;Object.defineProperty(exports,"__esModule",{value:!0}),exports.OUT_OF_STOCK_ACTION=void 0,(e=exports.OUT_OF_STOCK_ACTION||(exports.OUT_OF_STOCK_ACTION={})).HIDE="HIDE",e.NORMAL="NORMAL",e.BLUR="BLUR",exports.ScreenName=void 0,(r=exports.ScreenName||(exports.ScreenName={})).Collections="collections",r.RearrangeProducts="rearrange",r.SelectedProducts="view",r.SearchProducts="searchProducts",r.Products="products";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/delete.svg.js"),r=require("../../assets/icons/drag_handle.svg.js"),i=require("../../constants/Theme.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/delete.svg.js"),r=require("../../assets/icons/drag_handle.svg.js"),i=require("../tooltips/Tooltip.js"),a=require("../../constants/Theme.js"),s=require("../icon-button/IconButton.js"),n=require("../shimmer-image/ShimmerImage.js"),o=require("../TypographyStyle.js"),c=require("./constants.js"),l=require("./helpers/ProductHelper.js"),d=require("./ProductPickerTag.js"),u=require("./style.js");exports.VariantCardGridView=t=>{const{data:r}=t;return e.jsx(u.VariantCardGridStyle,{children:e.jsx(i.Tooltip,Object.assign({body:r.name,alwaysVisible:!1,variant:"dark",placement:"bottom"},{children:e.jsx(n.ShimmerImage,{width:72,height:72,imageUrl:r.image,alt:"Item",borderRadius:4})}))})},exports.VariantCardListView=j=>{var h,m,g;const{data:p,selectedCollectionsDispatch:x,outOfStockAction:y}=j,b=()=>{let e;return e=p.name.includes(p.productName)?p.name:`${p.productName} ${p.name}`,e},{dataForProductPickerTag:v,tagText:I,tagType:O}=l.ProductHelper.getDataForProductPickerTag(p,!0,y),T=`${p.currency&&null!==(h=c.CurrencySymbols[p.currency])&&void 0!==h?h:""}${null!==(g=null!==(m=p.price)&&void 0!==m?m:p.actualPrice)&&void 0!==g?g:""}`,S=p.skuId;return e.jsx(u.VariantCardListStyle,{children:e.jsxs("div",Object.assign({className:"text-container"},{children:[e.jsx(r.default,{width:24,height:24,color:a.COLORS.content.placeholder}),e.jsx("div",{children:e.jsx(n.ShimmerImage,{width:40,height:40,imageUrl:p.image,alt:"Item",borderRadius:4},p.variantId)}),e.jsxs("div",Object.assign({className:"info-container"},{children:[e.jsxs("div",Object.assign({className:"tooltip-title-tag"},{children:[e.jsx(i.Tooltip,Object.assign({body:b(),placement:"bottom",delay:400,variant:"light"},{children:e.jsx(o.TitleSmall,Object.assign({numberOfLines:1,style:{flex:1,minWidth:0}},{children:b()}))})),e.jsxs(u.ProductInfo,{children:[e.jsx(d.ProductPickerTag,{isVariant:!0,data:v,tagText:I,tagType:O}),e.jsx(s.IconButton,{Icon:()=>e.jsx(t.default,{width:24,height:24,color:a.COLORS.content.placeholder}),onClick:()=>{x&&x({type:"variantUnselected",data:{productId:p.productId,variantId:p.variantId,collectionId:p.collectionId}}),j.onDelete&&j.onDelete()}})]})]})),e.jsxs(u.ProductSubTitle,{children:[e.jsx(o.BodyCaption,Object.assign({color:a.COLORS.content.secondary},{children:!(null==v?void 0:v.fbStatus)||I?null:T})),S&&e.jsx(i.Tooltip,Object.assign({body:S,placement:"top"},{children:e.jsx(u.SKUIDBadge,{children:e.jsx(u.EllipsedBodyTiny,{children:`SKU ID: ${S}`})})}))]})]}))]}))})};
|