@redneckz/wildless-cms-uni-blocks 0.14.565 → 0.14.567

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 (171) hide show
  1. package/bundle/bundle.umd.js +10 -5
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/bundle/ui-kit/DatePicker/Calendar.d.ts +1 -0
  4. package/bundle/ui-kit/Loader/Loader.d.ts +1 -0
  5. package/bundle/ui-kit/{Timer → TimerCircle}/Timer.d.ts +4 -2
  6. package/bundle/ui-kit/TimerCircle/TimerCircle.d.ts +7 -0
  7. package/bundle/ui-kit/VerifyPhoneDialog/InputCode.d.ts +8 -0
  8. package/bundle/ui-kit/VerifyPhoneDialog/SubmitButton.d.ts +7 -0
  9. package/bundle/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +9 -0
  10. package/bundle/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +13 -0
  11. package/bundle/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.d.ts +6 -0
  12. package/dist/ui-kit/DatePicker/Calendar.d.ts +1 -0
  13. package/dist/ui-kit/DatePicker/Calendar.js +5 -2
  14. package/dist/ui-kit/DatePicker/Calendar.js.map +1 -1
  15. package/dist/ui-kit/DatePicker/DatePicker.js +1 -1
  16. package/dist/ui-kit/DatePicker/DatePicker.js.map +1 -1
  17. package/dist/ui-kit/Loader/Loader.d.ts +1 -0
  18. package/dist/ui-kit/Loader/Loader.js +3 -1
  19. package/dist/ui-kit/Loader/Loader.js.map +1 -1
  20. package/dist/ui-kit/{Timer → TimerCircle}/Timer.d.ts +4 -2
  21. package/dist/ui-kit/TimerCircle/Timer.js +25 -0
  22. package/dist/ui-kit/TimerCircle/Timer.js.map +1 -0
  23. package/dist/ui-kit/TimerCircle/TimerCircle.d.ts +7 -0
  24. package/{mobile/dist/ui-kit/Timer/Timer.js → dist/ui-kit/TimerCircle/TimerCircle.js} +5 -20
  25. package/dist/ui-kit/TimerCircle/TimerCircle.js.map +1 -0
  26. package/dist/ui-kit/VerifyPhoneDialog/InputCode.d.ts +8 -0
  27. package/dist/ui-kit/VerifyPhoneDialog/InputCode.js +49 -0
  28. package/dist/ui-kit/VerifyPhoneDialog/InputCode.js.map +1 -0
  29. package/dist/ui-kit/VerifyPhoneDialog/SubmitButton.d.ts +7 -0
  30. package/dist/ui-kit/VerifyPhoneDialog/SubmitButton.js +10 -0
  31. package/dist/ui-kit/VerifyPhoneDialog/SubmitButton.js.map +1 -0
  32. package/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +9 -0
  33. package/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js +38 -0
  34. package/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -0
  35. package/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +13 -0
  36. package/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js +30 -0
  37. package/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js.map +1 -0
  38. package/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.d.ts +6 -0
  39. package/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.js +14 -0
  40. package/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.js.map +1 -0
  41. package/lib/common.css +1 -1
  42. package/lib/ui-kit/DatePicker/Calendar.d.ts +1 -0
  43. package/lib/ui-kit/DatePicker/Calendar.js +5 -2
  44. package/lib/ui-kit/DatePicker/Calendar.js.map +1 -1
  45. package/lib/ui-kit/DatePicker/DatePicker.js +1 -1
  46. package/lib/ui-kit/DatePicker/DatePicker.js.map +1 -1
  47. package/lib/ui-kit/Loader/Loader.d.ts +1 -0
  48. package/lib/ui-kit/Loader/Loader.js +3 -1
  49. package/lib/ui-kit/Loader/Loader.js.map +1 -1
  50. package/lib/ui-kit/{Timer → TimerCircle}/Timer.d.ts +4 -2
  51. package/lib/ui-kit/TimerCircle/Timer.js +23 -0
  52. package/lib/ui-kit/TimerCircle/Timer.js.map +1 -0
  53. package/lib/ui-kit/TimerCircle/TimerCircle.d.ts +7 -0
  54. package/lib/ui-kit/{Timer/Timer.js → TimerCircle/TimerCircle.js} +5 -20
  55. package/lib/ui-kit/TimerCircle/TimerCircle.js.map +1 -0
  56. package/lib/ui-kit/VerifyPhoneDialog/InputCode.d.ts +8 -0
  57. package/lib/ui-kit/VerifyPhoneDialog/InputCode.js +47 -0
  58. package/lib/ui-kit/VerifyPhoneDialog/InputCode.js.map +1 -0
  59. package/lib/ui-kit/VerifyPhoneDialog/SubmitButton.d.ts +7 -0
  60. package/lib/ui-kit/VerifyPhoneDialog/SubmitButton.js +8 -0
  61. package/lib/ui-kit/VerifyPhoneDialog/SubmitButton.js.map +1 -0
  62. package/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +9 -0
  63. package/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.fixture.d.ts +6 -0
  64. package/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js +36 -0
  65. package/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -0
  66. package/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +13 -0
  67. package/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js +27 -0
  68. package/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js.map +1 -0
  69. package/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.d.ts +6 -0
  70. package/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.js +11 -0
  71. package/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.js.map +1 -0
  72. package/mobile/bundle/bundle.umd.js +10 -5
  73. package/mobile/bundle/bundle.umd.min.js +1 -1
  74. package/mobile/bundle/ui-kit/DatePicker/Calendar.d.ts +1 -0
  75. package/mobile/bundle/ui-kit/Loader/Loader.d.ts +1 -0
  76. package/mobile/bundle/ui-kit/{Timer → TimerCircle}/Timer.d.ts +4 -2
  77. package/mobile/bundle/ui-kit/TimerCircle/TimerCircle.d.ts +7 -0
  78. package/mobile/bundle/ui-kit/VerifyPhoneDialog/InputCode.d.ts +8 -0
  79. package/mobile/bundle/ui-kit/VerifyPhoneDialog/SubmitButton.d.ts +7 -0
  80. package/mobile/bundle/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +9 -0
  81. package/mobile/bundle/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +13 -0
  82. package/mobile/bundle/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.d.ts +6 -0
  83. package/mobile/dist/ui-kit/DatePicker/Calendar.d.ts +1 -0
  84. package/mobile/dist/ui-kit/DatePicker/Calendar.js +5 -2
  85. package/mobile/dist/ui-kit/DatePicker/Calendar.js.map +1 -1
  86. package/mobile/dist/ui-kit/DatePicker/DatePicker.js +1 -1
  87. package/mobile/dist/ui-kit/DatePicker/DatePicker.js.map +1 -1
  88. package/mobile/dist/ui-kit/Loader/Loader.d.ts +1 -0
  89. package/mobile/dist/ui-kit/Loader/Loader.js +3 -1
  90. package/mobile/dist/ui-kit/Loader/Loader.js.map +1 -1
  91. package/mobile/dist/ui-kit/TimerCircle/Timer.d.ts +9 -0
  92. package/mobile/dist/ui-kit/TimerCircle/Timer.js +25 -0
  93. package/mobile/dist/ui-kit/TimerCircle/Timer.js.map +1 -0
  94. package/mobile/dist/ui-kit/TimerCircle/TimerCircle.d.ts +7 -0
  95. package/{dist/ui-kit/Timer/Timer.js → mobile/dist/ui-kit/TimerCircle/TimerCircle.js} +5 -20
  96. package/mobile/dist/ui-kit/TimerCircle/TimerCircle.js.map +1 -0
  97. package/mobile/dist/ui-kit/VerifyPhoneDialog/InputCode.d.ts +8 -0
  98. package/mobile/dist/ui-kit/VerifyPhoneDialog/InputCode.js +49 -0
  99. package/mobile/dist/ui-kit/VerifyPhoneDialog/InputCode.js.map +1 -0
  100. package/mobile/dist/ui-kit/VerifyPhoneDialog/SubmitButton.d.ts +7 -0
  101. package/mobile/dist/ui-kit/VerifyPhoneDialog/SubmitButton.js +10 -0
  102. package/mobile/dist/ui-kit/VerifyPhoneDialog/SubmitButton.js.map +1 -0
  103. package/mobile/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +9 -0
  104. package/mobile/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js +38 -0
  105. package/mobile/dist/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -0
  106. package/mobile/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +13 -0
  107. package/mobile/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js +30 -0
  108. package/mobile/dist/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js.map +1 -0
  109. package/mobile/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.d.ts +6 -0
  110. package/mobile/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.js +14 -0
  111. package/mobile/dist/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.js.map +1 -0
  112. package/mobile/lib/common.css +1 -1
  113. package/mobile/lib/ui-kit/DatePicker/Calendar.d.ts +1 -0
  114. package/mobile/lib/ui-kit/DatePicker/Calendar.js +5 -2
  115. package/mobile/lib/ui-kit/DatePicker/Calendar.js.map +1 -1
  116. package/mobile/lib/ui-kit/DatePicker/DatePicker.js +1 -1
  117. package/mobile/lib/ui-kit/DatePicker/DatePicker.js.map +1 -1
  118. package/mobile/lib/ui-kit/Loader/Loader.d.ts +1 -0
  119. package/mobile/lib/ui-kit/Loader/Loader.js +3 -1
  120. package/mobile/lib/ui-kit/Loader/Loader.js.map +1 -1
  121. package/mobile/lib/ui-kit/TimerCircle/Timer.d.ts +9 -0
  122. package/mobile/lib/ui-kit/TimerCircle/Timer.js +23 -0
  123. package/mobile/lib/ui-kit/TimerCircle/Timer.js.map +1 -0
  124. package/mobile/lib/ui-kit/TimerCircle/TimerCircle.d.ts +7 -0
  125. package/mobile/lib/ui-kit/{Timer/Timer.js → TimerCircle/TimerCircle.js} +5 -20
  126. package/mobile/lib/ui-kit/TimerCircle/TimerCircle.js.map +1 -0
  127. package/mobile/lib/ui-kit/VerifyPhoneDialog/InputCode.d.ts +8 -0
  128. package/mobile/lib/ui-kit/VerifyPhoneDialog/InputCode.js +47 -0
  129. package/mobile/lib/ui-kit/VerifyPhoneDialog/InputCode.js.map +1 -0
  130. package/mobile/lib/ui-kit/VerifyPhoneDialog/SubmitButton.d.ts +7 -0
  131. package/mobile/lib/ui-kit/VerifyPhoneDialog/SubmitButton.js +8 -0
  132. package/mobile/lib/ui-kit/VerifyPhoneDialog/SubmitButton.js.map +1 -0
  133. package/mobile/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.d.ts +9 -0
  134. package/mobile/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js +36 -0
  135. package/mobile/lib/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -0
  136. package/mobile/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.d.ts +13 -0
  137. package/mobile/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js +27 -0
  138. package/mobile/lib/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.js.map +1 -0
  139. package/mobile/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.d.ts +6 -0
  140. package/mobile/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.js +11 -0
  141. package/mobile/lib/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.js.map +1 -0
  142. package/mobile/src/ui-kit/DatePicker/Calendar.tsx +6 -2
  143. package/mobile/src/ui-kit/DatePicker/DatePicker.tsx +1 -1
  144. package/mobile/src/ui-kit/Loader/Loader.tsx +20 -18
  145. package/mobile/src/ui-kit/TimerCircle/Timer.tsx +34 -0
  146. package/mobile/src/ui-kit/{Timer/Timer.tsx → TimerCircle/TimerCircle.tsx} +5 -25
  147. package/mobile/src/ui-kit/VerifyPhoneDialog/InputCode.tsx +90 -0
  148. package/mobile/src/ui-kit/VerifyPhoneDialog/SubmitButton.tsx +17 -0
  149. package/mobile/src/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.tsx +83 -0
  150. package/mobile/src/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.tsx +36 -0
  151. package/mobile/src/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.tsx +11 -0
  152. package/package.json +1 -1
  153. package/src/ui-kit/DatePicker/Calendar.tsx +6 -2
  154. package/src/ui-kit/DatePicker/DatePicker.tsx +1 -1
  155. package/src/ui-kit/Loader/Loader.tsx +20 -18
  156. package/src/ui-kit/TimerCircle/Timer.tsx +34 -0
  157. package/src/ui-kit/{Timer/Timer.fixture.tsx → TimerCircle/TimerCircle.fixture.tsx} +2 -2
  158. package/src/ui-kit/{Timer/Timer.tsx → TimerCircle/TimerCircle.tsx} +5 -25
  159. package/src/ui-kit/VerifyPhoneDialog/InputCode.tsx +90 -0
  160. package/src/ui-kit/VerifyPhoneDialog/SubmitButton.tsx +17 -0
  161. package/src/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.fixture.tsx +24 -0
  162. package/src/ui-kit/VerifyPhoneDialog/VerifyPhoneDialog.tsx +83 -0
  163. package/src/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.tsx +36 -0
  164. package/src/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.tsx +11 -0
  165. package/dist/ui-kit/Timer/Timer.js.map +0 -1
  166. package/lib/ui-kit/Timer/Timer.js.map +0 -1
  167. package/mobile/dist/ui-kit/Timer/Timer.d.ts +0 -7
  168. package/mobile/dist/ui-kit/Timer/Timer.js.map +0 -1
  169. package/mobile/lib/ui-kit/Timer/Timer.d.ts +0 -7
  170. package/mobile/lib/ui-kit/Timer/Timer.js.map +0 -1
  171. /package/lib/ui-kit/{Timer/Timer.fixture.d.ts → TimerCircle/TimerCircle.fixture.d.ts} +0 -0
@@ -0,0 +1,27 @@
1
+ const SEND_CODE_URL = '/api/v1/sms/checkCode';
2
+ export const submitVerifyPhoneForm = async (code) => {
3
+ const codeData = {
4
+ smsText: code,
5
+ smsCodesSetName: { key: 'AUTHENTICATION' },
6
+ };
7
+ const response = await fetch(SEND_CODE_URL, {
8
+ method: 'POST',
9
+ headers: {
10
+ 'Content-Type': 'application/json',
11
+ },
12
+ body: JSON.stringify(codeData),
13
+ });
14
+ if (response.ok) {
15
+ const data = await response.json();
16
+ return {
17
+ success: true,
18
+ expiresIn: data.expires_in,
19
+ };
20
+ }
21
+ else {
22
+ return {
23
+ success: false,
24
+ };
25
+ }
26
+ };
27
+ //# sourceMappingURL=submitVerifyPhoneForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"submitVerifyPhoneForm.js","sourceRoot":"","sources":["../../../src/ui-kit/VerifyPhoneDialog/submitVerifyPhoneForm.tsx"],"names":[],"mappings":"AAOA,MAAM,aAAa,GAAG,uBAAuB,CAAC;AAE9C,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;IAC1D,MAAM,QAAQ,GAAwB;QACpC,OAAO,EAAE,IAAI;QACb,eAAe,EAAE,EAAE,GAAG,EAAE,gBAAgB,EAAE;KAC3C,CAAC;IAEF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,aAAa,EAAE;QAC1C,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;KAC/B,CAAC,CAAC;IAEH,IAAI,QAAQ,CAAC,EAAE,EAAE;QACf,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAEnC,OAAO;YACL,OAAO,EAAE,IAAI;YACb,SAAS,EAAE,IAAI,CAAC,UAAU;SAC3B,CAAC;KACH;SAAM;QACL,OAAO;YACL,OAAO,EAAE,KAAK;SACf,CAAC;KACH;AACH,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { type DialogOptions } from '../DialogManager/useDialogManager';
2
+ import { type VerifyPhoneDialogProps } from './VerifyPhoneDialog';
3
+ export declare const useVerifyPhoneDialog: (props: VerifyPhoneDialogProps) => {
4
+ open: (options?: DialogOptions) => void;
5
+ close: () => void;
6
+ };
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "@redneckz/uni-jsx/jsx-runtime";
2
+ import { useDialogManager } from '../DialogManager/useDialogManager.js';
3
+ import { VerifyPhoneDialog } from './VerifyPhoneDialog.js';
4
+ export const useVerifyPhoneDialog = (props) => {
5
+ const { open, close } = useDialogManager();
6
+ return {
7
+ open: (options = {}) => open(_jsx(VerifyPhoneDialog, { ...props }), options),
8
+ close,
9
+ };
10
+ };
11
+ //# sourceMappingURL=useVerifyPhoneDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVerifyPhoneDialog.js","sourceRoot":"","sources":["../../../src/ui-kit/VerifyPhoneDialog/useVerifyPhoneDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAsB,MAAM,mCAAmC,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAA+B,MAAM,qBAAqB,CAAC;AAErF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAA6B,EAAE,EAAE;IACpE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,gBAAgB,EAAE,CAAC;IAE3C,OAAO;QACL,IAAI,EAAE,CAAC,UAAyB,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,KAAC,iBAAiB,OAAK,KAAK,GAAI,EAAE,OAAO,CAAC;QACtF,KAAK;KACN,CAAC;AACJ,CAAC,CAAC"}
@@ -12,11 +12,15 @@ interface CalendarProps {
12
12
  min?: Date;
13
13
  max?: Date;
14
14
  onDateSelect?: (date: Date) => void;
15
+ setValue?: (value: boolean) => void;
15
16
  }
16
17
 
17
18
  export const Calendar = JSX<CalendarProps>(
18
- ({ today, currentMonth, currentYear, min, max, onDateSelect = noop }) => {
19
- const handleDateClick = useCallback((date: Date) => onDateSelect(date), []);
19
+ ({ today, currentMonth, currentYear, min, max, onDateSelect = noop, setValue = noop }) => {
20
+ const handleDateClick = useCallback((date: Date) => {
21
+ onDateSelect(date);
22
+ setValue(false);
23
+ }, []);
20
24
 
21
25
  const { firstDayOfWeek, totalDays } = useMemo(
22
26
  () => ({
@@ -71,7 +71,7 @@ export const DatePicker = JSX<DatePickerProps>(
71
71
  <div className="relative">
72
72
  {renderDatePickerForm(handleChangeVisibleCalendar, value, valid)}
73
73
  {showCalendar ? (
74
- <div className="absolute bg-white z-20 select-none">
74
+ <div className="absolute bg-white z-20 select-none bottom-full">
75
75
  <div className="flex gap-s">
76
76
  <div className="my-auto" onClick={handlePrevMonth}>
77
77
  <Icon {...ICON_PROPS} className="-rotate-90 cursor-pointer" />
@@ -5,24 +5,26 @@ import { style } from '../../utils/style';
5
5
  interface LoaderProps {
6
6
  color?: TextColor;
7
7
  position?: 'static' | 'absolute';
8
+ blur?: boolean;
8
9
  }
9
10
 
10
- export const Loader = JSX<LoaderProps>(({ color = 'text-primary-main', position = 'absolute' }) => (
11
- <div
12
- className={style(
13
- 'flex justify-center items-center h-full w-full backdrop-blur-sm z-50',
14
- position,
15
- )}
16
- >
11
+ export const Loader = JSX<LoaderProps>(
12
+ ({ color = 'text-primary-main', position = 'absolute', blur = true }) => (
17
13
  <div
18
- className={style(
19
- 'inline-block h-28 w-28',
20
- 'animate-spin rounded-full',
21
- 'border-8 border-solid border-current',
22
- 'border-r-transparent',
23
- color,
24
- )}
25
- role="status"
26
- />
27
- </div>
28
- ));
14
+ className={style('flex justify-center items-center h-full w-full z-50', position, {
15
+ 'backdrop-blur': blur,
16
+ })}
17
+ >
18
+ <div
19
+ className={style(
20
+ 'inline-block h-28 w-28',
21
+ 'animate-spin rounded-full',
22
+ 'border-8 border-solid border-current',
23
+ 'border-r-transparent',
24
+ color,
25
+ )}
26
+ role="status"
27
+ />
28
+ </div>
29
+ ),
30
+ );
@@ -0,0 +1,34 @@
1
+ import { JSX } from '@redneckz/uni-jsx';
2
+ import { useEffect } from '@redneckz/uni-jsx/lib/hooks';
3
+
4
+ interface TimerProps {
5
+ time: number;
6
+ setTime: React.Dispatch<React.SetStateAction<number>>;
7
+ interval?: number;
8
+ className?: string;
9
+ }
10
+
11
+ export const Timer = JSX<TimerProps>(({ time, setTime, className }) => {
12
+ useEffect(() => {
13
+ const timer = setInterval(() => {
14
+ setTime(time - 1);
15
+ }, 1000);
16
+
17
+ if (time === 0) {
18
+ clearInterval(timer);
19
+ }
20
+
21
+ return () => {
22
+ clearInterval(timer);
23
+ };
24
+ }, [time]);
25
+
26
+ return <span className={className}>{secondsToMinSecPadded(time)}</span>;
27
+ });
28
+
29
+ const secondsToMinSecPadded = (time: number) => {
30
+ const minutes = `${Math.floor(time / 60)}`.padStart(2, '0');
31
+ const seconds = `${time % 60}`.padStart(2, '0');
32
+
33
+ return `${minutes}:${seconds}`;
34
+ };
@@ -1,31 +1,18 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import { useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
2
+ import { useState } from '@redneckz/uni-jsx/lib/hooks';
3
3
  import { Headline } from '../../components/Headline/Headline';
4
4
  import { RichText } from '../RichText/RichText';
5
+ import { Timer } from './Timer';
5
6
 
6
- interface TimerProps {
7
+ interface TimerCircleProps {
7
8
  interval?: number;
8
9
  title?: string;
9
10
  __html?: string;
10
11
  }
11
12
 
12
- export const Timer = JSX<TimerProps>(({ interval = 0, title, __html }) => {
13
+ export const TimerCircle = JSX<TimerCircleProps>(({ interval = 0, title, __html }) => {
13
14
  const [time, setTime] = useState(interval);
14
15
 
15
- useEffect(() => {
16
- const timer = setInterval(() => {
17
- setTime(time - 1);
18
- }, 1000);
19
-
20
- if (time === 0) {
21
- clearInterval(timer);
22
- }
23
-
24
- return () => {
25
- clearInterval(timer);
26
- };
27
- }, [time]);
28
-
29
16
  const gradientPercentage = 100 - ((interval - time) / interval) * 100;
30
17
 
31
18
  return (
@@ -40,7 +27,7 @@ export const Timer = JSX<TimerProps>(({ interval = 0, title, __html }) => {
40
27
  }}
41
28
  />
42
29
  <div className="z-10 flex items-center justify-center px-4 py-2 rounded-full w-56 h-56 bg-white text-3xl text-primary-text">
43
- {secondsToMinSecPadded(time)}
30
+ <Timer interval={interval} time={time} setTime={setTime} />
44
31
  </div>
45
32
  </div>
46
33
  <RichText __html={__html} />
@@ -48,10 +35,3 @@ export const Timer = JSX<TimerProps>(({ interval = 0, title, __html }) => {
48
35
  </div>
49
36
  );
50
37
  });
51
-
52
- const secondsToMinSecPadded = (time: number) => {
53
- const minutes = `${Math.floor(time / 60)}`.padStart(2, '0');
54
- const seconds = `${time % 60}`.padStart(2, '0');
55
-
56
- return `${minutes}:${seconds}`;
57
- };
@@ -0,0 +1,90 @@
1
+ import { JSX } from '@redneckz/uni-jsx';
2
+ import { useCallback, useEffect, useRef, useState } from '@redneckz/uni-jsx/lib/hooks';
3
+
4
+ type InputCodeProps = {
5
+ values: string[];
6
+ setValues: React.Dispatch<React.SetStateAction<string[]>>;
7
+ hasError?: boolean;
8
+ };
9
+
10
+ export const InputCode = JSX<InputCodeProps>(({ values, setValues, hasError }) => {
11
+ const [activeIndex, setActiveIndex] = useState(0);
12
+ const inputRefs = useRef<HTMLInputElement[]>([]);
13
+
14
+ useEffect(() => {
15
+ inputRefs.current?.[activeIndex]?.focus();
16
+ }, [activeIndex]);
17
+
18
+ const handleChange = useCallback(
19
+ (index: number) => (event: React.ChangeEvent<HTMLInputElement>) => {
20
+ const { value } = event.currentTarget;
21
+ const isLastIndex = index === values.length - 1;
22
+ const isMultipleCharacters = value.length > 1;
23
+ if (isLastIndex && isMultipleCharacters) {
24
+ return;
25
+ }
26
+ setValues(values.map((_, i) => (i === index ? value : _)));
27
+ setActiveIndex(index + 1);
28
+ },
29
+ [values],
30
+ );
31
+
32
+ const handleKeyDown = useCallback(
33
+ (currentIndex: number) => (event: React.KeyboardEvent<HTMLInputElement>) => {
34
+ const { key } = event;
35
+ if (key === 'Backspace' && !values[currentIndex]) {
36
+ const previousIndex = currentIndex > 0 ? currentIndex - 1 : values.length - 1;
37
+ const updatedValues = values.map((value, index) => (index === previousIndex ? '' : value));
38
+ setValues(updatedValues);
39
+ setActiveIndex(previousIndex);
40
+ }
41
+ },
42
+ [values],
43
+ );
44
+
45
+ const handlePaste = useCallback(
46
+ (event: React.ClipboardEvent<HTMLInputElement>) => {
47
+ event.preventDefault();
48
+ const pastedData = event.clipboardData.getData('text');
49
+ const updatedValues = values.map((_, idx) => (idx < pastedData.length ? pastedData[idx] : _));
50
+ setValues(updatedValues);
51
+ setActiveIndex(updatedValues.length - 1);
52
+ },
53
+ [values],
54
+ );
55
+
56
+ return (
57
+ <div className="flex flex-col gap-2 text-center">
58
+ <div>
59
+ {values.map((value, index) => (
60
+ <input
61
+ key={index}
62
+ type="number"
63
+ maxLength={1}
64
+ value={value}
65
+ onChange={handleChange(index)}
66
+ onPaste={handlePaste}
67
+ ref={(ref) => {
68
+ if (!inputRefs.current) {
69
+ inputRefs.current = [];
70
+ }
71
+ inputRefs.current[index] = ref as HTMLInputElement;
72
+ }}
73
+ onFocus={(event) => event.target.select()}
74
+ onKeyDown={handleKeyDown(index)}
75
+ className={getInputStyle(index, values, hasError)}
76
+ />
77
+ ))}
78
+ </div>
79
+ {hasError ? <div className="text-error">Неверный код</div> : null}
80
+ </div>
81
+ );
82
+ });
83
+
84
+ const getInputStyle = (index: number, values: string[], hasError?: boolean) => {
85
+ const isInputEmpty = !values[index];
86
+
87
+ return `w-16 h-20 text-3xl text-center p-2 m-2 border ${
88
+ hasError && isInputEmpty ? 'border-error' : 'border-gray'
89
+ } rounded-md caret-transparent outline-none`;
90
+ };
@@ -0,0 +1,17 @@
1
+ import { JSX } from '@redneckz/uni-jsx';
2
+ import { Button } from '../Button/Button';
3
+ import { Text } from '../Text/Text';
4
+
5
+ interface SubmitButtonProps {
6
+ isDisabled: boolean;
7
+ onClick: () => void;
8
+ text?: string;
9
+ }
10
+
11
+ export const SubmitButton = JSX<SubmitButtonProps>(({ isDisabled, onClick, text }) => {
12
+ return (
13
+ <Button type="button" onClick={onClick} disabled={isDisabled}>
14
+ <Text font="font-medium">{text}</Text>
15
+ </Button>
16
+ );
17
+ });
@@ -0,0 +1,83 @@
1
+ import { JSX } from '@redneckz/uni-jsx';
2
+ import { useCallback, useState } from '@redneckz/uni-jsx/lib/hooks';
3
+ import { useMemo } from 'react';
4
+ import { Headline } from '../../components/Headline/Headline';
5
+ import { Dialog } from '../DialogManager/Dialog';
6
+ import { useDialogManager } from '../DialogManager/useDialogManager';
7
+ import { LinkButton } from '../LinkButton/LinkButton';
8
+ import { Loader } from '../Loader/Loader';
9
+ import { RichText } from '../RichText/RichText';
10
+ import { Timer } from '../TimerCircle/Timer';
11
+ import { InputCode } from './InputCode';
12
+ import { SubmitButton } from './SubmitButton';
13
+ import { submitVerifyPhoneForm } from './submitVerifyPhoneForm';
14
+
15
+ export interface VerifyPhoneDialogProps {
16
+ title?: string;
17
+ description?: string;
18
+ code?: boolean;
19
+ __html?: string;
20
+ codeLength?: number;
21
+ textButton?: string;
22
+ }
23
+
24
+ export const VerifyPhoneDialog = JSX<VerifyPhoneDialogProps>(
25
+ ({ title, description, __html, code = true, codeLength = 4, textButton = '' }) => {
26
+ const { close } = useDialogManager();
27
+
28
+ const [values, setValues] = useState(Array(codeLength).fill(''));
29
+ const [hasError, setHasError] = useState(false);
30
+ const [isLoading, setIsLoading] = useState(false);
31
+ const [timeNextReq, setTimeNextReq] = useState<number>(0);
32
+
33
+ const isValidCode = useMemo(() => values.every(Boolean), [values]);
34
+
35
+ const handleSubmit = useCallback(async () => {
36
+ setIsLoading(true);
37
+ const { success, expiresIn } = await submitVerifyPhoneForm(values.join(''));
38
+ setIsLoading(false);
39
+
40
+ setTimeNextReq(expiresIn as number);
41
+
42
+ if (success) {
43
+ close();
44
+ } else {
45
+ setHasError(true);
46
+ }
47
+ }, [values]);
48
+
49
+ return (
50
+ <Dialog className="my-6xl max-w-3xl w-full min-h-fit mx-auto rounded-lg">
51
+ <div className="flex flex-col gap-lg items-center rounded-md">
52
+ <Headline
53
+ className="w-full"
54
+ title={title}
55
+ description={description}
56
+ headlineVersion="S"
57
+ isEmbedded={true}
58
+ />
59
+ {code ? <InputCode values={values} setValues={setValues} hasError={hasError} /> : null}
60
+ {timeNextReq ? (
61
+ <div className="flex flex-row text-l font-light text-primary-main">
62
+ Получить новый код можно через
63
+ <Timer
64
+ className="text-primary-main ml-1"
65
+ time={timeNextReq}
66
+ setTime={setTimeNextReq}
67
+ />
68
+ </div>
69
+ ) : (
70
+ <LinkButton className="text-primary-main">Получить новый код</LinkButton>
71
+ )}
72
+
73
+ <RichText itemSize="list-s" __html={__html} />
74
+ {textButton ? (
75
+ <SubmitButton isDisabled={!isValidCode} onClick={handleSubmit} text={textButton} />
76
+ ) : null}
77
+
78
+ {isLoading ? <Loader blur={false} /> : null}
79
+ </div>
80
+ </Dialog>
81
+ );
82
+ },
83
+ );
@@ -0,0 +1,36 @@
1
+ export interface VerifyPhoneFormData {
2
+ smsText: string;
3
+ smsCodesSetName: {
4
+ key: string;
5
+ };
6
+ }
7
+
8
+ const SEND_CODE_URL = '/api/v1/sms/checkCode';
9
+
10
+ export const submitVerifyPhoneForm = async (code: string) => {
11
+ const codeData: VerifyPhoneFormData = {
12
+ smsText: code,
13
+ smsCodesSetName: { key: 'AUTHENTICATION' },
14
+ };
15
+
16
+ const response = await fetch(SEND_CODE_URL, {
17
+ method: 'POST',
18
+ headers: {
19
+ 'Content-Type': 'application/json',
20
+ },
21
+ body: JSON.stringify(codeData),
22
+ });
23
+
24
+ if (response.ok) {
25
+ const data = await response.json();
26
+
27
+ return {
28
+ success: true,
29
+ expiresIn: data.expires_in,
30
+ };
31
+ } else {
32
+ return {
33
+ success: false,
34
+ };
35
+ }
36
+ };
@@ -0,0 +1,11 @@
1
+ import { useDialogManager, type DialogOptions } from '../DialogManager/useDialogManager';
2
+ import { VerifyPhoneDialog, type VerifyPhoneDialogProps } from './VerifyPhoneDialog';
3
+
4
+ export const useVerifyPhoneDialog = (props: VerifyPhoneDialogProps) => {
5
+ const { open, close } = useDialogManager();
6
+
7
+ return {
8
+ open: (options: DialogOptions = {}) => open(<VerifyPhoneDialog {...props} />, options),
9
+ close,
10
+ };
11
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.14.565",
3
+ "version": "0.14.567",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -12,11 +12,15 @@ interface CalendarProps {
12
12
  min?: Date;
13
13
  max?: Date;
14
14
  onDateSelect?: (date: Date) => void;
15
+ setValue?: (value: boolean) => void;
15
16
  }
16
17
 
17
18
  export const Calendar = JSX<CalendarProps>(
18
- ({ today, currentMonth, currentYear, min, max, onDateSelect = noop }) => {
19
- const handleDateClick = useCallback((date: Date) => onDateSelect(date), []);
19
+ ({ today, currentMonth, currentYear, min, max, onDateSelect = noop, setValue = noop }) => {
20
+ const handleDateClick = useCallback((date: Date) => {
21
+ onDateSelect(date);
22
+ setValue(false);
23
+ }, []);
20
24
 
21
25
  const { firstDayOfWeek, totalDays } = useMemo(
22
26
  () => ({
@@ -71,7 +71,7 @@ export const DatePicker = JSX<DatePickerProps>(
71
71
  <div className="relative">
72
72
  {renderDatePickerForm(handleChangeVisibleCalendar, value, valid)}
73
73
  {showCalendar ? (
74
- <div className="absolute bg-white z-20 select-none">
74
+ <div className="absolute bg-white z-20 select-none bottom-full">
75
75
  <div className="flex gap-s">
76
76
  <div className="my-auto" onClick={handlePrevMonth}>
77
77
  <Icon {...ICON_PROPS} className="-rotate-90 cursor-pointer" />
@@ -5,24 +5,26 @@ import { style } from '../../utils/style';
5
5
  interface LoaderProps {
6
6
  color?: TextColor;
7
7
  position?: 'static' | 'absolute';
8
+ blur?: boolean;
8
9
  }
9
10
 
10
- export const Loader = JSX<LoaderProps>(({ color = 'text-primary-main', position = 'absolute' }) => (
11
- <div
12
- className={style(
13
- 'flex justify-center items-center h-full w-full backdrop-blur-sm z-50',
14
- position,
15
- )}
16
- >
11
+ export const Loader = JSX<LoaderProps>(
12
+ ({ color = 'text-primary-main', position = 'absolute', blur = true }) => (
17
13
  <div
18
- className={style(
19
- 'inline-block h-28 w-28',
20
- 'animate-spin rounded-full',
21
- 'border-8 border-solid border-current',
22
- 'border-r-transparent',
23
- color,
24
- )}
25
- role="status"
26
- />
27
- </div>
28
- ));
14
+ className={style('flex justify-center items-center h-full w-full z-50', position, {
15
+ 'backdrop-blur': blur,
16
+ })}
17
+ >
18
+ <div
19
+ className={style(
20
+ 'inline-block h-28 w-28',
21
+ 'animate-spin rounded-full',
22
+ 'border-8 border-solid border-current',
23
+ 'border-r-transparent',
24
+ color,
25
+ )}
26
+ role="status"
27
+ />
28
+ </div>
29
+ ),
30
+ );
@@ -0,0 +1,34 @@
1
+ import { JSX } from '@redneckz/uni-jsx';
2
+ import { useEffect } from '@redneckz/uni-jsx/lib/hooks';
3
+
4
+ interface TimerProps {
5
+ time: number;
6
+ setTime: React.Dispatch<React.SetStateAction<number>>;
7
+ interval?: number;
8
+ className?: string;
9
+ }
10
+
11
+ export const Timer = JSX<TimerProps>(({ time, setTime, className }) => {
12
+ useEffect(() => {
13
+ const timer = setInterval(() => {
14
+ setTime(time - 1);
15
+ }, 1000);
16
+
17
+ if (time === 0) {
18
+ clearInterval(timer);
19
+ }
20
+
21
+ return () => {
22
+ clearInterval(timer);
23
+ };
24
+ }, [time]);
25
+
26
+ return <span className={className}>{secondsToMinSecPadded(time)}</span>;
27
+ });
28
+
29
+ const secondsToMinSecPadded = (time: number) => {
30
+ const minutes = `${Math.floor(time / 60)}`.padStart(2, '0');
31
+ const seconds = `${time % 60}`.padStart(2, '0');
32
+
33
+ return `${minutes}:${seconds}`;
34
+ };
@@ -1,11 +1,11 @@
1
1
  import '../../setup-fixture';
2
2
 
3
- import { Timer } from './Timer';
3
+ import { TimerCircle } from './TimerCircle';
4
4
 
5
5
  export default {
6
6
  default: (
7
7
  <div>
8
- <Timer
8
+ <TimerCircle
9
9
  interval={100}
10
10
  title="Заявка в обработке"
11
11
  __html="<p>Нам нужно больше времени для обработки вашей заявки.</p>
@@ -1,31 +1,18 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import { useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
2
+ import { useState } from '@redneckz/uni-jsx/lib/hooks';
3
3
  import { Headline } from '../../components/Headline/Headline';
4
4
  import { RichText } from '../RichText/RichText';
5
+ import { Timer } from './Timer';
5
6
 
6
- interface TimerProps {
7
+ interface TimerCircleProps {
7
8
  interval?: number;
8
9
  title?: string;
9
10
  __html?: string;
10
11
  }
11
12
 
12
- export const Timer = JSX<TimerProps>(({ interval = 0, title, __html }) => {
13
+ export const TimerCircle = JSX<TimerCircleProps>(({ interval = 0, title, __html }) => {
13
14
  const [time, setTime] = useState(interval);
14
15
 
15
- useEffect(() => {
16
- const timer = setInterval(() => {
17
- setTime(time - 1);
18
- }, 1000);
19
-
20
- if (time === 0) {
21
- clearInterval(timer);
22
- }
23
-
24
- return () => {
25
- clearInterval(timer);
26
- };
27
- }, [time]);
28
-
29
16
  const gradientPercentage = 100 - ((interval - time) / interval) * 100;
30
17
 
31
18
  return (
@@ -40,7 +27,7 @@ export const Timer = JSX<TimerProps>(({ interval = 0, title, __html }) => {
40
27
  }}
41
28
  />
42
29
  <div className="z-10 flex items-center justify-center px-4 py-2 rounded-full w-56 h-56 bg-white text-3xl text-primary-text">
43
- {secondsToMinSecPadded(time)}
30
+ <Timer interval={interval} time={time} setTime={setTime} />
44
31
  </div>
45
32
  </div>
46
33
  <RichText __html={__html} />
@@ -48,10 +35,3 @@ export const Timer = JSX<TimerProps>(({ interval = 0, title, __html }) => {
48
35
  </div>
49
36
  );
50
37
  });
51
-
52
- const secondsToMinSecPadded = (time: number) => {
53
- const minutes = `${Math.floor(time / 60)}`.padStart(2, '0');
54
- const seconds = `${time % 60}`.padStart(2, '0');
55
-
56
- return `${minutes}:${seconds}`;
57
- };