kui-crm 0.0.87 → 0.0.89
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/cjs/index.js +34 -23
- package/cjs/index.js.map +1 -1
- package/hooks/cjs/index.js +8 -3
- package/hooks/cjs/index.js.map +1 -1
- package/hooks/index.d.ts +1 -1
- package/hooks/index.js +8 -3
- package/hooks/index.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.js +35 -24
- package/index.js.map +1 -1
- package/package.json +1 -1
package/cjs/index.js
CHANGED
|
@@ -364,7 +364,7 @@ var CitiesStore = /** @class */ (function () {
|
|
|
364
364
|
return CitiesStore;
|
|
365
365
|
}());
|
|
366
366
|
|
|
367
|
-
var useAutocomplete = function (filter, paginator, fetchAll, defaultFilter, withoutRequest) {
|
|
367
|
+
var useAutocomplete = function (filter, paginator, fetchAll, isOpen, defaultFilter, withoutRequest) {
|
|
368
368
|
React.useEffect(function () {
|
|
369
369
|
if (defaultFilter)
|
|
370
370
|
filter.updateFilterQuery(defaultFilter);
|
|
@@ -373,11 +373,16 @@ var useAutocomplete = function (filter, paginator, fetchAll, defaultFilter, with
|
|
|
373
373
|
paginator.startFetching();
|
|
374
374
|
}, []);
|
|
375
375
|
React.useEffect(function () {
|
|
376
|
-
|
|
376
|
+
console.log("effect", paginator.isFetching, paginator.isFinishPage, withoutRequest, isOpen);
|
|
377
|
+
if (paginator.isFetching &&
|
|
378
|
+
!paginator.isFinishPage &&
|
|
379
|
+
!withoutRequest &&
|
|
380
|
+
isOpen) {
|
|
377
381
|
fetchAll();
|
|
378
382
|
}
|
|
379
|
-
}, [fetchAll, paginator.isFetching]);
|
|
383
|
+
}, [fetchAll, paginator.isFetching, isOpen]);
|
|
380
384
|
kuiUtils.useDebounce(filter.searchQuery, 500, function () {
|
|
385
|
+
console.log("update search query");
|
|
381
386
|
paginator.clearOffset();
|
|
382
387
|
paginator.startFetching();
|
|
383
388
|
});
|
|
@@ -401,17 +406,18 @@ var useAutocomplete = function (filter, paginator, fetchAll, defaultFilter, with
|
|
|
401
406
|
};
|
|
402
407
|
|
|
403
408
|
function CityAutocomplete(props) {
|
|
409
|
+
var _a = React.useState(false), isOpen = _a[0], setIsOpen = _a[1];
|
|
404
410
|
var form = props.form, name = props.name, label = props.label, onSelect = props.onSelect, regionName = props.regionName, otherProps = __rest(props, ["form", "name", "label", "onSelect", "regionName"]);
|
|
405
411
|
var citiesStoreRef = React.useRef(new CitiesStore());
|
|
406
|
-
var
|
|
412
|
+
var _b = React.useState(false), isMounted = _b[0], setIsMounted = _b[1];
|
|
407
413
|
var inputRef = React.useRef(null);
|
|
408
|
-
var
|
|
414
|
+
var _c = citiesStoreRef.current, cities = _c.cities, fetchCities = _c.fetchCities, paginator = _c.paginator, filter = _c.filter, loader = _c.loader;
|
|
409
415
|
var isLoading = loader.isLoading;
|
|
410
416
|
var region = reactHookForm.useWatch({
|
|
411
417
|
control: form.control,
|
|
412
418
|
name: regionName,
|
|
413
419
|
});
|
|
414
|
-
var
|
|
420
|
+
var _d = useAutocomplete(filter, paginator, fetchCities, isOpen, (region === null || region === void 0 ? void 0 : region.id) ? "®ion=".concat(region.id) : ""), onSearchItem = _d.onSearchItem, onScrollEnd = _d.onScrollEnd;
|
|
415
421
|
var onSelectItem = function (item) {
|
|
416
422
|
form.setValue("".concat(name, ".id"), item === null || item === void 0 ? void 0 : item.id);
|
|
417
423
|
form.setValue("".concat(name, ".name"), item === null || item === void 0 ? void 0 : item.name, { shouldValidate: true });
|
|
@@ -431,7 +437,7 @@ function CityAutocomplete(props) {
|
|
|
431
437
|
}
|
|
432
438
|
setIsMounted(true);
|
|
433
439
|
}, [region === null || region === void 0 ? void 0 : region.id]);
|
|
434
|
-
return (jsxRuntime.jsx(kuiComplex.InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsxRuntime.jsx(kuiComplex.AutocompleteOption, { label: option.name })); }, isLoading: isLoading, options: cities, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), onSelectItem: onSelectItem, onSearchItem: onSearchItem, handleScrollEnd: onScrollEnd, inputRef: inputRef }, otherProps)));
|
|
440
|
+
return (jsxRuntime.jsx(kuiComplex.InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsxRuntime.jsx(kuiComplex.AutocompleteOption, { label: option.name })); }, isLoading: isLoading, options: cities, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), onSelectItem: onSelectItem, onSearchItem: onSearchItem, handleScrollEnd: onScrollEnd, inputRef: inputRef, onOpen: setIsOpen }, otherProps)));
|
|
435
441
|
}
|
|
436
442
|
CityAutocomplete.defaultProps = {
|
|
437
443
|
label: "City",
|
|
@@ -471,18 +477,19 @@ var CountriesStore = /** @class */ (function () {
|
|
|
471
477
|
}());
|
|
472
478
|
|
|
473
479
|
function CountryAutocomplete(props) {
|
|
480
|
+
var _a = React.useState(false), isOpen = _a[0], setIsOpen = _a[1];
|
|
474
481
|
var form = props.form, name = props.name, label = props.label, defaultFilter = props.defaultFilter, onSelect = props.onSelect, otherProps = __rest(props, ["form", "name", "label", "defaultFilter", "onSelect"]);
|
|
475
482
|
var countriesStoreRef = React.useRef(new CountriesStore());
|
|
476
|
-
var
|
|
483
|
+
var _b = countriesStoreRef.current, countries = _b.countries, fetchCountries = _b.fetchCountries, paginator = _b.paginator, filter = _b.filter, loader = _b.loader;
|
|
477
484
|
var isLoading = loader.isLoading;
|
|
478
|
-
var
|
|
485
|
+
var _c = useAutocomplete(filter, paginator, fetchCountries, isOpen, defaultFilter), onSearchItem = _c.onSearchItem, onScrollEnd = _c.onScrollEnd;
|
|
479
486
|
var onSelectItem = function (item) {
|
|
480
487
|
form.setValue("".concat(name, ".id"), item === null || item === void 0 ? void 0 : item.id);
|
|
481
488
|
form.setValue("".concat(name, ".name"), item === null || item === void 0 ? void 0 : item.name, { shouldValidate: true });
|
|
482
489
|
if (onSelect)
|
|
483
490
|
onSelect(item);
|
|
484
491
|
};
|
|
485
|
-
return (jsxRuntime.jsx(kuiComplex.InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsxRuntime.jsx(kuiComplex.AutocompleteOption, { label: option.name })); }, isLoading: isLoading, options: countries, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), onSelectItem: onSelectItem, onSearchItem: onSearchItem, handleScrollEnd: onScrollEnd }, otherProps)));
|
|
492
|
+
return (jsxRuntime.jsx(kuiComplex.InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsxRuntime.jsx(kuiComplex.AutocompleteOption, { label: option.name })); }, isLoading: isLoading, options: countries, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), onSelectItem: onSelectItem, onSearchItem: onSearchItem, handleScrollEnd: onScrollEnd, onOpen: setIsOpen }, otherProps)));
|
|
486
493
|
}
|
|
487
494
|
CountryAutocomplete.defaultProps = {
|
|
488
495
|
label: "Country",
|
|
@@ -591,17 +598,18 @@ var RegionsStore = /** @class */ (function () {
|
|
|
591
598
|
}());
|
|
592
599
|
|
|
593
600
|
function RegionAutocomplete(props) {
|
|
601
|
+
var _a = React.useState(false), isOpen = _a[0], setIsOpen = _a[1];
|
|
594
602
|
var form = props.form, name = props.name, label = props.label, onSelect = props.onSelect, countryName = props.countryName, otherProps = __rest(props, ["form", "name", "label", "onSelect", "countryName"]);
|
|
595
603
|
var regionsStoreRef = React.useRef(new RegionsStore());
|
|
596
|
-
var
|
|
604
|
+
var _b = React.useState(false), isMounted = _b[0], setIsMounted = _b[1];
|
|
597
605
|
var inputRef = React.useRef(null);
|
|
598
|
-
var
|
|
606
|
+
var _c = regionsStoreRef.current, regions = _c.regions, fetchRegions = _c.fetchRegions, paginator = _c.paginator, filter = _c.filter, loader = _c.loader;
|
|
599
607
|
var isLoading = loader.isLoading;
|
|
600
608
|
var country = reactHookForm.useWatch({
|
|
601
609
|
control: form.control,
|
|
602
610
|
name: countryName,
|
|
603
611
|
});
|
|
604
|
-
var
|
|
612
|
+
var _d = useAutocomplete(filter, paginator, fetchRegions, isOpen, (country === null || country === void 0 ? void 0 : country.id) ? "&country=".concat(country.id) : ""), onSearchItem = _d.onSearchItem, onScrollEnd = _d.onScrollEnd;
|
|
605
613
|
var onSelectItem = function (item) {
|
|
606
614
|
form.setValue("".concat(name, ".id"), item === null || item === void 0 ? void 0 : item.id);
|
|
607
615
|
form.setValue("".concat(name, ".name"), item === null || item === void 0 ? void 0 : item.name, { shouldValidate: true });
|
|
@@ -621,7 +629,7 @@ function RegionAutocomplete(props) {
|
|
|
621
629
|
}
|
|
622
630
|
setIsMounted(true);
|
|
623
631
|
}, [country === null || country === void 0 ? void 0 : country.id]);
|
|
624
|
-
return (jsxRuntime.jsx(kuiComplex.InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsxRuntime.jsx(kuiComplex.AutocompleteOption, { label: option.name })); }, isLoading: isLoading, options: regions, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), onSelectItem: onSelectItem, onSearchItem: onSearchItem, handleScrollEnd: onScrollEnd, inputRef: inputRef }, otherProps)));
|
|
632
|
+
return (jsxRuntime.jsx(kuiComplex.InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsxRuntime.jsx(kuiComplex.AutocompleteOption, { label: option.name })); }, isLoading: isLoading, options: regions, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), onSelectItem: onSelectItem, onSearchItem: onSearchItem, handleScrollEnd: onScrollEnd, inputRef: inputRef, onOpen: setIsOpen }, otherProps)));
|
|
625
633
|
}
|
|
626
634
|
RegionAutocomplete.defaultProps = {
|
|
627
635
|
label: "Region",
|
|
@@ -1518,14 +1526,15 @@ var CompaniesStore = /** @class */ (function () {
|
|
|
1518
1526
|
|
|
1519
1527
|
function CompanyAutocomplete(props) {
|
|
1520
1528
|
var _this = this;
|
|
1529
|
+
var _a = React.useState(false), isOpen = _a[0], setIsOpen = _a[1];
|
|
1521
1530
|
var form = props.form, name = props.name, label = props.label, handleSelect = props.handleSelect, forApartment = props.forApartment, otherProps = __rest(props, ["form", "name", "label", "handleSelect", "forApartment"]);
|
|
1522
1531
|
var companiesStore = React.useRef(new CompaniesStore());
|
|
1523
|
-
var
|
|
1532
|
+
var _b = companiesStore.current, companies = _b.companies, paginator = _b.paginator, fetchAll = _b.fetchAll, loader = _b.loader, filter = _b.filter;
|
|
1524
1533
|
var logo = reactHookForm.useWatch({
|
|
1525
1534
|
control: form.control,
|
|
1526
1535
|
name: "".concat(name, ".logo"),
|
|
1527
1536
|
});
|
|
1528
|
-
var
|
|
1537
|
+
var _c = useAutocomplete(filter, paginator, fetchAll, isOpen), onSearchItem = _c.onSearchItem, onScrollEnd = _c.onScrollEnd;
|
|
1529
1538
|
var onSearch = function (value) {
|
|
1530
1539
|
if (forApartment) {
|
|
1531
1540
|
if (value) {
|
|
@@ -1562,7 +1571,7 @@ function CompanyAutocomplete(props) {
|
|
|
1562
1571
|
filter.updateFilterQuery("&for_apartment=".concat(forApartment));
|
|
1563
1572
|
}
|
|
1564
1573
|
}, [forApartment]);
|
|
1565
|
-
return (jsxRuntime.jsx(kuiComplex.InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsxRuntime.jsx(TwoOptionForAutocomplete, { option: option })); }, options: companies, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), isLoading: loader.isLoading, onSelectItem: onSelectItem, onSearchItem: onSearch, handleScrollEnd: onScrollEnd, creatingLabel: "Add new company", endComponent: logo && jsxRuntime.jsx(SquarePreviewImage, { size: "sm", imageSrc: logo }), renderCreatingModal: function (modalProps) { return (jsxRuntime.jsx(CompanyCreationModal$1, __assign({ createCompany: onCreate }, modalProps))); } }, otherProps)));
|
|
1574
|
+
return (jsxRuntime.jsx(kuiComplex.InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsxRuntime.jsx(TwoOptionForAutocomplete, { option: option })); }, options: companies, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), isLoading: loader.isLoading, onSelectItem: onSelectItem, onSearchItem: onSearch, handleScrollEnd: onScrollEnd, creatingLabel: "Add new company", endComponent: logo && jsxRuntime.jsx(SquarePreviewImage, { size: "sm", imageSrc: logo }), renderCreatingModal: function (modalProps) { return (jsxRuntime.jsx(CompanyCreationModal$1, __assign({ createCompany: onCreate }, modalProps))); }, onOpen: setIsOpen }, otherProps)));
|
|
1566
1575
|
}
|
|
1567
1576
|
CompanyAutocomplete.defaultProps = {
|
|
1568
1577
|
label: "Company",
|
|
@@ -2398,17 +2407,18 @@ var DistrictsStore = /** @class */ (function () {
|
|
|
2398
2407
|
}());
|
|
2399
2408
|
|
|
2400
2409
|
function DistrictAutocomplete(props) {
|
|
2410
|
+
var _a = React.useState(false), isOpen = _a[0], setIsOpen = _a[1];
|
|
2401
2411
|
var form = props.form, name = props.name, label = props.label, onSelect = props.onSelect, cityName = props.cityName, otherProps = __rest(props, ["form", "name", "label", "onSelect", "cityName"]);
|
|
2402
2412
|
var districtsStoreRef = React.useRef(new DistrictsStore());
|
|
2403
|
-
var
|
|
2413
|
+
var _b = React.useState(false), isMounted = _b[0], setIsMounted = _b[1];
|
|
2404
2414
|
var inputRef = React.useRef(null);
|
|
2405
|
-
var
|
|
2415
|
+
var _c = districtsStoreRef.current, districts = _c.districts, fetchDistricts = _c.fetchDistricts, paginator = _c.paginator, filter = _c.filter, loader = _c.loader;
|
|
2406
2416
|
var isLoading = loader.isLoading;
|
|
2407
2417
|
var city = reactHookForm.useWatch({
|
|
2408
2418
|
control: form.control,
|
|
2409
2419
|
name: cityName,
|
|
2410
2420
|
});
|
|
2411
|
-
var
|
|
2421
|
+
var _d = useAutocomplete(filter, paginator, fetchDistricts, isOpen, (city === null || city === void 0 ? void 0 : city.id) ? "&city=".concat(city.id) : ""), onSearchItem = _d.onSearchItem, onScrollEnd = _d.onScrollEnd;
|
|
2412
2422
|
var onSelectItem = function (item) {
|
|
2413
2423
|
form.setValue("".concat(name, ".id"), item === null || item === void 0 ? void 0 : item.id);
|
|
2414
2424
|
form.setValue("".concat(name, ".name"), item === null || item === void 0 ? void 0 : item.name, { shouldValidate: true });
|
|
@@ -2428,7 +2438,7 @@ function DistrictAutocomplete(props) {
|
|
|
2428
2438
|
}
|
|
2429
2439
|
setIsMounted(true);
|
|
2430
2440
|
}, [city === null || city === void 0 ? void 0 : city.id]);
|
|
2431
|
-
return (jsxRuntime.jsx(kuiComplex.InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsxRuntime.jsx(kuiComplex.AutocompleteOption, { label: option.name })); }, isLoading: isLoading, options: districts, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), onSelectItem: onSelectItem, onSearchItem: onSearchItem, handleScrollEnd: onScrollEnd, inputRef: inputRef }, otherProps)));
|
|
2441
|
+
return (jsxRuntime.jsx(kuiComplex.InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsxRuntime.jsx(kuiComplex.AutocompleteOption, { label: option.name })); }, isLoading: isLoading, options: districts, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), onSelectItem: onSelectItem, onSearchItem: onSearchItem, handleScrollEnd: onScrollEnd, inputRef: inputRef, onOpen: setIsOpen }, otherProps)));
|
|
2432
2442
|
}
|
|
2433
2443
|
DistrictAutocomplete.defaultProps = {
|
|
2434
2444
|
label: "District",
|
|
@@ -2672,6 +2682,7 @@ function TariffCreationModal(props) {
|
|
|
2672
2682
|
function TariffGroupAutocomplete(props) {
|
|
2673
2683
|
var _this = this;
|
|
2674
2684
|
var form = props.form, name = props.name, label = props.label, resource = props.resource, filterQuery = props.filter, filterRequired = props.filterRequired, otherProps = __rest(props, ["form", "name", "label", "resource", "filter", "filterRequired"]);
|
|
2685
|
+
var _a = React.useState(false), isOpen = _a[0], setIsOpen = _a[1];
|
|
2675
2686
|
var tariffsStoreRef = React.useRef(new TariffsLiteStore());
|
|
2676
2687
|
var tariffsStore = tariffsStoreRef.current;
|
|
2677
2688
|
var tariffs = tariffsStore.tariffs, paginator = tariffsStore.paginator, fetchAll = tariffsStore.fetchAll, loader = tariffsStore.loader, filter = tariffsStore.filter;
|
|
@@ -2680,7 +2691,7 @@ function TariffGroupAutocomplete(props) {
|
|
|
2680
2691
|
fetchAll(resource);
|
|
2681
2692
|
}
|
|
2682
2693
|
}, [resource, filter.filterQuery]);
|
|
2683
|
-
var
|
|
2694
|
+
var _b = useAutocomplete(filter, paginator, fetchAllByResource, isOpen), onSearchItem = _b.onSearchItem, onScrollEnd = _b.onScrollEnd;
|
|
2684
2695
|
var onSelectItem = function (item) {
|
|
2685
2696
|
form.setValue("".concat(name, ".id"), item === null || item === void 0 ? void 0 : item.id);
|
|
2686
2697
|
form.setValue("".concat(name, ".type"), resource);
|
|
@@ -2702,7 +2713,7 @@ function TariffGroupAutocomplete(props) {
|
|
|
2702
2713
|
React.useEffect(function () {
|
|
2703
2714
|
filter.updateFilterQuery(filterQuery);
|
|
2704
2715
|
}, [filterQuery]);
|
|
2705
|
-
return (jsxRuntime.jsx(kuiComplex.InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsxRuntime.jsx(kuiComplex.AutocompleteOption, { label: option.name })); }, options: tariffs, isLoading: loader.isLoading, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), onSelectItem: onSelectItem, onSearchItem: onSearchItem, handleScrollEnd: onScrollEnd, creatingLabel: "Add new tariff group", renderCreatingModal: function (modalProps) { return (jsxRuntime.jsx(TariffCreationModal, __assign({ creationForm: tariffsStore.creationForm, createTariff: onCreate, defaultResource: resource }, modalProps))); } }, otherProps)));
|
|
2716
|
+
return (jsxRuntime.jsx(kuiComplex.InputWithAutocomplete, __assign({ renderOption: function (option) { return (jsxRuntime.jsx(kuiComplex.AutocompleteOption, { label: option.name })); }, options: tariffs, isLoading: loader.isLoading, label: label, form: form, name: "".concat(name, ".name"), hideName: "".concat(name, ".id"), onSelectItem: onSelectItem, onSearchItem: onSearchItem, handleScrollEnd: onScrollEnd, creatingLabel: "Add new tariff group", renderCreatingModal: function (modalProps) { return (jsxRuntime.jsx(TariffCreationModal, __assign({ creationForm: tariffsStore.creationForm, createTariff: onCreate, defaultResource: resource }, modalProps))); }, onOpen: setIsOpen }, otherProps)));
|
|
2706
2717
|
}
|
|
2707
2718
|
TariffGroupAutocomplete.defaultProps = {
|
|
2708
2719
|
name: "tariffGroup",
|