@intra-mart/smartlime 0.0.1-beta
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/.gitattributes +1 -0
- package/LICENSE +21 -0
- package/README.md +7 -0
- package/lib/_shared/renderTarget.d.ts +14 -0
- package/lib/_shared/renderTarget.js +31 -0
- package/lib/index.d.ts +14 -0
- package/lib/index.js +18 -0
- package/lib/packages/Fetch/IMFecthError.d.ts +4 -0
- package/lib/packages/Fetch/IMFecthError.js +10 -0
- package/lib/packages/Fetch/index.d.ts +14 -0
- package/lib/packages/Fetch/index.js +112 -0
- package/lib/packages/Me/Context.d.ts +10 -0
- package/lib/packages/Me/Context.js +2 -0
- package/lib/packages/Me/IMMeError.d.ts +4 -0
- package/lib/packages/Me/IMMeError.js +10 -0
- package/lib/packages/Me/hooks/index.d.ts +2 -0
- package/lib/packages/Me/hooks/index.js +2 -0
- package/lib/packages/Me/hooks/useMe.d.ts +6 -0
- package/lib/packages/Me/hooks/useMe.js +11 -0
- package/lib/packages/Me/hooks/useMeState.d.ts +2 -0
- package/lib/packages/Me/hooks/useMeState.js +21 -0
- package/lib/packages/Me/index.d.ts +22 -0
- package/lib/packages/Me/index.js +55 -0
- package/lib/packages/Me/type.d.ts +85 -0
- package/lib/packages/Me/type.js +1 -0
- package/lib/packages/OAuth/Context.d.ts +14 -0
- package/lib/packages/OAuth/Context.js +2 -0
- package/lib/packages/OAuth/IMOAuthError.d.ts +4 -0
- package/lib/packages/OAuth/IMOAuthError.js +10 -0
- package/lib/packages/OAuth/hooks/index.d.ts +5 -0
- package/lib/packages/OAuth/hooks/index.js +5 -0
- package/lib/packages/OAuth/hooks/useAuthState.d.ts +2 -0
- package/lib/packages/OAuth/hooks/useAuthState.js +25 -0
- package/lib/packages/OAuth/hooks/useAuthStateEffect.d.ts +6 -0
- package/lib/packages/OAuth/hooks/useAuthStateEffect.js +14 -0
- package/lib/packages/OAuth/hooks/useIMOAuth.d.ts +7 -0
- package/lib/packages/OAuth/hooks/useIMOAuth.js +13 -0
- package/lib/packages/OAuth/hooks/useIMToken.d.ts +2 -0
- package/lib/packages/OAuth/hooks/useIMToken.js +21 -0
- package/lib/packages/OAuth/hooks/useStartAuth.d.ts +2 -0
- package/lib/packages/OAuth/hooks/useStartAuth.js +12 -0
- package/lib/packages/OAuth/index.d.ts +39 -0
- package/lib/packages/OAuth/index.js +299 -0
- package/lib/packages/Search/Context.d.ts +6 -0
- package/lib/packages/Search/Context.js +2 -0
- package/lib/packages/Search/IMSearchError.d.ts +4 -0
- package/lib/packages/Search/IMSearchError.js +10 -0
- package/lib/packages/Search/hooks/index.d.ts +11 -0
- package/lib/packages/Search/hooks/index.js +11 -0
- package/lib/packages/Search/hooks/useDepartmentPostSearch.d.ts +2 -0
- package/lib/packages/Search/hooks/useDepartmentPostSearch.js +48 -0
- package/lib/packages/Search/hooks/useDepartmentSerch.d.ts +2 -0
- package/lib/packages/Search/hooks/useDepartmentSerch.js +56 -0
- package/lib/packages/Search/hooks/useDepartmentTopSerch.d.ts +2 -0
- package/lib/packages/Search/hooks/useDepartmentTopSerch.js +47 -0
- package/lib/packages/Search/hooks/useIMSearch.d.ts +4 -0
- package/lib/packages/Search/hooks/useIMSearch.js +11 -0
- package/lib/packages/Search/hooks/usePostSerch.d.ts +2 -0
- package/lib/packages/Search/hooks/usePostSerch.js +48 -0
- package/lib/packages/Search/hooks/usePublicGroupRoleSerch.d.ts +2 -0
- package/lib/packages/Search/hooks/usePublicGroupRoleSerch.js +50 -0
- package/lib/packages/Search/hooks/usePublicGroupSerch.d.ts +2 -0
- package/lib/packages/Search/hooks/usePublicGroupSerch.js +56 -0
- package/lib/packages/Search/hooks/usePublicGroupTopSerch.d.ts +2 -0
- package/lib/packages/Search/hooks/usePublicGroupTopSerch.js +47 -0
- package/lib/packages/Search/hooks/useRoleSerch.d.ts +2 -0
- package/lib/packages/Search/hooks/useRoleSerch.js +50 -0
- package/lib/packages/Search/hooks/useUserAdditionalInformationSearch.d.ts +2 -0
- package/lib/packages/Search/hooks/useUserAdditionalInformationSearch.js +50 -0
- package/lib/packages/Search/hooks/useUserSerch.d.ts +2 -0
- package/lib/packages/Search/hooks/useUserSerch.js +68 -0
- package/lib/packages/Search/hooks/utils.d.ts +4 -0
- package/lib/packages/Search/hooks/utils.js +25 -0
- package/lib/packages/Search/index.d.ts +49 -0
- package/lib/packages/Search/index.js +72 -0
- package/lib/packages/Search/types.d.ts +208 -0
- package/lib/packages/Search/types.js +1 -0
- package/lib/packages/Session/Context.d.ts +16 -0
- package/lib/packages/Session/Context.js +2 -0
- package/lib/packages/Session/IMSessionError.d.ts +4 -0
- package/lib/packages/Session/IMSessionError.js +10 -0
- package/lib/packages/Session/hooks/index.d.ts +2 -0
- package/lib/packages/Session/hooks/index.js +2 -0
- package/lib/packages/Session/hooks/useSession.d.ts +12 -0
- package/lib/packages/Session/hooks/useSession.js +11 -0
- package/lib/packages/Session/hooks/useSessionState.d.ts +4 -0
- package/lib/packages/Session/hooks/useSessionState.js +24 -0
- package/lib/packages/Session/index.d.ts +16 -0
- package/lib/packages/Session/index.js +164 -0
- package/lib/packages/Session/type.d.ts +5 -0
- package/lib/packages/Session/type.js +1 -0
- package/lib/packages/Session/utils.d.ts +2 -0
- package/lib/packages/Session/utils.js +6 -0
- package/lib/packages/Smartlime/NotSearchPropError.d.ts +2 -0
- package/lib/packages/Smartlime/NotSearchPropError.js +13 -0
- package/lib/packages/Smartlime/index.d.ts +19 -0
- package/lib/packages/Smartlime/index.js +23 -0
- package/lib/packages/Tenant/Context.d.ts +6 -0
- package/lib/packages/Tenant/Context.js +2 -0
- package/lib/packages/Tenant/IMTenantError.d.ts +4 -0
- package/lib/packages/Tenant/IMTenantError.js +10 -0
- package/lib/packages/Tenant/hooks/index.d.ts +1 -0
- package/lib/packages/Tenant/hooks/index.js +1 -0
- package/lib/packages/Tenant/hooks/useIMBaseUrl.d.ts +2 -0
- package/lib/packages/Tenant/hooks/useIMBaseUrl.js +10 -0
- package/lib/packages/Tenant/index.d.ts +10 -0
- package/lib/packages/Tenant/index.js +19 -0
- package/lib/packages/WebView/IMWebViewError.d.ts +4 -0
- package/lib/packages/WebView/IMWebViewError.js +10 -0
- package/lib/packages/WebView/hooks/index.d.ts +1 -0
- package/lib/packages/WebView/hooks/index.js +1 -0
- package/lib/packages/WebView/hooks/useHackSearchUI.d.ts +8 -0
- package/lib/packages/WebView/hooks/useHackSearchUI.js +49 -0
- package/lib/packages/WebView/index.d.ts +11 -0
- package/lib/packages/WebView/index.js +166 -0
- package/lib/utils/mergeRef.d.ts +1 -0
- package/lib/utils/mergeRef.js +14 -0
- package/lib/utils/path.d.ts +1 -0
- package/lib/utils/path.js +16 -0
- package/package.json +87 -0
- package/tsconfig.json +36 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { useIMFetch } from '../../Fetch';
|
|
3
|
+
import { IMSearchError } from '../IMSearchError';
|
|
4
|
+
import { makeParamStringIncludeCriteria, makeParamStringIncludeProp, makeParamStringIncludeTargetDate, } from './utils';
|
|
5
|
+
const getEncodeParams = (parameters, userCriteria) => {
|
|
6
|
+
return `parameters=${encodeURIComponent(parameters)}&userCriteria=${encodeURIComponent(userCriteria)}`;
|
|
7
|
+
};
|
|
8
|
+
export const usePublicGroupRoleSearch = (paramString) => {
|
|
9
|
+
const imFetch = useIMFetch();
|
|
10
|
+
const search = useCallback(async (publicGroupSet, init) => {
|
|
11
|
+
try {
|
|
12
|
+
const parameters = makeParamStringIncludeCriteria(makeParamStringIncludeProp(makeParamStringIncludeTargetDate(paramString)));
|
|
13
|
+
const userCriteria = JSON.stringify({
|
|
14
|
+
public_group_set: publicGroupSet,
|
|
15
|
+
});
|
|
16
|
+
const body = getEncodeParams(parameters, userCriteria);
|
|
17
|
+
const response = await imFetch('api/smacolow/master/search/public_group_role/tree_with_attached_role/role', {
|
|
18
|
+
...init,
|
|
19
|
+
headers: {
|
|
20
|
+
...init?.headers,
|
|
21
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
22
|
+
Accept: 'application/json',
|
|
23
|
+
},
|
|
24
|
+
method: 'POST',
|
|
25
|
+
body: body,
|
|
26
|
+
});
|
|
27
|
+
if (response.status === 200) {
|
|
28
|
+
const json = await response.json();
|
|
29
|
+
return {
|
|
30
|
+
type: 'success',
|
|
31
|
+
response: json,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return {
|
|
36
|
+
type: 'error',
|
|
37
|
+
detail: new IMSearchError('response status other than 200 was returned.'),
|
|
38
|
+
response: response,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
return {
|
|
44
|
+
type: 'exception',
|
|
45
|
+
detail: e,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}, [paramString]);
|
|
49
|
+
return search;
|
|
50
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { useIMFetch } from '../../Fetch';
|
|
3
|
+
import { IMSearchError } from '../IMSearchError';
|
|
4
|
+
import { makeParamStringIncludeCriteria, makeParamStringIncludeProp, makeParamStringIncludeTargetDate, } from './utils';
|
|
5
|
+
const getEncodeParams = (parameters, userCriteria) => {
|
|
6
|
+
return `parameters=${encodeURIComponent(parameters)}&userCriteria=${encodeURIComponent(userCriteria)}`;
|
|
7
|
+
};
|
|
8
|
+
export const usePublicGroupSerch = (paramString) => {
|
|
9
|
+
const imFetch = useIMFetch();
|
|
10
|
+
const search = useCallback(async (keyword, init) => {
|
|
11
|
+
try {
|
|
12
|
+
const parameters = makeParamStringIncludeCriteria(makeParamStringIncludeProp(makeParamStringIncludeTargetDate(paramString)));
|
|
13
|
+
const userCriteria = JSON.stringify({
|
|
14
|
+
keyword: keyword,
|
|
15
|
+
keyword_target: [
|
|
16
|
+
'public_group_cd',
|
|
17
|
+
'public_group_name',
|
|
18
|
+
'public_group_search_name',
|
|
19
|
+
],
|
|
20
|
+
keyword_type: 'part',
|
|
21
|
+
});
|
|
22
|
+
const body = getEncodeParams(parameters, userCriteria);
|
|
23
|
+
const response = await imFetch('api/smacolow/master/search/public_group/list', {
|
|
24
|
+
...init,
|
|
25
|
+
headers: {
|
|
26
|
+
...init?.headers,
|
|
27
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
28
|
+
Accept: 'application/json',
|
|
29
|
+
},
|
|
30
|
+
method: 'POST',
|
|
31
|
+
body: body,
|
|
32
|
+
});
|
|
33
|
+
if (response.status === 200) {
|
|
34
|
+
const json = await response.json();
|
|
35
|
+
return {
|
|
36
|
+
type: 'success',
|
|
37
|
+
response: json,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return {
|
|
42
|
+
type: 'error',
|
|
43
|
+
detail: new IMSearchError('response status other than 200 was returned.'),
|
|
44
|
+
response: response,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
return {
|
|
50
|
+
type: 'exception',
|
|
51
|
+
detail: e,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}, [paramString]);
|
|
55
|
+
return search;
|
|
56
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { useIMFetch } from '../../Fetch';
|
|
3
|
+
import { IMSearchError } from '../IMSearchError';
|
|
4
|
+
import { makeParamStringIncludeCriteria, makeParamStringIncludeTargetDate, } from './utils';
|
|
5
|
+
const getEncodeParams = (parameters) => {
|
|
6
|
+
return `parameters=${encodeURIComponent(parameters)}`;
|
|
7
|
+
};
|
|
8
|
+
export const usePublicGroupTopSerch = (paramString) => {
|
|
9
|
+
const imFetch = useIMFetch();
|
|
10
|
+
const search = useCallback(async (init) => {
|
|
11
|
+
try {
|
|
12
|
+
const parameters = makeParamStringIncludeCriteria(makeParamStringIncludeTargetDate(paramString));
|
|
13
|
+
const body = getEncodeParams(parameters);
|
|
14
|
+
const response = await imFetch('api/smacolow/master/search/public_group_role/tree/public_group_top', {
|
|
15
|
+
...init,
|
|
16
|
+
headers: {
|
|
17
|
+
...init?.headers,
|
|
18
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
19
|
+
Accept: 'application/json',
|
|
20
|
+
},
|
|
21
|
+
method: 'POST',
|
|
22
|
+
body: body,
|
|
23
|
+
});
|
|
24
|
+
if (response.status === 200) {
|
|
25
|
+
const json = await response.json();
|
|
26
|
+
return {
|
|
27
|
+
type: 'success',
|
|
28
|
+
response: json,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return {
|
|
33
|
+
type: 'error',
|
|
34
|
+
detail: new IMSearchError('response status other than 200 was returned.'),
|
|
35
|
+
response: response,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
return {
|
|
41
|
+
type: 'exception',
|
|
42
|
+
detail: e,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}, [paramString]);
|
|
46
|
+
return search;
|
|
47
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { useIMFetch } from '../../Fetch';
|
|
3
|
+
import { IMSearchError } from '../IMSearchError';
|
|
4
|
+
import { makeParamStringIncludeCriteria, makeParamStringIncludeProp, makeParamStringIncludeTargetDate, } from './utils';
|
|
5
|
+
const getEncodeParams = (parameters, userCriteria) => {
|
|
6
|
+
return `parameters=${encodeURIComponent(parameters)}&userCriteria=${encodeURIComponent(userCriteria)}`;
|
|
7
|
+
};
|
|
8
|
+
export const useRoleSerch = (paramString) => {
|
|
9
|
+
const imFetch = useIMFetch();
|
|
10
|
+
const search = useCallback(async (publicGroupSet, init) => {
|
|
11
|
+
try {
|
|
12
|
+
const parameters = makeParamStringIncludeCriteria(makeParamStringIncludeProp(makeParamStringIncludeTargetDate(paramString)));
|
|
13
|
+
const userCriteria = JSON.stringify({
|
|
14
|
+
public_group_set: publicGroupSet,
|
|
15
|
+
});
|
|
16
|
+
const body = getEncodeParams(parameters, userCriteria);
|
|
17
|
+
const response = await imFetch('api/smacolow/master/search/public_group_role/tree/role', {
|
|
18
|
+
...init,
|
|
19
|
+
headers: {
|
|
20
|
+
...init?.headers,
|
|
21
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
22
|
+
Accept: 'application/json',
|
|
23
|
+
},
|
|
24
|
+
method: 'POST',
|
|
25
|
+
body: body,
|
|
26
|
+
});
|
|
27
|
+
if (response.status === 200) {
|
|
28
|
+
const json = await response.json();
|
|
29
|
+
return {
|
|
30
|
+
type: 'success',
|
|
31
|
+
response: json,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return {
|
|
36
|
+
type: 'error',
|
|
37
|
+
detail: new IMSearchError('response status other than 200 was returned.'),
|
|
38
|
+
response: response,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
return {
|
|
44
|
+
type: 'exception',
|
|
45
|
+
detail: e,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}, [paramString]);
|
|
49
|
+
return search;
|
|
50
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { useIMFetch } from '../../Fetch';
|
|
3
|
+
import { IMSearchError } from '../IMSearchError';
|
|
4
|
+
import { makeParamStringIncludeTargetDate } from './utils';
|
|
5
|
+
const getEncodeParams = (parameters, userCriteria) => {
|
|
6
|
+
return `parameters=${encodeURIComponent(parameters)}&userCriteria=${encodeURIComponent(userCriteria)}`;
|
|
7
|
+
};
|
|
8
|
+
export const useUserAdditionalInformationSearch = (paramString) => {
|
|
9
|
+
const imFetch = useIMFetch();
|
|
10
|
+
const search = useCallback(async (userCd, init) => {
|
|
11
|
+
try {
|
|
12
|
+
const parameters = makeParamStringIncludeTargetDate(paramString);
|
|
13
|
+
const userCriteria = JSON.stringify({
|
|
14
|
+
user_cd: userCd,
|
|
15
|
+
});
|
|
16
|
+
const body = getEncodeParams(parameters, userCriteria);
|
|
17
|
+
const response = await imFetch('api/smacolow/master/search/user/search/additional', {
|
|
18
|
+
...init,
|
|
19
|
+
headers: {
|
|
20
|
+
...init?.headers,
|
|
21
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
22
|
+
Accept: 'application/json',
|
|
23
|
+
},
|
|
24
|
+
method: 'POST',
|
|
25
|
+
body: body,
|
|
26
|
+
});
|
|
27
|
+
if (response.status === 200) {
|
|
28
|
+
const json = await response.json();
|
|
29
|
+
return {
|
|
30
|
+
type: 'success',
|
|
31
|
+
response: json,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return {
|
|
36
|
+
type: 'error',
|
|
37
|
+
detail: new IMSearchError('response status other than 200 was returned.'),
|
|
38
|
+
response: response,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
return {
|
|
44
|
+
type: 'exception',
|
|
45
|
+
detail: e,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}, [paramString]);
|
|
49
|
+
return search;
|
|
50
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { useIMFetch } from '../../Fetch';
|
|
3
|
+
import { IMSearchError } from '../IMSearchError';
|
|
4
|
+
import { makeParamStringIncludeTargetDate } from './utils';
|
|
5
|
+
const getEncodeParams = (parameters, userCriteria) => {
|
|
6
|
+
return `parameters=${encodeURIComponent(parameters)}&userCriteria=${encodeURIComponent(userCriteria)}`;
|
|
7
|
+
};
|
|
8
|
+
const key = 'jp.co.intra_mart.master.app.search.tabs.user.list_user';
|
|
9
|
+
const value = ['email_address1', 'user_search_name'];
|
|
10
|
+
const margeProp = (prop) => {
|
|
11
|
+
return {
|
|
12
|
+
[key]: prop && prop[key] ? [...new Set([...value, ...prop[key]])] : value,
|
|
13
|
+
...prop,
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
const mergeDefaultPropinString = (paramString) => {
|
|
17
|
+
const json = JSON.parse(paramString);
|
|
18
|
+
const prop = margeProp(json.prop);
|
|
19
|
+
return JSON.stringify({
|
|
20
|
+
...json,
|
|
21
|
+
prop,
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
export const useUserSearch = (paramString) => {
|
|
25
|
+
const imFetch = useIMFetch();
|
|
26
|
+
const search = useCallback(async (keyword, init) => {
|
|
27
|
+
try {
|
|
28
|
+
const parameters = mergeDefaultPropinString(makeParamStringIncludeTargetDate(paramString));
|
|
29
|
+
const userCriteria = JSON.stringify({
|
|
30
|
+
keyword: keyword,
|
|
31
|
+
keyword_target: ['user_cd', 'user_name', 'user_search_name'],
|
|
32
|
+
keyword_type: 'part',
|
|
33
|
+
});
|
|
34
|
+
const body = getEncodeParams(parameters, userCriteria);
|
|
35
|
+
const response = await imFetch('api/smacolow/master/search/user/search', {
|
|
36
|
+
...init,
|
|
37
|
+
headers: {
|
|
38
|
+
...init?.headers,
|
|
39
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
40
|
+
Accept: 'application/json',
|
|
41
|
+
},
|
|
42
|
+
method: 'POST',
|
|
43
|
+
body: body,
|
|
44
|
+
});
|
|
45
|
+
if (response.status === 200) {
|
|
46
|
+
const json = await response.json();
|
|
47
|
+
return {
|
|
48
|
+
type: 'success',
|
|
49
|
+
response: json,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return {
|
|
54
|
+
type: 'error',
|
|
55
|
+
detail: new IMSearchError('response status other than 200 was returned.'),
|
|
56
|
+
response: response,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
return {
|
|
62
|
+
type: 'exception',
|
|
63
|
+
detail: e,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}, [paramString]);
|
|
67
|
+
return search;
|
|
68
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const zeroPadding: (number: number) => string;
|
|
2
|
+
export declare const makeParamStringIncludeTargetDate: (paramString: string) => string;
|
|
3
|
+
export declare const makeParamStringIncludeProp: (paramString: string) => string;
|
|
4
|
+
export declare const makeParamStringIncludeCriteria: (paramString: string) => string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const zeroPadding = (number) => {
|
|
2
|
+
return `${number < 10 ? '0' : ''}${number}`;
|
|
3
|
+
};
|
|
4
|
+
export const makeParamStringIncludeTargetDate = (paramString) => {
|
|
5
|
+
const json = JSON.parse(paramString);
|
|
6
|
+
const date = new Date();
|
|
7
|
+
return JSON.stringify({
|
|
8
|
+
target_date: `${date.getFullYear()}-${zeroPadding(date.getMonth() + 1)}-${zeroPadding(date.getDate())}`,
|
|
9
|
+
...json,
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
export const makeParamStringIncludeProp = (paramString) => {
|
|
13
|
+
const json = JSON.parse(paramString);
|
|
14
|
+
return JSON.stringify({
|
|
15
|
+
prop: {},
|
|
16
|
+
...json,
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
export const makeParamStringIncludeCriteria = (paramString) => {
|
|
20
|
+
const json = JSON.parse(paramString);
|
|
21
|
+
return JSON.stringify({
|
|
22
|
+
criteria: {},
|
|
23
|
+
...json,
|
|
24
|
+
});
|
|
25
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Context as DefaultContext } from './Context';
|
|
3
|
+
import { DepartmentPostSearchRecord, DepartmentSearchRecord, PostSearchRecord, PublicGroupSearchRecord, RoleSearchRecord, UserSearchRecord } from './types';
|
|
4
|
+
export type SearchTarget = 'jp.co.intra_mart.master.search.user' | 'jp.co.intra_mart.master.search.company' | 'jp.co.intra_mart.master.search.company_post' | 'jp.co.intra_mart.master.search.department' | 'jp.co.intra_mart.master.search.public_group' | 'jp.co.intra_mart.master.search.private_group' | 'jp.co.intra_mart.master.search.public_group_role' | 'jp.co.intra_mart.master.search.role' | 'jp.co.intra_mart.master.search.attached_department_post' | 'jp.co.intra_mart.master.search.attached_public_group_role' | undefined;
|
|
5
|
+
export type SearchType = 'single' | 'multiple';
|
|
6
|
+
declare const useLock: () => import("react").MutableRefObject<boolean>;
|
|
7
|
+
declare const useVisible: () => [boolean, import("react").Dispatch<import("react").SetStateAction<boolean>>];
|
|
8
|
+
declare const useSearchTarget: () => [SearchTarget, import("react").Dispatch<import("react").SetStateAction<SearchTarget>>];
|
|
9
|
+
declare const useSearchType: () => [SearchType, import("react").Dispatch<import("react").SetStateAction<SearchType>>];
|
|
10
|
+
declare const useParamString: () => [string, import("react").Dispatch<import("react").SetStateAction<string>>];
|
|
11
|
+
export type SuccessSingleResult = UserSearchRecord | DepartmentSearchRecord | PostSearchRecord | PublicGroupSearchRecord | RoleSearchRecord | DepartmentPostSearchRecord;
|
|
12
|
+
export type SuccessMultipleResult = UserSearchRecord[] | DepartmentSearchRecord[] | PostSearchRecord[] | PublicGroupSearchRecord[] | RoleSearchRecord[] | DepartmentPostSearchRecord[];
|
|
13
|
+
export type SuccessResult<T extends SearchType> = T extends 'single' ? SuccessSingleResult : SuccessMultipleResult;
|
|
14
|
+
export interface Cancel {
|
|
15
|
+
readonly type: 'cancel' | 'locked';
|
|
16
|
+
}
|
|
17
|
+
export interface Error {
|
|
18
|
+
readonly type: 'error';
|
|
19
|
+
readonly detail: unknown;
|
|
20
|
+
}
|
|
21
|
+
export interface Success<T extends SearchType> {
|
|
22
|
+
readonly type: 'success';
|
|
23
|
+
readonly result: SuccessResult<T>;
|
|
24
|
+
}
|
|
25
|
+
export type StartSearchResult<T extends SearchType> = Cancel | Error | Success<T>;
|
|
26
|
+
export type SearchSuccess = ReturnType<typeof useSearch>[1];
|
|
27
|
+
export type SearchCancel = ReturnType<typeof useSearch>[2];
|
|
28
|
+
export type SearchError = ReturnType<typeof useSearch>[3];
|
|
29
|
+
export interface SelectSearchProps {
|
|
30
|
+
searchTarget: SearchTarget;
|
|
31
|
+
searchType: SearchType;
|
|
32
|
+
paramString: string;
|
|
33
|
+
success: SearchSuccess;
|
|
34
|
+
cancel: SearchCancel;
|
|
35
|
+
error: SearchError;
|
|
36
|
+
}
|
|
37
|
+
export interface StartSearchArg {
|
|
38
|
+
target: SearchTarget;
|
|
39
|
+
type: SearchType;
|
|
40
|
+
paramString: string;
|
|
41
|
+
}
|
|
42
|
+
declare const useSearch: (setIsVisible: ReturnType<typeof useVisible>[1], setSearchTarget: ReturnType<typeof useSearchTarget>[1], setSearchType: ReturnType<typeof useSearchType>[1], setParamString: ReturnType<typeof useParamString>[1], lockRef: ReturnType<typeof useLock>) => readonly [({ target, type, paramString }: StartSearchArg) => Promise<StartSearchResult<SearchType>>, (result: SuccessSingleResult | SuccessMultipleResult) => void, () => void, (e: unknown) => void];
|
|
43
|
+
interface IMSearchProps {
|
|
44
|
+
children: JSX.Element;
|
|
45
|
+
searchContext?: typeof DefaultContext;
|
|
46
|
+
SearchComponent: (props: SelectSearchProps) => JSX.Element;
|
|
47
|
+
}
|
|
48
|
+
export declare const IMSearch: ({ children, searchContext, SearchComponent, }: IMSearchProps) => JSX.Element;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { useCallback, useRef, useState } from 'react';
|
|
2
|
+
import { Modal } from 'react-native';
|
|
3
|
+
import { Context as DefaultContext } from './Context';
|
|
4
|
+
import { IMSearchError } from './IMSearchError';
|
|
5
|
+
const useLock = () => {
|
|
6
|
+
return useRef(false);
|
|
7
|
+
};
|
|
8
|
+
const useVisible = () => {
|
|
9
|
+
return useState(false);
|
|
10
|
+
};
|
|
11
|
+
const useSearchTarget = () => {
|
|
12
|
+
return useState(undefined);
|
|
13
|
+
};
|
|
14
|
+
const useSearchType = () => {
|
|
15
|
+
return useState('single');
|
|
16
|
+
};
|
|
17
|
+
const useParamString = () => {
|
|
18
|
+
return useState('');
|
|
19
|
+
};
|
|
20
|
+
const useSearch = (setIsVisible, setSearchTarget, setSearchType, setParamString, lockRef) => {
|
|
21
|
+
const serchResolveRef = useRef(null);
|
|
22
|
+
const start = useCallback(({ target, type, paramString }) => {
|
|
23
|
+
return new Promise((resolve) => {
|
|
24
|
+
if (lockRef.current)
|
|
25
|
+
resolve({ type: 'locked' });
|
|
26
|
+
lockRef.current = true;
|
|
27
|
+
serchResolveRef.current = resolve;
|
|
28
|
+
setSearchTarget(target);
|
|
29
|
+
setSearchType(type);
|
|
30
|
+
setParamString(paramString);
|
|
31
|
+
setIsVisible(true);
|
|
32
|
+
});
|
|
33
|
+
}, [setIsVisible, setSearchTarget, setSearchType, setParamString]);
|
|
34
|
+
const complate = useCallback((result) => {
|
|
35
|
+
if (serchResolveRef.current != null)
|
|
36
|
+
serchResolveRef.current(result);
|
|
37
|
+
else
|
|
38
|
+
throw new IMSearchError('not found resolve');
|
|
39
|
+
serchResolveRef.current = null;
|
|
40
|
+
lockRef.current = false;
|
|
41
|
+
setIsVisible(false);
|
|
42
|
+
}, [setIsVisible]);
|
|
43
|
+
const success = useCallback((result) => {
|
|
44
|
+
complate({ type: 'success', result });
|
|
45
|
+
}, [complate]);
|
|
46
|
+
const cancel = useCallback(() => {
|
|
47
|
+
complate({ type: 'cancel' });
|
|
48
|
+
}, [complate]);
|
|
49
|
+
const error = useCallback((e) => {
|
|
50
|
+
complate({ type: 'error', detail: e });
|
|
51
|
+
}, [complate]);
|
|
52
|
+
return [start, success, cancel, error];
|
|
53
|
+
};
|
|
54
|
+
export const IMSearch = ({ children, searchContext, SearchComponent, }) => {
|
|
55
|
+
const Context = searchContext || DefaultContext;
|
|
56
|
+
const contextRef = useRef();
|
|
57
|
+
const lockRef = useLock();
|
|
58
|
+
const [isVisible, setIsVisible] = useVisible();
|
|
59
|
+
const [searchTarget, setSearchTarget] = useSearchTarget();
|
|
60
|
+
const [searchType, setSearchType] = useSearchType();
|
|
61
|
+
const [paramString, setParamString] = useParamString();
|
|
62
|
+
const [start, success, cancel, error] = useSearch(setIsVisible, setSearchTarget, setSearchType, setParamString, lockRef);
|
|
63
|
+
contextRef.current = {
|
|
64
|
+
start,
|
|
65
|
+
};
|
|
66
|
+
return (<Context.Provider value={contextRef.current}>
|
|
67
|
+
<Modal visible={isVisible} animationType={'slide'} transparent={true}>
|
|
68
|
+
<SearchComponent searchTarget={searchTarget} searchType={searchType} paramString={paramString} success={success} cancel={cancel} error={error}/>
|
|
69
|
+
</Modal>
|
|
70
|
+
{children}
|
|
71
|
+
</Context.Provider>);
|
|
72
|
+
};
|