ekm-ui 0.3.89 → 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/.turbo/turbo-build.log +108 -98
- package/CHANGELOG.md +12 -0
- package/dist/card-payment-block.css +1 -1
- package/dist/card-payment-block.css.map +1 -1
- package/dist/card-payment-block.js +14 -13
- package/dist/chunk-3NO5IHBO.js +10 -0
- package/dist/chunk-3NO5IHBO.js.map +1 -0
- package/dist/chunk-46XKR7EO.js +36 -0
- package/dist/chunk-46XKR7EO.js.map +1 -0
- package/dist/chunk-5GLAT3VP.js +9 -0
- package/dist/chunk-5GLAT3VP.js.map +1 -0
- package/dist/chunk-5VOOMPCL.js +12 -0
- package/dist/chunk-5VOOMPCL.js.map +1 -0
- package/dist/{chunk-UUMCAKW4.js → chunk-E4USZ2Q3.js} +2 -2
- package/dist/chunk-F47A36U7.js +8 -0
- package/dist/chunk-F47A36U7.js.map +1 -0
- package/dist/{chunk-4GDWK5BI.js → chunk-YOHYKIR3.js} +2 -2
- package/dist/{chunk-Q3HXAUZP.js → chunk-YZ2YZSNQ.js} +3 -3
- package/dist/chunk-YZ2YZSNQ.js.map +1 -0
- package/dist/country-picker/country-listing.d.ts +19 -0
- package/dist/country-picker/country-listing.js +7 -0
- package/dist/country-picker/country-modal.css +2 -0
- package/dist/country-picker/country-modal.css.map +1 -0
- package/dist/country-picker/country-modal.d.ts +25 -0
- package/dist/{product-picker/product-drawer.js → country-picker/country-modal.js} +15 -14
- package/dist/country-picker/country-modal.js.map +1 -0
- package/dist/date-range-picker.js +3 -3
- package/dist/drag-and-drop.css +1 -1
- package/dist/drag-and-drop.css.map +1 -1
- package/dist/drag-and-drop.js +14 -13
- package/dist/file-picker/file-picker.css +1 -1
- package/dist/file-picker/file-picker.css.map +1 -1
- package/dist/file-picker/file-picker.js +14 -13
- package/dist/form-row.js +2 -3
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +14 -13
- package/dist/label.js +1 -2
- package/dist/layout/layout.css +1 -1
- package/dist/layout/layout.css.map +1 -1
- package/dist/layout/layout.js +14 -13
- package/dist/product-picker/product-listing.d.ts +4 -7
- package/dist/product-picker/product-listing.js +1 -1
- package/dist/product-picker/product-modal.css +2 -0
- package/dist/product-picker/product-modal.css.map +1 -0
- package/dist/product-picker/product-modal.js +62 -0
- package/dist/product-picker/product-modal.js.map +1 -0
- package/dist/stacked-list-item.css +1 -1
- package/dist/stacked-list-item.css.map +1 -1
- package/dist/stacked-list-item.js +14 -13
- package/dist/table-result-block.css +1 -1
- package/dist/table-result-block.css.map +1 -1
- package/dist/table-result-block.js +14 -13
- package/dist/text-row.js +2 -1
- package/dist/toast/index.js +1 -1
- package/package.json +1 -1
- package/src/country-picker/country-listing.tsx +77 -0
- package/src/country-picker/country-modal.tsx +236 -0
- package/src/index.tsx +2 -1
- package/src/label.tsx +2 -6
- package/src/product-picker/product-listing.tsx +9 -12
- package/src/product-picker/{product-drawer.tsx → product-modal.tsx} +86 -161
- package/src/text-row.tsx +2 -1
- package/src/toast/index.tsx +2 -1
- package/dist/chunk-4RKNVFVG.js +0 -9
- package/dist/chunk-4RKNVFVG.js.map +0 -1
- package/dist/chunk-5QCQEH52.js +0 -8
- package/dist/chunk-5QCQEH52.js.map +0 -1
- package/dist/chunk-CVZY2CLV.js +0 -12
- package/dist/chunk-CVZY2CLV.js.map +0 -1
- package/dist/chunk-PZSZTHB6.js +0 -34
- package/dist/chunk-PZSZTHB6.js.map +0 -1
- package/dist/chunk-Q3HXAUZP.js.map +0 -1
- package/dist/product-picker/product-drawer.css +0 -2
- package/dist/product-picker/product-drawer.css.map +0 -1
- /package/dist/{chunk-UUMCAKW4.js.map → chunk-E4USZ2Q3.js.map} +0 -0
- /package/dist/{chunk-4GDWK5BI.js.map → chunk-YOHYKIR3.js.map} +0 -0
- /package/dist/{product-picker/product-drawer.js.map → country-picker/country-listing.js.map} +0 -0
- /package/dist/product-picker/{product-drawer.d.ts → product-modal.d.ts} +0 -0
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
export { e as TableResultBlock } from './chunk-
|
|
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
|
-
import './chunk-
|
|
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-
|
|
8
|
-
import './chunk-
|
|
9
|
-
import './chunk-Q3HXAUZP.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-
|
|
14
|
-
import './chunk-7Q6OMA2A.js';
|
|
15
|
-
import './chunk-5QCQEH52.js';
|
|
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-
|
|
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';
|
|
@@ -40,10 +41,10 @@ import './chunk-6YBVKGQW.js';
|
|
|
40
41
|
import './chunk-ISA6E23B.js';
|
|
41
42
|
import './chunk-7Z2AKRKU.js';
|
|
42
43
|
import './chunk-WSRPB5OU.js';
|
|
43
|
-
import './chunk-
|
|
44
|
+
import './chunk-YOHYKIR3.js';
|
|
44
45
|
import './chunk-DSJ5TRZW.js';
|
|
45
|
-
import './chunk-
|
|
46
|
-
import './chunk-
|
|
46
|
+
import './chunk-E4USZ2Q3.js';
|
|
47
|
+
import './chunk-F47A36U7.js';
|
|
47
48
|
import './chunk-M4UBHZDH.js';
|
|
48
49
|
import './chunk-TMO76FWT.js';
|
|
49
50
|
import './chunk-YDCYBJPC.js';
|
package/dist/text-row.js
CHANGED
package/dist/toast/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { a as ToastContext, b as ToastProvider, c as useToast } from '../chunk-
|
|
1
|
+
export { a as ToastContext, b as ToastProvider, c as useToast } from '../chunk-YZ2YZSNQ.js';
|
|
2
2
|
import '../chunk-Z4LPO673.js';
|
|
3
3
|
//# sourceMappingURL=out.js.map
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -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
|
@@ -54,9 +54,10 @@ export { Spinner } from "./spinner";
|
|
|
54
54
|
export { FeaturePageGroup } from "./featurePageComponents/feature-page-group";
|
|
55
55
|
export { TableResultBlock } from "./table-result-block";
|
|
56
56
|
export { DateRangePicker } from "./date-range-picker";
|
|
57
|
-
export { ProductPicker } from "./product-picker/product-
|
|
57
|
+
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";
|
package/src/label.tsx
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
//@ts-nocheck
|
|
2
|
-
import { twMerge } from "tailwind-merge";
|
|
3
2
|
|
|
4
3
|
export function Label({ children, ...props }) {
|
|
5
4
|
return (
|
|
6
5
|
<label
|
|
7
|
-
className={twMerge(
|
|
8
|
-
"text-sm font-medium text-gray-900 dark:text-white",
|
|
9
|
-
props.className && props.className
|
|
10
|
-
)}
|
|
11
|
-
data-testid="flowbite-label"
|
|
12
6
|
{...props}
|
|
7
|
+
className={`text-sm font-medium text-gray-900 dark:text-white ${props.className ? props.className : ''}`}
|
|
8
|
+
data-testid="flowbite-label"
|
|
13
9
|
>
|
|
14
10
|
{children}
|
|
15
11
|
</label>
|
|
@@ -10,7 +10,6 @@ function BuildImageUrl(imageUrl) {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export function Listing({
|
|
13
|
-
border,
|
|
14
13
|
products,
|
|
15
14
|
isMore,
|
|
16
15
|
selected,
|
|
@@ -53,14 +52,14 @@ export function Listing({
|
|
|
53
52
|
<div
|
|
54
53
|
id="product-list"
|
|
55
54
|
ref={scrollRef}
|
|
56
|
-
className={
|
|
55
|
+
className={`h-[500px] overflow-y-auto rounded-md border`}
|
|
57
56
|
>
|
|
58
57
|
{(products || []).map((p) => {
|
|
59
58
|
return (
|
|
60
59
|
<ProductRow
|
|
61
|
-
key={`product-row-${p.
|
|
60
|
+
key={`product-row-${p.ProductId}`}
|
|
62
61
|
product={p}
|
|
63
|
-
selected={selected.
|
|
62
|
+
selected={selected.has(p.ProductId)}
|
|
64
63
|
callback={handleProductSelection}
|
|
65
64
|
/>
|
|
66
65
|
);
|
|
@@ -70,7 +69,7 @@ export function Listing({
|
|
|
70
69
|
);
|
|
71
70
|
}
|
|
72
71
|
|
|
73
|
-
function ProductRow({ product, selected
|
|
72
|
+
function ProductRow({ product, selected, callback }) {
|
|
74
73
|
const handleProductSelection = (e) => {
|
|
75
74
|
callback(product.ProductId);
|
|
76
75
|
};
|
|
@@ -84,7 +83,7 @@ function ProductRow({ product, selected = false, callback }) {
|
|
|
84
83
|
<div className="ml-3 flex items-center">
|
|
85
84
|
<div className="flex-shrink-0">
|
|
86
85
|
<Checkbox
|
|
87
|
-
id={`cb-prod-${product.
|
|
86
|
+
id={`cb-prod-${product.ProductId}`}
|
|
88
87
|
name={product.Name}
|
|
89
88
|
checked={selected}
|
|
90
89
|
onChange={() => {}}
|
|
@@ -113,7 +112,7 @@ function ProductRow({ product, selected = false, callback }) {
|
|
|
113
112
|
</div>
|
|
114
113
|
<div className="ml-4">
|
|
115
114
|
<div className=" font-medium text-gray-900">{product.Name}</div>
|
|
116
|
-
{product.Categories
|
|
115
|
+
{product.Categories?.length > 0 ? (
|
|
117
116
|
<div className="text-xs text-gray-500">{`${
|
|
118
117
|
product.CategoryName
|
|
119
118
|
} & ${pluralize("other", product.Categories.length, true)}`}</div>
|
|
@@ -134,14 +133,12 @@ function ProductRow({ product, selected = false, callback }) {
|
|
|
134
133
|
}
|
|
135
134
|
|
|
136
135
|
Listing.propTypes = {
|
|
137
|
-
/**
|
|
138
|
-
border: PropTypes.string,
|
|
139
|
-
/** Array of files to list */
|
|
136
|
+
/** Array of products to list */
|
|
140
137
|
products: PropTypes.array,
|
|
141
138
|
/** Boolean to indicate if there are more products to load */
|
|
142
139
|
isMore: PropTypes.bool,
|
|
143
|
-
/**
|
|
144
|
-
selected: PropTypes.
|
|
140
|
+
/** Set of selected ids */
|
|
141
|
+
selected: PropTypes.instanceOf(Set),
|
|
145
142
|
/** Current page */
|
|
146
143
|
page: PropTypes.number,
|
|
147
144
|
/** Total number of pages */
|