@authme/util 2.8.3 → 2.8.4

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.cjs CHANGED
@@ -835,7 +835,9 @@ function debugTools() {
835
835
  const debugImage = yield getDebugImageData(data);
836
836
  // 創建一個虛擬的 canvas
837
837
  const canvas = document.createElement('canvas');
838
- const ctx = canvas.getContext('2d');
838
+ const ctx = canvas.getContext('2d', {
839
+ willReadFrequently: true
840
+ });
839
841
  // 設置 canvas 的尺寸
840
842
  canvas.width = width;
841
843
  canvas.height = height;
@@ -916,7 +918,9 @@ function getImageData(canvas, ctx, video, sizeInfo, base64 = false, imageType =
916
918
  }
917
919
 
918
920
  function clearCanvas(canvas) {
919
- const ctx = canvas.getContext('2d');
921
+ const ctx = canvas.getContext('2d', {
922
+ willReadFrequently: true
923
+ });
920
924
  ctx.clearRect(0, 0, canvas.width, canvas.height);
921
925
  }
922
926
 
@@ -1030,12 +1034,19 @@ const uiThemeHint = (dom, hintStyle) => {
1030
1034
  dom.style.fontWeight = fontWeight[hintStyle.textWeight];
1031
1035
  dom.style.fontSize = `${hintStyle.fontSize}px`;
1032
1036
  };
1033
- const uiThemeButton = (dom, buttonStyle) => {
1034
- dom.style.borderRadius = `${buttonStyle.cornerRadius}px`;
1035
- dom.style.backgroundColor = buttonStyle.backgroundColor;
1037
+ const uiThemeButton = (dom, buttonStyle, disabled) => {
1036
1038
  dom.style.opacity = buttonStyle.backgroundOpacity;
1037
- dom.style.color = buttonStyle.textColor;
1038
- dom.style.borderColor = hexToRgba(buttonStyle.borderColor, buttonStyle.borderOpacity);
1039
+ if (disabled) {
1040
+ dom.style.color = buttonStyle.disabledTextColor;
1041
+ dom.style.borderRadius = `${buttonStyle.cornerRadius}px`;
1042
+ dom.style.backgroundColor = buttonStyle.disabledBackgroundColor;
1043
+ dom.style.borderColor = hexToRgba(buttonStyle.disabledBorderColor, buttonStyle.borderOpacity);
1044
+ } else {
1045
+ dom.style.color = buttonStyle.textColor;
1046
+ dom.style.borderRadius = `${buttonStyle.cornerRadius}px`;
1047
+ dom.style.backgroundColor = buttonStyle.backgroundColor;
1048
+ dom.style.borderColor = hexToRgba(buttonStyle.borderColor, buttonStyle.borderOpacity);
1049
+ }
1039
1050
  dom.style.borderWidth = `${buttonStyle.borderWidth}px`;
1040
1051
  dom.style.fontWeight = fontWeight[buttonStyle.textWeight];
1041
1052
  dom.style.fontSize = `${buttonStyle.fontSize}px`;
@@ -2675,6 +2686,46 @@ const uploadModal = arg => {
2675
2686
  };
2676
2687
  };
2677
2688
 
2689
+ const dropMenu = function dropMenu(dom, callback) {
2690
+ if (!dom) {
2691
+ console.error('dom is required');
2692
+ return;
2693
+ }
2694
+ const ul = dom.querySelector('ul');
2695
+ const ulSection = dom.querySelector('section');
2696
+ const list = dom.querySelectorAll('li');
2697
+ dom.querySelector('.drop_menu_title').addEventListener('click', function (e) {
2698
+ e.stopPropagation();
2699
+ ulSection.classList.toggle('hide');
2700
+ dom.querySelector('.drop_menu_title').classList.toggle('focus');
2701
+ });
2702
+ for (let i = 0; i < list.length; i++) {
2703
+ const element = list[i];
2704
+ element.addEventListener('click', function (e) {
2705
+ e.stopPropagation();
2706
+ if (ul.querySelector('.active')) {
2707
+ ul.querySelector('.active').classList.remove('active');
2708
+ }
2709
+ this.classList.add('active');
2710
+ dom.querySelector('.drop_menu_title span').innerText = this.innerText.trim();
2711
+ if (callback) {
2712
+ callback(this);
2713
+ }
2714
+ ulSection.classList.toggle('hide');
2715
+ dom.querySelector('.drop_menu_title').classList.toggle('focus');
2716
+ });
2717
+ }
2718
+ window.addEventListener('click', function (e) {
2719
+ e.stopPropagation();
2720
+ if (!ulSection.classList.contains('hide')) {
2721
+ ulSection.classList.add('hide');
2722
+ }
2723
+ if (dom.querySelector('.drop_menu_title').classList.contains('focus')) {
2724
+ dom.querySelector('.drop_menu_title').classList.remove('focus');
2725
+ }
2726
+ });
2727
+ };
2728
+
2678
2729
  const QUEUE_LENGTH = 10;
2679
2730
  const requstQueue = [];
2680
2731
  function pushRequest(request) {
@@ -2978,12 +3029,33 @@ const themeConfigDefault = {
2978
3029
  textColor: '#E0E0E0',
2979
3030
  textWeight: 'regular',
2980
3031
  fontSize: 12
3032
+ },
3033
+ resultTitle: {
3034
+ // G.6
3035
+ // Figma標示resultPage_text_title
3036
+ textColor: '#25608A',
3037
+ textWeight: 'medium',
3038
+ fontSize: 22
3039
+ },
3040
+ resultBody: {
3041
+ // G.7
3042
+ // Figma標示resultPage_text_body
3043
+ textColor: '#757575',
3044
+ textWeight: 'regular',
3045
+ fontSize: 14
3046
+ },
3047
+ resultTime: {
3048
+ // G.8
3049
+ // Figma標示resultPage_timeText
3050
+ textColor: '#FF3B30',
3051
+ textWeight: 'medium',
3052
+ fontSize: 16
2981
3053
  }
2982
3054
  };
2983
3055
 
2984
3056
  var name = "authme/sdk";
2985
- var version$1 = "2.8.3";
2986
- var date = "2025-03-05T06:16:55+0000";
3057
+ var version$1 = "2.8.4";
3058
+ var date = "2025-03-13T06:47:53+0000";
2987
3059
  var packageInfo = {
2988
3060
  name: name,
2989
3061
  version: version$1,
@@ -3014,6 +3086,7 @@ exports.dataURItoBlob = dataURItoBlob;
3014
3086
  exports.debugLog = debugLog;
3015
3087
  exports.debugTools = debugTools;
3016
3088
  exports.decodeToken = decodeToken;
3089
+ exports.dropMenu = dropMenu;
3017
3090
  exports.fontWeight = fontWeight;
3018
3091
  exports.getCanvasSize = getCanvasSize;
3019
3092
  exports.getCssVariable = getCssVariable;
package/index.js CHANGED
@@ -825,7 +825,9 @@ function debugTools() {
825
825
  const debugImage = yield getDebugImageData(data);
826
826
  // 創建一個虛擬的 canvas
827
827
  const canvas = document.createElement('canvas');
828
- const ctx = canvas.getContext('2d');
828
+ const ctx = canvas.getContext('2d', {
829
+ willReadFrequently: true
830
+ });
829
831
  // 設置 canvas 的尺寸
830
832
  canvas.width = width;
831
833
  canvas.height = height;
@@ -906,7 +908,9 @@ function getImageData(canvas, ctx, video, sizeInfo, base64 = false, imageType =
906
908
  }
907
909
 
908
910
  function clearCanvas(canvas) {
909
- const ctx = canvas.getContext('2d');
911
+ const ctx = canvas.getContext('2d', {
912
+ willReadFrequently: true
913
+ });
910
914
  ctx.clearRect(0, 0, canvas.width, canvas.height);
911
915
  }
912
916
 
@@ -1020,12 +1024,19 @@ const uiThemeHint = (dom, hintStyle) => {
1020
1024
  dom.style.fontWeight = fontWeight[hintStyle.textWeight];
1021
1025
  dom.style.fontSize = `${hintStyle.fontSize}px`;
1022
1026
  };
1023
- const uiThemeButton = (dom, buttonStyle) => {
1024
- dom.style.borderRadius = `${buttonStyle.cornerRadius}px`;
1025
- dom.style.backgroundColor = buttonStyle.backgroundColor;
1027
+ const uiThemeButton = (dom, buttonStyle, disabled) => {
1026
1028
  dom.style.opacity = buttonStyle.backgroundOpacity;
1027
- dom.style.color = buttonStyle.textColor;
1028
- dom.style.borderColor = hexToRgba(buttonStyle.borderColor, buttonStyle.borderOpacity);
1029
+ if (disabled) {
1030
+ dom.style.color = buttonStyle.disabledTextColor;
1031
+ dom.style.borderRadius = `${buttonStyle.cornerRadius}px`;
1032
+ dom.style.backgroundColor = buttonStyle.disabledBackgroundColor;
1033
+ dom.style.borderColor = hexToRgba(buttonStyle.disabledBorderColor, buttonStyle.borderOpacity);
1034
+ } else {
1035
+ dom.style.color = buttonStyle.textColor;
1036
+ dom.style.borderRadius = `${buttonStyle.cornerRadius}px`;
1037
+ dom.style.backgroundColor = buttonStyle.backgroundColor;
1038
+ dom.style.borderColor = hexToRgba(buttonStyle.borderColor, buttonStyle.borderOpacity);
1039
+ }
1029
1040
  dom.style.borderWidth = `${buttonStyle.borderWidth}px`;
1030
1041
  dom.style.fontWeight = fontWeight[buttonStyle.textWeight];
1031
1042
  dom.style.fontSize = `${buttonStyle.fontSize}px`;
@@ -2665,6 +2676,46 @@ const uploadModal = arg => {
2665
2676
  };
2666
2677
  };
2667
2678
 
2679
+ const dropMenu = function dropMenu(dom, callback) {
2680
+ if (!dom) {
2681
+ console.error('dom is required');
2682
+ return;
2683
+ }
2684
+ const ul = dom.querySelector('ul');
2685
+ const ulSection = dom.querySelector('section');
2686
+ const list = dom.querySelectorAll('li');
2687
+ dom.querySelector('.drop_menu_title').addEventListener('click', function (e) {
2688
+ e.stopPropagation();
2689
+ ulSection.classList.toggle('hide');
2690
+ dom.querySelector('.drop_menu_title').classList.toggle('focus');
2691
+ });
2692
+ for (let i = 0; i < list.length; i++) {
2693
+ const element = list[i];
2694
+ element.addEventListener('click', function (e) {
2695
+ e.stopPropagation();
2696
+ if (ul.querySelector('.active')) {
2697
+ ul.querySelector('.active').classList.remove('active');
2698
+ }
2699
+ this.classList.add('active');
2700
+ dom.querySelector('.drop_menu_title span').innerText = this.innerText.trim();
2701
+ if (callback) {
2702
+ callback(this);
2703
+ }
2704
+ ulSection.classList.toggle('hide');
2705
+ dom.querySelector('.drop_menu_title').classList.toggle('focus');
2706
+ });
2707
+ }
2708
+ window.addEventListener('click', function (e) {
2709
+ e.stopPropagation();
2710
+ if (!ulSection.classList.contains('hide')) {
2711
+ ulSection.classList.add('hide');
2712
+ }
2713
+ if (dom.querySelector('.drop_menu_title').classList.contains('focus')) {
2714
+ dom.querySelector('.drop_menu_title').classList.remove('focus');
2715
+ }
2716
+ });
2717
+ };
2718
+
2668
2719
  const QUEUE_LENGTH = 10;
2669
2720
  const requstQueue = [];
2670
2721
  function pushRequest(request) {
@@ -2968,12 +3019,33 @@ const themeConfigDefault = {
2968
3019
  textColor: '#E0E0E0',
2969
3020
  textWeight: 'regular',
2970
3021
  fontSize: 12
3022
+ },
3023
+ resultTitle: {
3024
+ // G.6
3025
+ // Figma標示resultPage_text_title
3026
+ textColor: '#25608A',
3027
+ textWeight: 'medium',
3028
+ fontSize: 22
3029
+ },
3030
+ resultBody: {
3031
+ // G.7
3032
+ // Figma標示resultPage_text_body
3033
+ textColor: '#757575',
3034
+ textWeight: 'regular',
3035
+ fontSize: 14
3036
+ },
3037
+ resultTime: {
3038
+ // G.8
3039
+ // Figma標示resultPage_timeText
3040
+ textColor: '#FF3B30',
3041
+ textWeight: 'medium',
3042
+ fontSize: 16
2971
3043
  }
2972
3044
  };
2973
3045
 
2974
3046
  var name = "authme/sdk";
2975
- var version$1 = "2.8.3";
2976
- var date = "2025-03-05T06:16:55+0000";
3047
+ var version$1 = "2.8.4";
3048
+ var date = "2025-03-13T06:47:53+0000";
2977
3049
  var packageInfo = {
2978
3050
  name: name,
2979
3051
  version: version$1,
@@ -2986,4 +3058,4 @@ const version = packageInfo.version;
2986
3058
  (_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
2987
3059
  window[Symbol.for('authme-sdk')][packageInfo.name] = version;
2988
3060
 
2989
- export { AuthmeError, ErrorCode, Icon, RGBToLottieColor, RUN_FUNCTION_NAME, STORAGE_KEY, Storage, TIME_UNIT, UintArrayToBlob, asyncOnLineShowErrorMessage, asyncShowErrorMessage, asyncShowPopup, backgroundRequest, checkOnlineStatus, clearCanvas, colorStringToRGB, colorToRGB, combineResult, cropByRatio, dataURItoBlob, debugLog, debugTools, decodeToken, fontWeight, getCanvasSize, getCssVariable, getDeviceInfo, getImageData, getSystemInfo, hexToRGB, hideElement, hideErrorMessage, hidePopup, isIphone14proOrProMax, isMobile, isMobileOrTablet, osVersion, requestCamera, resize, retryPromiseWithCondition, showElement, showErrorMessage, showErrorMessageEventName, showPopup, splitResult, startLoadingSDK, startSpinner, stopLoadingSDK, stopSpinner, switchCamera, themeConfigDefault, uiThemeButton, uiThemeHint, uiThemeSmallButton, uiThemeText, uploadModal, useState, verificationErrorMessages, version, videoConstraintsFactory, waitTime };
3061
+ export { AuthmeError, ErrorCode, Icon, RGBToLottieColor, RUN_FUNCTION_NAME, STORAGE_KEY, Storage, TIME_UNIT, UintArrayToBlob, asyncOnLineShowErrorMessage, asyncShowErrorMessage, asyncShowPopup, backgroundRequest, checkOnlineStatus, clearCanvas, colorStringToRGB, colorToRGB, combineResult, cropByRatio, dataURItoBlob, debugLog, debugTools, decodeToken, dropMenu, fontWeight, getCanvasSize, getCssVariable, getDeviceInfo, getImageData, getSystemInfo, hexToRGB, hideElement, hideErrorMessage, hidePopup, isIphone14proOrProMax, isMobile, isMobileOrTablet, osVersion, requestCamera, resize, retryPromiseWithCondition, showElement, showErrorMessage, showErrorMessageEventName, showPopup, splitResult, startLoadingSDK, startSpinner, stopLoadingSDK, stopSpinner, switchCamera, themeConfigDefault, uiThemeButton, uiThemeHint, uiThemeSmallButton, uiThemeText, uploadModal, useState, verificationErrorMessages, version, videoConstraintsFactory, waitTime };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@authme/util",
3
- "version": "2.8.3",
3
+ "version": "2.8.4",
4
4
  "peerDependencies": {
5
5
  "core-js": "^3.6.0",
6
6
  "jwt-decode": "3.1.2",
@@ -0,0 +1 @@
1
+ export declare const dropMenu: (dom: any, callback: any) => void;
package/src/ui/index.d.ts CHANGED
@@ -9,3 +9,4 @@ export * from './sdk-loading';
9
9
  export * from './cssToJs';
10
10
  export * from './uiThemeStyle';
11
11
  export * from './uploadModal';
12
+ export * from './dropMenu';
@@ -1,5 +1,5 @@
1
1
  export declare const fontWeight: any;
2
2
  export declare const uiThemeText: (dom: any, textStyle: any) => void;
3
3
  export declare const uiThemeHint: (dom: any, hintStyle: any) => void;
4
- export declare const uiThemeButton: (dom: any, buttonStyle: any) => void;
4
+ export declare const uiThemeButton: (dom: any, buttonStyle: any, disabled?: boolean) => void;
5
5
  export declare const uiThemeSmallButton: (dom: any, buttonStyle: any) => void;