awing-library 2.1.2-stage → 2.1.3-stage

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.
@@ -125,7 +125,7 @@ function SubCampaignDetail(props) {
125
125
  ? subCampaign.bonusAmount < 0
126
126
  ? translationText.notNegative
127
127
  : translationText.helperText
128
- : '' }) }), service.attributesGetByObjectTypeCode ? ((0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 4, style: { padding: 8 }, children: (0, jsx_runtime_1.jsx)(material_1.TextField, { id: "billingUnit", required: true, select: true, variant: "standard", fullWidth: true, label: translationText.BillingUnit, value: String(subCampaign.billingUnit), onChange: function (e) {
128
+ : '' }) }), (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 4, style: { padding: 8 }, children: (0, jsx_runtime_1.jsx)(material_1.TextField, { id: "billingUnit", required: true, select: true, variant: "standard", fullWidth: true, label: translationText.BillingUnit, value: String(subCampaign.billingUnit), onChange: function (e) {
129
129
  onSubCampaignChange(function (pre) { return (__assign(__assign({}, pre), { billingUnit: Number(e.target.value) })); });
130
130
  }, error: subValid.billingUnit !== undefined &&
131
131
  !subValid.billingUnit, helperText: subValid.billingUnit !== undefined &&
@@ -133,7 +133,7 @@ function SubCampaignDetail(props) {
133
133
  ? translationText.helperText
134
134
  : '', children: Object.values(Enum_2.AnalyticType)
135
135
  .filter(function (item) { return !isNaN(Number(item)); })
136
- .map(function (type) { return ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: type, children: t("Campaign.BillingUnit.".concat((0, lodash_1.capitalize)((0, lodash_1.camelCase)(Enum_2.AnalyticType[type])))) }, type)); }) }) })) : null] })), (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 4, style: { padding: 8 }, children: (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { checked: subCampaign.isReserved, onChange: function (e) {
136
+ .map(function (type) { return ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: type, children: t("Campaign.BillingUnit.".concat((0, lodash_1.capitalize)((0, lodash_1.camelCase)(Enum_2.AnalyticType[type])))) }, type)); }) }) })] })), (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 4, style: { padding: 8 }, children: (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { checked: subCampaign.isReserved, onChange: function (e) {
137
137
  e.persist();
138
138
  onSubCampaignChange(function (pre) { return (__assign(__assign({}, pre), { isReserved: e.target.checked })); });
139
139
  }, name: "isReserved", color: "primary" }), label: translationText.reserved, style: { marginTop: 6 } }) })] })] }));
@@ -107,9 +107,12 @@ function BasicField(props) {
107
107
  var renderField = function () {
108
108
  // const isError = !!getValueByPath(/*errors*/ {}, fieldPath)
109
109
  var isError = errors.includes(fieldPath);
110
- var field = register(fieldPath, __assign({ required: isRequired }, fieldType === Enum_1.TYPE_FIELD_TEMPLATE.URL && {
111
- onValidate: function (value) { return (0, validation_1.urlValid)(value); }
110
+ var field = register(fieldPath, __assign(__assign({ required: isRequired }, fieldType === Enum_1.TYPE_FIELD_TEMPLATE.URL && {
111
+ onValidate: validation_1.urlValid
112
+ }), fieldType === Enum_1.TYPE_FIELD_TEMPLATE.COLOR && {
113
+ onValidate: validation_1.colorValid
112
114
  }));
115
+ // onChangeViewValid(isError)
113
116
  switch (fieldType) {
114
117
  case Enum_1.TYPE_FIELD_TEMPLATE.TEXT_FIELD_NUMBER:
115
118
  case Enum_1.TYPE_FIELD_TEMPLATE.TEXT_FIELD:
@@ -238,10 +241,7 @@ var getValidationParams = function (templateDatas, pagePath, configs) {
238
241
  var runValidate = debounce(function (scriptValidate, fields, pagePath, notifyError, changeViewValidStatus, changeViewValidProcess, configs) {
239
242
  if (scriptValidate) {
240
243
  changeViewValidProcess(Enum_1.VALIDATE_PROCESS_CODE.VALIDATING);
241
- var params = getValidationParams(fields, pagePath, configs);
242
- (0, common_1.runScript)(
243
- // getValidationParams(fields, pagePath, configs),
244
- params, scriptValidate).then(function (result) {
244
+ (0, common_1.runScript)(getValidationParams(fields, pagePath, configs), scriptValidate).then(function (result) {
245
245
  if (result) {
246
246
  var fieldsError_1 = [];
247
247
  var newAnswer = result.map(function (validInfo) {
@@ -1,3 +1,4 @@
1
+ /// <reference types="lodash" />
1
2
  import React from 'react';
2
3
  import { FieldOptions } from './Utils/Types';
3
4
  export declare const useForm: (props: {
@@ -17,7 +18,7 @@ export declare const useForm: (props: {
17
18
  onBlur(e: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement, Element>): void;
18
19
  };
19
20
  watch: () => any;
20
- getValues: (fieldNames: string | string[]) => any;
21
+ getValues: ((fieldNames: string | string[]) => any) & import("lodash").MemoizedFunction;
21
22
  control: {
22
23
  _getFieldArray: <T>(name: string) => Partial<T>[];
23
24
  _updateFieldArray: (name: string, value: unknown) => void;
@@ -23,6 +23,7 @@ var compact_1 = __importDefault(require("./Utils/compact"));
23
23
  var get_1 = __importDefault(require("./Utils/get"));
24
24
  var convertToArrayPayload_1 = __importDefault(require("./Utils/convertToArrayPayload"));
25
25
  var cloneProxy_1 = __importDefault(require("./Utils/cloneProxy"));
26
+ var lodash_1 = require("lodash");
26
27
  var useForm = function (props) {
27
28
  var defaultValue = props.defaultValue;
28
29
  var isMount = (0, useMounted_1.default)();
@@ -53,7 +54,8 @@ var useForm = function (props) {
53
54
  var _updateFieldArray = function (name, value) {
54
55
  (0, set_1.default)(_formControl.current, name, value);
55
56
  };
56
- var getValues = function (fieldNames) {
57
+ // eslint-disable-next-line react-hooks/exhaustive-deps
58
+ var getValues = react_1.default.useCallback((0, lodash_1.memoize)(function (fieldNames) {
57
59
  var data = (0, convertToArrayPayload_1.default)(fieldNames).map(function (fieldName) {
58
60
  return (0, cloneProxy_1.default)((0, get_1.default)(_formControl.current, fieldName));
59
61
  });
@@ -61,7 +63,7 @@ var useForm = function (props) {
61
63
  return data;
62
64
  if (data.length && data.length === 1)
63
65
  return data[0];
64
- };
66
+ }), []);
65
67
  var register = function (fieldPath, options) {
66
68
  var isRequired = options === null || options === void 0 ? void 0 : options.required;
67
69
  var onValidate = options === null || options === void 0 ? void 0 : options.onValidate;
@@ -10,6 +10,7 @@ export declare function dateRangeValid(value: (Date | null | undefined)[] | null
10
10
  export declare function emailValid(value: string | null | undefined): boolean;
11
11
  export declare function numberOnlyValid(value: string | null | undefined): boolean;
12
12
  export declare function urlValid(value: string | null | undefined): boolean;
13
+ export declare function colorValid(value: string | null | undefined): boolean;
13
14
  export declare function passwordValid(value: string | null | undefined): boolean;
14
15
  export declare function containsOnlyDigits(str: string): boolean;
15
16
  export declare function logicExpressionValid(value: string | null | undefined): boolean;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.textValidation = exports.logicExpressionValid = exports.containsOnlyDigits = exports.passwordValid = exports.urlValid = exports.numberOnlyValid = exports.emailValid = exports.dateRangeValid = exports.dateValid = exports.notNullValid = exports.stringNullableValid = exports.stringNotNullValid = exports.numberNotNullValid = exports.numberPercentageNotNullValid = exports.positiveNumberNotNullValid = exports.arrayIsNotEmptyValid = void 0;
6
+ exports.textValidation = exports.logicExpressionValid = exports.containsOnlyDigits = exports.passwordValid = exports.colorValid = exports.urlValid = exports.numberOnlyValid = exports.emailValid = exports.dateRangeValid = exports.dateValid = exports.notNullValid = exports.stringNullableValid = exports.stringNotNullValid = exports.numberNotNullValid = exports.numberPercentageNotNullValid = exports.positiveNumberNotNullValid = exports.arrayIsNotEmptyValid = void 0;
7
7
  /* eslint-disable no-useless-escape */
8
8
  var i18n_1 = __importDefault(require("../../i18n"));
9
9
  var lodash_1 = __importDefault(require("lodash"));
@@ -69,6 +69,11 @@ function urlValid(value) {
69
69
  }
70
70
  }
71
71
  exports.urlValid = urlValid;
72
+ function colorValid(value) {
73
+ var re = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
74
+ return value !== undefined && value !== null && re.test('#' + value);
75
+ }
76
+ exports.colorValid = colorValid;
72
77
  function passwordValid(value) {
73
78
  var re = /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$/;
74
79
  return value === undefined && value === null && re.test(value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "awing-library",
3
- "version": "2.1.2-stage",
3
+ "version": "2.1.3-stage",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",