@sunggang/ui-lib 0.1.87 → 0.1.89

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/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- export { B as BaseTable, r as BigCalender, C as CkEditor, i as CustomUpload, l as DataTable, k as DateRangePicker, s as DnDCalendar, D as DropImage, R as ReactDateRange, m as Regex, S as Spin, j as Switch, U as UiLibrary, o as decryptByEcPay, p as encryptByEcPay, u as useLiff, q as useOnClickOutside, n as verifyId, v as verifyTaxId } from './index.esm2.js';
1
+ export { B as BaseTable, q as BigCalender, C as CkEditor, i as CustomUpload, l as DataTable, k as DateRangePicker, r as DnDCalendar, D as DropImage, R as ReactDateRange, m as Regex, S as Spin, j as Switch, U as UiLibrary, o as decryptByEcPay, p as encryptByEcPay, u as useLiff, n as verifyId, v as verifyTaxId } from './index.esm2.js';
2
2
  import 'react/jsx-runtime';
3
3
  import 'react';
4
4
  import '@iconify/react';
@@ -20,7 +20,6 @@ import 'date-fns/format/index.js';
20
20
  import '@tanstack/react-table';
21
21
  import '@radix-ui/react-dropdown-menu';
22
22
  import '@radix-ui/react-icons';
23
- import 'crypto';
24
23
  import 'util';
25
24
  import 'stream';
26
25
  import 'path';
@@ -33,3 +32,4 @@ import 'tty';
33
32
  import 'os';
34
33
  import 'zlib';
35
34
  import 'events';
35
+ import 'crypto';
package/index.esm2.js CHANGED
@@ -20,7 +20,6 @@ import format$1 from 'date-fns/format/index.js';
20
20
  import { useReactTable, getCoreRowModel, getPaginationRowModel, getSortedRowModel, getFilteredRowModel, flexRender } from '@tanstack/react-table';
21
21
  import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
22
22
  import { ChevronRightIcon, CheckIcon, DotFilledIcon } from '@radix-ui/react-icons';
23
- import crypto$1 from 'crypto';
24
23
  import require$$1, { TextEncoder as TextEncoder$1 } from 'util';
25
24
  import stream, { Readable } from 'stream';
26
25
  import require$$1$1 from 'path';
@@ -33,6 +32,7 @@ import require$$1$2 from 'tty';
33
32
  import require$$0$2 from 'os';
34
33
  import zlib from 'zlib';
35
34
  import { EventEmitter } from 'events';
35
+ import crypto$1 from 'crypto';
36
36
 
37
37
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
38
38
  function getDefaultExportFromCjs(x) {
@@ -81937,148 +81937,6 @@ var Regex = {
81937
81937
  carrier: carrier
81938
81938
  };
81939
81939
 
81940
- var verifyTaiwanIdIntermediateString = function(input) {
81941
- var idArray = input.split("");
81942
- var intRadix = 10;
81943
- var TAIWAN_ID_LOCALE_CODE_LIST = [
81944
- 1,
81945
- 10,
81946
- 19,
81947
- 28,
81948
- 37,
81949
- 46,
81950
- 55,
81951
- 64,
81952
- 39,
81953
- 73,
81954
- 82,
81955
- 2,
81956
- 11,
81957
- 20,
81958
- 48,
81959
- 29,
81960
- 38,
81961
- 47,
81962
- 56,
81963
- 65,
81964
- 74,
81965
- 83,
81966
- 21,
81967
- 3,
81968
- 12,
81969
- 30
81970
- ];
81971
- var RESIDENT_CERTIFICATE_NUMBER_LIST = [
81972
- "0",
81973
- "1",
81974
- "2",
81975
- "3",
81976
- "4",
81977
- "5",
81978
- "6",
81979
- "7",
81980
- "4",
81981
- "8",
81982
- "9",
81983
- "0",
81984
- "1",
81985
- "2",
81986
- "5",
81987
- "3",
81988
- "4",
81989
- "5",
81990
- "6",
81991
- "7",
81992
- "8",
81993
- "9",
81994
- "2",
81995
- "0",
81996
- "1",
81997
- "3"
81998
- ];
81999
- // if is not a number (居留證編號)
82000
- // eslint-disable-next-line no-restricted-globals
82001
- if (isNaN(parseInt(idArray[1], intRadix))) {
82002
- idArray[1] = RESIDENT_CERTIFICATE_NUMBER_LIST[input.charCodeAt(1) - "A".charCodeAt(0)];
82003
- }
82004
- var result = idArray.reduce(function(sum, n, index) {
82005
- if (index === 0) {
82006
- return sum + TAIWAN_ID_LOCALE_CODE_LIST[idArray[0].charCodeAt(0) - "A".charCodeAt(0)];
82007
- }
82008
- if (index === 9) {
82009
- return sum + parseInt(idArray[9], intRadix);
82010
- }
82011
- return sum + parseInt(idArray[index], intRadix) * (9 - index);
82012
- }, 0);
82013
- if (result % 10 === 0) {
82014
- return true;
82015
- }
82016
- return false;
82017
- };
82018
- var verifyId = function(input) {
82019
- var regex = /^[A-Z][1,2,8,9]\d{8}$/;
82020
- if (!regex.test(input)) {
82021
- return false;
82022
- }
82023
- return verifyTaiwanIdIntermediateString(input);
82024
- };
82025
- var verifyTaxId = function(idStr) {
82026
- var regex = /^\d{8}$/;
82027
- if (!regex.test(idStr)) {
82028
- console.log("Fail, 長度錯誤");
82029
- return false;
82030
- }
82031
- var len = 8;
82032
- var idArray = new Array(len);
82033
- var weight = [
82034
- 1,
82035
- 2,
82036
- 1,
82037
- 2,
82038
- 1,
82039
- 2,
82040
- 4,
82041
- 1
82042
- ];
82043
- var sum = 0;
82044
- // eslint-disable-next-line no-plusplus
82045
- for(var i = 0; i < len; i++){
82046
- idArray[i] = parseInt(idStr[i], 10);
82047
- var p = idArray[i] * weight[i];
82048
- var s = Math.floor(p / 10) + p % 10;
82049
- sum += s;
82050
- }
82051
- var checkNumber = 5;
82052
- var isLegal = sum % checkNumber === 0 || (sum + 1) % checkNumber === 0 && idArray[6] === 7;
82053
- if (!isLegal) {
82054
- console.log("Fail, 不合法的統一編號驗證");
82055
- }
82056
- return isLegal;
82057
- };
82058
-
82059
- var decryptByEcPay = function(data, hashKey, hashIV) {
82060
- var decipher = crypto$1.createDecipheriv("aes-128-cbc", Buffer.from(hashKey), Buffer.from(hashIV));
82061
- decipher.setAutoPadding(true); // 使用 PKCS7 填充模式
82062
- var decrypted = decipher.update(data, "base64", "utf8");
82063
- decrypted += decipher.final("utf8");
82064
- // 步驟 3: 解析解密後的資料
82065
- var decodedData = decodeURIComponent(decrypted);
82066
- var decoded = JSON.parse(decodedData);
82067
- return decoded;
82068
- };
82069
- var encryptByEcPay = function(data, hashKey, hashIV) {
82070
- // 步驟 1: 轉換資料為 JSON 字串
82071
- var jsonData = JSON.stringify(data);
82072
- // 步驟 2: URLEncode 編碼
82073
- var urlEncodedData = window.encodeURIComponent(jsonData);
82074
- // 步驟 3: AES 加密
82075
- var cipher = crypto$1.createCipheriv("aes-128-cbc", Buffer.from(hashKey), Buffer.from(hashIV));
82076
- cipher.setAutoPadding(true); // 使用 PKCS7 填充模式
82077
- var encrypted = cipher.update(urlEncodedData, "utf8", "base64");
82078
- encrypted += cipher.final("base64");
82079
- return encrypted;
82080
- };
82081
-
82082
81940
  function bind(fn, thisArg) {
82083
81941
  return function wrap() {
82084
81942
  return fn.apply(thisArg, arguments);
@@ -102792,25 +102650,147 @@ var useLiff = function(publickLiffId, localStorageToken, loginFunc, checkTokenUr
102792
102650
  };
102793
102651
  };
102794
102652
 
102795
- function useOnClickOutside(ref, handler) {
102796
- useEffect(function() {
102797
- var listener = function(event) {
102798
- if (!ref.current || ref.current.contains(event.target)) {
102799
- return;
102800
- }
102801
- handler(event);
102802
- };
102803
- document.addEventListener("mousedown", listener);
102804
- document.addEventListener("touchstart", listener);
102805
- return function() {
102806
- document.removeEventListener("mousedown", listener);
102807
- document.removeEventListener("touchstart", listener);
102808
- };
102809
- }, [
102810
- ref,
102811
- handler
102812
- ]);
102813
- }
102653
+ var verifyTaiwanIdIntermediateString = function(input) {
102654
+ var idArray = input.split("");
102655
+ var intRadix = 10;
102656
+ var TAIWAN_ID_LOCALE_CODE_LIST = [
102657
+ 1,
102658
+ 10,
102659
+ 19,
102660
+ 28,
102661
+ 37,
102662
+ 46,
102663
+ 55,
102664
+ 64,
102665
+ 39,
102666
+ 73,
102667
+ 82,
102668
+ 2,
102669
+ 11,
102670
+ 20,
102671
+ 48,
102672
+ 29,
102673
+ 38,
102674
+ 47,
102675
+ 56,
102676
+ 65,
102677
+ 74,
102678
+ 83,
102679
+ 21,
102680
+ 3,
102681
+ 12,
102682
+ 30
102683
+ ];
102684
+ var RESIDENT_CERTIFICATE_NUMBER_LIST = [
102685
+ "0",
102686
+ "1",
102687
+ "2",
102688
+ "3",
102689
+ "4",
102690
+ "5",
102691
+ "6",
102692
+ "7",
102693
+ "4",
102694
+ "8",
102695
+ "9",
102696
+ "0",
102697
+ "1",
102698
+ "2",
102699
+ "5",
102700
+ "3",
102701
+ "4",
102702
+ "5",
102703
+ "6",
102704
+ "7",
102705
+ "8",
102706
+ "9",
102707
+ "2",
102708
+ "0",
102709
+ "1",
102710
+ "3"
102711
+ ];
102712
+ // if is not a number (居留證編號)
102713
+ // eslint-disable-next-line no-restricted-globals
102714
+ if (isNaN(parseInt(idArray[1], intRadix))) {
102715
+ idArray[1] = RESIDENT_CERTIFICATE_NUMBER_LIST[input.charCodeAt(1) - "A".charCodeAt(0)];
102716
+ }
102717
+ var result = idArray.reduce(function(sum, n, index) {
102718
+ if (index === 0) {
102719
+ return sum + TAIWAN_ID_LOCALE_CODE_LIST[idArray[0].charCodeAt(0) - "A".charCodeAt(0)];
102720
+ }
102721
+ if (index === 9) {
102722
+ return sum + parseInt(idArray[9], intRadix);
102723
+ }
102724
+ return sum + parseInt(idArray[index], intRadix) * (9 - index);
102725
+ }, 0);
102726
+ if (result % 10 === 0) {
102727
+ return true;
102728
+ }
102729
+ return false;
102730
+ };
102731
+ var verifyId = function(input) {
102732
+ var regex = /^[A-Z][1,2,8,9]\d{8}$/;
102733
+ if (!regex.test(input)) {
102734
+ return false;
102735
+ }
102736
+ return verifyTaiwanIdIntermediateString(input);
102737
+ };
102738
+ var verifyTaxId = function(idStr) {
102739
+ var regex = /^\d{8}$/;
102740
+ if (!regex.test(idStr)) {
102741
+ console.log("Fail, 長度錯誤");
102742
+ return false;
102743
+ }
102744
+ var len = 8;
102745
+ var idArray = new Array(len);
102746
+ var weight = [
102747
+ 1,
102748
+ 2,
102749
+ 1,
102750
+ 2,
102751
+ 1,
102752
+ 2,
102753
+ 4,
102754
+ 1
102755
+ ];
102756
+ var sum = 0;
102757
+ // eslint-disable-next-line no-plusplus
102758
+ for(var i = 0; i < len; i++){
102759
+ idArray[i] = parseInt(idStr[i], 10);
102760
+ var p = idArray[i] * weight[i];
102761
+ var s = Math.floor(p / 10) + p % 10;
102762
+ sum += s;
102763
+ }
102764
+ var checkNumber = 5;
102765
+ var isLegal = sum % checkNumber === 0 || (sum + 1) % checkNumber === 0 && idArray[6] === 7;
102766
+ if (!isLegal) {
102767
+ console.log("Fail, 不合法的統一編號驗證");
102768
+ }
102769
+ return isLegal;
102770
+ };
102771
+
102772
+ var decryptByEcPay = function(data, hashKey, hashIV) {
102773
+ var decipher = crypto$1.createDecipheriv("aes-128-cbc", Buffer.from(hashKey), Buffer.from(hashIV));
102774
+ decipher.setAutoPadding(true); // 使用 PKCS7 填充模式
102775
+ var decrypted = decipher.update(data, "base64", "utf8");
102776
+ decrypted += decipher.final("utf8");
102777
+ // 步驟 3: 解析解密後的資料
102778
+ var decodedData = decodeURIComponent(decrypted);
102779
+ var decoded = JSON.parse(decodedData);
102780
+ return decoded;
102781
+ };
102782
+ var encryptByEcPay = function(data, hashKey, hashIV) {
102783
+ // 步驟 1: 轉換資料為 JSON 字串
102784
+ var jsonData = JSON.stringify(data);
102785
+ // 步驟 2: URLEncode 編碼
102786
+ var urlEncodedData = window.encodeURIComponent(jsonData);
102787
+ // 步驟 3: AES 加密
102788
+ var cipher = crypto$1.createCipheriv("aes-128-cbc", Buffer.from(hashKey), Buffer.from(hashIV));
102789
+ cipher.setAutoPadding(true); // 使用 PKCS7 填充模式
102790
+ var encrypted = cipher.update(urlEncodedData, "utf8", "base64");
102791
+ encrypted += cipher.final("base64");
102792
+ return encrypted;
102793
+ };
102814
102794
 
102815
102795
  function _objectWithoutProperties(e, t) {
102816
102796
  if (null == e) return {};
@@ -123174,4 +123154,4 @@ function DnDCalendar(props) {
123174
123154
  });
123175
123155
  }
123176
123156
 
123177
- export { BaseTable as B, CkEditor as C, DropImage as D, ReactDateRange as R, Spin as S, UiLibrary as U, __spreadArray as _, __read as a, __extends as b, __assign as c, __makeTemplateObject as d, __awaiter as e, __generator as f, commonjsGlobal as g, __values as h, CustomUpload as i, Switch as j, DateRangePicker as k, DataTable as l, Regex as m, verifyId as n, decryptByEcPay as o, encryptByEcPay as p, useOnClickOutside as q, BigCalender as r, DnDCalendar as s, useLiff as u, verifyTaxId as v };
123157
+ export { BaseTable as B, CkEditor as C, DropImage as D, ReactDateRange as R, Spin as S, UiLibrary as U, __spreadArray as _, __read as a, __extends as b, __assign as c, __makeTemplateObject as d, __awaiter as e, __generator as f, commonjsGlobal as g, __values as h, CustomUpload as i, Switch as j, DateRangePicker as k, DataTable as l, Regex as m, verifyId as n, decryptByEcPay as o, encryptByEcPay as p, BigCalender as q, DnDCalendar as r, useLiff as u, verifyTaxId as v };
package/index.esm3.js CHANGED
@@ -20,7 +20,6 @@ import 'date-fns/format/index.js';
20
20
  import '@tanstack/react-table';
21
21
  import '@radix-ui/react-dropdown-menu';
22
22
  import '@radix-ui/react-icons';
23
- import 'crypto';
24
23
  import 'util';
25
24
  import 'stream';
26
25
  import 'path';
@@ -33,6 +32,7 @@ import 'tty';
33
32
  import 'os';
34
33
  import 'zlib';
35
34
  import 'events';
35
+ import 'crypto';
36
36
 
37
37
  /* eslint-disable no-prototype-builtins */ function _instanceof$4(left, right) {
38
38
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sunggang/ui-lib",
3
- "version": "0.1.87",
3
+ "version": "0.1.89",
4
4
  "dependencies": {
5
5
  "@iconify/react": "^4.1.1",
6
6
  "@mdx-js/react": "^3.0.1",
package/src/index.d.ts CHANGED
@@ -11,6 +11,5 @@ export * from './components/ui/reactDateRange';
11
11
  export * from './lib/DataTable';
12
12
  export * from './lib/DataTable/BaseTable';
13
13
  export * from './lib/Function';
14
- export * from './utils/hooks';
15
14
  export * from './lib/BigCalender';
16
15
  export * from './lib/BigCalender/dnd';
@@ -0,0 +1,26 @@
1
+ interface LoginAuth {
2
+ status?: boolean;
3
+ data?: {
4
+ access_token?: string;
5
+ };
6
+ }
7
+ interface UserInfo {
8
+ [key: string]: any;
9
+ }
10
+ interface Liff {
11
+ init: (options: {
12
+ liffId: string;
13
+ withLoginOnExternalBrowser?: boolean;
14
+ }) => Promise<void>;
15
+ getAccessToken: () => string | null;
16
+ login: () => void;
17
+ }
18
+ interface UseLiffResult {
19
+ liffObject: Liff | null;
20
+ liffError: string | null;
21
+ token: string;
22
+ userInfo: UserInfo | null;
23
+ loginAuth: LoginAuth | null;
24
+ }
25
+ declare const useLiff: (publickLiffId: string, localStorageToken: string, loginFunc: (loginToken: string) => string, checkTokenUrl: string, memberInfoUrl: string) => UseLiffResult;
26
+ export default useLiff;
@@ -1,4 +1,5 @@
1
1
  import Regex from './Regex';
2
- export { Regex };
2
+ import useLiff from './Hook/useLiff';
3
+ export { Regex, useLiff };
3
4
  export { verifyTaxId, verifyId } from './verify';
4
5
  export * from './crypto';