jordy 0.12.0

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.
Files changed (128) hide show
  1. package/README.md +11 -0
  2. package/esm5/adaptive-render/AdaptiveRender.js +14 -0
  3. package/esm5/adaptive-render/DeviceDetectContext.js +62 -0
  4. package/esm5/adaptive-render/adaptive-render.type.js +1 -0
  5. package/esm5/adaptive-render/device.type.js +9 -0
  6. package/esm5/adaptive-render/index.js +4 -0
  7. package/esm5/adaptive-render/withAdaptiveRender.js +29 -0
  8. package/esm5/hooks/index.js +3 -0
  9. package/esm5/hooks/useDebounce.js +26 -0
  10. package/esm5/hooks/useQueryParams.js +20 -0
  11. package/esm5/hooks/useThrottle.js +18 -0
  12. package/esm5/http-api/httpApi.factory.js +143 -0
  13. package/esm5/http-api/httpHeader.factory.js +46 -0
  14. package/esm5/http-api/index.js +3 -0
  15. package/esm5/http-api/network.type.js +1 -0
  16. package/esm5/http-api/networkParser.js +73 -0
  17. package/esm5/index.js +11 -0
  18. package/esm5/proxies/cache.proxy.js +40 -0
  19. package/esm5/proxies/index.js +1 -0
  20. package/esm5/queries/buildMutationCreator.js +87 -0
  21. package/esm5/queries/buildQueryCreator.js +124 -0
  22. package/esm5/queries/index.js +2 -0
  23. package/esm5/queries/useMakeDeps.js +23 -0
  24. package/esm5/queries/utils/clearCacheByKeyword.js +50 -0
  25. package/esm5/queries/utils/createCacheKey.js +23 -0
  26. package/esm5/queries/utils/index.js +2 -0
  27. package/esm5/route-system/AsyncGuard.js +37 -0
  28. package/esm5/route-system/index.js +3 -0
  29. package/esm5/route-system/moduleRoute.model.js +1 -0
  30. package/esm5/route-system/renderRouteSystem.js +64 -0
  31. package/esm5/route-system/routeSystem.util.js +23 -0
  32. package/esm5/storage/CookieStorageAdapter.js +20 -0
  33. package/esm5/storage/ExpiableStorageAdapter.js +36 -0
  34. package/esm5/storage/MemorySimpleStorage.js +18 -0
  35. package/esm5/storage/SimpleStorageAdapter.js +18 -0
  36. package/esm5/storage/cookie.js +27 -0
  37. package/esm5/storage/index.js +4 -0
  38. package/esm5/storage/memoryStorage.js +35 -0
  39. package/esm5/storage/storage.factory.js +30 -0
  40. package/esm5/storage/storage.type.js +1 -0
  41. package/esm5/storage/token-provider.factory.js +23 -0
  42. package/esm5/types/component.type.js +1 -0
  43. package/esm5/types/index.js +2 -0
  44. package/esm5/types/marshalling.type.js +1 -0
  45. package/esm5/util/collection.js +17 -0
  46. package/esm5/util/envCheck.js +55 -0
  47. package/esm5/util/etc.js +12 -0
  48. package/esm5/util/filter.js +10 -0
  49. package/esm5/util/format.js +8 -0
  50. package/esm5/util/index.js +15 -0
  51. package/esm5/util/josa.js +57 -0
  52. package/esm5/util/json.js +19 -0
  53. package/esm5/util/libLoader.js +27 -0
  54. package/esm5/util/path.js +16 -0
  55. package/esm5/util/queryString.js +62 -0
  56. package/esm5/util/redux.js +6 -0
  57. package/esm5/util/template.js +65 -0
  58. package/esm5/util/typeCheck.js +33 -0
  59. package/esm5/validate/fn.js +66 -0
  60. package/esm5/validate/index.js +7 -0
  61. package/esm5/validate/mergeValidates.js +22 -0
  62. package/esm5/validate/validate.js +22 -0
  63. package/esm5/validate/validate.type.js +1 -0
  64. package/esm5/validate/validateSubUtils.js +67 -0
  65. package/libs/adaptive-render/AdaptiveRender.d.ts +25 -0
  66. package/libs/adaptive-render/DeviceDetectContext.d.ts +16 -0
  67. package/libs/adaptive-render/adaptive-render.type.d.ts +63 -0
  68. package/libs/adaptive-render/device.type.d.ts +14 -0
  69. package/libs/adaptive-render/index.d.ts +4 -0
  70. package/libs/adaptive-render/withAdaptiveRender.d.ts +35 -0
  71. package/libs/hooks/index.d.ts +3 -0
  72. package/libs/hooks/useDebounce.d.ts +29 -0
  73. package/libs/hooks/useQueryParams.d.ts +19 -0
  74. package/libs/hooks/useThrottle.d.ts +25 -0
  75. package/libs/http-api/httpApi.factory.d.ts +9 -0
  76. package/libs/http-api/httpHeader.factory.d.ts +15 -0
  77. package/libs/http-api/index.d.ts +3 -0
  78. package/libs/http-api/network.type.d.ts +109 -0
  79. package/libs/http-api/networkParser.d.ts +9 -0
  80. package/libs/index.d.ts +11 -0
  81. package/libs/proxies/cache.proxy.d.ts +11 -0
  82. package/libs/proxies/index.d.ts +1 -0
  83. package/libs/queries/buildMutationCreator.d.ts +37 -0
  84. package/libs/queries/buildQueryCreator.d.ts +115 -0
  85. package/libs/queries/index.d.ts +2 -0
  86. package/libs/queries/useMakeDeps.d.ts +1 -0
  87. package/libs/queries/utils/clearCacheByKeyword.d.ts +14 -0
  88. package/libs/queries/utils/createCacheKey.d.ts +1 -0
  89. package/libs/queries/utils/index.d.ts +2 -0
  90. package/libs/route-system/AsyncGuard.d.ts +8 -0
  91. package/libs/route-system/index.d.ts +3 -0
  92. package/libs/route-system/moduleRoute.model.d.ts +49 -0
  93. package/libs/route-system/renderRouteSystem.d.ts +5 -0
  94. package/libs/route-system/routeSystem.util.d.ts +4 -0
  95. package/libs/storage/CookieStorageAdapter.d.ts +11 -0
  96. package/libs/storage/ExpiableStorageAdapter.d.ts +11 -0
  97. package/libs/storage/MemorySimpleStorage.d.ts +10 -0
  98. package/libs/storage/SimpleStorageAdapter.d.ts +10 -0
  99. package/libs/storage/cookie.d.ts +2 -0
  100. package/libs/storage/index.d.ts +4 -0
  101. package/libs/storage/memoryStorage.d.ts +7 -0
  102. package/libs/storage/storage.factory.d.ts +31 -0
  103. package/libs/storage/storage.type.d.ts +96 -0
  104. package/libs/storage/token-provider.factory.d.ts +9 -0
  105. package/libs/types/component.type.d.ts +23 -0
  106. package/libs/types/index.d.ts +2 -0
  107. package/libs/types/marshalling.type.d.ts +5 -0
  108. package/libs/util/collection.d.ts +25 -0
  109. package/libs/util/envCheck.d.ts +56 -0
  110. package/libs/util/etc.d.ts +11 -0
  111. package/libs/util/filter.d.ts +2 -0
  112. package/libs/util/format.d.ts +6 -0
  113. package/libs/util/index.d.ts +15 -0
  114. package/libs/util/josa.d.ts +66 -0
  115. package/libs/util/json.d.ts +14 -0
  116. package/libs/util/libLoader.d.ts +1 -0
  117. package/libs/util/path.d.ts +20 -0
  118. package/libs/util/queryString.d.ts +35 -0
  119. package/libs/util/redux.d.ts +3 -0
  120. package/libs/util/template.d.ts +38 -0
  121. package/libs/util/typeCheck.d.ts +42 -0
  122. package/libs/validate/fn.d.ts +111 -0
  123. package/libs/validate/index.d.ts +58 -0
  124. package/libs/validate/mergeValidates.d.ts +21 -0
  125. package/libs/validate/validate.d.ts +2 -0
  126. package/libs/validate/validate.type.d.ts +84 -0
  127. package/libs/validate/validateSubUtils.d.ts +12 -0
  128. package/package.json +58 -0
@@ -0,0 +1,55 @@
1
+ var bIsStorageAvailable = typeof localStorage !== 'undefined';
2
+ var bIsServer = typeof window === 'undefined';
3
+ export var isServer = function () { return bIsServer; };
4
+ export var setIsServer = function (val) {
5
+ bIsServer = val;
6
+ };
7
+ export var isStorageAvailable = function () { return bIsStorageAvailable; };
8
+ export var setIsStorageAvailable = function (val) {
9
+ bIsStorageAvailable = val;
10
+ };
11
+ var userAgent = isServer() ? '' : window.navigator.userAgent;
12
+ export function setUserAgent(ua) {
13
+ if (isServer() && ua) {
14
+ userAgent = ua;
15
+ }
16
+ }
17
+ export function getUserAgent() {
18
+ return userAgent;
19
+ }
20
+ export function isMobile() {
21
+ var ua = userAgent;
22
+ if (!ua) {
23
+ return false;
24
+ }
25
+ return /iPhone|iPod|Android/.test(ua);
26
+ }
27
+ export function isTablet() {
28
+ var ua = userAgent;
29
+ if (!ua) {
30
+ return false;
31
+ }
32
+ return /iPad/.test(ua);
33
+ }
34
+ export function isIOS() {
35
+ var ua = userAgent;
36
+ if (!ua) {
37
+ return false;
38
+ }
39
+ return /iPad|iPhone|iPad/.test(ua);
40
+ }
41
+ var nativeAppKeyword = '';
42
+ var bIsNativeApp = null;
43
+ export function setNativeAppKeyword(keyword) {
44
+ nativeAppKeyword = keyword;
45
+ }
46
+ export function isNativeApp() {
47
+ var ua = userAgent;
48
+ if (!ua) {
49
+ return false;
50
+ }
51
+ if (bIsNativeApp === null) {
52
+ bIsNativeApp = ua.indexOf(nativeAppKeyword) >= 0;
53
+ }
54
+ return bIsNativeApp;
55
+ }
@@ -0,0 +1,12 @@
1
+ export function timeout(time, value, stopCallback) {
2
+ return new Promise(function (resolve, reject) {
3
+ var t = setTimeout(function () { return resolve(value); }, time);
4
+ if (stopCallback) {
5
+ stopCallback(function () {
6
+ clearTimeout(t);
7
+ reject(new Error('timeout stopped.'));
8
+ });
9
+ }
10
+ });
11
+ }
12
+ export function noop() { }
@@ -0,0 +1,10 @@
1
+ import _throttle from 'lodash-es/throttle';
2
+ import _debounce from 'lodash-es/debounce';
3
+ export function throttle(func, wait) {
4
+ if (wait === void 0) { wait = 300; }
5
+ return _throttle(func, wait, { trailing: false });
6
+ }
7
+ export function debounce(func, wait) {
8
+ if (wait === void 0) { wait = 300; }
9
+ return _debounce(func, wait);
10
+ }
@@ -0,0 +1,8 @@
1
+ import { isNumber } from './typeCheck';
2
+ export function numberFormat(value, def) {
3
+ if (def === void 0) { def = '0'; }
4
+ if (!value || !isNumber(value)) {
5
+ return def;
6
+ }
7
+ return value.toLocaleString();
8
+ }
@@ -0,0 +1,15 @@
1
+ export * from './collection';
2
+ import * as envCheck from './envCheck';
3
+ export * from './typeCheck';
4
+ export * from './etc';
5
+ export * from './filter';
6
+ export * from './format';
7
+ export * from './josa';
8
+ export * from './json';
9
+ export * from './path';
10
+ export * from './queryString';
11
+ export * from './redux';
12
+ export * from './template';
13
+ export * from './libLoader';
14
+ var isServer = envCheck.isServer;
15
+ export { envCheck, isServer };
@@ -0,0 +1,57 @@
1
+ function _hasJong(string) {
2
+ var str = string.charCodeAt(string.length - 1);
3
+ return (str - 0xac00) % 28 > 0;
4
+ }
5
+ var _f = [
6
+ function (string) {
7
+ return _hasJong(string) ? '을' : '를';
8
+ },
9
+ function (string) {
10
+ return _hasJong(string) ? '은' : '는';
11
+ },
12
+ function (string) {
13
+ return _hasJong(string) ? '이' : '가';
14
+ },
15
+ function (string) {
16
+ return _hasJong(string) ? '과' : '와';
17
+ },
18
+ function (string) {
19
+ return _hasJong(string) ? '으로' : '로';
20
+ },
21
+ function (string) {
22
+ return _hasJong(string) ? '이' : '';
23
+ },
24
+ ];
25
+ var _formats = {
26
+ '을/를': _f[0],
27
+ 을: _f[0],
28
+ 를: _f[0],
29
+ 을를: _f[0],
30
+ '은/는': _f[1],
31
+ 은: _f[1],
32
+ 는: _f[1],
33
+ 은는: _f[1],
34
+ '이/가': _f[2],
35
+ 이: _f[2],
36
+ 가: _f[2],
37
+ 이가: _f[2],
38
+ '와/과': _f[3],
39
+ 와: _f[3],
40
+ 과: _f[3],
41
+ 와과: _f[3],
42
+ '으로/로': _f[4],
43
+ 으로: _f[4],
44
+ 로: _f[4],
45
+ 으로로: _f[4],
46
+ '이/': _f[5],
47
+ };
48
+ export var josa = {
49
+ c: function (word, format) {
50
+ if (typeof _formats[format] === 'undefined')
51
+ throw 'Invalid format!';
52
+ return _formats[format](word);
53
+ },
54
+ r: function (word, format) {
55
+ return word + josa.c(word, format);
56
+ },
57
+ };
@@ -0,0 +1,19 @@
1
+ export function marshalJson(value) {
2
+ if (typeof value === 'string') {
3
+ return value;
4
+ }
5
+ return JSON.stringify(value);
6
+ }
7
+ export function unmarshalJson(raw) {
8
+ if (raw) {
9
+ if (/(^\{.*\}$|^\[.*\]$)/.test(raw)) {
10
+ try {
11
+ return JSON.parse(raw);
12
+ }
13
+ catch (error) {
14
+ return null;
15
+ }
16
+ }
17
+ }
18
+ return raw;
19
+ }
@@ -0,0 +1,27 @@
1
+ import { __awaiter, __generator } from "tslib";
2
+ var libSet = new Set();
3
+ export function loadOuterScript(url) {
4
+ return __awaiter(this, void 0, void 0, function () {
5
+ return __generator(this, function (_a) {
6
+ if (libSet.has(url)) {
7
+ return [2, true];
8
+ }
9
+ return [2, new Promise(function (resolve, reject) {
10
+ var script = document.createElement('script');
11
+ try {
12
+ script.src = url;
13
+ script.type = 'text/javascript';
14
+ script.async = true;
15
+ document.body.appendChild(script);
16
+ script.onload = function () {
17
+ libSet.add(url);
18
+ resolve(true);
19
+ };
20
+ }
21
+ catch (error) {
22
+ reject(false);
23
+ }
24
+ })];
25
+ });
26
+ });
27
+ }
@@ -0,0 +1,16 @@
1
+ import { qs } from './queryString';
2
+ export function getFileName(url) {
3
+ try {
4
+ return url.substring(url.lastIndexOf('/') + 1).split('?')[0];
5
+ }
6
+ catch (error) {
7
+ return url;
8
+ }
9
+ }
10
+ export function parseQueryString(url) {
11
+ return qs.parse(url);
12
+ }
13
+ export function serializeToQueryString(params, withQuestionMark) {
14
+ if (withQuestionMark === void 0) { withQuestionMark = false; }
15
+ return qs.serialize(params, withQuestionMark);
16
+ }
@@ -0,0 +1,62 @@
1
+ import { isNullable, isObject } from './typeCheck';
2
+ function _serialize(params, parentKey) {
3
+ if (parentKey === void 0) { parentKey = ''; }
4
+ return Object.entries(params).reduce(function (acc, _a) {
5
+ var oriKey = _a[0], value = _a[1];
6
+ var key = parentKey ? "".concat(parentKey, "%5B").concat(oriKey, "%5D") : oriKey;
7
+ var ret = acc + (acc.length > 1 ? '&' : '');
8
+ if (isObject(value)) {
9
+ ret += _serialize(value, key);
10
+ }
11
+ else {
12
+ ret =
13
+ ret +
14
+ key +
15
+ '=' +
16
+ encodeURIComponent(isNullable(value) || Number.isNaN(value) ? '' : value);
17
+ }
18
+ return ret;
19
+ }, '');
20
+ }
21
+ var cache = new Map();
22
+ export var qs = {
23
+ parse: function (url) {
24
+ var _a;
25
+ if (cache.has(url)) {
26
+ return cache.get(url);
27
+ }
28
+ cache.clear();
29
+ var result = {};
30
+ try {
31
+ var queryString = url.split('?')[1];
32
+ var splittedQueries = queryString.split('&');
33
+ var len = splittedQueries.length;
34
+ var key = '';
35
+ var value = '';
36
+ for (var i = 0; i < len; i++) {
37
+ _a = splittedQueries[i].split('='), key = _a[0], value = _a[1];
38
+ result[key] = decodeURIComponent(value);
39
+ }
40
+ }
41
+ catch (error) {
42
+ }
43
+ cache.set(url, result);
44
+ return result;
45
+ },
46
+ serialize: function (params, withQuestionMark) {
47
+ if (withQuestionMark === void 0) { withQuestionMark = false; }
48
+ if (!isObject(params)) {
49
+ throw new Error("serializeToQueryString: params is not object.\n".concat(params ? JSON.stringify(params) : params));
50
+ }
51
+ return (withQuestionMark ? '?' : '') + _serialize(params);
52
+ },
53
+ append: function (search, data) {
54
+ if (!search) {
55
+ return qs.serialize(data, true);
56
+ }
57
+ if (search.length >= 1 && search[0] === '?') {
58
+ return "".concat(search, "&").concat(qs.serialize(data));
59
+ }
60
+ throw new Error("qs.append : \"".concat(search, "\" is invalid search string."));
61
+ },
62
+ };
@@ -0,0 +1,6 @@
1
+ import { __assign } from "tslib";
2
+ export function clearMessageBy(errorMessages, name) {
3
+ var result = __assign({}, errorMessages);
4
+ delete result[name];
5
+ return result;
6
+ }
@@ -0,0 +1,65 @@
1
+ import { isEmptyObject } from './typeCheck';
2
+ import { josa } from './josa';
3
+ function getJosaRegexp() {
4
+ return /^(을\/를|을|를|을를|은\/는|은|는|은는|이\/가|이|가|이가|와\/과|와|과|와과|으로\/로|으로|로|으로로|이\/)$/;
5
+ }
6
+ function parse(value) {
7
+ var arr = [];
8
+ var template = value;
9
+ var result = /{(.*?)}/g.exec(template);
10
+ var firstPos = -1;
11
+ while (result) {
12
+ firstPos = result.index;
13
+ if (firstPos !== 0) {
14
+ arr.push(template.substring(0, firstPos));
15
+ template = template.slice(firstPos);
16
+ }
17
+ arr.push(result[0]);
18
+ template = template.slice(result[0].length);
19
+ result = /{(.*?)}/g.exec(template);
20
+ }
21
+ if (template) {
22
+ arr.push(template);
23
+ }
24
+ return arr;
25
+ }
26
+ function compileToString(arr) {
27
+ var result = ['\'\''];
28
+ result = arr.reduce(function (acc, tmp) {
29
+ var subTmp = '';
30
+ if (tmp.startsWith('{') && tmp.endsWith('}')) {
31
+ subTmp = tmp.split(/\{|\}/).filter(Boolean)[0].trim();
32
+ if (getJosaRegexp().test(subTmp) && acc.latestTmp) {
33
+ acc.result.push("+j.c(d.".concat(acc.latestTmp, ",'").concat(subTmp, "')"));
34
+ }
35
+ else {
36
+ acc.result.push("+d.".concat(subTmp));
37
+ acc.latestTmp = subTmp;
38
+ }
39
+ }
40
+ else {
41
+ acc.result.push("+'".concat(tmp.replace(/\n/gm, '\\n'), "'"));
42
+ }
43
+ return acc;
44
+ }, { result: result, latestTmp: '' }).result;
45
+ return result.join('');
46
+ }
47
+ var compiledFns = {};
48
+ export function messageTemplate(tmplText, data) {
49
+ if (!tmplText || !data || isEmptyObject(data)) {
50
+ return '';
51
+ }
52
+ if (Array.isArray(data)) {
53
+ throw new Error('messageTemplate: The "data" argument cannot be an array.');
54
+ }
55
+ var fn = compiledFns[tmplText];
56
+ if (!fn) {
57
+ fn = new Function('d', 'j', "return ".concat(compileToString(messageTemplate.parse(tmplText))));
58
+ compiledFns[tmplText] = fn;
59
+ }
60
+ return fn(data, josa);
61
+ }
62
+ messageTemplate.parse = parse;
63
+ messageTemplate.clear = function () {
64
+ compiledFns = {};
65
+ };
@@ -0,0 +1,33 @@
1
+ export function isUndefined(val) {
2
+ return typeof val === 'undefined';
3
+ }
4
+ export function isString(val) {
5
+ return Object.prototype.toString.call(val) === '[object String]';
6
+ }
7
+ export function isNullable(val) {
8
+ return (isUndefined(val) || val === null || val === 'undefined' || val === 'null');
9
+ }
10
+ export function isEmptyArray(val) {
11
+ return !Array.isArray(val) || val.length === 0;
12
+ }
13
+ export function isNumber(val) {
14
+ return Object.prototype.toString.call(val) === '[object Number]';
15
+ }
16
+ export function isNumberLike(val) {
17
+ if (isNumber(val)) {
18
+ return true;
19
+ }
20
+ if (isString(val)) {
21
+ return /^[0-9]+$/.test(val);
22
+ }
23
+ return false;
24
+ }
25
+ export function isEmptyObject(val) {
26
+ return val && Object.keys(val).length === 0 && val.constructor === Object;
27
+ }
28
+ export function isFunction(val) {
29
+ return Object.prototype.toString.call(val) === '[object Function]';
30
+ }
31
+ export function isObject(val) {
32
+ return Object.prototype.toString.call(val) === '[object Object]';
33
+ }
@@ -0,0 +1,66 @@
1
+ import { isNullable } from '../util/typeCheck';
2
+ function required(val) {
3
+ return !isNullable(val) && !!val;
4
+ }
5
+ var length = function (min, max) { return function (val) {
6
+ return required(val) && val.length >= min && val.length <= max;
7
+ }; };
8
+ function email(val) {
9
+ return (length(7, 100)(val) && /^(\w|-|\.)+@\w+([.-]?\w+)*(\.\w{2,5})+$/.test(val));
10
+ }
11
+ function passwordWeak(val) {
12
+ return /^(?=.*[A-z])(?=.*[0-9])(?=.{6,20})/.test(val);
13
+ }
14
+ function password(val) {
15
+ return /^(?=.*[A-z])(?=.*[~!@#$%^&*()\-=+_';<>/.`:"\\,[\]?|{}])(?=.*[0-9]).{6,32}$/.test(val);
16
+ }
17
+ function lowercase(val) {
18
+ return /^(?=.*[a-z])/.test(val);
19
+ }
20
+ function uppercase(val) {
21
+ return /^(?=.*[A-Z])/.test(val);
22
+ }
23
+ function numbers(val) {
24
+ return /^(?=.*\d)/.test(val);
25
+ }
26
+ function symbols(val) {
27
+ return /^(?=.*[~!@#$%^&*()\-=+_';<>/.`:"\\,[\]?|{}])/.test(val);
28
+ }
29
+ function korAndEng(val) {
30
+ return /^([A-Za-z]|[가-힣]){2,100}$/.test(val);
31
+ }
32
+ function numberOnly(val) {
33
+ return /^[0-9]{1,}$/.test(val);
34
+ }
35
+ function range(min, max) {
36
+ return function innerRange(val) {
37
+ var num = Number(val);
38
+ return num >= min && num <= max;
39
+ };
40
+ }
41
+ function phoneWithDash(val) {
42
+ return /^(\d{4}-\d{4}|\d{2,3}-\d{3,4}-\d{3,4})$/.test(val);
43
+ }
44
+ function phone(val) {
45
+ return length(8, 11)(val) && numbers(val);
46
+ }
47
+ function companyRegNumber(val) {
48
+ return /^\d{3}-\d{2}-\d{5}$/.test(val);
49
+ }
50
+ export default {
51
+ required: required,
52
+ email: email,
53
+ passwordWeak: passwordWeak,
54
+ password: password,
55
+ lowercase: lowercase,
56
+ uppercase: uppercase,
57
+ numbers: numbers,
58
+ symbols: symbols,
59
+ korAndEng: korAndEng,
60
+ numberOnly: numberOnly,
61
+ range: range,
62
+ phoneWithDash: phoneWithDash,
63
+ phone: phone,
64
+ companyRegNumber: companyRegNumber,
65
+ length: length,
66
+ };
@@ -0,0 +1,7 @@
1
+ import { validate } from './validate';
2
+ import fn from './fn';
3
+ var validateFn = validate;
4
+ validateFn.fn = fn;
5
+ export default validateFn;
6
+ export * from './mergeValidates';
7
+ export * from './validate.type';
@@ -0,0 +1,22 @@
1
+ import { __assign } from "tslib";
2
+ import { validateSubUtils } from './validateSubUtils';
3
+ export function mergeValidates() {
4
+ var args = [];
5
+ for (var _i = 0; _i < arguments.length; _i++) {
6
+ args[_i] = arguments[_i];
7
+ }
8
+ if (args.length === 1) {
9
+ return args[0];
10
+ }
11
+ return args.reduce(function (acc, arg) {
12
+ acc.errorMessages = __assign(__assign({}, acc.errorMessages), arg.errorMessages);
13
+ if (arg.firstMessage && !acc.firstMessage) {
14
+ acc.firstMessage = arg.firstMessage;
15
+ }
16
+ Array.prototype.push.apply(acc.invalidKeys, arg.invalidKeys);
17
+ acc.isValid = acc.isValid && arg.isValid;
18
+ acc.results = __assign(__assign({}, acc.results), arg.results);
19
+ Array.prototype.push.apply(acc.validKeys, arg.validKeys);
20
+ return acc;
21
+ }, validateSubUtils.createValidateBulkResultModel());
22
+ }
@@ -0,0 +1,22 @@
1
+ import { validateSubUtils } from './validateSubUtils';
2
+ var createValidateBulkResultModel = validateSubUtils.createValidateBulkResultModel, validateBulk = validateSubUtils.validateBulk;
3
+ export function validate(state, opt) {
4
+ return Object.keys(opt).reduce(function (acc, key) {
5
+ var val = state[key];
6
+ var items = opt[key];
7
+ var _mRet = validateBulk(val, items);
8
+ acc.results[key] = _mRet;
9
+ acc.isValid = acc.isValid && _mRet.result;
10
+ if (_mRet.result) {
11
+ acc.validKeys.push(key);
12
+ }
13
+ else {
14
+ acc.invalidKeys.push(key);
15
+ acc.errorMessages[key] = _mRet.message;
16
+ if (!acc.firstMessage) {
17
+ acc.firstMessage = _mRet.message;
18
+ }
19
+ }
20
+ return acc;
21
+ }, createValidateBulkResultModel());
22
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,67 @@
1
+ function createValidateBulkResultModel() {
2
+ var result = {
3
+ isValid: true,
4
+ results: {},
5
+ validKeys: [],
6
+ invalidKeys: [],
7
+ firstMessage: '',
8
+ errorMessages: {},
9
+ };
10
+ return result;
11
+ }
12
+ function validateSingle(val, _a) {
13
+ var check = _a.check, message = _a.message;
14
+ var result = check(val);
15
+ var msg = !result ? message : '';
16
+ return {
17
+ result: result,
18
+ message: msg,
19
+ };
20
+ }
21
+ function checkIgnore(ignore, val) {
22
+ if (!ignore) {
23
+ return false;
24
+ }
25
+ return ignore === true || ignore(val);
26
+ }
27
+ function createValidateResultModel() {
28
+ return {
29
+ result: true,
30
+ message: '',
31
+ };
32
+ }
33
+ function validateBulk(val, opt) {
34
+ var mRes;
35
+ if (Array.isArray(opt)) {
36
+ if (opt.length > 0 && checkIgnore(opt[0].ignore, val)) {
37
+ return createValidateResultModel();
38
+ }
39
+ opt.every(function (_opt) {
40
+ var _mRes = validateSingle(val, _opt);
41
+ if (!_mRes.result) {
42
+ mRes = _mRes;
43
+ }
44
+ return _mRes.result;
45
+ });
46
+ }
47
+ else if (typeof opt === 'function') {
48
+ var tmpRes = opt(val);
49
+ mRes = {
50
+ result: tmpRes.isValid,
51
+ message: tmpRes.firstMessage,
52
+ };
53
+ }
54
+ else {
55
+ if (checkIgnore(opt.ignore, val)) {
56
+ return createValidateResultModel();
57
+ }
58
+ mRes = validateSingle(val, opt);
59
+ }
60
+ return mRes || createValidateResultModel();
61
+ }
62
+ export var validateSubUtils = {
63
+ createValidateBulkResultModel: createValidateBulkResultModel,
64
+ validateSingle: validateSingle,
65
+ validateBulk: validateBulk,
66
+ checkIgnore: checkIgnore,
67
+ };
@@ -0,0 +1,25 @@
1
+ import React, { ReactElement, ReactNode } from 'react';
2
+ interface Props {
3
+ /**
4
+ * 데스크탑에서만 보여질 컴포넌트
5
+ */
6
+ desktop?: ReactElement | ReactNode | boolean;
7
+ /**
8
+ * 모바일 에서만 보이는지의 여부. 기본 false
9
+ */
10
+ mobile?: boolean;
11
+ /**
12
+ * 태블릿일 때는 보이지 않음 여부. 기본 false
13
+ */
14
+ notTablet?: boolean;
15
+ }
16
+ /**
17
+ * 적응형으로 렌더링 할 때 쓰인다.
18
+ *
19
+ * 이 컴포넌트의 자식 요소는 기본적으로 모바일일 경우 렌더링 되지 않는다.
20
+ *
21
+ * 모바일일 경우에만 보이게 할 때는 mobile 프로퍼티를 적용 시키면 된다.
22
+ * @param props
23
+ */
24
+ export declare const AdaptiveRender: React.FC<Props>;
25
+ export {};
@@ -0,0 +1,16 @@
1
+ import React, { FC } from 'react';
2
+ export declare const DeviceDetectContext: React.Context<boolean[]>;
3
+ /**
4
+ * 컨텍스트: UserAgent 및 Resizing 여부에 따른 태블릿/모바일 여부를 판별 해 준다.
5
+ *
6
+ * 지정된 곳 이외에서는 사용치 않는다.
7
+ *
8
+ * 내부적으로 window.mediaQuery API를 사용한다.
9
+ *
10
+ * @see https://stackoverflow.com/questions/29046324/whats-the-most-reliable-way-to-integrate-javascript-with-media-queries
11
+ * @see https://jsperf.com/matchmedia-vs-resize/3
12
+ */
13
+ export declare const DeviceDetectProvider: FC;
14
+ export declare const useIsMobile: () => boolean;
15
+ export declare const useIsTablet: () => boolean;
16
+ export declare const useIsNative: () => boolean;