@pisell/private-materials 6.3.36 → 6.3.37

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.
@@ -30,7 +30,7 @@ export declare const calculateSubtotal: (items: CartItem[]) => string;
30
30
  * @return {*}
31
31
  * @Author: xiangfeng.xue
32
32
  */
33
- export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) => Decimal | "0.00";
33
+ export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) => "0.00" | Decimal;
34
34
  /**
35
35
  * 计算所有价格明细
36
36
  * @param items - 购物车商品数组
@@ -244,4 +244,4 @@ export declare const updateAppointmentServicePrice: (state: any, { start_date, e
244
244
  * @Author: WangHan
245
245
  * @Date: 2024-12-24 11:32
246
246
  */
247
- export declare const updateServicePrice: (state: any) => Promise<any> | never[];
247
+ export declare const updateServicePrice: (state: any) => never[] | Promise<any>;
@@ -165,10 +165,10 @@ export declare const getProductTotalPrice: (item: any) => number;
165
165
  export declare const getDuration: (duration: number | {
166
166
  type: string;
167
167
  value: number;
168
- }) => number | {
168
+ }) => number | "flexible" | {
169
169
  type: string;
170
170
  value: number;
171
- } | "flexible";
171
+ };
172
172
  export declare const isWalkIn: (customer_id?: number | string) => boolean;
173
173
  export declare const getIsEdit: (state: any) => boolean;
174
174
  export {};
@@ -8,7 +8,7 @@ import { PosProps } from './const';
8
8
  */
9
9
  declare const _default: ({ className, onChange, onClose, formatAmount, isMobile, net, client }: {
10
10
  className?: string | undefined;
11
- onChange?: ((status: "success" | "page" | "fail" | "print" | "mark_tx_processed", params?: string | {
11
+ onChange?: ((status: "page" | "success" | "print" | "fail" | "mark_tx_processed", params?: string | {
12
12
  [keys: string]: unknown;
13
13
  } | undefined, other?: any) => void) | undefined;
14
14
  onClose: () => void;
@@ -10,7 +10,7 @@ import './device.less';
10
10
  declare const _default: ({ api, onChange, onClose, className, device_number, isMobile, net, client, formatAmount, }: {
11
11
  api: PayProps['api'];
12
12
  className?: string | undefined;
13
- onChange?: ((status: "success" | "page" | "fail" | "print" | "mark_tx_processed", params?: string | {
13
+ onChange?: ((status: "page" | "success" | "print" | "fail" | "mark_tx_processed", params?: string | {
14
14
  [keys: string]: unknown;
15
15
  } | undefined, other?: any) => void) | undefined;
16
16
  onClose: () => void;
@@ -15,11 +15,11 @@ export declare const useStoreRef: <T extends {
15
15
  readonly numRef: React.MutableRefObject<string | number | undefined>;
16
16
  readonly orderIdRef: React.MutableRefObject<string | number>;
17
17
  readonly modeRef: React.MutableRefObject<ModeEnum>;
18
- readonly statusRef: React.MutableRefObject<"success" | "warn" | "loading" | "fail" | "pedding" | "resove" | "reject" | "question">;
18
+ readonly statusRef: React.MutableRefObject<"loading" | "warn" | "success" | "fail" | "pedding" | "resove" | "reject" | "question">;
19
19
  readonly netRef: React.MutableRefObject<boolean | undefined>;
20
20
  readonly symbolRef: React.MutableRefObject<string>;
21
21
  readonly amountRef: React.MutableRefObject<string | number>;
22
- readonly eftposRef: React.MutableRefObject<"payo" | "tyro" | "windcave" | "stripe" | "linkly">;
22
+ readonly eftposRef: React.MutableRefObject<"stripe" | "payo" | "tyro" | "windcave" | "linkly">;
23
23
  readonly clientRef: React.MutableRefObject<ClientEnum>;
24
24
  readonly dataRef: React.MutableRefObject<import("./store").State>;
25
25
  };
@@ -174,7 +174,7 @@ export declare const updateCustom: (payload: {
174
174
  export declare const updateStatus: (status: 'loading' | 'warn' | 'fail' | 'success' | 'question') => {
175
175
  type: EActionTypes;
176
176
  payload: {
177
- status: "success" | "warn" | "loading" | "fail" | "question";
177
+ status: "loading" | "warn" | "success" | "fail" | "question";
178
178
  };
179
179
  };
180
180
  /**
@@ -295,20 +295,20 @@ export declare const backUpFree: (payload: Partial<State>) => {
295
295
  name?: string | undefined;
296
296
  symbol?: string | undefined;
297
297
  amount?: string | number | undefined;
298
- mode?: "pay" | "fullPay" | "refund" | "query" | undefined;
298
+ mode?: "refund" | "pay" | "fullPay" | "query" | undefined;
299
299
  order_id?: string | number | undefined;
300
- eftpos?: "payo" | "tyro" | "windcave" | "stripe" | "linkly" | undefined;
301
- action?: "amount" | "deviceList" | "pay" | undefined;
300
+ eftpos?: "stripe" | "payo" | "tyro" | "windcave" | "linkly" | undefined;
301
+ action?: "amount" | "pay" | "deviceList" | undefined;
302
302
  key?: number | undefined;
303
303
  step?: number | undefined;
304
304
  title?: string | undefined;
305
305
  subTitle?: string | undefined;
306
- type?: "step" | "unset" | undefined;
306
+ type?: "unset" | "step" | undefined;
307
307
  render?: boolean | undefined;
308
308
  net?: boolean | undefined;
309
309
  component?: string | undefined;
310
310
  form?: string | undefined;
311
- status?: "success" | "warn" | "loading" | "fail" | "pedding" | "resove" | "reject" | "question" | undefined;
311
+ status?: "loading" | "warn" | "success" | "fail" | "pedding" | "resove" | "reject" | "question" | undefined;
312
312
  warn?: string | undefined;
313
313
  steps?: {
314
314
  /** 用于重置当前步骤 */
@@ -117,17 +117,11 @@ var Login2 = function Login2(_ref) {
117
117
  // 初始化 currentLoginMethod(当 loginMethods 变化时)
118
118
  useEffect(function () {
119
119
  if (loginMethods.length > 0 && !currentLoginMethod) {
120
- // 优先选择非OAuth类型的登录方式作为当前激活方式
121
- var nonOAuthMethod = loginMethods.find(function (method) {
122
- return method.type === 'email' || method.type === 'phone';
123
- });
124
- var first = nonOAuthMethod || loginMethods[0];
125
- setCurrentLoginMethod(first);
126
-
127
- // 设置默认验证方式
128
- if (first.type === 'email' || first.type === 'phone') {
129
- var _first$verificationMe;
130
- setCurrentVerificationMethod(((_first$verificationMe = first.verificationMethods) === null || _first$verificationMe === void 0 ? void 0 : _first$verificationMe[0]) || 'password');
120
+ var initialMethod = loginMethods[0];
121
+ setCurrentLoginMethod(initialMethod);
122
+ if ((initialMethod === null || initialMethod === void 0 ? void 0 : initialMethod.type) === 'email' || (initialMethod === null || initialMethod === void 0 ? void 0 : initialMethod.type) === 'phone') {
123
+ var _initialMethod$verifi;
124
+ setCurrentVerificationMethod(((_initialMethod$verifi = initialMethod.verificationMethods) === null || _initialMethod$verifi === void 0 ? void 0 : _initialMethod$verifi[0]) || 'password');
131
125
  }
132
126
  }
133
127
  // 如果只有 guest 登录,则默认直接使用 guest 登录
@@ -1885,14 +1879,18 @@ var Login2 = function Login2(_ref) {
1885
1879
  // 渲染底部切换选项区域
1886
1880
  var renderSwitchOptions = function renderSwitchOptions() {
1887
1881
  if (!currentLoginMethod) return null;
1888
- var nonOauthButtons = [];
1889
- if (currentLoginMethod.type === 'email' || currentLoginMethod.type === 'phone') {
1882
+ var primaryMethod = loginMethods[0];
1883
+ var currentIsFormMethod = currentLoginMethod.type === 'email' || currentLoginMethod.type === 'phone';
1884
+ var primaryIsFormMethod = (primaryMethod === null || primaryMethod === void 0 ? void 0 : primaryMethod.type) === 'email' || (primaryMethod === null || primaryMethod === void 0 ? void 0 : primaryMethod.type) === 'phone';
1885
+ var shouldUseFormLayout = currentIsFormMethod || primaryIsFormMethod;
1886
+ var verificationSwitchButtons = [];
1887
+ if (currentIsFormMethod) {
1890
1888
  (currentLoginMethod.verificationMethods || []).filter(function (method) {
1891
1889
  return method !== currentVerificationMethod;
1892
1890
  }).forEach(function (method) {
1893
1891
  if (method === 'verification_code') {
1894
1892
  var text = currentLoginMethod.type === 'email' ? locales.getText('pisell-login2-switch-to-email-code') : locales.getText('pisell-login2-switch-to-sms-code');
1895
- nonOauthButtons.push( /*#__PURE__*/React.createElement("button", {
1893
+ verificationSwitchButtons.push( /*#__PURE__*/React.createElement("button", {
1896
1894
  key: "switch-to-code",
1897
1895
  className: "login2-switch-option-button",
1898
1896
  onClick: function onClick() {
@@ -1906,7 +1904,7 @@ var Login2 = function Login2(_ref) {
1906
1904
  className: "option-text"
1907
1905
  }, text)));
1908
1906
  } else {
1909
- nonOauthButtons.push( /*#__PURE__*/React.createElement("button", {
1907
+ verificationSwitchButtons.push( /*#__PURE__*/React.createElement("button", {
1910
1908
  key: "switch-to-password",
1911
1909
  className: "login2-switch-option-button",
1912
1910
  onClick: function onClick() {
@@ -1920,16 +1918,15 @@ var Login2 = function Login2(_ref) {
1920
1918
  }
1921
1919
  });
1922
1920
  }
1921
+ var emailPhoneSwitchButtons = [];
1923
1922
  loginMethods.forEach(function (method, index) {
1924
1923
  if (method.type === 'email' || method.type === 'phone') {
1925
- if (method.type === currentLoginMethod.type) {
1926
- return;
1927
- }
1924
+ if (method.type === currentLoginMethod.type) return;
1928
1925
  var isLast = isLastLoginMethod(method.type);
1929
1926
  var _className = classNames('login2-switch-option-button', {
1930
1927
  'has-last-login-badge': isLast
1931
1928
  });
1932
- nonOauthButtons.push( /*#__PURE__*/React.createElement("button", {
1929
+ emailPhoneSwitchButtons.push( /*#__PURE__*/React.createElement("button", {
1933
1930
  key: "".concat(method.type, "-").concat(index),
1934
1931
  className: _className,
1935
1932
  onClick: function onClick() {
@@ -1944,7 +1941,7 @@ var Login2 = function Login2(_ref) {
1944
1941
  }, method.type === 'email' ? locales.getText('pisell-login2-switch-to-email') : locales.getText('pisell-login2-switch-to-phone'))));
1945
1942
  }
1946
1943
  });
1947
- var showDivider = nonOauthButtons.length > 0 && oauthProviders.length > 0;
1944
+ var nonOauthButtons = [].concat(verificationSwitchButtons, emailPhoneSwitchButtons);
1948
1945
  var registerPrompt = onSwitchToRegister && /*#__PURE__*/React.createElement("div", {
1949
1946
  className: "login2-register-prompt"
1950
1947
  }, /*#__PURE__*/React.createElement("span", {
@@ -1956,18 +1953,72 @@ var Login2 = function Login2(_ref) {
1956
1953
  if (!nonOauthButtons.length && !oauthProviders.length) {
1957
1954
  return registerPrompt;
1958
1955
  }
1959
- return /*#__PURE__*/React.createElement(React.Fragment, null, showDivider && /*#__PURE__*/React.createElement("div", {
1960
- className: "login2-divider"
1961
- }, locales.getText('pisell-login2-or')), (nonOauthButtons.length > 0 || oauthProviders.length > 0) && /*#__PURE__*/React.createElement("div", {
1956
+ if (shouldUseFormLayout) {
1957
+ var groups = [];
1958
+ if (nonOauthButtons.length > 0) {
1959
+ groups.push( /*#__PURE__*/React.createElement("div", {
1960
+ key: "non-oauth",
1961
+ className: "login2-switch-options"
1962
+ }, nonOauthButtons));
1963
+ }
1964
+ if (oauthProviders.length > 0) {
1965
+ groups.push( /*#__PURE__*/React.createElement(OAuthButtonGroup, {
1966
+ key: "oauth",
1967
+ providers: oauthProviders,
1968
+ wrapperClassName: "login2-oauth-buttons",
1969
+ buttonClassName: "login2-oauth-button",
1970
+ gap: 12
1971
+ }));
1972
+ }
1973
+ if (!groups.length) {
1974
+ return registerPrompt;
1975
+ }
1976
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
1977
+ className: "login2-divider"
1978
+ }, locales.getText('pisell-login2-or')), /*#__PURE__*/React.createElement("div", {
1979
+ className: "login2-switch-groups"
1980
+ }, groups), registerPrompt);
1981
+ }
1982
+ var primaryProvider = oauthProviders.find(function (provider) {
1983
+ return provider.key === (primaryMethod === null || primaryMethod === void 0 ? void 0 : primaryMethod.type);
1984
+ });
1985
+ var secondaryOauthProviders = oauthProviders.filter(function (provider) {
1986
+ return provider.key !== (primaryMethod === null || primaryMethod === void 0 ? void 0 : primaryMethod.type);
1987
+ });
1988
+ var hasSecondaryButtons = nonOauthButtons.length > 0 || secondaryOauthProviders.length > 0;
1989
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
1962
1990
  className: "login2-switch-groups"
1963
- }, nonOauthButtons.length > 0 && /*#__PURE__*/React.createElement("div", {
1991
+ }, primaryProvider ? /*#__PURE__*/React.createElement(OAuthButtonGroup, {
1992
+ providers: [primaryProvider],
1993
+ wrapperClassName: "login2-oauth-buttons",
1994
+ buttonClassName: "login2-oauth-button",
1995
+ gap: 12
1996
+ }) : /*#__PURE__*/React.createElement("div", {
1997
+ className: "login2-switch-options"
1998
+ }, /*#__PURE__*/React.createElement("button", {
1999
+ key: "primary-fallback",
2000
+ className: "login2-switch-option-button",
2001
+ onClick: function onClick() {
2002
+ if ((primaryMethod === null || primaryMethod === void 0 ? void 0 : primaryMethod.type) === 'guest') {
2003
+ handleGuestLogin();
2004
+ } else if ((primaryMethod === null || primaryMethod === void 0 ? void 0 : primaryMethod.type) === 'google' || (primaryMethod === null || primaryMethod === void 0 ? void 0 : primaryMethod.type) === 'facebook' || (primaryMethod === null || primaryMethod === void 0 ? void 0 : primaryMethod.type) === 'apple') {
2005
+ handleOAuthClick(primaryMethod.type);
2006
+ }
2007
+ }
2008
+ }, /*#__PURE__*/React.createElement(Iconfont, {
2009
+ type: (primaryMethod === null || primaryMethod === void 0 ? void 0 : primaryMethod.type) === 'guest' ? 'pisell2-user-01' : (primaryMethod === null || primaryMethod === void 0 ? void 0 : primaryMethod.type) === 'google' ? 'pisell2-google' : (primaryMethod === null || primaryMethod === void 0 ? void 0 : primaryMethod.type) === 'facebook' ? 'pisell2-facebook' : 'pisell2-apple'
2010
+ }), /*#__PURE__*/React.createElement("span", {
2011
+ className: "option-text"
2012
+ }, (primaryMethod === null || primaryMethod === void 0 ? void 0 : primaryMethod.type) === 'guest' ? locales.getText('pisell-login2-login-as-guest') : "".concat(locales.getText('pisell-login2-continue-with'), " ").concat(primaryMethod !== null && primaryMethod !== void 0 && primaryMethod.type ? primaryMethod.type.charAt(0).toUpperCase() + primaryMethod.type.slice(1) : '')))), hasSecondaryButtons && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
2013
+ className: "login2-divider"
2014
+ }, locales.getText('pisell-login2-or')), nonOauthButtons.length > 0 && /*#__PURE__*/React.createElement("div", {
1964
2015
  className: "login2-switch-options"
1965
- }, nonOauthButtons), oauthProviders.length > 0 && /*#__PURE__*/React.createElement(OAuthButtonGroup, {
1966
- providers: oauthProviders,
2016
+ }, nonOauthButtons), secondaryOauthProviders.length > 0 && /*#__PURE__*/React.createElement(OAuthButtonGroup, {
2017
+ providers: secondaryOauthProviders,
1967
2018
  wrapperClassName: "login2-oauth-buttons",
1968
2019
  buttonClassName: "login2-oauth-button",
1969
2020
  gap: 12
1970
- })), registerPrompt);
2021
+ }))), registerPrompt);
1971
2022
  };
1972
2023
 
1973
2024
  // 渲染 OAuth 按钮
@@ -30,7 +30,7 @@ export declare const calculateSubtotal: (items: CartItem[]) => string;
30
30
  * @return {*}
31
31
  * @Author: xiangfeng.xue
32
32
  */
33
- export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) => Decimal | "0.00";
33
+ export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) => "0.00" | Decimal;
34
34
  /**
35
35
  * 计算所有价格明细
36
36
  * @param items - 购物车商品数组
@@ -244,4 +244,4 @@ export declare const updateAppointmentServicePrice: (state: any, { start_date, e
244
244
  * @Author: WangHan
245
245
  * @Date: 2024-12-24 11:32
246
246
  */
247
- export declare const updateServicePrice: (state: any) => Promise<any> | never[];
247
+ export declare const updateServicePrice: (state: any) => never[] | Promise<any>;
@@ -165,10 +165,10 @@ export declare const getProductTotalPrice: (item: any) => number;
165
165
  export declare const getDuration: (duration: number | {
166
166
  type: string;
167
167
  value: number;
168
- }) => number | {
168
+ }) => number | "flexible" | {
169
169
  type: string;
170
170
  value: number;
171
- } | "flexible";
171
+ };
172
172
  export declare const isWalkIn: (customer_id?: number | string) => boolean;
173
173
  export declare const getIsEdit: (state: any) => boolean;
174
174
  export {};
@@ -8,7 +8,7 @@ import { PosProps } from './const';
8
8
  */
9
9
  declare const _default: ({ className, onChange, onClose, formatAmount, isMobile, net, client }: {
10
10
  className?: string | undefined;
11
- onChange?: ((status: "success" | "page" | "fail" | "print" | "mark_tx_processed", params?: string | {
11
+ onChange?: ((status: "page" | "success" | "print" | "fail" | "mark_tx_processed", params?: string | {
12
12
  [keys: string]: unknown;
13
13
  } | undefined, other?: any) => void) | undefined;
14
14
  onClose: () => void;
@@ -10,7 +10,7 @@ import './device.less';
10
10
  declare const _default: ({ api, onChange, onClose, className, device_number, isMobile, net, client, formatAmount, }: {
11
11
  api: PayProps['api'];
12
12
  className?: string | undefined;
13
- onChange?: ((status: "success" | "page" | "fail" | "print" | "mark_tx_processed", params?: string | {
13
+ onChange?: ((status: "page" | "success" | "print" | "fail" | "mark_tx_processed", params?: string | {
14
14
  [keys: string]: unknown;
15
15
  } | undefined, other?: any) => void) | undefined;
16
16
  onClose: () => void;
@@ -15,11 +15,11 @@ export declare const useStoreRef: <T extends {
15
15
  readonly numRef: React.MutableRefObject<string | number | undefined>;
16
16
  readonly orderIdRef: React.MutableRefObject<string | number>;
17
17
  readonly modeRef: React.MutableRefObject<ModeEnum>;
18
- readonly statusRef: React.MutableRefObject<"success" | "warn" | "loading" | "fail" | "pedding" | "resove" | "reject" | "question">;
18
+ readonly statusRef: React.MutableRefObject<"loading" | "warn" | "success" | "fail" | "pedding" | "resove" | "reject" | "question">;
19
19
  readonly netRef: React.MutableRefObject<boolean | undefined>;
20
20
  readonly symbolRef: React.MutableRefObject<string>;
21
21
  readonly amountRef: React.MutableRefObject<string | number>;
22
- readonly eftposRef: React.MutableRefObject<"payo" | "tyro" | "windcave" | "stripe" | "linkly">;
22
+ readonly eftposRef: React.MutableRefObject<"stripe" | "payo" | "tyro" | "windcave" | "linkly">;
23
23
  readonly clientRef: React.MutableRefObject<ClientEnum>;
24
24
  readonly dataRef: React.MutableRefObject<import("./store").State>;
25
25
  };
@@ -174,7 +174,7 @@ export declare const updateCustom: (payload: {
174
174
  export declare const updateStatus: (status: 'loading' | 'warn' | 'fail' | 'success' | 'question') => {
175
175
  type: EActionTypes;
176
176
  payload: {
177
- status: "success" | "warn" | "loading" | "fail" | "question";
177
+ status: "loading" | "warn" | "success" | "fail" | "question";
178
178
  };
179
179
  };
180
180
  /**
@@ -295,20 +295,20 @@ export declare const backUpFree: (payload: Partial<State>) => {
295
295
  name?: string | undefined;
296
296
  symbol?: string | undefined;
297
297
  amount?: string | number | undefined;
298
- mode?: "pay" | "fullPay" | "refund" | "query" | undefined;
298
+ mode?: "refund" | "pay" | "fullPay" | "query" | undefined;
299
299
  order_id?: string | number | undefined;
300
- eftpos?: "payo" | "tyro" | "windcave" | "stripe" | "linkly" | undefined;
301
- action?: "amount" | "deviceList" | "pay" | undefined;
300
+ eftpos?: "stripe" | "payo" | "tyro" | "windcave" | "linkly" | undefined;
301
+ action?: "amount" | "pay" | "deviceList" | undefined;
302
302
  key?: number | undefined;
303
303
  step?: number | undefined;
304
304
  title?: string | undefined;
305
305
  subTitle?: string | undefined;
306
- type?: "step" | "unset" | undefined;
306
+ type?: "unset" | "step" | undefined;
307
307
  render?: boolean | undefined;
308
308
  net?: boolean | undefined;
309
309
  component?: string | undefined;
310
310
  form?: string | undefined;
311
- status?: "success" | "warn" | "loading" | "fail" | "pedding" | "resove" | "reject" | "question" | undefined;
311
+ status?: "loading" | "warn" | "success" | "fail" | "pedding" | "resove" | "reject" | "question" | undefined;
312
312
  warn?: string | undefined;
313
313
  steps?: {
314
314
  /** 用于重置当前步骤 */
@@ -104,14 +104,11 @@ var Login2 = ({
104
104
  (0, import_react.useEffect)(() => {
105
105
  var _a2;
106
106
  if (loginMethods.length > 0 && !currentLoginMethod) {
107
- const nonOAuthMethod = loginMethods.find(
108
- (method) => method.type === "email" || method.type === "phone"
109
- );
110
- const first = nonOAuthMethod || loginMethods[0];
111
- setCurrentLoginMethod(first);
112
- if (first.type === "email" || first.type === "phone") {
107
+ const initialMethod = loginMethods[0];
108
+ setCurrentLoginMethod(initialMethod);
109
+ if ((initialMethod == null ? void 0 : initialMethod.type) === "email" || (initialMethod == null ? void 0 : initialMethod.type) === "phone") {
113
110
  setCurrentVerificationMethod(
114
- ((_a2 = first.verificationMethods) == null ? void 0 : _a2[0]) || "password"
111
+ ((_a2 = initialMethod.verificationMethods) == null ? void 0 : _a2[0]) || "password"
115
112
  );
116
113
  }
117
114
  }
@@ -1219,12 +1216,16 @@ var Login2 = ({
1219
1216
  };
1220
1217
  const renderSwitchOptions = () => {
1221
1218
  if (!currentLoginMethod) return null;
1222
- const nonOauthButtons = [];
1223
- if (currentLoginMethod.type === "email" || currentLoginMethod.type === "phone") {
1219
+ const primaryMethod = loginMethods[0];
1220
+ const currentIsFormMethod = currentLoginMethod.type === "email" || currentLoginMethod.type === "phone";
1221
+ const primaryIsFormMethod = (primaryMethod == null ? void 0 : primaryMethod.type) === "email" || (primaryMethod == null ? void 0 : primaryMethod.type) === "phone";
1222
+ const shouldUseFormLayout = currentIsFormMethod || primaryIsFormMethod;
1223
+ const verificationSwitchButtons = [];
1224
+ if (currentIsFormMethod) {
1224
1225
  (currentLoginMethod.verificationMethods || []).filter((method) => method !== currentVerificationMethod).forEach((method) => {
1225
1226
  if (method === "verification_code") {
1226
1227
  const text = currentLoginMethod.type === "email" ? import_utils.locales.getText("pisell-login2-switch-to-email-code") : import_utils.locales.getText("pisell-login2-switch-to-sms-code");
1227
- nonOauthButtons.push(
1228
+ verificationSwitchButtons.push(
1228
1229
  /* @__PURE__ */ import_react.default.createElement(
1229
1230
  "button",
1230
1231
  {
@@ -1237,7 +1238,7 @@ var Login2 = ({
1237
1238
  )
1238
1239
  );
1239
1240
  } else {
1240
- nonOauthButtons.push(
1241
+ verificationSwitchButtons.push(
1241
1242
  /* @__PURE__ */ import_react.default.createElement(
1242
1243
  "button",
1243
1244
  {
@@ -1252,17 +1253,15 @@ var Login2 = ({
1252
1253
  }
1253
1254
  });
1254
1255
  }
1256
+ const emailPhoneSwitchButtons = [];
1255
1257
  loginMethods.forEach((method, index) => {
1256
1258
  if (method.type === "email" || method.type === "phone") {
1257
- if (method.type === currentLoginMethod.type) {
1258
- return;
1259
- }
1259
+ if (method.type === currentLoginMethod.type) return;
1260
1260
  const isLast = isLastLoginMethod(method.type);
1261
- const className2 = (0, import_classnames.default)(
1262
- "login2-switch-option-button",
1263
- { "has-last-login-badge": isLast }
1264
- );
1265
- nonOauthButtons.push(
1261
+ const className2 = (0, import_classnames.default)("login2-switch-option-button", {
1262
+ "has-last-login-badge": isLast
1263
+ });
1264
+ emailPhoneSwitchButtons.push(
1266
1265
  /* @__PURE__ */ import_react.default.createElement(
1267
1266
  "button",
1268
1267
  {
@@ -1282,7 +1281,10 @@ var Login2 = ({
1282
1281
  );
1283
1282
  }
1284
1283
  });
1285
- const showDivider = nonOauthButtons.length > 0 && oauthProviders.length > 0;
1284
+ const nonOauthButtons = [
1285
+ ...verificationSwitchButtons,
1286
+ ...emailPhoneSwitchButtons
1287
+ ];
1286
1288
  const registerPrompt = onSwitchToRegister && /* @__PURE__ */ import_react.default.createElement("div", { className: "login2-register-prompt" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "register-prompt-text" }, import_utils.locales.getText("pisell-login2-no-account")), /* @__PURE__ */ import_react.default.createElement(
1287
1289
  "button",
1288
1290
  {
@@ -1294,15 +1296,76 @@ var Login2 = ({
1294
1296
  if (!nonOauthButtons.length && !oauthProviders.length) {
1295
1297
  return registerPrompt;
1296
1298
  }
1297
- return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, showDivider && /* @__PURE__ */ import_react.default.createElement("div", { className: "login2-divider" }, import_utils.locales.getText("pisell-login2-or")), (nonOauthButtons.length > 0 || oauthProviders.length > 0) && /* @__PURE__ */ import_react.default.createElement("div", { className: "login2-switch-groups" }, nonOauthButtons.length > 0 && /* @__PURE__ */ import_react.default.createElement("div", { className: "login2-switch-options" }, nonOauthButtons), oauthProviders.length > 0 && /* @__PURE__ */ import_react.default.createElement(
1299
+ if (shouldUseFormLayout) {
1300
+ const groups = [];
1301
+ if (nonOauthButtons.length > 0) {
1302
+ groups.push(
1303
+ /* @__PURE__ */ import_react.default.createElement("div", { key: "non-oauth", className: "login2-switch-options" }, nonOauthButtons)
1304
+ );
1305
+ }
1306
+ if (oauthProviders.length > 0) {
1307
+ groups.push(
1308
+ /* @__PURE__ */ import_react.default.createElement(
1309
+ import_OAuthButtonGroup.default,
1310
+ {
1311
+ key: "oauth",
1312
+ providers: oauthProviders,
1313
+ wrapperClassName: "login2-oauth-buttons",
1314
+ buttonClassName: "login2-oauth-button",
1315
+ gap: 12
1316
+ }
1317
+ )
1318
+ );
1319
+ }
1320
+ if (!groups.length) {
1321
+ return registerPrompt;
1322
+ }
1323
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: "login2-divider" }, import_utils.locales.getText("pisell-login2-or")), /* @__PURE__ */ import_react.default.createElement("div", { className: "login2-switch-groups" }, groups), registerPrompt);
1324
+ }
1325
+ const primaryProvider = oauthProviders.find(
1326
+ (provider) => provider.key === (primaryMethod == null ? void 0 : primaryMethod.type)
1327
+ );
1328
+ const secondaryOauthProviders = oauthProviders.filter(
1329
+ (provider) => provider.key !== (primaryMethod == null ? void 0 : primaryMethod.type)
1330
+ );
1331
+ const hasSecondaryButtons = nonOauthButtons.length > 0 || secondaryOauthProviders.length > 0;
1332
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: "login2-switch-groups" }, primaryProvider ? /* @__PURE__ */ import_react.default.createElement(
1333
+ import_OAuthButtonGroup.default,
1334
+ {
1335
+ providers: [primaryProvider],
1336
+ wrapperClassName: "login2-oauth-buttons",
1337
+ buttonClassName: "login2-oauth-button",
1338
+ gap: 12
1339
+ }
1340
+ ) : /* @__PURE__ */ import_react.default.createElement("div", { className: "login2-switch-options" }, /* @__PURE__ */ import_react.default.createElement(
1341
+ "button",
1342
+ {
1343
+ key: "primary-fallback",
1344
+ className: "login2-switch-option-button",
1345
+ onClick: () => {
1346
+ if ((primaryMethod == null ? void 0 : primaryMethod.type) === "guest") {
1347
+ handleGuestLogin();
1348
+ } else if ((primaryMethod == null ? void 0 : primaryMethod.type) === "google" || (primaryMethod == null ? void 0 : primaryMethod.type) === "facebook" || (primaryMethod == null ? void 0 : primaryMethod.type) === "apple") {
1349
+ handleOAuthClick(primaryMethod.type);
1350
+ }
1351
+ }
1352
+ },
1353
+ /* @__PURE__ */ import_react.default.createElement(
1354
+ import_materials2.Iconfont,
1355
+ {
1356
+ type: (primaryMethod == null ? void 0 : primaryMethod.type) === "guest" ? "pisell2-user-01" : (primaryMethod == null ? void 0 : primaryMethod.type) === "google" ? "pisell2-google" : (primaryMethod == null ? void 0 : primaryMethod.type) === "facebook" ? "pisell2-facebook" : "pisell2-apple"
1357
+ }
1358
+ ),
1359
+ /* @__PURE__ */ import_react.default.createElement("span", { className: "option-text" }, (primaryMethod == null ? void 0 : primaryMethod.type) === "guest" ? import_utils.locales.getText("pisell-login2-login-as-guest") : `${import_utils.locales.getText("pisell-login2-continue-with")} ${(primaryMethod == null ? void 0 : primaryMethod.type) ? primaryMethod.type.charAt(0).toUpperCase() + primaryMethod.type.slice(1) : ""}`)
1360
+ )), hasSecondaryButtons && /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: "login2-divider" }, import_utils.locales.getText("pisell-login2-or")), nonOauthButtons.length > 0 && /* @__PURE__ */ import_react.default.createElement("div", { className: "login2-switch-options" }, nonOauthButtons), secondaryOauthProviders.length > 0 && /* @__PURE__ */ import_react.default.createElement(
1298
1361
  import_OAuthButtonGroup.default,
1299
1362
  {
1300
- providers: oauthProviders,
1363
+ providers: secondaryOauthProviders,
1301
1364
  wrapperClassName: "login2-oauth-buttons",
1302
1365
  buttonClassName: "login2-oauth-button",
1303
1366
  gap: 12
1304
1367
  }
1305
- )), registerPrompt);
1368
+ ))), registerPrompt);
1306
1369
  };
1307
1370
  if (!visible) {
1308
1371
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "6.3.36",
3
+ "version": "6.3.37",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",