@steroidsjs/core 3.0.57 → 3.0.59
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/actions/router.d.ts +1 -0
- package/actions/router.js +3 -2
- package/components/MetaComponent.js +17 -16
- package/docs-autogen-result.json +3275 -4328
- package/en.json +2 -0
- package/enums/FieldEnum.d.ts +68 -0
- package/enums/FieldEnum.js +96 -0
- package/enums/index.d.ts +3 -0
- package/enums/index.js +8 -0
- package/hooks/index.d.ts +2 -1
- package/hooks/index.js +3 -1
- package/hooks/useDataSelect.js +1 -0
- package/hooks/useListField.d.ts +32 -0
- package/hooks/useListField.js +103 -0
- package/package.json +1 -1
- package/ui/form/AutoCompleteField/AutoCompleteField.js +2 -1
- package/ui/form/BlankField/BlankField.js +2 -1
- package/ui/form/Button/Button.js +13 -4
- package/ui/form/CheckboxField/CheckboxField.d.ts +5 -5
- package/ui/form/CheckboxField/CheckboxField.js +11 -5
- package/ui/form/CheckboxListField/CheckboxListField.d.ts +2 -1
- package/ui/form/CheckboxListField/CheckboxListField.js +16 -93
- package/ui/form/CheckboxTreeField/CheckboxTreeField.js +2 -1
- package/ui/form/DateField/DateField.js +2 -1
- package/ui/form/DateRangeField/DateRangeField.js +2 -1
- package/ui/form/DateTimeField/DateTimeField.js +2 -1
- package/ui/form/DateTimeRangeField/DateTimeRangeField.js +2 -1
- package/ui/form/DropDownField/DropDownField.d.ts +10 -1
- package/ui/form/DropDownField/DropDownField.js +14 -12
- package/ui/form/EmailField/EmailField.js +2 -1
- package/ui/form/Field/Field.js +2 -1
- package/ui/form/Field/fieldWrapper.d.ts +2 -1
- package/ui/form/FieldList/FieldList.js +4 -3
- package/ui/form/FileField/FileField.js +2 -1
- package/ui/form/Form/Form.js +37 -22
- package/ui/form/HtmlField/HtmlField.js +2 -1
- package/ui/form/ImageField/ImageField.js +2 -1
- package/ui/form/InputField/InputField.js +2 -1
- package/ui/form/InputField/hooks/useInputFieldWarningByType.js +16 -14
- package/ui/form/NavField/NavField.js +2 -1
- package/ui/form/NumberField/NumberField.js +10 -19
- package/ui/form/NumberField/hooks/useInputTypeNumber.d.ts +1 -1
- package/ui/form/NumberField/hooks/useInputTypeNumber.js +12 -3
- package/ui/form/PasswordField/PasswordField.js +2 -1
- package/ui/form/RadioField/RadioField.d.ts +3 -26
- package/ui/form/RadioField/RadioField.js +9 -53
- package/ui/form/RadioListField/RadioListField.d.ts +3 -42
- package/ui/form/RadioListField/RadioListField.js +8 -83
- package/ui/form/RateField/RateField.js +2 -1
- package/ui/form/ReCaptchaField/ReCaptchaField.js +2 -1
- package/ui/form/SliderField/SliderField.js +2 -1
- package/ui/form/SwitcherField/SwitcherField.d.ts +3 -39
- package/ui/form/SwitcherField/SwitcherField.js +4 -80
- package/ui/form/SwitcherListField/SwitcherListField.d.ts +3 -0
- package/ui/form/SwitcherListField/SwitcherListField.js +22 -0
- package/ui/form/SwitcherListField/index.d.ts +2 -0
- package/ui/form/SwitcherListField/index.js +7 -0
- package/ui/form/TextField/TextField.js +2 -1
- package/ui/form/TimeField/TimeField.js +2 -1
- package/ui/form/TimeRangeField/TimeRangeField.js +2 -1
- package/ui/form/index.d.ts +7 -5
- package/ui/form/index.js +8 -5
package/en.json
CHANGED
|
@@ -1018,7 +1018,9 @@
|
|
|
1018
1018
|
"Активирует логику:\n- Если кликнули по дате начала или конца диапазона, то позволяем её изменить следующим кликом\n- Если клик не на дату конца или начала диапазона, а диапазон есть, то сбрасываем его\n- Если клик не на дату конца или начала диапазона, а диапазона нет, то устанавливаем кликнутую дату в поле from": "",
|
|
1019
1019
|
"Добавляет дополнительные кнопки к календарю\ntrue - будут отображены кнопки по-умолчанию\nсписок:\n string - одна из кнопок по-умолчанию\n object - кастомная кнопка": "",
|
|
1020
1020
|
"Разделитель для даты и времени, не влияет на отображение": "",
|
|
1021
|
+
"Свойства, которые напрямую передаются в DropDown компонент": "",
|
|
1021
1022
|
"Нужно ли подгружать данные после закрытия DropDown": "",
|
|
1023
|
+
"Число в пикселях, больше которого не может быть выпадающее меню": "",
|
|
1022
1024
|
"Начальные элементы списка": "",
|
|
1023
1025
|
"Значения для полей при нажатии кнопки 'Добавить'": "",
|
|
1024
1026
|
"Название иконки, которая отобразится для удаления группы с полями": "",
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import Enum from '../base/Enum';
|
|
2
|
+
export default class FieldEnum extends Enum {
|
|
3
|
+
static readonly AUTO_COMPLETE_FIELD = "AutoCompleteField";
|
|
4
|
+
static readonly BLANK_FIELD = "BlankField";
|
|
5
|
+
static readonly CHECKBOX_FIELD = "CheckboxField";
|
|
6
|
+
static readonly CHECKBOX_LIST_FIELD = "CheckboxListField";
|
|
7
|
+
static readonly CHECKBOX_TREE_FIELD = "CheckboxTreeField";
|
|
8
|
+
static readonly DATE_FIELD = "DateField";
|
|
9
|
+
static readonly DATE_RANGE_FIELD = "DateRangeField";
|
|
10
|
+
static readonly DATE_TIME_FIELD = "DateTimeField";
|
|
11
|
+
static readonly DATE_TIME_RANGE_FIELD = "DateTimeRangeField";
|
|
12
|
+
static readonly DROPDOWN_FIELD = "DropDownField";
|
|
13
|
+
static readonly EMAIL_FIELD = "EmailField";
|
|
14
|
+
static readonly FIELD = "Field";
|
|
15
|
+
static readonly FIELD_LIST = "FieldList";
|
|
16
|
+
static readonly FIELD_SET = "FieldSet";
|
|
17
|
+
static readonly FILE_FIELD = "FileField";
|
|
18
|
+
static readonly HTML_FIELD = "HtmlField";
|
|
19
|
+
static readonly IMAGE_FIELD = "ImageField";
|
|
20
|
+
static readonly INPUT_FIELD = "InputField";
|
|
21
|
+
static readonly MASK_FIELD = "MaskField";
|
|
22
|
+
static readonly NAV_FIELD = "NavField";
|
|
23
|
+
static readonly NUMBER_FIELD = "NumberField";
|
|
24
|
+
static readonly PASSWORD_FIELD = "PasswordField";
|
|
25
|
+
static readonly RADIO_FIELD = "RadioField";
|
|
26
|
+
static readonly RADIO_LIST_FIELD = "RadioListField";
|
|
27
|
+
static readonly RATE_FIELD = "RateField";
|
|
28
|
+
static readonly RE_CAPTCHA_FIELD = "ReCaptchaField";
|
|
29
|
+
static readonly SLIDER_FIELD = "SliderField";
|
|
30
|
+
static readonly SWITCHER_FIELD = "SwitcherField";
|
|
31
|
+
static readonly TEXT_FIELD = "TextField";
|
|
32
|
+
static readonly TIME_FIELD = "TimeField";
|
|
33
|
+
static readonly TIME_RANGE_FIELD = "TimeRangeField";
|
|
34
|
+
static getLabels(): {
|
|
35
|
+
AutoCompleteField: string;
|
|
36
|
+
BlankField: string;
|
|
37
|
+
CheckboxField: string;
|
|
38
|
+
CheckboxListField: string;
|
|
39
|
+
CheckboxTreeField: string;
|
|
40
|
+
DateField: string;
|
|
41
|
+
DateRangeField: string;
|
|
42
|
+
DateTimeField: string;
|
|
43
|
+
DateTimeRangeField: string;
|
|
44
|
+
DropDownField: string;
|
|
45
|
+
EmailField: string;
|
|
46
|
+
Field: string;
|
|
47
|
+
FieldList: string;
|
|
48
|
+
FieldSet: string;
|
|
49
|
+
FileField: string;
|
|
50
|
+
HtmlField: string;
|
|
51
|
+
ImageField: string;
|
|
52
|
+
InputField: string;
|
|
53
|
+
MaskField: string;
|
|
54
|
+
NavField: string;
|
|
55
|
+
NumberField: string;
|
|
56
|
+
PasswordField: string;
|
|
57
|
+
RadioField: string;
|
|
58
|
+
RadioListField: string;
|
|
59
|
+
RateField: string;
|
|
60
|
+
ReCaptchaField: string;
|
|
61
|
+
SliderField: string;
|
|
62
|
+
SwitcherField: string;
|
|
63
|
+
TextField: string;
|
|
64
|
+
TimeField: string;
|
|
65
|
+
TimeRangeField: string;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export type FieldEnumType = ReturnType<typeof Array<keyof ReturnType<typeof FieldEnum.getLabels>>>[number];
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
exports.__esModule = true;
|
|
21
|
+
var Enum_1 = __importDefault(require("../base/Enum"));
|
|
22
|
+
var FieldEnum = /** @class */ (function (_super) {
|
|
23
|
+
__extends(FieldEnum, _super);
|
|
24
|
+
function FieldEnum() {
|
|
25
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
26
|
+
}
|
|
27
|
+
FieldEnum.getLabels = function () {
|
|
28
|
+
var _a;
|
|
29
|
+
return _a = {},
|
|
30
|
+
_a[FieldEnum.AUTO_COMPLETE_FIELD] = 'AutoCompleteField',
|
|
31
|
+
_a[FieldEnum.BLANK_FIELD] = 'BlankField',
|
|
32
|
+
_a[FieldEnum.CHECKBOX_FIELD] = 'CheckboxField',
|
|
33
|
+
_a[FieldEnum.CHECKBOX_LIST_FIELD] = 'CheckboxListField',
|
|
34
|
+
_a[FieldEnum.CHECKBOX_TREE_FIELD] = 'CheckboxTreeField',
|
|
35
|
+
_a[FieldEnum.DATE_FIELD] = 'DateField',
|
|
36
|
+
_a[FieldEnum.DATE_RANGE_FIELD] = 'DateRangeField',
|
|
37
|
+
_a[FieldEnum.DATE_TIME_FIELD] = 'DateTimeField',
|
|
38
|
+
_a[FieldEnum.DATE_TIME_RANGE_FIELD] = 'DateTimeRangeField',
|
|
39
|
+
_a[FieldEnum.DROPDOWN_FIELD] = 'DropDownField',
|
|
40
|
+
_a[FieldEnum.EMAIL_FIELD] = 'EmailField',
|
|
41
|
+
_a[FieldEnum.FIELD] = 'Field',
|
|
42
|
+
_a[FieldEnum.FIELD_LIST] = 'FieldList',
|
|
43
|
+
_a[FieldEnum.FIELD_SET] = 'FieldSet',
|
|
44
|
+
_a[FieldEnum.FILE_FIELD] = 'FileField',
|
|
45
|
+
_a[FieldEnum.HTML_FIELD] = 'HtmlField',
|
|
46
|
+
_a[FieldEnum.IMAGE_FIELD] = 'ImageField',
|
|
47
|
+
_a[FieldEnum.INPUT_FIELD] = 'InputField',
|
|
48
|
+
_a[FieldEnum.MASK_FIELD] = 'MaskField',
|
|
49
|
+
_a[FieldEnum.NAV_FIELD] = 'NavField',
|
|
50
|
+
_a[FieldEnum.NUMBER_FIELD] = 'NumberField',
|
|
51
|
+
_a[FieldEnum.PASSWORD_FIELD] = 'PasswordField',
|
|
52
|
+
_a[FieldEnum.RADIO_FIELD] = 'RadioField',
|
|
53
|
+
_a[FieldEnum.RADIO_LIST_FIELD] = 'RadioListField',
|
|
54
|
+
_a[FieldEnum.RATE_FIELD] = 'RateField',
|
|
55
|
+
_a[FieldEnum.RE_CAPTCHA_FIELD] = 'ReCaptchaField',
|
|
56
|
+
_a[FieldEnum.SLIDER_FIELD] = 'SliderField',
|
|
57
|
+
_a[FieldEnum.SWITCHER_FIELD] = 'SwitcherField',
|
|
58
|
+
_a[FieldEnum.TEXT_FIELD] = 'TextField',
|
|
59
|
+
_a[FieldEnum.TIME_FIELD] = 'TimeField',
|
|
60
|
+
_a[FieldEnum.TIME_RANGE_FIELD] = 'TimeRangeField',
|
|
61
|
+
_a;
|
|
62
|
+
};
|
|
63
|
+
FieldEnum.AUTO_COMPLETE_FIELD = 'AutoCompleteField';
|
|
64
|
+
FieldEnum.BLANK_FIELD = 'BlankField';
|
|
65
|
+
FieldEnum.CHECKBOX_FIELD = 'CheckboxField';
|
|
66
|
+
FieldEnum.CHECKBOX_LIST_FIELD = 'CheckboxListField';
|
|
67
|
+
FieldEnum.CHECKBOX_TREE_FIELD = 'CheckboxTreeField';
|
|
68
|
+
FieldEnum.DATE_FIELD = 'DateField';
|
|
69
|
+
FieldEnum.DATE_RANGE_FIELD = 'DateRangeField';
|
|
70
|
+
FieldEnum.DATE_TIME_FIELD = 'DateTimeField';
|
|
71
|
+
FieldEnum.DATE_TIME_RANGE_FIELD = 'DateTimeRangeField';
|
|
72
|
+
FieldEnum.DROPDOWN_FIELD = 'DropDownField';
|
|
73
|
+
FieldEnum.EMAIL_FIELD = 'EmailField';
|
|
74
|
+
FieldEnum.FIELD = 'Field';
|
|
75
|
+
FieldEnum.FIELD_LIST = 'FieldList';
|
|
76
|
+
FieldEnum.FIELD_SET = 'FieldSet';
|
|
77
|
+
FieldEnum.FILE_FIELD = 'FileField';
|
|
78
|
+
FieldEnum.HTML_FIELD = 'HtmlField';
|
|
79
|
+
FieldEnum.IMAGE_FIELD = 'ImageField';
|
|
80
|
+
FieldEnum.INPUT_FIELD = 'InputField';
|
|
81
|
+
FieldEnum.MASK_FIELD = 'MaskField';
|
|
82
|
+
FieldEnum.NAV_FIELD = 'NavField';
|
|
83
|
+
FieldEnum.NUMBER_FIELD = 'NumberField';
|
|
84
|
+
FieldEnum.PASSWORD_FIELD = 'PasswordField';
|
|
85
|
+
FieldEnum.RADIO_FIELD = 'RadioField';
|
|
86
|
+
FieldEnum.RADIO_LIST_FIELD = 'RadioListField';
|
|
87
|
+
FieldEnum.RATE_FIELD = 'RateField';
|
|
88
|
+
FieldEnum.RE_CAPTCHA_FIELD = 'ReCaptchaField';
|
|
89
|
+
FieldEnum.SLIDER_FIELD = 'SliderField';
|
|
90
|
+
FieldEnum.SWITCHER_FIELD = 'SwitcherField';
|
|
91
|
+
FieldEnum.TEXT_FIELD = 'TextField';
|
|
92
|
+
FieldEnum.TIME_FIELD = 'TimeField';
|
|
93
|
+
FieldEnum.TIME_RANGE_FIELD = 'TimeRangeField';
|
|
94
|
+
return FieldEnum;
|
|
95
|
+
}(Enum_1["default"]));
|
|
96
|
+
exports["default"] = FieldEnum;
|
package/enums/index.d.ts
ADDED
package/enums/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.FieldEnum = void 0;
|
|
7
|
+
var FieldEnum_1 = __importDefault(require("./FieldEnum"));
|
|
8
|
+
exports.FieldEnum = FieldEnum_1["default"];
|
package/hooks/index.d.ts
CHANGED
|
@@ -24,4 +24,5 @@ import useWeekGrid from '../ui/content/CalendarSystem/hooks/useWeekGrid';
|
|
|
24
24
|
import useDisplayDate from '../ui/content/CalendarSystem/hooks/useDisplayDate';
|
|
25
25
|
import useCalendarControls from '../ui/content/CalendarSystem/hooks/useCalendarControls';
|
|
26
26
|
import useSaveCursorPosition from './useSaveCursorPosition';
|
|
27
|
-
|
|
27
|
+
import useListField from './useListField';
|
|
28
|
+
export { useAbsolutePositioning, useAddressBar, useApplication, useBem, useComponents, useDataProvider, useDataSelect, useDispatch, useFetch, useFile, useForm, useInitial, useLayout, useList, useModel, useScreen, useSelector, useSsr, useUniqueId, useTheme, useTree, useMonthGrid, useWeekGrid, useDisplayDate, useCalendarControls, useSaveCursorPosition, useListField, };
|
package/hooks/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
exports.__esModule = true;
|
|
6
|
-
exports.useSaveCursorPosition = exports.useCalendarControls = exports.useDisplayDate = exports.useWeekGrid = exports.useMonthGrid = exports.useTree = exports.useTheme = exports.useUniqueId = exports.useSsr = exports.useSelector = exports.useScreen = exports.useModel = exports.useList = exports.useLayout = exports.useInitial = exports.useForm = exports.useFile = exports.useFetch = exports.useDispatch = exports.useDataSelect = exports.useDataProvider = exports.useComponents = exports.useBem = exports.useApplication = exports.useAddressBar = exports.useAbsolutePositioning = void 0;
|
|
6
|
+
exports.useListField = exports.useSaveCursorPosition = exports.useCalendarControls = exports.useDisplayDate = exports.useWeekGrid = exports.useMonthGrid = exports.useTree = exports.useTheme = exports.useUniqueId = exports.useSsr = exports.useSelector = exports.useScreen = exports.useModel = exports.useList = exports.useLayout = exports.useInitial = exports.useForm = exports.useFile = exports.useFetch = exports.useDispatch = exports.useDataSelect = exports.useDataProvider = exports.useComponents = exports.useBem = exports.useApplication = exports.useAddressBar = exports.useAbsolutePositioning = void 0;
|
|
7
7
|
var useAbsolutePositioning_1 = __importDefault(require("./useAbsolutePositioning"));
|
|
8
8
|
exports.useAbsolutePositioning = useAbsolutePositioning_1["default"];
|
|
9
9
|
var useAddressBar_1 = __importDefault(require("./useAddressBar"));
|
|
@@ -56,3 +56,5 @@ var useCalendarControls_1 = __importDefault(require("../ui/content/CalendarSyste
|
|
|
56
56
|
exports.useCalendarControls = useCalendarControls_1["default"];
|
|
57
57
|
var useSaveCursorPosition_1 = __importDefault(require("./useSaveCursorPosition"));
|
|
58
58
|
exports.useSaveCursorPosition = useSaveCursorPosition_1["default"];
|
|
59
|
+
var useListField_1 = __importDefault(require("./useListField"));
|
|
60
|
+
exports.useListField = useListField_1["default"];
|
package/hooks/useDataSelect.js
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DataProviderItems, IDataProvider } from '@steroidsjs/core/hooks/useDataProvider';
|
|
3
|
+
import { IInputParams } from '../ui/form/Field/fieldWrapper';
|
|
4
|
+
interface IUseListFieldProps {
|
|
5
|
+
defaultItemView: string;
|
|
6
|
+
selectedIds: (PrimaryKey | any)[];
|
|
7
|
+
inputType: string;
|
|
8
|
+
input?: IInputParams;
|
|
9
|
+
items?: DataProviderItems;
|
|
10
|
+
dataProvider?: IDataProvider;
|
|
11
|
+
multiple?: boolean;
|
|
12
|
+
selectFirst?: boolean;
|
|
13
|
+
primaryKey?: string;
|
|
14
|
+
inputProps?: any;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
onChange?: (...args: any[]) => any;
|
|
17
|
+
itemView?: CustomView;
|
|
18
|
+
itemViewProps?: CustomViewProps;
|
|
19
|
+
}
|
|
20
|
+
export default function useListField(props: IUseListFieldProps): {
|
|
21
|
+
selectedIds: PrimaryKey[];
|
|
22
|
+
items: {
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
id: string | number | boolean;
|
|
25
|
+
label?: string;
|
|
26
|
+
}[];
|
|
27
|
+
inputProps: any;
|
|
28
|
+
onItemSelect: (id: any) => void;
|
|
29
|
+
setSelectedIds: (ids: PrimaryKey | PrimaryKey[], skipToggle?: boolean) => void;
|
|
30
|
+
renderItem: (itemProps: any) => JSX.Element;
|
|
31
|
+
};
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
exports.__esModule = true;
|
|
40
|
+
var react_1 = __importStar(require("react"));
|
|
41
|
+
var hooks_1 = require("@steroidsjs/core/hooks");
|
|
42
|
+
var isEqual_1 = __importDefault(require("lodash-es/isEqual"));
|
|
43
|
+
var react_use_1 = require("react-use");
|
|
44
|
+
function useListField(props) {
|
|
45
|
+
var components = (0, hooks_1.useComponents)();
|
|
46
|
+
var inputSelectedIds = (0, react_1.useMemo)(function () { return props.selectedIds || [].concat(props.input.value || []); }, [props.input.value, props.selectedIds]);
|
|
47
|
+
// Data provider
|
|
48
|
+
var items = (0, hooks_1.useDataProvider)({
|
|
49
|
+
items: props.items,
|
|
50
|
+
initialSelectedIds: inputSelectedIds,
|
|
51
|
+
dataProvider: props.dataProvider
|
|
52
|
+
}).items;
|
|
53
|
+
// Data select
|
|
54
|
+
var _a = (0, hooks_1.useDataSelect)({
|
|
55
|
+
multiple: props.multiple,
|
|
56
|
+
selectedIds: inputSelectedIds,
|
|
57
|
+
selectFirst: props.selectFirst,
|
|
58
|
+
primaryKey: props.primaryKey,
|
|
59
|
+
items: items,
|
|
60
|
+
inputValue: props.input.value
|
|
61
|
+
}), selectedIds = _a.selectedIds, setSelectedIds = _a.setSelectedIds;
|
|
62
|
+
var onItemSelect = (0, react_1.useCallback)(function (id) {
|
|
63
|
+
setSelectedIds(id);
|
|
64
|
+
}, [setSelectedIds]);
|
|
65
|
+
var inputProps = (0, react_1.useMemo)(function () { return (__assign(__assign({}, props.inputProps), { type: props.inputType, name: props.input.name, disabled: props.disabled, onChange: function (value) { return props.input.onChange(value); } })); }, [props.disabled, props.input, props.inputProps, props.inputType]);
|
|
66
|
+
// Sync with form
|
|
67
|
+
var prevSelectedIds = (0, react_use_1.usePrevious)(selectedIds);
|
|
68
|
+
(0, react_1.useEffect)(function () {
|
|
69
|
+
if (!(0, isEqual_1["default"])(prevSelectedIds || [], selectedIds)) {
|
|
70
|
+
var valueToSave = props.multiple ? selectedIds : selectedIds[0];
|
|
71
|
+
props.input.onChange.call(null, valueToSave);
|
|
72
|
+
if (props.onChange) {
|
|
73
|
+
props.onChange.call(null, valueToSave);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77
|
+
}, [props.input.onChange, selectedIds]);
|
|
78
|
+
var onReset = (0, react_1.useCallback)(function () {
|
|
79
|
+
setSelectedIds([]);
|
|
80
|
+
}, [setSelectedIds]);
|
|
81
|
+
// Reset selected ids on form reset
|
|
82
|
+
var prevInputValue = (0, react_use_1.usePrevious)(props.input.value);
|
|
83
|
+
(0, react_use_1.useUpdateEffect)(function () {
|
|
84
|
+
// if form reset
|
|
85
|
+
if (prevInputValue && props.input.value === undefined && selectedIds.length > 0) {
|
|
86
|
+
onReset();
|
|
87
|
+
}
|
|
88
|
+
}, [onReset, prevInputValue, props.input.value, selectedIds.length]);
|
|
89
|
+
var renderItem = (0, react_1.useCallback)(function (itemProps) {
|
|
90
|
+
var defaultItemView = props.defaultItemView;
|
|
91
|
+
var ItemFieldView = itemProps.view || props.itemView || components.ui.getView(defaultItemView);
|
|
92
|
+
return (react_1["default"].createElement(ItemFieldView, __assign({}, itemProps, props.itemViewProps, { type: props.inputType })));
|
|
93
|
+
}, [components.ui, props.defaultItemView, props.inputType, props.itemView, props.itemViewProps]);
|
|
94
|
+
return {
|
|
95
|
+
selectedIds: selectedIds,
|
|
96
|
+
items: items,
|
|
97
|
+
inputProps: inputProps,
|
|
98
|
+
onItemSelect: onItemSelect,
|
|
99
|
+
setSelectedIds: setSelectedIds,
|
|
100
|
+
renderItem: renderItem
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
exports["default"] = useListField;
|
package/package.json
CHANGED
|
@@ -19,6 +19,7 @@ var react_use_1 = require("react-use");
|
|
|
19
19
|
var useComponents_1 = __importDefault(require("../../../hooks/useComponents"));
|
|
20
20
|
var fieldWrapper_1 = __importDefault(require("../../../ui/form/Field/fieldWrapper"));
|
|
21
21
|
var hooks_1 = require("../../../hooks");
|
|
22
|
+
var enums_1 = require("../../../enums");
|
|
22
23
|
var getCategories = function (items) {
|
|
23
24
|
if (!items) {
|
|
24
25
|
return [];
|
|
@@ -131,4 +132,4 @@ AutoCompleteField.defaultProps = {
|
|
|
131
132
|
required: false,
|
|
132
133
|
showClear: false
|
|
133
134
|
};
|
|
134
|
-
exports["default"] = (0, fieldWrapper_1["default"])(
|
|
135
|
+
exports["default"] = (0, fieldWrapper_1["default"])(enums_1.FieldEnum.AUTO_COMPLETE_FIELD, AutoCompleteField);
|
|
@@ -28,8 +28,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
exports.__esModule = true;
|
|
29
29
|
var React = __importStar(require("react"));
|
|
30
30
|
var fieldWrapper_1 = __importDefault(require("../Field/fieldWrapper"));
|
|
31
|
+
var enums_1 = require("../../../enums");
|
|
31
32
|
function BlankField(props) {
|
|
32
33
|
var _a;
|
|
33
34
|
return React.createElement("span", null, props.text || props.children || ((_a = props.input) === null || _a === void 0 ? void 0 : _a.value));
|
|
34
35
|
}
|
|
35
|
-
exports["default"] = (0, fieldWrapper_1["default"])(
|
|
36
|
+
exports["default"] = (0, fieldWrapper_1["default"])(enums_1.FieldEnum.BLANK_FIELD, BlankField);
|
package/ui/form/Button/Button.js
CHANGED
|
@@ -84,9 +84,18 @@ function Button(props) {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
if (props.toRoute) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
if (props.target) {
|
|
88
|
+
//TODO remove @ts-ignore
|
|
89
|
+
// @ts-ignore
|
|
90
|
+
var filteredParams = (0, router_1.filterParamsForPath)(routePath, props.toRouteParams);
|
|
91
|
+
var routeUrl = (0, router_2.buildUrl)(routePath, filteredParams);
|
|
92
|
+
window.open(routeUrl, props.target);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
//TODO remove @ts-ignore
|
|
96
|
+
// @ts-ignore
|
|
97
|
+
dispatch((0, router_1.goToRoute)(props.toRoute, props.toRouteParams));
|
|
98
|
+
}
|
|
90
99
|
}
|
|
91
100
|
if (props.onClick) {
|
|
92
101
|
var result = props.onClick(e);
|
|
@@ -124,7 +133,7 @@ function Button(props) {
|
|
|
124
133
|
});
|
|
125
134
|
}
|
|
126
135
|
}
|
|
127
|
-
}, [dispatch, props, tag]);
|
|
136
|
+
}, [dispatch, props, routePath, tag]);
|
|
128
137
|
var viewProps = (0, react_1.useMemo)(function () { return ({
|
|
129
138
|
badge: badge,
|
|
130
139
|
isFailed: isFailed,
|
|
@@ -24,11 +24,11 @@ export interface ICheckboxFieldProps extends IFieldWrapperInputProps, IUiCompone
|
|
|
24
24
|
}
|
|
25
25
|
export interface ICheckboxFieldViewProps extends ICheckboxFieldProps, IFieldWrapperOutputProps {
|
|
26
26
|
inputProps: {
|
|
27
|
-
name
|
|
28
|
-
type
|
|
29
|
-
checked
|
|
30
|
-
onChange
|
|
31
|
-
disabled
|
|
27
|
+
name?: string;
|
|
28
|
+
type?: string;
|
|
29
|
+
checked?: boolean;
|
|
30
|
+
onChange?: (value: string | React.ChangeEvent) => void;
|
|
31
|
+
disabled?: boolean;
|
|
32
32
|
required?: boolean;
|
|
33
33
|
};
|
|
34
34
|
}
|
|
@@ -40,6 +40,7 @@ exports.__esModule = true;
|
|
|
40
40
|
var react_1 = __importStar(require("react"));
|
|
41
41
|
var fieldWrapper_1 = __importDefault(require("../Field/fieldWrapper"));
|
|
42
42
|
var hooks_1 = require("../../../hooks");
|
|
43
|
+
var enums_1 = require("../../../enums");
|
|
43
44
|
function CheckboxField(props) {
|
|
44
45
|
var _a, _b;
|
|
45
46
|
var components = (0, hooks_1.useComponents)();
|
|
@@ -52,18 +53,23 @@ function CheckboxField(props) {
|
|
|
52
53
|
}, [props]);
|
|
53
54
|
var inputProps = (0, react_1.useMemo)(function () {
|
|
54
55
|
var _a, _b;
|
|
55
|
-
return (__assign({ name: (_a = props.input) === null || _a === void 0 ? void 0 : _a.name, type: 'checkbox', checked: !!((_b = props.input) === null || _b === void 0 ? void 0 : _b.value), onChange: onChangeHandler, disabled: props.disabled, required: props.required }, props.inputProps));
|
|
56
|
-
}, [onChangeHandler, props.disabled, (_a = props.input) === null || _a === void 0 ? void 0 : _a.name, (_b = props.input) === null || _b === void 0 ? void 0 : _b.value, props.inputProps, props.required]);
|
|
56
|
+
return (__assign({ name: (_a = props.input) === null || _a === void 0 ? void 0 : _a.name, type: props.multiply ? 'checkbox' : 'radio', checked: !!((_b = props.input) === null || _b === void 0 ? void 0 : _b.value), onChange: onChangeHandler, disabled: props.disabled, required: props.required }, props.inputProps));
|
|
57
|
+
}, [onChangeHandler, props.disabled, (_a = props.input) === null || _a === void 0 ? void 0 : _a.name, (_b = props.input) === null || _b === void 0 ? void 0 : _b.value, props.inputProps, props.multiply, props.required]);
|
|
57
58
|
var viewProps = (0, react_1.useMemo)(function () { return ({
|
|
58
59
|
inputProps: inputProps,
|
|
59
60
|
color: props.color,
|
|
60
61
|
size: props.size,
|
|
61
62
|
errors: props.errors,
|
|
63
|
+
checked: props.checked,
|
|
62
64
|
className: props.className,
|
|
65
|
+
disabled: props.disabled,
|
|
63
66
|
style: props.style,
|
|
64
67
|
id: props.id,
|
|
65
|
-
label: props.label
|
|
66
|
-
|
|
68
|
+
label: props.label,
|
|
69
|
+
onChange: props.onChange,
|
|
70
|
+
required: props.required
|
|
71
|
+
}); }, [inputProps, props.checked, props.className, props.color, props.disabled,
|
|
72
|
+
props.errors, props.id, props.label, props.onChange, props.required, props.size, props.style]);
|
|
67
73
|
return components.ui.renderView(props.view || 'form.CheckboxFieldView', viewProps);
|
|
68
74
|
}
|
|
69
75
|
CheckboxField.defaultProps = {
|
|
@@ -72,4 +78,4 @@ CheckboxField.defaultProps = {
|
|
|
72
78
|
className: '',
|
|
73
79
|
inputProps: {}
|
|
74
80
|
};
|
|
75
|
-
exports["default"] = (0, fieldWrapper_1["default"])(
|
|
81
|
+
exports["default"] = (0, fieldWrapper_1["default"])(enums_1.FieldEnum.CHECKBOX_FIELD, CheckboxField, { label: false });
|
|
@@ -84,8 +84,9 @@ export interface ICheckboxListFieldViewProps extends IFieldWrapperOutputProps, I
|
|
|
84
84
|
onItemSelect: (id: PrimaryKey | any) => void;
|
|
85
85
|
orientation?: Orientation;
|
|
86
86
|
disabled?: boolean;
|
|
87
|
-
|
|
87
|
+
renderItem: (checkboxProps: ICheckboxFieldViewProps) => JSX.Element;
|
|
88
88
|
size?: Size;
|
|
89
|
+
className?: string;
|
|
89
90
|
}
|
|
90
91
|
declare const _default: import("../../../ui/form/Field/fieldWrapper").FieldWrapperComponent<ICheckboxListFieldProps>;
|
|
91
92
|
export default _default;
|
|
@@ -1,118 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
4
|
};
|
|
39
5
|
exports.__esModule = true;
|
|
40
|
-
var react_1 =
|
|
41
|
-
var react_use_1 = require("react-use");
|
|
42
|
-
var isEqual_1 = __importDefault(require("lodash-es/isEqual"));
|
|
6
|
+
var react_1 = require("react");
|
|
43
7
|
var hooks_1 = require("../../../hooks");
|
|
44
8
|
var fieldWrapper_1 = __importDefault(require("../../../ui/form/Field/fieldWrapper"));
|
|
9
|
+
var enums_1 = require("../../../enums");
|
|
45
10
|
function CheckboxListField(props) {
|
|
46
11
|
var components = (0, hooks_1.useComponents)();
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
|
|
12
|
+
var _a = (0, hooks_1.useListField)({
|
|
13
|
+
inputType: props.multiple ? 'checkbox' : 'radio',
|
|
14
|
+
defaultItemView: props.multiple ? 'form.CheckboxFieldView' : 'form.RadioFieldView',
|
|
15
|
+
selectedIds: props.selectedIds,
|
|
16
|
+
input: props.input,
|
|
50
17
|
items: props.items,
|
|
51
|
-
|
|
52
|
-
dataProvider: props.dataProvider
|
|
53
|
-
}).items;
|
|
54
|
-
// Data select
|
|
55
|
-
var _a = (0, hooks_1.useDataSelect)({
|
|
56
|
-
selectedIds: inputSelectedIds,
|
|
18
|
+
dataProvider: props.dataProvider,
|
|
57
19
|
multiple: props.multiple,
|
|
58
|
-
primaryKey: props.primaryKey,
|
|
59
20
|
selectFirst: props.selectFirst,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
setSelectedIds(id);
|
|
65
|
-
}, [setSelectedIds]);
|
|
66
|
-
var inputProps = (0, react_1.useMemo)(function () { return (__assign(__assign({}, props.inputProps), { type: 'checkbox', name: props.input.name, disabled: props.disabled })); }, [props.disabled, props.input, props.inputProps]);
|
|
67
|
-
// Sync with form
|
|
68
|
-
var prevSelectedIds = (0, react_use_1.usePrevious)(selectedIds);
|
|
69
|
-
(0, react_1.useEffect)(function () {
|
|
70
|
-
if (!(0, isEqual_1["default"])(prevSelectedIds || [], selectedIds)) {
|
|
71
|
-
props.input.onChange.call(null, selectedIds);
|
|
72
|
-
if (props.onChange) {
|
|
73
|
-
props.onChange.call(null, selectedIds);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77
|
-
}, [props.input.onChange, selectedIds]);
|
|
78
|
-
var onReset = (0, react_1.useCallback)(function () {
|
|
79
|
-
setSelectedIds([]);
|
|
80
|
-
}, [setSelectedIds]);
|
|
81
|
-
// Reset selected ids on form reset
|
|
82
|
-
var prevInputValue = (0, react_use_1.usePrevious)(props.input.value);
|
|
83
|
-
(0, react_use_1.useUpdateEffect)(function () {
|
|
84
|
-
// if form reset
|
|
85
|
-
if (prevInputValue && props.input.value === undefined && selectedIds.length > 0) {
|
|
86
|
-
onReset();
|
|
87
|
-
}
|
|
88
|
-
}, [onReset, prevInputValue, props.input.value, selectedIds.length]);
|
|
89
|
-
var CheckboxFieldView = props.itemView || components.ui.getView('form.CheckboxFieldView');
|
|
90
|
-
var renderCheckbox = (0, react_1.useCallback)(function (checkboxProps) { return (react_1["default"].createElement(CheckboxFieldView, __assign({}, checkboxProps, props.itemViewProps))); }, [CheckboxFieldView, props.itemViewProps]);
|
|
21
|
+
primaryKey: props.primaryKey,
|
|
22
|
+
inputProps: props.inputProps,
|
|
23
|
+
disabled: props.disabled
|
|
24
|
+
}), selectedIds = _a.selectedIds, items = _a.items, inputProps = _a.inputProps, onItemSelect = _a.onItemSelect, renderItem = _a.renderItem;
|
|
91
25
|
var viewProps = (0, react_1.useMemo)(function () { return ({
|
|
92
26
|
items: items,
|
|
93
27
|
inputProps: inputProps,
|
|
94
28
|
onItemSelect: onItemSelect,
|
|
95
29
|
selectedIds: selectedIds,
|
|
96
|
-
|
|
30
|
+
renderItem: renderItem,
|
|
97
31
|
orientation: props.orientation,
|
|
98
32
|
size: props.size,
|
|
99
33
|
disabled: props.disabled,
|
|
100
34
|
className: props.className,
|
|
101
35
|
style: props.style,
|
|
102
36
|
viewProps: props.viewProps
|
|
103
|
-
}); }, [
|
|
104
|
-
|
|
105
|
-
items,
|
|
106
|
-
onItemSelect,
|
|
107
|
-
props.className,
|
|
108
|
-
props.disabled,
|
|
109
|
-
props.orientation,
|
|
110
|
-
props.size,
|
|
111
|
-
props.style,
|
|
112
|
-
props.viewProps,
|
|
113
|
-
renderCheckbox,
|
|
114
|
-
selectedIds,
|
|
115
|
-
]);
|
|
37
|
+
}); }, [inputProps, items, onItemSelect, props.className, props.disabled,
|
|
38
|
+
props.orientation, props.size, props.style, props.viewProps, renderItem, selectedIds]);
|
|
116
39
|
return components.ui.renderView(props.view || 'form.CheckboxListFieldView', viewProps);
|
|
117
40
|
}
|
|
118
41
|
CheckboxListField.defaultProps = {
|
|
@@ -122,4 +45,4 @@ CheckboxListField.defaultProps = {
|
|
|
122
45
|
multiple: true,
|
|
123
46
|
orientation: 'vertical'
|
|
124
47
|
};
|
|
125
|
-
exports["default"] = (0, fieldWrapper_1["default"])(
|
|
48
|
+
exports["default"] = (0, fieldWrapper_1["default"])(enums_1.FieldEnum.CHECKBOX_LIST_FIELD, CheckboxListField);
|