@antscorp/antsomi-ui 1.3.6-beta.7 → 1.3.6-beta.9

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.
@@ -8,7 +8,7 @@ import { isEmpty } from 'lodash';
8
8
  // Utils
9
9
  import { calculateTotalCodes, generateCodeWithPrefixAndSuffix, generateRandomCodeWithConfig, } from './utils';
10
10
  // Types
11
- import { CapitalizationType, CharacterOrderType, CharacterType, RefillType, RefillUnitType, SeparatorType, } from './type';
11
+ import { CapitalizationType, CharacterOrderType, CharacterType, RefillUnitType, SeparatorType, } from './type';
12
12
  // Constants
13
13
  import { CAPITALIZATION_OPTIONS, CHARACTER_ORDER_OPTIONS, CHARACTER_TYPE_OPTIONS, REFILL_UNIT_OPTIONS, SEPARATOR_OPTIONS, } from './constants';
14
14
  import { BlockAbsolute, CodeStructureWrapper } from './styled';
@@ -36,7 +36,7 @@ const { Title } = Typography;
36
36
  * @returns {React.ReactElement} The rendered component.
37
37
  */
38
38
  export const CodeStructure = memo(({ initialData, onChange }) => {
39
- const { characterType = CharacterType.DIGIT_AND_LETTERS, digitalNumbers = 2, alphabetLetters = 3, capitalization = CapitalizationType.UPPERCASE, characterOrder = CharacterOrderType.RANDOM, separator = SeparatorType.UNDERSCORE, quantity = 50, suffix = '', refillInterval = RefillType.MANUAL, prefix = '', refillThreshold = 10, refillUnit = RefillUnitType.CODES, } = initialData;
39
+ const { characterType = CharacterType.DIGIT_AND_LETTERS, digitalNumbers = 2, alphabetLetters = 3, capitalization = CapitalizationType.UPPERCASE, characterOrder = CharacterOrderType.RANDOM, separator = SeparatorType.UNDERSCORE, quantity = 50, suffix = '', refillInterval, prefix = '', refillThreshold = 10, refillUnit = RefillUnitType.CODES, } = initialData;
40
40
  const [form] = Form.useForm();
41
41
  const [state, setState] = useImmer({
42
42
  codeSample: '',
@@ -167,7 +167,13 @@ export const CodeStructure = memo(({ initialData, onChange }) => {
167
167
  return Promise.resolve();
168
168
  },
169
169
  },
170
- ], children: _jsx(InputNumber, { min: 1, max: refillUnit === RefillUnitType.PERCENT ? 100 : undefined, style: { width: '63px' } }) }));
170
+ ], children: _jsx(InputNumber, { onBlur: e => {
171
+ const { value } = e.target;
172
+ if (isEmpty(value)) {
173
+ form.setFieldsValue({ refillThreshold: 1 });
174
+ form.validateFields(['refillThreshold']);
175
+ }
176
+ }, min: 1, max: refillUnit === RefillUnitType.PERCENT ? 100 : undefined, style: { width: '63px' } }) }));
171
177
  } }), _jsx(Form.Item, { noStyle: true, shouldUpdate: true, children: () => (_jsx(Form.Item, { name: "refillUnit", noStyle: true, rules: [
172
178
  { required: true, message: '' },
173
179
  {
@@ -29,10 +29,10 @@ export const CAPITALIZATION_OPTIONS = [
29
29
  value: CapitalizationType.LOWERCASE,
30
30
  label: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CAP_LOW, 'lowercase'),
31
31
  },
32
- // {
33
- // value: CapitalizationType.TITLE_CASE,
34
- // label: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CAP_TITL, 'Title case'),
35
- // },
32
+ {
33
+ value: CapitalizationType.RANDOM,
34
+ label: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CHAC_ORDER_RANDOM, 'Random'),
35
+ },
36
36
  ];
37
37
  export const CHARACTER_ORDER_OPTIONS = [
38
38
  {
@@ -10,7 +10,8 @@ export declare enum CharacterOrderType {
10
10
  }
11
11
  export declare enum CapitalizationType {
12
12
  UPPERCASE = "upper",
13
- LOWERCASE = "lower"
13
+ LOWERCASE = "lower",
14
+ RANDOM = "random"
14
15
  }
15
16
  export declare enum SeparatorType {
16
17
  HYPHEN = "hyphen",
@@ -14,6 +14,7 @@ export var CapitalizationType;
14
14
  (function (CapitalizationType) {
15
15
  CapitalizationType["UPPERCASE"] = "upper";
16
16
  CapitalizationType["LOWERCASE"] = "lower";
17
+ CapitalizationType["RANDOM"] = "random";
17
18
  })(CapitalizationType || (CapitalizationType = {}));
18
19
  export var SeparatorType;
19
20
  (function (SeparatorType) {
@@ -18,9 +18,11 @@ export const generateRandomCodeWithConfig = ({ characterType, digitalNumbers, al
18
18
  else if (capitalization === CapitalizationType.LOWERCASE) {
19
19
  letterPart = letterPart.toLowerCase();
20
20
  }
21
- // } else if (capitalization === CapitalizationType.TITLE_CASE && letterPart.length > 0) {
22
- // letterPart = letterPart.charAt(0).toUpperCase() + letterPart.slice(1).toLowerCase();
23
- // }
21
+ else if (capitalization === CapitalizationType.RANDOM) {
22
+ letterPart = Array.from(letterPart)
23
+ .map(char => (Math.random() < 0.5 ? char.toUpperCase() : char.toLowerCase()))
24
+ .join('');
25
+ }
24
26
  // Order characters
25
27
  let finalCode = '';
26
28
  if (characterOrder === CharacterOrderType.RANDOM) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.6-beta.007",
3
+ "version": "1.3.6-beta.009",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",