ekm-ui 0.3.91 → 0.3.93

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/index.js CHANGED
@@ -1,23 +1,24 @@
1
- export { g as CardPaymentBlock, c as DragAndDrop, d as FilePicker, b as Layout, f as ProductPicker, a as StackedListItem, e as TableResultBlock } from './chunk-44UX4FUN.js';
1
+ export { h as CardPaymentBlock, g as CountryPicker, c as DragAndDrop, d as FilePicker, b as Layout, f as ProductPicker, a as StackedListItem, e as TableResultBlock } from './chunk-46XKR7EO.js';
2
+ export { a as TableHeader } from './chunk-ZHMUFBQM.js';
3
+ export { b as ToastProvider, c as useToast } from './chunk-YZ2YZSNQ.js';
4
+ export { a as ToolTip } from './chunk-E62SCYLR.js';
5
+ export { a as NBUI_Card } from './chunk-X6RBGNFS.js';
6
+ export { a as NBUI_Container } from './chunk-7Q6OMA2A.js';
2
7
  export { a as Pagination } from './chunk-RHBXFO7R.js';
3
8
  import './chunk-5VOOMPCL.js';
4
9
  export { a as Search } from './chunk-N7JQ6EAC.js';
5
10
  export { b as Sidebar } from './chunk-HVNLAQA6.js';
6
11
  export { a as Sort } from './chunk-52VBZOHL.js';
7
- export { a as TableHeader } from './chunk-ZHMUFBQM.js';
8
- export { a as ToolTip } from './chunk-E62SCYLR.js';
9
- export { b as ToastProvider, c as useToast } from './chunk-YZ2YZSNQ.js';
12
+ export { a as FeatureCard } from './chunk-7WJGATIR.js';
13
+ export { a as StaffPickCard } from './chunk-RTRHNOTP.js';
10
14
  export { a as FeaturePageGroup } from './chunk-JHGOFDVG.js';
11
15
  import './chunk-4E6CDLVE.js';
12
16
  export { a as Navbar } from './chunk-XXP5K6Y4.js';
13
- export { a as NBUI_Card } from './chunk-X6RBGNFS.js';
14
- export { a as NBUI_Container } from './chunk-7Q6OMA2A.js';
15
17
  export { a as TextRow } from './chunk-5GLAT3VP.js';
16
18
  export { a as TextArea } from './chunk-QCHLLBHM.js';
17
19
  export { a as VideoDashboardNotification } from './chunk-LIXVY47P.js';
18
20
  export { a as VideoModal } from './chunk-G2WGEIWK.js';
19
- export { a as FeatureCard } from './chunk-7WJGATIR.js';
20
- export { a as StaffPickCard } from './chunk-RTRHNOTP.js';
21
+ import './chunk-3NO5IHBO.js';
21
22
  export { a as PageHeader } from './chunk-SFEJDNIA.js';
22
23
  export { a as ProgressBar } from './chunk-E5KIDP3Z.js';
23
24
  export { a as Radio } from './chunk-TBJGGVSZ.js';
@@ -1,23 +1,24 @@
1
- export { b as Layout } from '../chunk-44UX4FUN.js';
1
+ export { b as Layout } from '../chunk-46XKR7EO.js';
2
+ import '../chunk-ZHMUFBQM.js';
3
+ import '../chunk-YZ2YZSNQ.js';
4
+ import '../chunk-E62SCYLR.js';
5
+ import '../chunk-X6RBGNFS.js';
6
+ import '../chunk-7Q6OMA2A.js';
2
7
  import '../chunk-RHBXFO7R.js';
3
8
  import '../chunk-5VOOMPCL.js';
4
9
  import '../chunk-N7JQ6EAC.js';
5
10
  import '../chunk-HVNLAQA6.js';
6
11
  import '../chunk-52VBZOHL.js';
7
- import '../chunk-ZHMUFBQM.js';
8
- import '../chunk-E62SCYLR.js';
9
- import '../chunk-YZ2YZSNQ.js';
12
+ import '../chunk-7WJGATIR.js';
13
+ import '../chunk-RTRHNOTP.js';
10
14
  import '../chunk-JHGOFDVG.js';
11
15
  import '../chunk-4E6CDLVE.js';
12
16
  import '../chunk-XXP5K6Y4.js';
13
- import '../chunk-X6RBGNFS.js';
14
- import '../chunk-7Q6OMA2A.js';
15
17
  import '../chunk-5GLAT3VP.js';
16
18
  import '../chunk-QCHLLBHM.js';
17
19
  import '../chunk-LIXVY47P.js';
18
20
  import '../chunk-G2WGEIWK.js';
19
- import '../chunk-7WJGATIR.js';
20
- import '../chunk-RTRHNOTP.js';
21
+ import '../chunk-3NO5IHBO.js';
21
22
  import '../chunk-SFEJDNIA.js';
22
23
  import '../chunk-E5KIDP3Z.js';
23
24
  import '../chunk-TBJGGVSZ.js';
@@ -1,23 +1,24 @@
1
- export { f as ProductPicker } from '../chunk-44UX4FUN.js';
1
+ export { f as ProductPicker } from '../chunk-46XKR7EO.js';
2
+ import '../chunk-ZHMUFBQM.js';
3
+ import '../chunk-YZ2YZSNQ.js';
4
+ import '../chunk-E62SCYLR.js';
5
+ import '../chunk-X6RBGNFS.js';
6
+ import '../chunk-7Q6OMA2A.js';
2
7
  import '../chunk-RHBXFO7R.js';
3
8
  import '../chunk-5VOOMPCL.js';
4
9
  import '../chunk-N7JQ6EAC.js';
5
10
  import '../chunk-HVNLAQA6.js';
6
11
  import '../chunk-52VBZOHL.js';
7
- import '../chunk-ZHMUFBQM.js';
8
- import '../chunk-E62SCYLR.js';
9
- import '../chunk-YZ2YZSNQ.js';
12
+ import '../chunk-7WJGATIR.js';
13
+ import '../chunk-RTRHNOTP.js';
10
14
  import '../chunk-JHGOFDVG.js';
11
15
  import '../chunk-4E6CDLVE.js';
12
16
  import '../chunk-XXP5K6Y4.js';
13
- import '../chunk-X6RBGNFS.js';
14
- import '../chunk-7Q6OMA2A.js';
15
17
  import '../chunk-5GLAT3VP.js';
16
18
  import '../chunk-QCHLLBHM.js';
17
19
  import '../chunk-LIXVY47P.js';
18
20
  import '../chunk-G2WGEIWK.js';
19
- import '../chunk-7WJGATIR.js';
20
- import '../chunk-RTRHNOTP.js';
21
+ import '../chunk-3NO5IHBO.js';
21
22
  import '../chunk-SFEJDNIA.js';
22
23
  import '../chunk-E5KIDP3Z.js';
23
24
  import '../chunk-TBJGGVSZ.js';
@@ -1,23 +1,24 @@
1
- export { a as StackedListItem } from './chunk-44UX4FUN.js';
1
+ export { a as StackedListItem } from './chunk-46XKR7EO.js';
2
+ import './chunk-ZHMUFBQM.js';
3
+ import './chunk-YZ2YZSNQ.js';
4
+ import './chunk-E62SCYLR.js';
5
+ import './chunk-X6RBGNFS.js';
6
+ import './chunk-7Q6OMA2A.js';
2
7
  import './chunk-RHBXFO7R.js';
3
8
  import './chunk-5VOOMPCL.js';
4
9
  import './chunk-N7JQ6EAC.js';
5
10
  import './chunk-HVNLAQA6.js';
6
11
  import './chunk-52VBZOHL.js';
7
- import './chunk-ZHMUFBQM.js';
8
- import './chunk-E62SCYLR.js';
9
- import './chunk-YZ2YZSNQ.js';
12
+ import './chunk-7WJGATIR.js';
13
+ import './chunk-RTRHNOTP.js';
10
14
  import './chunk-JHGOFDVG.js';
11
15
  import './chunk-4E6CDLVE.js';
12
16
  import './chunk-XXP5K6Y4.js';
13
- import './chunk-X6RBGNFS.js';
14
- import './chunk-7Q6OMA2A.js';
15
17
  import './chunk-5GLAT3VP.js';
16
18
  import './chunk-QCHLLBHM.js';
17
19
  import './chunk-LIXVY47P.js';
18
20
  import './chunk-G2WGEIWK.js';
19
- import './chunk-7WJGATIR.js';
20
- import './chunk-RTRHNOTP.js';
21
+ import './chunk-3NO5IHBO.js';
21
22
  import './chunk-SFEJDNIA.js';
22
23
  import './chunk-E5KIDP3Z.js';
23
24
  import './chunk-TBJGGVSZ.js';
@@ -1,23 +1,24 @@
1
- export { e as TableResultBlock } from './chunk-44UX4FUN.js';
1
+ export { e as TableResultBlock } from './chunk-46XKR7EO.js';
2
+ import './chunk-ZHMUFBQM.js';
3
+ import './chunk-YZ2YZSNQ.js';
4
+ import './chunk-E62SCYLR.js';
5
+ import './chunk-X6RBGNFS.js';
6
+ import './chunk-7Q6OMA2A.js';
2
7
  import './chunk-RHBXFO7R.js';
3
8
  import './chunk-5VOOMPCL.js';
4
9
  import './chunk-N7JQ6EAC.js';
5
10
  import './chunk-HVNLAQA6.js';
6
11
  import './chunk-52VBZOHL.js';
7
- import './chunk-ZHMUFBQM.js';
8
- import './chunk-E62SCYLR.js';
9
- import './chunk-YZ2YZSNQ.js';
12
+ import './chunk-7WJGATIR.js';
13
+ import './chunk-RTRHNOTP.js';
10
14
  import './chunk-JHGOFDVG.js';
11
15
  import './chunk-4E6CDLVE.js';
12
16
  import './chunk-XXP5K6Y4.js';
13
- import './chunk-X6RBGNFS.js';
14
- import './chunk-7Q6OMA2A.js';
15
17
  import './chunk-5GLAT3VP.js';
16
18
  import './chunk-QCHLLBHM.js';
17
19
  import './chunk-LIXVY47P.js';
18
20
  import './chunk-G2WGEIWK.js';
19
- import './chunk-7WJGATIR.js';
20
- import './chunk-RTRHNOTP.js';
21
+ import './chunk-3NO5IHBO.js';
21
22
  import './chunk-SFEJDNIA.js';
22
23
  import './chunk-E5KIDP3Z.js';
23
24
  import './chunk-TBJGGVSZ.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ekm-ui",
3
- "version": "0.3.91",
3
+ "version": "0.3.93",
4
4
  "sideEffects": [
5
5
  "**/*.css"
6
6
  ],
@@ -0,0 +1,77 @@
1
+ // @ts-nocheck
2
+ import PropTypes from "prop-types";
3
+ import { Checkbox } from "../checkbox";
4
+
5
+ export function CountryListing({countryData, selectedCountries, countrySelectCallback}) {
6
+
7
+ return (
8
+ <div
9
+ id="country-list"
10
+ className={`h-[500px] overflow-y-auto rounded-md border`}
11
+ >
12
+ {(countryData || []).map((c) => {
13
+ const countrySelected = selectedCountries.some(s => s.CountryCode === c.CountryCode)
14
+ return (
15
+ <CountryRow
16
+ key={`country-row-${c.ID}`}
17
+ country={c}
18
+ selected={countrySelected}
19
+ callback={countrySelectCallback}
20
+ />
21
+ );
22
+ })}
23
+ </div>
24
+ );
25
+ }
26
+
27
+ const CountryRow = ({country, selected, callback}) => {
28
+
29
+ const handleCountrySelection = () => {
30
+ callback({Id: country.ID, Country: country.Country, CountryCode: country.CountryCode}, selected)
31
+ }
32
+
33
+ return (
34
+ <div
35
+ className={`flex items-center pt-4 pb-4 mt-1 mb-1 ${selected && 'bg-blue-50'} justify-between border-b border-gray-100 cursor-pointer`}
36
+ onClick={handleCountrySelection}
37
+ >
38
+ <div className="flex items-center ml-3">
39
+ <div className="flex-shrink-0">
40
+ <Checkbox id={`cb-country-${country.ID}`} checked={selected} onChange={() => {}} />
41
+ </div>
42
+ <div className="ml-4">
43
+ <img
44
+ src={`https://shared.ekmcdn.com/images/uifw/flags/4x3/${country.CountryCode.toLowerCase()}.svg`}
45
+ alt={country.CountryName}
46
+ onError={(e) => {
47
+ e.target.onerror = null
48
+ e.target.src = 'https://shared.ekmcdn.com/images/uifw/flags/4x3/unknown.svg'
49
+ }}
50
+ className="h-9 w-12 rounded-sm"
51
+ />
52
+ </div>
53
+ <div className="ml-4">
54
+ <div className="font-medium text-gray-900">{country.Country}</div>
55
+ </div>
56
+ </div>
57
+ </div>
58
+ )
59
+ }
60
+
61
+ CountryListing.propTypes = {
62
+ /** Array of countries to list in the form { Id: 383, CountryCode 'CN': Country: 'China'} */
63
+ countryData: PropTypes.array.isRequired,
64
+ /** Array of selected countries in the form { Id: 383, CountryCode 'CN': Country: 'China'} */
65
+ selectedCountries: PropTypes.array.isRequired,
66
+ /** Callback to handle selection of a country */
67
+ countrySelectCallback: PropTypes.func.isRequired,
68
+ }
69
+
70
+ CountryRow.propTypes = {
71
+ /** Details of country */
72
+ country: PropTypes.object.isRequired,
73
+ /** Whether country is selected */
74
+ selected: PropTypes.bool.isRequired,
75
+ /** Callback to handle selection of the country */
76
+ callback: PropTypes.func.isRequired,
77
+ }
@@ -0,0 +1,236 @@
1
+ // @ts-nocheck
2
+ import pluralize from "pluralize";
3
+ import PropTypes from "prop-types";
4
+ import {
5
+ useEffect,
6
+ useReducer,
7
+ useRef,
8
+ useState,
9
+ } from "react";
10
+ import { HiClipboardList } from "react-icons/hi";
11
+ import { Button } from "../button";
12
+ import { Search } from "../search/search";
13
+ import { TableResultBlock } from "../table-result-block";
14
+ import { Modal } from "../modal";
15
+ import { CountryListing } from "./country-listing";
16
+
17
+ const Status = Object.freeze({
18
+ EMPTY: "EMPTY",
19
+ LOADING: "LOADING",
20
+ LOADED: "LOADED",
21
+ SEARCH_RESULTS: "SEARCH-RESULTS",
22
+ SEARCH_EMPTY: "SEARCH-EMPTY",
23
+ });
24
+
25
+ const initialState = Object.freeze({
26
+ mode: Status.LOADING,
27
+ searchDisabled: false,
28
+ });
29
+
30
+ function CountryPickerReducer(state, action) {
31
+ switch (action.type) {
32
+ case Status.EMPTY:
33
+ return {
34
+ mode: Status.EMPTY,
35
+ searchDisabled: true,
36
+ };
37
+ case Status.LOADING:
38
+ return initialState;
39
+ case Status.LOADED:
40
+ return {
41
+ mode: Status.LOADED,
42
+ searchDisabled: false,
43
+ };
44
+ case Status.SEARCH_RESULTS:
45
+ return {
46
+ mode: Status.SEARCH_RESULTS,
47
+ searchDisabled: false,
48
+ };
49
+ case Status.SEARCH_EMPTY:
50
+ return {
51
+ mode: Status.SEARCH_EMPTY,
52
+ searchDisabled: false,
53
+ };
54
+ default:
55
+ throw new Error("Unknown file picker state: " + action.page ?? "");
56
+ }
57
+ }
58
+
59
+ export function CountryPicker({initialLoadComplete, allCountryData, preSelected = [],
60
+ onClose, callback}) {
61
+ const [state, dispatch] = useReducer(CountryPickerReducer, initialState);
62
+ const [search, setSearch] = useState("");
63
+ const [displayedCountries, setDisplayedCountries] = useState([]);
64
+ // Selected State
65
+ const [selectedCountries, setSelectedCountries] = useState([])
66
+ const allCountriesRef = useRef([])
67
+
68
+ useEffect(() => {
69
+ if (allCountryData?.length > 0 || initialLoadComplete) {
70
+ allCountriesRef.current = allCountryData
71
+ performSearch('')
72
+ }
73
+ }, [allCountryData])
74
+
75
+ useEffect(() => {
76
+ setSelectedCountries(preSelected)
77
+ }, [preSelected])
78
+
79
+ const handleSearchRequest = (searchTerm) => {
80
+ const newSearchText = searchTerm.text ?? "";
81
+ const oldSearchText = search ?? "";
82
+ if (newSearchText != oldSearchText) {
83
+ dispatch({ type: Status.LOADING });
84
+ performSearch(newSearchText)
85
+ }
86
+ setSearch(newSearchText);
87
+ };
88
+
89
+ const performSearch = (searchText) => {
90
+ const newCountries = searchText ? allCountriesRef.current.filter(c => c.Country.toLowerCase().includes(searchText.toLowerCase())) :
91
+ allCountriesRef.current
92
+ if (newCountries?.length > 0) {
93
+ setDisplayedCountries(newCountries)
94
+ dispatch({type: searchText?.length > 0 ? Status.SEARCH_RESULTS : Status.LOADED})
95
+ } else {
96
+ setDisplayedCountries([])
97
+ dispatch({type: searchText?.length > 0 ? Status.SEARCH_EMPTY : Status.EMPTY})
98
+ }
99
+
100
+ }
101
+
102
+ const handleAddLocations = () => {
103
+ callback(selectedCountries);
104
+ };
105
+
106
+ const handleCountrySelection = (details, selected) => {
107
+ const newCountries = selected ? selectedCountries.filter( c => c.CountryCode != details.CountryCode) :
108
+ [...selectedCountries, details]
109
+ setSelectedCountries(newCountries)
110
+ }
111
+
112
+ const renderList = () => {
113
+ switch (state.mode) {
114
+ case Status.EMPTY:
115
+ return (
116
+ <NoResultsView
117
+ title="No Countries"
118
+ msg="Available countries will appear here"
119
+ />
120
+ );
121
+ case Status.LOADING:
122
+ return (
123
+ <NoResultsView
124
+ title="Loading Countries"
125
+ msg="Don't worry, this won't take long..."
126
+ showSpinner={true}
127
+ />
128
+ );
129
+ case Status.SEARCH_RESULTS:
130
+ case Status.LOADED:
131
+ return (
132
+ <CountryListing
133
+ countryData={displayedCountries}
134
+ selectedCountries={selectedCountries}
135
+ countrySelectCallback={handleCountrySelection}
136
+ />
137
+ );
138
+ case Status.SEARCH_EMPTY:
139
+ return (
140
+ <NoResultsView
141
+ title="No Countries Found"
142
+ msg="No countries were found matching your search"
143
+ blockHeight="h-[460px]"
144
+ />
145
+ );
146
+
147
+ default:
148
+ break;
149
+ }
150
+ };
151
+
152
+ const renderContent = () => (
153
+ <>
154
+ {selectedCountries?.length > 0 && (
155
+ <div className="mb-4 rounded-md border border-orange-200 bg-yellow-50 p-4">
156
+ <p className="text-center text-sm text-yellow-800">
157
+ {`${pluralize("country", selectedCountries?.length, true)} selected.`}
158
+ <span
159
+ onClick={() => setSelectedCountries([])}
160
+ className="cursor-pointer text-primary-600 hover:underline"
161
+ >{` Clear Selection.`}</span>
162
+ </p>
163
+ </div>
164
+ )}
165
+ <Search
166
+ id="locationSearch"
167
+ placeholder="Search for countries"
168
+ disabled={state.searchDisabled}
169
+ callback={handleSearchRequest}
170
+ />
171
+ <div className="mb-4 mt-4">
172
+ {(state.mode === Status.SEARCH_RESULTS ||
173
+ state.mode === Status.SEARCH_EMPTY) &&
174
+ search.length > 0 && (
175
+ <span className="ms-1 text-sm font-medium text-gray-500 dark:text-gray-400 md:ms-2">{`Showing results for..."${search}"`}</span>
176
+ )}
177
+ </div>
178
+ {renderList()}
179
+ </>
180
+ );
181
+
182
+ return (
183
+ <Modal
184
+ show={true}
185
+ onClose={onClose}
186
+ title="Choose Locations"
187
+ size="md"
188
+ >
189
+ <Modal.Body>
190
+ <div className="h-full">{renderContent()}</div>
191
+ </Modal.Body>
192
+ <Modal.Footer>
193
+ <div className={`flex-grow grid grid-col-2 grid-flow-col gap-4`}>
194
+ <Button color="light" onClick={onClose}>
195
+ Close
196
+ </Button>
197
+ <Button
198
+ color="success"
199
+ onClick={handleAddLocations}
200
+ disabled={selectedCountries?.length === 0}
201
+ >
202
+ Add Locations
203
+ </Button>
204
+ </div>
205
+ </Modal.Footer>
206
+ </Modal>
207
+ );
208
+
209
+ }
210
+
211
+ const NoResultsView =({title, msg, blockHeight="h-[500px]", showSpinner = false}) => {
212
+ return (
213
+ <div className={`${blockHeight} flex items-center justify-center`}>
214
+ <TableResultBlock
215
+ icon={!showSpinner && <HiClipboardList className="mb-4 h-16 w-16 text-gray-500 dark:text-gray-400" />}
216
+ title={title}
217
+ message={msg}
218
+ spinner={showSpinner}
219
+ />
220
+ </div>
221
+ )
222
+ }
223
+
224
+ CountryPicker.propTypes = {
225
+ /** Boolean to indicate that the load of the country data this is passed to this component has been completed */
226
+ initialLoadComplete: PropTypes.bool.isRequired,
227
+ /** Array of all the country data in the form { Id: 383, CountryCode 'CN': Country: 'China'} */
228
+ allCountryData: PropTypes.array.isRequired,
229
+ /** Array of preselected countries in the form { Id: 383, CountryCode 'CN': Country: 'China'} */
230
+ preSelected: PropTypes.array.isRequired,
231
+ /** Callback to close the modal */
232
+ onClose: PropTypes.func.isRequired,
233
+ /** Callback which returns an array of the selected products in the form { Id: 383, CountryCode 'CN': Country: 'China'} */
234
+ callback: PropTypes.func.isRequired,
235
+
236
+ }
package/src/index.tsx CHANGED
@@ -58,5 +58,6 @@ export { ProductPicker } from "./product-picker/product-modal";
58
58
  export { TestComponent } from "./test-component";
59
59
  export { NBUI_Container } from "./nbui/nbui-container";
60
60
  export { NBUI_Card } from "./nbui/nbui-card";
61
+ export { CountryPicker} from "./country-picker/country-modal";
61
62
 
62
63
  import "./styles.css";
@@ -1,35 +0,0 @@
1
- import { a as a$h } from './chunk-5VOOMPCL.js';
2
- import { a as a$e } from './chunk-N7JQ6EAC.js';
3
- import { a as a$8, b } from './chunk-HVNLAQA6.js';
4
- import { a as a$i } from './chunk-4E6CDLVE.js';
5
- import { a as a$9 } from './chunk-XXP5K6Y4.js';
6
- import { a as a$4 } from './chunk-TBJGGVSZ.js';
7
- import { a as a$d } from './chunk-QKHEEDZ4.js';
8
- import { a as a$7 } from './chunk-HTXOCBXA.js';
9
- import { a as a$a } from './chunk-LTMZ5RRZ.js';
10
- import { a as a$1 } from './chunk-VGGEDWFD.js';
11
- import { a as a$c } from './chunk-AVTJXS4U.js';
12
- import { a as a$b } from './chunk-F7AUKLLE.js';
13
- import { a as a$3 } from './chunk-WSRPB5OU.js';
14
- import { a as a$6 } from './chunk-E4USZ2Q3.js';
15
- import { a as a$5 } from './chunk-F47A36U7.js';
16
- import { a as a$g } from './chunk-ELWZ674J.js';
17
- import { a as a$f } from './chunk-2OPJLYW6.js';
18
- import { a as a$2 } from './chunk-BLUJNMXF.js';
19
- import { a } from './chunk-6LHL364H.js';
20
- import { e, f as f$1 } from './chunk-Z4LPO673.js';
21
- import { Badge, Sidebar } from 'flowbite-react';
22
- import { HiCreditCard, HiClipboardList, HiOutlineSearch } from 'react-icons/hi';
23
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
24
- import { forwardRef, useRef, useReducer, useState, useEffect, useImperativeHandle, useMemo } from 'react';
25
- import { HiChartPie, HiTag, HiShoppingBag, HiPaintBrush, HiStar, HiDocument, HiRocketLaunch, HiGlobeAlt } from 'react-icons/hi2';
26
- import { BiSearch } from 'react-icons/bi';
27
- import { BsCloudUpload, BsFillCheckCircleFill, BsFillImageFill } from 'react-icons/bs';
28
- import { FaTimesCircle } from 'react-icons/fa';
29
- import Br from 'pluralize';
30
-
31
- function ze({cardPayment:e,enablePayPal:t}){return jsxs(a$3,{className:"border-0 shadow-sm ",children:[jsx("h3",{className:"text-xl font-semibold dark:text-white",children:"Billing Details"}),jsx("div",{className:"flex items-center justify-between pb-4",children:jsxs("fieldset",{className:"flex w-full flex-col gap-4",id:"radio",children:[jsxs("div",{className:"flex flex-col gap-2",children:[jsxs("div",{className:"flex items-center gap-2",children:[t&&jsx(a$4,{id:"creditDebitCard",name:"paymentType",value:"creditDebitCard"}),jsx(a$5,{htmlFor:"creditDebitCard",children:"Pay by Credit or Debit card"})]}),jsxs("div",{className:t?"ml-6 flex gap-2":"flex gap-2",children:[jsx("img",{src:"https://shared.ekmcdn.com/images/uifw/cards/visa.png",alt:"VISA Card Logo"}),jsx("img",{src:"https://shared.ekmcdn.com/images/uifw/cards/mastercard.png",alt:"MasterCard Card Logo"}),jsx("img",{src:"https://shared.ekmcdn.com/images/uifw/cards/maestro.png",alt:"Maestro Card Logo"}),jsx("img",{src:"https://shared.ekmcdn.com/images/uifw/cards/amex.png",alt:"AMEX Card Logo"})]})]}),e&&jsxs(Fragment,{children:[jsxs("div",{className:"grid grid-cols-1 content-start gap-6 md:grid-cols-2",children:[jsx(a$6,{label:"Name on Card *",htmlFor:"nameOnCard",helperText:"This is your name as is appears on the front of your credit or debit card.",children:jsx(a$7,{id:"nameOnCard",name:"nameOnCard",placeholder:"Your name",type:"text",required:!0})}),jsx(a$6,{label:"Card Number *",htmlFor:"cardNumber",helperText:"This is the long number on the front of your credit or debit card.",children:jsx(a$7,{id:"nameOnCard",name:"nameOnCard",placeholder:"0000 0000 0000 0000",type:"number",rightIcon:HiCreditCard,required:!0})})]}),jsxs("div",{className:"grid grid-cols-1 content-start gap-6 sm:grid-cols-3 md:grid-cols-4",children:[jsx(a$6,{label:"Expiry Date *",htmlFor:"nameOnCard",helperText:"The expiry date as it appears on your card.",children:jsx(a$7,{id:"nameOnCard",name:"nameOnCard",placeholder:"MM / YY",type:"text",required:!0})}),jsx(a$6,{label:"Security Code (CVC) *",htmlFor:"cardNumber",helperText:"The last three digits on the back of your card\u2019s signature strip.",children:jsx(a$7,{id:"nameOnCard",name:"nameOnCard",placeholder:"123",type:"text",rightIcon:HiCreditCard,required:!0})}),jsx("img",{className:"mt-7 hidden h-auto w-16 sm:block",src:"https://shared.ekmcdn.com/images/rise/cvc-reminder-image.png",alt:""})]})]}),t&&jsxs("div",{className:"flex flex-col gap-2",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(a$4,{id:"PayPal",name:"paymentType",value:"PayPal"}),jsx(a$5,{htmlFor:"PayPal",children:"PayPal"})]}),jsx("div",{className:"ml-6",children:jsx("img",{src:"https://shared.ekmcdn.com/images/uifw/cards/paypal.png",alt:"PayPal Icon"})})]})]})})]})}ze.displayName="CardPaymentBlock";function je(){return jsxs(Sidebar.Items,{children:[jsxs(Sidebar.ItemGroup,{children:[jsx(Sidebar.Item,{href:"/",icon:HiChartPie,className:"bg-gray-100 dark:bg-gray-700",children:"Dashboard"}),jsx(Sidebar.Item,{href:"/products",icon:HiTag,className:"",children:"Products"}),jsx(Sidebar.Item,{href:"/orders",icon:HiShoppingBag,label:"27",className:"",children:"Orders"}),jsxs(Sidebar.Collapse,{icon:HiPaintBrush,label:"Design",children:[jsx(Sidebar.Item,{href:"/design/design",className:"",children:"Theme"}),jsx(Sidebar.Item,{href:"/design/editor",className:"",children:"Editor"}),jsx(Sidebar.Item,{href:"/theme/webpages",className:"",children:"Webpages"})]}),jsx(Sidebar.Item,{href:"/features",icon:HiStar,className:"",children:"Features"})]}),jsxs(Sidebar.ItemGroup,{children:[jsx(Sidebar.Item,{href:"https://github.com/themesberg/flowbite-react/",icon:HiDocument,children:"Docs"}),jsx(Sidebar.Item,{href:"https://flowbite-react.com/",icon:HiRocketLaunch,children:"What's New"}),jsx(Sidebar.Item,{href:"https://github.com/themesberg/flowbite-react/issues",icon:HiGlobeAlt,children:"Support Centre"})]})]})}function mr({children:e,hasHeader:t}){let[o,i]=useState(!1),[y,D]=useState(!1);return useMemo(()=>{a$8()&&!o&&D(!0);},[o]),jsxs(Fragment,{children:[jsx(a$9,{onMenuButtonClick:()=>{i(!o);},showCloseButton:y,avatarImg:"https://avatars.githubusercontent.com/u/49406022?v=4"}),jsxs("div",{className:"flex",children:[jsx(b,{collapsed:o,children:jsx(je,{})}),jsxs("div",{className:"flex w-3/4 flex-grow flex-col",children:[jsx("main",{className:`"relative dark:bg-gray-900" flex h-full flex-grow flex-col gap-4 overflow-y-auto bg-gray-50 ${t?"":"p-4"}`,children:e}),jsx(a$a,{companyName:"EKM"})]})]})]})}var H=e(a(),1);var f=Object.freeze({NONE:"none",OVER:"drag-over",UPLOADING:"uploading",ERROR:"error",SUCCESS:"success"}),yr=Object.freeze({[f.NONE]:"border-gray-300 bg-gray-50 dark:hover:bg-gray-800 dark:bg-gray-700 hover:bg-gray-100 dark:border-gray-600 dark:hover:border-gray-500 dark:hover:bg-gray-600",[f.OVER]:"border-blue-300 bg-gray-50 dark:hover:bg-gray-800 dark:bg-gray-700 hover:bg-gray-100 dark:border-blue-600 dark:hover:border-blue-500 dark:hover:bg-blue-600",[f.UPLOADING]:"border-blue-300 bg-gray-50 dark:hover:bg-gray-800 dark:bg-gray-700 hover:bg-gray-100 dark:border-blue-600 dark:hover:border-blue-500 dark:hover:bg-blue-600",[f.ERROR]:"border-red-300 bg-gray-50 dark:hover:bg-gray-800 dark:bg-gray-700 hover:bg-gray-100 dark:border-red-600 dark:hover:border-red-500 dark:hover:bg-red-600",[f.SUCCESS]:"border-green-300 bg-gray-50 dark:hover:bg-gray-800 dark:bg-gray-700 hover:bg-gray-100 dark:border-green-600 dark:hover:border-green-500 dark:hover:bg-green-600"}),Sr=["png","webp","jpg","gif","jpeg"];function $e(e,t){let o=!t||t.length===0?Sr:t;if(!e||e.length===0)return !1;let i=e.split(".").pop().toLowerCase();return o.includes(i)}function Q({subtitle:e="PNG, WEBP, JPG, JPEG or GIF",filetypes:t,uploaded:o,exitCallback:i,callback:y,errorCallback:D,pickerCallback:R}){let[n,m]=useState(f.NONE);useEffect(()=>{Object.values(f).includes(o)&&(m(o),setTimeout(()=>{o===f.ERROR&&D?D():m(f.NONE);},2e3));},[o]);let A=c=>{c.preventDefault(),m(f.OVER);},j=c=>{c.preventDefault(),i&&i(),m(f.NONE);},v=c=>{c.preventDefault(),$e(c.dataTransfer.files[0].name,t)?(m(f.UPLOADING),y(c.dataTransfer.files[0])):(m(f.ERROR),setTimeout(()=>{D();},2e3));},S=c=>{$e(c.target.files[0].name,t)?m(f.UPLOADING):m(f.ERROR),y(c.target.files[0]);},C=()=>{R&&R();},T=()=>jsxs("div",{className:"flex flex-col items-center justify-center pb-6 pt-5",children:[jsx(BsCloudUpload,{className:"h-12 w-12 text-gray-400 dark:text-gray-500"}),jsxs("p",{className:"mb-2 mt-5 text-sm text-gray-500 dark:text-gray-400",children:[jsx("span",{className:"font-semibold",children:"Click to upload"})," or drag and drop"]}),jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:e}),R&&jsx("div",{className:"mt-5",children:jsxs(a$2,{color:"default",onClick:C,children:[jsx(BiSearch,{className:"mr-2"}),"Browse File Manager"]})})]}),h=()=>jsx("div",{className:"flex flex-col items-center justify-center pb-6 pt-5",children:jsx("p",{className:"mb-2 mt-5 text-sm text-blue-500 dark:text-blue-400",children:jsx("span",{className:"font-semibold",children:"Drop here to upload"})})}),x=()=>jsxs("div",{className:"flex flex-col items-center justify-center pb-6 pt-5",children:[jsxs("svg",{"aria-hidden":"true",className:"mr-2 inline h-10 w-10 animate-spin text-gray-200 dark:text-gray-600",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]}),jsx("p",{className:"mb-2 mt-5 text-sm text-blue-500 dark:text-blue-400",children:jsx("span",{className:"font-semibold",children:"Uploading..."})})]}),M=()=>jsxs("div",{className:"flex flex-col items-center justify-center pb-6 pt-5",children:[jsx(FaTimesCircle,{className:"h-12 w-12 text-red-400 dark:text-red-500"}),jsx("p",{className:"mb-2 mt-5 text-sm text-red-500 dark:text-red-400",children:jsx("span",{className:"font-semibold",children:"Unable to upload"})})]}),_=()=>jsxs("div",{className:"flex flex-col items-center justify-center pb-6 pt-5",children:[jsx(BsFillCheckCircleFill,{className:"h-12 w-12 text-green-400 dark:text-green-500"}),jsx("p",{className:"mb-2 mt-5 text-sm text-green-500 dark:text-green-400",children:jsx("span",{className:"font-semibold",children:"Uploaded"})})]}),l=()=>{switch(n){case f.OVER:return h();case f.UPLOADING:return x();case f.ERROR:return M();case f.SUCCESS:return _();default:return T()}};return jsx("div",{onDragEnter:c=>c.preventDefault(),onDragOver:A,onDrop:v,onDragLeave:j,className:"flex h-full w-full items-center justify-center",children:jsxs("label",{htmlFor:"dropzone-file",className:`flex h-full w-full cursor-pointer flex-col items-center justify-center rounded-lg border-2 border-dashed ${yr[n]}`,children:[l(),n===f.NONE&&jsx("input",{id:"dropzone-file",type:"file",className:"hidden",onChange:S})]})})}Q.propTypes={filetypes:H.default.arrayOf(H.default.string),subtitle:H.default.string,uploaded:H.default.oneOf(["none","success","error"]).isRequired,exitCallback:H.default.func,errorCallback:H.default.func.isRequired,callback:H.default.func.isRequired,pickerCallback:H.default.func};Q.displayName="DragAndDrop";var q=e(a(),1);var Ve="/admin/api/common/directoryinformation/",r=Object.freeze({EMPTY:"EMPTY",SEARCH_LOADING:"SEARCH-LOADING",LOADING:"LOADING",LOADED:"LOADED",LOADED_NO_DRAG:"LOADED_NO_DRAG",SEARCH_RESULTS:"SEARCH-RESULTS",SEARCH_EMPTY:"SEARCH-EMPTY",UPLOAD_ERROR:"ERROR",DRAGGING:"DRAGGING"}),vr=Object.freeze({mode:r.LOADING,actionBtnTxt:"I Accept",actionBtnColor:"success",listSize:"h-5/6",listBorder:"",searchDisabled:!1});function Dr(e,t){switch(t.type){case r.EMPTY:return {mode:r.EMPTY,actionBtnTxt:"Add Image",actionBtnColor:"default",listSize:"h-5/6",listBorder:"",searchDisabled:!0};case r.LOADING:return vr;case r.LOADED:return {mode:r.LOADED,actionBtnTxt:"I Accept",actionBtnColor:"success",listSize:"h-[68.666667%]",listBorder:"border",searchDisabled:!1};case r.LOADED_NO_DRAG:return {mode:r.LOADED_NO_DRAG,actionBtnTxt:"I Accept",actionBtnColor:"success",listSize:"h-[87.666667%]",listBorder:"border",searchDisabled:!1};case r.SEARCH_RESULTS:return {mode:r.SEARCH_RESULTS,actionBtnTxt:"I Accept",actionBtnColor:"success",listSize:"h-5/6",listBorder:"border",searchDisabled:!1};case r.SEARCH_EMPTY:return {mode:r.SEARCH_EMPTY,actionBtnTxt:"I Accept",actionBtnColor:"success",listSize:"h-5/6",listBorder:"",searchDisabled:!1};default:throw new Error("Unknown file picker state: "+t.page)}}function Ie({appUrl:e,uri:t,show:o,hideDrag:i=!1,onClose:y,callback:D}){let R=useRef(),[n,m]=useReducer(Dr,{mode:r.LOADING,footerBorder:"border-t"}),[A,j]=useState(0),v=useRef(1),[S,C]=useState(!1),[T,h]=useState(!1),x=useRef({pages:0,totalEntries:0}),[M,_]=useState(!1),[l,c]=useState(null),[k,G]=useState(null),[ye,V]=useState([]),[te,O]=useState("none");useEffect(()=>{o&&(m({type:r.LOADING}),G(null),x.current={pages:0,totalEntries:0},ce(),s(1));},[o]),useEffect(()=>{o&&(v.current=1,s(),h(!1));},[l]),useEffect(()=>{k&&G(null),T&&h(!1);},[n.mode]);let ce=()=>{V([]),O("none"),_(!1),G(null),h(!1);},s=(b=0)=>f$1(this,null,function*(){try{let I=b===0?v.current:b,W=(l==null?void 0:l.length)>0?`&FileNameIncludesString=${l}`:"&FileNameIncludesString=",B=yield (yield fetch(`${e}${Ve}?CurrentPage=${I}&PageSize=10&Uri=${t}${W}`,{method:"GET",credentials:"same-origin",headers:{"Content-Type":"application/json"}})).json();if((l==null?void 0:l.length)>0&&m({type:r.SEARCH_RESULTS}),B.Items.Data.length>0&&I>1?V(Ce=>[...Ce,...B.Items.Data]):V(B.Items.Data),x.current={pages:B.Items.NumberOfPages,totalEntries:B.Items.Total},j(B.Items.NumberOfPages),(l==null?void 0:l.length)>0)m({type:B.Items.Data.length>0?r.SEARCH_RESULTS:r.SEARCH_EMPTY});else {let Ce=i?r.LOADED_NO_DRAG:r.LOADED;m({type:B.Items.Data.length>0?Ce:r.EMPTY});}O("none"),_(!1),C(!1);}catch(I){m({type:(l==null?void 0:l.length)===0?r.SEARCH_EMPTY:r.EMPTY});}}),N=b=>{i||(C(!0),R.current.removeFocus(),b.preventDefault());},Z=b=>{i||C(!1);},U=b=>{var ae;let I=(ae=b.text)!=null?ae:"",W=l!=null?l:"";c(b.text),(W.length>0&&I.length===0||W.length===0&&I.length>0&&n.mode!==r.LOADING)&&m({type:r.LOADING});},J=()=>{h(!0),C(!1),O("none");},Xe=()=>{D(`https://files.ekmcdn.com/${k.Uri}`),Se();},Se=()=>{ce(),y();},Me=b=>f$1(this,null,function*(){if(b==null){O("error"),J();return}try{let I=Or(b.name),W=yield Tr(b),ae={Path:`/${t}/`,Name:I,Bytes:Lr(W),ForceOverwriteFile:!0};(yield fetch(`${e}${Ve}`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify(ae)})).status===200?(O("success"),c(null),R.current.clear(),V([]),h(!1),s(1)):O("error");}catch(I){O("error");}}),Ke=b=>{switch(b.type){case"FETCH_DATA":_(b.payload),v.current<x.current.pages&&!M&&(_(!0),v.current=v.current+1,s());break;case"SELECTION":G(b.payload),h(!1);break;}},Qe=()=>{switch(n.mode){case r.EMPTY:return jsx(Rr,{});case r.LOADING:return jsx(Ar,{});case r.SEARCH_RESULTS:case r.LOADED:case r.LOADED_NO_DRAG:return jsx(a$i,{border:n.listSize,files:ye,isMore:v.current<x.current.pages,selected:k==null?void 0:k.Name,page:v.current,pages:A,callback:Ke});case r.SEARCH_EMPTY:return jsx(kr,{});}},er=()=>jsxs(Fragment,{children:[jsx(a$e,{id:"file-search",ref:R,placeholder:"Search your images",disabled:n.searchDisabled,callback:U}),jsxs("div",{className:"mb-4 mt-4",children:[T&&jsxs(a$g,{type:"danger",onDismiss:()=>{h(!1);},children:[jsx("p",{className:"font-semibold",children:"File could not be uploaded"}),jsx("p",{children:"There was an error uploading the file. Please try again."})]}),n.mode!==r.SEARCH_RESULTS&&n.mode!==r.SEARCH_EMPTY&&!i&&jsx("div",{className:"h-68",children:jsx(Q,{uploaded:te,callback:Me,errorCallback:J})}),(n.mode===r.SEARCH_RESULTS||n.mode===r.SEARCH_EMPTY)&&(l==null?void 0:l.length)>0&&jsx("span",{className:"ms-1 text-sm font-medium text-gray-500 dark:text-gray-400 md:ms-2",children:`Showing results for..."${l}"`})]}),Qe()]});return jsxs(a$b,{show:o,onClose:Se,title:"File Picker",onHide:()=>{},children:[jsxs("div",{className:"h-full",onDragEnter:N,children:[o&&S&&!i&&(()=>jsx("div",{className:"absolute z-50 h-[90.666667%] w-[93.666667%]",children:jsx(Q,{uploaded:te,exitCallback:Z,callback:Me,errorCallback:J})}))(),o&&er()]}),jsxs("div",{className:"bottom-0 mt-0 grid grid-flow-col grid-cols-2 gap-4 bg-white pt-2 dark:border-gray-600",style:{marginTop:"-50px"},children:[jsx(a$2,{color:"light",onClick:Se,children:"Close"}),jsx(a$2,{color:n.actionBtnColor,onClick:Xe,disabled:k==null,children:n.actionBtnTxt})]})]})}Ie.propTypes={appUrl:q.default.string.isRequired,uri:q.default.string.isRequired,show:q.default.bool.isRequired,hideDrag:q.default.bool,onClose:q.default.func.isRequired,callback:q.default.func.isRequired};Ie.displayName="FilePicker";function Rr(){return jsxs("div",{className:"mt-5 flex flex-col items-center justify-center",children:[jsx("h1",{children:jsx(BsFillImageFill,{className:"text-9xl text-gray-700"})}),jsx("p",{className:"mt-4 text-2xl font-semibold text-gray-900",children:"You Have No Images"}),jsx("p",{className:"mt-4 text-sm text-gray-500",children:"Images will appear here when you upload them"})]})}function Ar(){return jsx("div",{className:"flex h-2/3 items-center justify-center overflow-y-auto",children:jsxs("div",{className:"flex flex-col items-center justify-center",children:[jsx("h1",{children:jsx(Pr,{})}),jsx("p",{className:"mt-4 text-2xl font-semibold text-gray-900",children:"Loading Files"}),jsx("p",{className:"mt-4 text-sm text-gray-500",children:"Don't worry, this won't take long..."})]})})}function kr(){return jsx("div",{className:"flex h-5/6 items-center justify-center overflow-y-auto",children:jsxs("div",{className:"flex flex-col items-center justify-center",children:[jsx("h1",{children:jsx(HiOutlineSearch,{className:"text-9xl text-gray-700"})}),jsx("p",{className:"mt-4 text-2xl font-semibold text-gray-900",children:"No Files Found"}),jsx("p",{className:"mt-4 text-sm text-gray-500",children:"No files were found matching your search"})]})})}function Pr(){return jsxs("div",{role:"status",children:[jsxs("svg",{"aria-hidden":"true",className:"inline h-14 w-14 animate-spin fill-blue-600 text-gray-200 dark:text-gray-600",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]}),jsx("span",{className:"sr-only",children:"Loading..."})]})}function Tr(e){return f$1(this,null,function*(){return new Uint8Array(yield wr(e))})}function wr(e){return new Promise((t,o)=>{let i=new FileReader;i.onloadend=y=>t(y.target.result),i.onerror=y=>o(y),i.readAsArrayBuffer(e);})}function Lr(e){return btoa(Array.from(e).map(t=>String.fromCharCode(t)).join(""))}function Or(e){return e.replace(/[^a-z0-9_\.-]/gi,"_").toLowerCase()}var ee=e(a(),1);function ie({title:e,message:t,icon:o,children:i}){return jsx(a$c,{icon:o||jsx(a$d,{}),title:e,text:t,children:i})}ie.propTypes={title:ee.PropTypes.string.isRequired,message:ee.PropTypes.string,useSpinner:ee.PropTypes.bool,icon:ee.PropTypes.node,children:ee.PropTypes.node};ie.displayName="TableResultBlock";var re=e(a(),1);var d=Object.freeze({EMPTY:"EMPTY",SEARCH_LOADING:"SEARCH-LOADING",LOADING:"LOADING",LOADED:"LOADED",SEARCH_RESULTS:"SEARCH-RESULTS",SEARCH_EMPTY:"SEARCH-EMPTY"}),he=[{display:"Name",value:"Name"},{display:"Category",value:"Category"},{display:"Product Code",value:"ProductCode"}],Je=Object.freeze({mode:d.LOADING,searchDisabled:!1});function Ur(e,t){switch(t.type){case d.EMPTY:return {mode:d.EMPTY,searchDisabled:!0};case d.LOADING:return Je;case d.LOADED:return {mode:d.LOADED,searchDisabled:!1};case d.SEARCH_RESULTS:return {mode:d.SEARCH_RESULTS,searchDisabled:!1};case d.SEARCH_EMPTY:return {mode:d.SEARCH_EMPTY,searchDisabled:!1};default:throw new Error("Unknown file picker state: "+t.page)}}var He=forwardRef(function({preSelected:t=[],onClose:o,productCodeEnabled:i,requestCallback:y,callback:D},R){let n=useRef(),[m,A]=useReducer(Ur,Je),[j,v]=useState(0),S=useRef(1),C=useRef({pages:0,totalEntries:0}),[T,h]=useState(!1),[x,M]=useState({text:"",category:he[0]}),[_,l]=useState([]),[c,k]=useState(new Set([]));useEffect(()=>{G("",he[0].value),k(new Set(t));},[]);let G=(s,N)=>{y({SearchText:s||"",PageSize:11,Page:S.current,SearchType:N});};useImperativeHandle(R,()=>({responseHandler:s=>{var N,Z;try{s.Result.Data.length>0&&S.current>1?l(U=>[...U,...s.Result.Data]):l(s.Result.Data),C.current={pages:s.Result.NumberOfPages,totalEntries:s.Result.Total},v(s.Result.NumberOfPages),((N=x.text)==null?void 0:N.length)>0?A({type:s.Result.Data.length>0?d.SEARCH_RESULTS:d.SEARCH_EMPTY}):A({type:s.Result.Data.length>0?d.LOADED:d.EMPTY}),h(!1);}catch(U){console.error("Error fetching products",U),A({type:((Z=x.text)==null?void 0:Z.length)===0?d.SEARCH_EMPTY:d.EMPTY});}}}));let ye=s=>{var U,J;let N=(U=s.text)!=null?U:"",Z=(J=x.text)!=null?J:"";(N!=Z||s.category.value!=x.category.value)&&(S.current=1,A({type:d.LOADING}),G(N,s.category.value)),M({text:N,category:s.category});},V=()=>{D(Array.from(c));},te=s=>{switch(s.type){case"FETCH_DATA":h(s.payload),S.current<C.current.pages&&!T&&(h(!0),S.current=S.current+1,G());break;case"SELECTION":c.has(s.payload)?(c.delete(s.payload),k(N=>new Set(N))):(c.add(s.payload),k(N=>new Set(N)));break;case"DESELECT_ALL":k(new Set([]));break;}},O=()=>{switch(m.mode){case d.EMPTY:return jsx(Fe,{title:"You Have No Products",msg:"Your products will appear here"});case d.LOADING:return jsx(Fe,{title:"Loading Products",msg:"Don't worry, this won't take long...",showSpinner:!0});case d.SEARCH_RESULTS:case d.LOADED:return jsx(a$h,{products:_,isMore:S.current<C.current.pages,selected:c,page:S.current,pages:j,callback:te});case d.SEARCH_EMPTY:return jsx(Fe,{title:"No Products Found",msg:"No products were found matching your search",blockHeight:"h-[460px]"});}},ce=()=>jsxs(Fragment,{children:[c.size>0&&jsx("div",{className:"mb-4 rounded-md border border-orange-200 bg-yellow-50 p-4",children:jsxs("p",{className:"text-center text-sm text-yellow-800",children:[`${Br("product",c.size,!0)} selected.`,jsx("span",{onClick:()=>te({type:"DESELECT_ALL",payload:null}),className:"cursor-pointer text-primary-600 hover:underline",children:" Clear Selection."})]})}),jsx(a$e,{id:"file-search",ref:n,categories:i?he:he.filter(s=>s.value!=="ProductCode"),placeholder:"Search your products",disabled:m.searchDisabled,callback:ye}),jsx("div",{className:"mb-4 mt-4",children:(m.mode===d.SEARCH_RESULTS||m.mode===d.SEARCH_EMPTY)&&x.text.length>0&&jsx("span",{className:"ms-1 text-sm font-medium text-gray-500 dark:text-gray-400 md:ms-2",children:`Showing results for..."${x.text}"`})}),O()]});return jsxs(a$1,{show:!0,onClose:o,title:"Choose Products",size:"lg",children:[jsx(a$1.Body,{children:jsx("div",{className:"h-full",children:ce()})}),jsx(a$1.Footer,{children:jsxs("div",{className:"flex-grow grid grid-col-2 grid-flow-col gap-4",children:[jsx(a$2,{color:"light",onClick:o,children:"Close"}),jsx(a$2,{color:"success",onClick:V,disabled:c.size===0,children:"Add Products"})]})})]})}),Fe=({title:e,msg:t,blockHeight:o="h-[500px]",showSpinner:i=!1})=>jsx("div",{className:`${o} flex items-center justify-center`,children:jsx(ie,{icon:!i&&jsx(HiClipboardList,{className:"mb-4 h-16 w-16 text-gray-500 dark:text-gray-400"}),title:e,message:t,spinner:i})});He.propTypes={preSelected:re.default.array,onClose:re.default.func.isRequired,productCodeEnabled:re.default.bool,requestCallback:re.default.func.isRequired,callback:re.default.func.isRequired};He.displayName="ProductPicker";function We({id:e,title:t,text:o,avatarShow:i,avatarColor:y,avatarBorder:D,children:R,badgeText:n,badgeColor:m,icon:A}){function j(S){var C=S.split(" "),T=C[0],h=C[C.length-1],x=T.charAt(0);if(T!==h)var M=h.charAt(0);else var M="";return x+M}let v=j(t);return jsxs("li",{className:"hover:bg-gray-90 relative flex justify-between gap-x-6 px-4 py-5 dark:hover:bg-gray-900",children:[jsxs("div",{className:"flex min-w-0 flex-auto items-center gap-x-4",children:[i&&jsx(a$f,{placeholderInitials:v,color:y,border:D}),A&&A,jsxs("div",{className:"min-w-0 flex-auto",children:[jsxs("div",{className:"flex gap-2",children:[jsx("p",{className:"truncate text-sm font-semibold text-gray-900 dark:text-white",children:t}),n&&jsx(Badge,{color:m||"info",children:n})]}),jsx("p",{className:"mt-1 flex text-xs text-gray-500 dark:text-gray-400",children:jsx("span",{className:"relative truncate",children:o})})]})]}),jsx("div",{className:"flex flex-shrink-0 items-center gap-x-4",children:jsx("div",{className:"sm:flex sm:flex-col sm:items-end",children:R})})]},e)}We.displayName="StackedListItem";
32
-
33
- export { We as a, mr as b, Q as c, Ie as d, ie as e, He as f, ze as g };
34
- //# sourceMappingURL=out.js.map
35
- //# sourceMappingURL=chunk-44UX4FUN.js.map