forstok-ui-lib 5.13.4 → 5.13.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forstok-ui-lib",
3
- "version": "5.13.4",
3
+ "version": "5.13.5",
4
4
  "description": "Forstok UI Components Library",
5
5
  "path": "dist",
6
6
  "main": "dist/index.js",
@@ -5,30 +5,30 @@ import { TObject } from '../../typeds/base.typed';
5
5
  import { errorTitle } from './helper';
6
6
 
7
7
  export const getStorage = (name: string, type: string = 'string', defaultVal?: any, loadName: string = 'load') => {
8
- let result: any;
8
+ let result: any
9
9
  if (sessionStorage.getItem(loadName) !== null) {
10
- result = sessionStorage.getItem(name) !== null ? sessionStorage.getItem(name) : defaultVal;
10
+ result = sessionStorage.getItem(name) !== null ? sessionStorage.getItem(name) : defaultVal
11
11
  } else {
12
- result = localStorage.getItem(name) !== null ? localStorage.getItem(name) : defaultVal;
13
- localStorage.getItem(name) !== null && sessionStorage.setItem(name, result);
12
+ result = localStorage.getItem(name) !== null ? localStorage.getItem(name) : defaultVal
13
+ localStorage.getItem(name) !== null && sessionStorage.setItem(name, result)
14
14
  }
15
15
  switch (type) {
16
16
  case 'boolean':
17
- result = (result !== undefined && result !== 'undefined') ? (result === 'true') : false;
18
- break;
17
+ result = (result !== undefined && result !== 'undefined') ? (result === 'true') : false
18
+ break
19
19
  case 'number':
20
20
  case 'integer':
21
- result = (result !== undefined && result !== 'undefined') ? parseInt(result) : 0;
22
- break;
21
+ result = (result !== undefined && result !== 'undefined') ? parseInt(result) : 0
22
+ break
23
23
  case 'object':
24
24
  case 'array':
25
- result = (result !== undefined && result !== 'undefined') ? JSON.parse(result) : undefined;
26
- break;
25
+ result = (result !== undefined && result !== 'undefined') ? (typeof result === 'string' ? (result !== '' ? JSON.parse(result) : undefined) : result) : undefined
26
+ break
27
27
  default:
28
- result = (result === undefined || result === 'undefined') ? '' : result;
29
- break;
28
+ result = (result === undefined || result === 'undefined') ? '' : result
29
+ break
30
30
  }
31
- return result;
31
+ return result
32
32
  }
33
33
 
34
34
  export const setStorage = (name: string, value?: any, only?: string) => {
@@ -13,7 +13,7 @@ import ImageComponent from '../image';
13
13
  import TextComponent from '../text';
14
14
  import CheckboxComponent from '../checkbox';
15
15
  import LinkComponent from '../link';
16
- import { generateMessage, generateMessageQuestion, generateValue, validateByApproveJs } from '../../assets/javascripts/function';
16
+ import { evGenerateValueMatch, generateMessage, generateMessageQuestion, generateValue, validateByApproveJs } from '../../assets/javascripts/function';
17
17
 
18
18
  import DateEditors from './partials/editors/date';
19
19
  import DateBareEditors from './partials/editors/date.bare';
@@ -112,7 +112,7 @@ const MasterTableComponent = (props: TMasterProps) => {
112
112
  const evChange = (head: THeadProps, value: any, idx: number, variantIdx?: number) => {
113
113
  const _type = (head?.condition === 'category') ? 'Array' : (head.typeData || 'String');
114
114
  const _value = generateValue(_type, value);
115
- const valid = head?.condition === 'category' ? validateByApproveJs(head, _value, (head?.condition[0].toUpperCase() + head?.condition.substring(1))) : validateByApproveJs(head, _value);
115
+ const valid = head?.condition === 'category' ? validateByApproveJs(head, _value, (head?.condition[0].toUpperCase() + head?.condition.substring(1))) : validateByApproveJs(head, _value, undefined, evGenerateValueMatch(head.validations, data?.[idx]));
116
116
  if (idx >= 0) {
117
117
  let newData = [...data];
118
118
  let newDataByIdx = newData[idx];
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useState } from 'react';
2
2
  import ReactSelect from 'react-select';
3
- import type { SingleValueProps, OptionProps, StylesConfig, ActionMeta, ControlProps, MultiValueProps, OnChangeValue, CSSObjectWithLabel } from 'react-select';
3
+ import type { SingleValueProps, OptionProps, StylesConfig, ActionMeta, ControlProps, MultiValueProps, OnChangeValue, CSSObjectWithLabel, MenuListProps, MultiValueRemoveProps } from 'react-select';
4
4
  import CreatableSelect from 'react-select/creatable';
5
5
  import type { CSSObject } from '@emotion/serialize';
6
6
  import { generateMessageQuestion } from '../../assets/javascripts/function';
@@ -15,6 +15,8 @@ type TSelect = {
15
15
  name?: string
16
16
  customOption?: (arg0: OptionProps) => void
17
17
  customLabel?: (arg0: SingleValueProps) => void
18
+ customMenuList?: (arg0: MenuListProps) => void
19
+ customMultiValueRemove?: (arg0: MultiValueRemoveProps) => void
18
20
  MenuList?: any
19
21
  isCreateable?: boolean
20
22
  isClearable?: boolean
@@ -42,7 +44,7 @@ type TSelect = {
42
44
  height?: string
43
45
  }
44
46
 
45
- const SelectComponent = ({ type, isError=false, mode, customOption, customLabel, MenuList, isCreateable=false, isClearable=false, selectKey, disabled, defaultValue, width, reset, setReset, isForceUpdate, setForceUpdate, isCheckAutoCopy, evChangeCustom, isField, evCreate, evChange, isMinOption, isMulti=false, options, name, placeholder, removeMessage, evCreateMessageQuestion, isLoading, height, ...props }: TSelect) => {
47
+ const SelectComponent = ({ type, isError=false, mode, customOption, customLabel, MenuList, isCreateable=false, isClearable=false, selectKey, disabled, defaultValue, width, reset, setReset, isForceUpdate, setForceUpdate, isCheckAutoCopy, evChangeCustom, isField, evCreate, evChange, isMinOption, isMulti=false, options, name, placeholder, removeMessage, evCreateMessageQuestion, isLoading, height, customMenuList, customMultiValueRemove, ...props }: TSelect) => {
46
48
  const [valueState, setValue] = useState<typeof defaultValue>(defaultValue || null)
47
49
 
48
50
  useEffect(()=> {
@@ -297,6 +299,8 @@ const SelectComponent = ({ type, isError=false, mode, customOption, customLabel,
297
299
  isClearable={isClearable ? ((Array.isArray(valueState) && valueState.length) ? valueState.some((v) => !v.isFixed) : true) : isClearable}
298
300
  {...isMulti && { isMulti: true }}
299
301
  {...customOption && { components: { Option: customOption } }}
302
+ {...customMenuList && { components: { MenuList: customMenuList } }}
303
+ {...customMultiValueRemove && { components: { MultiValueRemove: customMultiValueRemove } }}
300
304
  {...MenuList && { components: { MenuList, Option: customOption } }}
301
305
  {...selectKey && { key: selectKey }}
302
306
  {...disabled && { isDisabled: disabled }}
@@ -321,6 +325,8 @@ const SelectComponent = ({ type, isError=false, mode, customOption, customLabel,
321
325
  {...customOption && { components: { Option: customOption } }}
322
326
  {...mode === 'paymentReceiveStore' && { components: { Option: customOption, SingleValue: customLabel } }}
323
327
  {...customLabel && { components: { SingleValue: customLabel } }}
328
+ {...customMenuList && { components: { MenuList: customMenuList } }}
329
+ {...customMultiValueRemove && { components: { MultiValueRemove: customMultiValueRemove } }}
324
330
  {...MenuList && { components: { MenuList, Option: customOption } }}
325
331
  {...(customLabel && customOption) && { components: { SingleValue: customLabel, Option: customOption } }}
326
332
  {...selectKey && { key: selectKey }}
@@ -134,10 +134,10 @@ export type TInPart = {
134
134
  evCloseDropdown?: TCloseDropdownFunction
135
135
  evCreateMessage?: TMessageFunction
136
136
  evCreateMessageQuestion?: TMessageQuestionFunction
137
- saveSubscription?: (statuses: (string | null)[], id: number) => void
137
+ saveSubscription?: (statuses: (string | null)[], id: string | number) => void
138
138
  clearSubscription?: ()=> void
139
139
  data?: any
140
- id?: string
140
+ id?: string | number
141
141
  evPrintReceipt?: (dataOrder: any) => void
142
142
  }
143
143