injast-core 1.0.78
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/LICENSE +15 -0
- package/README.md +127 -0
- package/dist/components/index.js +3187 -0
- package/dist/constants/index.js +138 -0
- package/dist/context/index.js +308 -0
- package/dist/fonts/IranYekan/Woff/IRANYekanXFaNum-Black.woff +0 -0
- package/dist/fonts/IranYekan/Woff/IRANYekanXFaNum-Bold.woff +0 -0
- package/dist/fonts/IranYekan/Woff/IRANYekanXFaNum-DemiBold.woff +0 -0
- package/dist/fonts/IranYekan/Woff/IRANYekanXFaNum-ExtraBlack.woff +0 -0
- package/dist/fonts/IranYekan/Woff/IRANYekanXFaNum-ExtraBold.woff +0 -0
- package/dist/fonts/IranYekan/Woff/IRANYekanXFaNum-Heavy.woff +0 -0
- package/dist/fonts/IranYekan/Woff/IRANYekanXFaNum-Light.woff +0 -0
- package/dist/fonts/IranYekan/Woff/IRANYekanXFaNum-Medium.woff +0 -0
- package/dist/fonts/IranYekan/Woff/IRANYekanXFaNum-Regular.woff +0 -0
- package/dist/fonts/IranYekan/Woff/IRANYekanXFaNum-Thin.woff +0 -0
- package/dist/fonts/IranYekan/Woff/IRANYekanXFaNum-UltraLight.woff +0 -0
- package/dist/fonts/IranYekan/Woff2/IRANYekanXFaNum-Black.woff2 +0 -0
- package/dist/fonts/IranYekan/Woff2/IRANYekanXFaNum-Bold.woff2 +0 -0
- package/dist/fonts/IranYekan/Woff2/IRANYekanXFaNum-DemiBold.woff2 +0 -0
- package/dist/fonts/IranYekan/Woff2/IRANYekanXFaNum-ExtraBlack.woff2 +0 -0
- package/dist/fonts/IranYekan/Woff2/IRANYekanXFaNum-ExtraBold.woff2 +0 -0
- package/dist/fonts/IranYekan/Woff2/IRANYekanXFaNum-Heavy.woff2 +0 -0
- package/dist/fonts/IranYekan/Woff2/IRANYekanXFaNum-Light.woff2 +0 -0
- package/dist/fonts/IranYekan/Woff2/IRANYekanXFaNum-Medium.woff2 +0 -0
- package/dist/fonts/IranYekan/Woff2/IRANYekanXFaNum-Regular.woff2 +0 -0
- package/dist/fonts/IranYekan/Woff2/IRANYekanXFaNum-Thin.woff2 +0 -0
- package/dist/fonts/IranYekan/Woff2/IRANYekanXFaNum-UltraLight.woff2 +0 -0
- package/dist/fonts/fonts.css +245 -0
- package/dist/hooks/index.js +107 -0
- package/dist/index.js +3831 -0
- package/dist/libs/index.js +142 -0
- package/dist/providers/index.js +305 -0
- package/dist/types/components/Accordion.d.ts +4 -0
- package/dist/types/components/AccordionDetails.d.ts +4 -0
- package/dist/types/components/AccordionSummary.d.ts +4 -0
- package/dist/types/components/Autocomplete.d.ts +3 -0
- package/dist/types/components/Box.d.ts +4 -0
- package/dist/types/components/Button.d.ts +9 -0
- package/dist/types/components/CardNumberInput.d.ts +13 -0
- package/dist/types/components/Checkbox.d.ts +11 -0
- package/dist/types/components/CircularProgress.d.ts +4 -0
- package/dist/types/components/Container.d.ts +4 -0
- package/dist/types/components/CounterBoxInput.d.ts +23 -0
- package/dist/types/components/DataGrid.d.ts +57 -0
- package/dist/types/components/Dialog.d.ts +4 -0
- package/dist/types/components/Divider.d.ts +4 -0
- package/dist/types/components/Drawer.d.ts +9 -0
- package/dist/types/components/Fab.d.ts +4 -0
- package/dist/types/components/FormControl.d.ts +4 -0
- package/dist/types/components/FormControlLabel.d.ts +4 -0
- package/dist/types/components/Grid.d.ts +4 -0
- package/dist/types/components/IconButton.d.ts +4 -0
- package/dist/types/components/Image.d.ts +12 -0
- package/dist/types/components/InputLabel.d.ts +4 -0
- package/dist/types/components/InputPhoneNumber.d.ts +15 -0
- package/dist/types/components/IosHiddenOtpInput.d.ts +6 -0
- package/dist/types/components/List.d.ts +4 -0
- package/dist/types/components/ListItem.d.ts +4 -0
- package/dist/types/components/Loading.d.ts +7 -0
- package/dist/types/components/LoadingModal.d.ts +6 -0
- package/dist/types/components/MenuItem.d.ts +4 -0
- package/dist/types/components/MobileDatePicker.d.ts +19 -0
- package/dist/types/components/Modal.d.ts +9 -0
- package/dist/types/components/MultiSelect.d.ts +14 -0
- package/dist/types/components/NumberInput.d.ts +19 -0
- package/dist/types/components/OtpInput.d.ts +16 -0
- package/dist/types/components/Pagination.d.ts +4 -0
- package/dist/types/components/ProgressBar.d.ts +10 -0
- package/dist/types/components/Radio.d.ts +4 -0
- package/dist/types/components/RadioGroup.d.ts +4 -0
- package/dist/types/components/Select.d.ts +4 -0
- package/dist/types/components/Skeleton.d.ts +4 -0
- package/dist/types/components/Slider.d.ts +4 -0
- package/dist/types/components/Step.d.ts +4 -0
- package/dist/types/components/StepConnector.d.ts +4 -0
- package/dist/types/components/StepContent.d.ts +4 -0
- package/dist/types/components/StepLabel.d.ts +4 -0
- package/dist/types/components/Stepper.d.ts +4 -0
- package/dist/types/components/SvgIcon.d.ts +8 -0
- package/dist/types/components/Tab.d.ts +12 -0
- package/dist/types/components/TextField.d.ts +9 -0
- package/dist/types/components/Toast.d.ts +20 -0
- package/dist/types/components/Toggle.d.ts +10 -0
- package/dist/types/components/Typography.d.ts +8 -0
- package/dist/types/components/WheelDatePicker.d.ts +37 -0
- package/dist/types/components/index.d.ts +53 -0
- package/dist/types/constants/colors.d.ts +2 -0
- package/dist/types/constants/index.d.ts +2 -0
- package/dist/types/constants/stepConnectorClasses.d.ts +2 -0
- package/dist/types/constants/typography.d.ts +82 -0
- package/dist/types/context/MessageHandler.d.ts +15 -0
- package/dist/types/context/index.d.ts +1 -0
- package/dist/types/hooks/index.d.ts +8 -0
- package/dist/types/hooks/useErrorHandler.d.ts +10 -0
- package/dist/types/hooks/useMessage.d.ts +2 -0
- package/dist/types/hooks/useWebOtpListener.d.ts +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.js +19 -0
- package/dist/types/libs/create-api-request.d.ts +10 -0
- package/dist/types/libs/create-logger.d.ts +9 -0
- package/dist/types/libs/create-sentry-instrument.d.ts +9 -0
- package/dist/types/libs/index.d.ts +10 -0
- package/dist/types/providers/SPAThemeProvider.d.ts +11 -0
- package/dist/types/providers/ThemeProvider.d.ts +9 -0
- package/dist/types/providers/index.d.ts +2 -0
- package/dist/types/stories/persian.d.ts +81 -0
- package/dist/types/types/axios.d.ts +8 -0
- package/dist/types/types/color.d.ts +38 -0
- package/dist/types/types/index.d.ts +7 -0
- package/dist/types/types/material-react-table-types.d.ts +2 -0
- package/dist/types/types/mui-types.d.ts +2 -0
- package/dist/types/types/services.d.ts +26 -0
- package/dist/types/types/typography.d.ts +62 -0
- package/dist/types/types/window.d.ts +135 -0
- package/dist/types/utils/checkUser.d.ts +1 -0
- package/dist/types/utils/convertRialToToman.d.ts +7 -0
- package/dist/types/utils/createQueryParams.d.ts +3 -0
- package/dist/types/utils/dateHelpers.d.ts +19 -0
- package/dist/types/utils/delay.d.ts +1 -0
- package/dist/types/utils/formatPersianNumber.d.ts +1 -0
- package/dist/types/utils/getClaims.d.ts +11 -0
- package/dist/types/utils/index.d.ts +17 -0
- package/dist/types/utils/injastStyled.d.ts +2 -0
- package/dist/types/utils/postToParent.d.ts +2 -0
- package/dist/types/utils/toLatinDigit.d.ts +1 -0
- package/dist/utils/index.js +256 -0
- package/package.json +159 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/* 100 – Thin */
|
|
2
|
+
@font-face {
|
|
3
|
+
font-family: 'IRANYekanX';
|
|
4
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-Thin.woff') format('woff'),
|
|
5
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-Thin.woff2') format('woff2');
|
|
6
|
+
font-weight: 100;
|
|
7
|
+
font-style: normal;
|
|
8
|
+
font-display: swap;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/* 200 – ExtraLight / UltraLight */
|
|
12
|
+
@font-face {
|
|
13
|
+
font-family: 'IRANYekanX';
|
|
14
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-UltraLight.woff') format('woff'),
|
|
15
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-UltraLight.woff2') format('woff2');
|
|
16
|
+
font-weight: 200;
|
|
17
|
+
font-style: normal;
|
|
18
|
+
font-display: swap;
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* 300 – Light */
|
|
23
|
+
@font-face {
|
|
24
|
+
font-family: 'IRANYekanX';
|
|
25
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-Light.woff') format('woff'),
|
|
26
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-Light.woff2') format('woff2');
|
|
27
|
+
font-weight: 300;
|
|
28
|
+
font-style: normal;
|
|
29
|
+
font-display: swap;
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* 400 – Regular */
|
|
34
|
+
@font-face {
|
|
35
|
+
font-family: 'IRANYekanX';
|
|
36
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-Regular.woff') format('woff'),
|
|
37
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-Regular.woff2') format('woff2');
|
|
38
|
+
font-weight: 400;
|
|
39
|
+
font-style: normal;
|
|
40
|
+
font-display: swap;
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@font-face {
|
|
45
|
+
font-family: 'IRANYekanX';
|
|
46
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-Regular.woff') format('woff'),
|
|
47
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-Regular.woff2') format('woff2');
|
|
48
|
+
font-weight: normal;
|
|
49
|
+
font-style: normal;
|
|
50
|
+
font-display: swap;
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* 500 – Medium */
|
|
55
|
+
@font-face {
|
|
56
|
+
font-family: 'IRANYekanX';
|
|
57
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-Medium.woff') format('woff'),
|
|
58
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-Medium.woff2') format('woff2');
|
|
59
|
+
font-weight: 500;
|
|
60
|
+
font-style: normal;
|
|
61
|
+
font-display: swap;
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* 600 – DemiBold */
|
|
66
|
+
@font-face {
|
|
67
|
+
font-family: 'IRANYekanX';
|
|
68
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-DemiBold.woff') format('woff'),
|
|
69
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-DemiBold.woff2') format('woff2');
|
|
70
|
+
font-weight: 600;
|
|
71
|
+
font-style: normal;
|
|
72
|
+
font-display: swap;
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* 700 – Bold */
|
|
77
|
+
@font-face {
|
|
78
|
+
font-family: 'IRANYekanX';
|
|
79
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-Bold.woff') format('woff'),
|
|
80
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-Bold.woff2') format('woff2');
|
|
81
|
+
font-weight: 700;
|
|
82
|
+
font-style: normal;
|
|
83
|
+
font-display: swap;
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@font-face {
|
|
88
|
+
font-family: 'IRANYekanX';
|
|
89
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-Bold.woff') format('woff'),
|
|
90
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-Bold.woff2') format('woff2');
|
|
91
|
+
font-weight: bold;
|
|
92
|
+
font-style: normal;
|
|
93
|
+
font-display: swap;
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/* 800 – ExtraBold */
|
|
98
|
+
@font-face {
|
|
99
|
+
font-family: 'IRANYekanX';
|
|
100
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-ExtraBold.woff') format('woff'),
|
|
101
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-ExtraBold.woff2') format('woff2');
|
|
102
|
+
font-weight: 800;
|
|
103
|
+
font-style: normal;
|
|
104
|
+
font-display: swap;
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* 900 – Black */
|
|
109
|
+
@font-face {
|
|
110
|
+
font-family: 'IRANYekanX';
|
|
111
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-Black.woff') format('woff'),
|
|
112
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-Black.woff2') format('woff2');
|
|
113
|
+
font-weight: 900;
|
|
114
|
+
font-style: normal;
|
|
115
|
+
font-display: swap;
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* 950 – ExtraBlack */
|
|
120
|
+
@font-face {
|
|
121
|
+
font-family: 'IRANYekanX';
|
|
122
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-ExtraBlack.woff') format('woff'),
|
|
123
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-ExtraBlack.woff2') format('woff2');
|
|
124
|
+
font-weight: 950;
|
|
125
|
+
font-style: normal;
|
|
126
|
+
font-display: swap;
|
|
127
|
+
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* 1000 – Heavy */
|
|
131
|
+
@font-face {
|
|
132
|
+
font-family: 'IRANYekanX';
|
|
133
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-Heavy.woff') format('woff'),
|
|
134
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-Heavy.woff2') format('woff2');
|
|
135
|
+
font-weight: 1000;
|
|
136
|
+
font-style: normal;
|
|
137
|
+
font-display: swap;
|
|
138
|
+
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/* Alias for theme (SPAThemeProvider uses IRANYekanXFaNum) */
|
|
142
|
+
@font-face {
|
|
143
|
+
font-family: 'IRANYekanXFaNum';
|
|
144
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-Thin.woff') format('woff'),
|
|
145
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-Thin.woff2') format('woff2');
|
|
146
|
+
font-weight: 100;
|
|
147
|
+
font-style: normal;
|
|
148
|
+
font-display: swap;
|
|
149
|
+
}
|
|
150
|
+
@font-face {
|
|
151
|
+
font-family: 'IRANYekanXFaNum';
|
|
152
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-UltraLight.woff') format('woff'),
|
|
153
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-UltraLight.woff2') format('woff2');
|
|
154
|
+
font-weight: 200;
|
|
155
|
+
font-style: normal;
|
|
156
|
+
font-display: swap;
|
|
157
|
+
}
|
|
158
|
+
@font-face {
|
|
159
|
+
font-family: 'IRANYekanXFaNum';
|
|
160
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-Light.woff') format('woff'),
|
|
161
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-Light.woff2') format('woff2');
|
|
162
|
+
font-weight: 300;
|
|
163
|
+
font-style: normal;
|
|
164
|
+
font-display: swap;
|
|
165
|
+
}
|
|
166
|
+
@font-face {
|
|
167
|
+
font-family: 'IRANYekanXFaNum';
|
|
168
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-Regular.woff') format('woff'),
|
|
169
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-Regular.woff2') format('woff2');
|
|
170
|
+
font-weight: 400;
|
|
171
|
+
font-style: normal;
|
|
172
|
+
font-display: swap;
|
|
173
|
+
}
|
|
174
|
+
@font-face {
|
|
175
|
+
font-family: 'IRANYekanXFaNum';
|
|
176
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-Regular.woff') format('woff'),
|
|
177
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-Regular.woff2') format('woff2');
|
|
178
|
+
font-weight: normal;
|
|
179
|
+
font-style: normal;
|
|
180
|
+
font-display: swap;
|
|
181
|
+
}
|
|
182
|
+
@font-face {
|
|
183
|
+
font-family: 'IRANYekanXFaNum';
|
|
184
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-Medium.woff') format('woff'),
|
|
185
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-Medium.woff2') format('woff2');
|
|
186
|
+
font-weight: 500;
|
|
187
|
+
font-style: normal;
|
|
188
|
+
font-display: swap;
|
|
189
|
+
}
|
|
190
|
+
@font-face {
|
|
191
|
+
font-family: 'IRANYekanXFaNum';
|
|
192
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-DemiBold.woff') format('woff'),
|
|
193
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-DemiBold.woff2') format('woff2');
|
|
194
|
+
font-weight: 600;
|
|
195
|
+
font-style: normal;
|
|
196
|
+
font-display: swap;
|
|
197
|
+
}
|
|
198
|
+
@font-face {
|
|
199
|
+
font-family: 'IRANYekanXFaNum';
|
|
200
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-Bold.woff') format('woff'),
|
|
201
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-Bold.woff2') format('woff2');
|
|
202
|
+
font-weight: 700;
|
|
203
|
+
font-style: normal;
|
|
204
|
+
font-display: swap;
|
|
205
|
+
}
|
|
206
|
+
@font-face {
|
|
207
|
+
font-family: 'IRANYekanXFaNum';
|
|
208
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-Bold.woff') format('woff'),
|
|
209
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-Bold.woff2') format('woff2');
|
|
210
|
+
font-weight: bold;
|
|
211
|
+
font-style: normal;
|
|
212
|
+
font-display: swap;
|
|
213
|
+
}
|
|
214
|
+
@font-face {
|
|
215
|
+
font-family: 'IRANYekanXFaNum';
|
|
216
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-ExtraBold.woff') format('woff'),
|
|
217
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-ExtraBold.woff2') format('woff2');
|
|
218
|
+
font-weight: 800;
|
|
219
|
+
font-style: normal;
|
|
220
|
+
font-display: swap;
|
|
221
|
+
}
|
|
222
|
+
@font-face {
|
|
223
|
+
font-family: 'IRANYekanXFaNum';
|
|
224
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-Black.woff') format('woff'),
|
|
225
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-Black.woff2') format('woff2');
|
|
226
|
+
font-weight: 900;
|
|
227
|
+
font-style: normal;
|
|
228
|
+
font-display: swap;
|
|
229
|
+
}
|
|
230
|
+
@font-face {
|
|
231
|
+
font-family: 'IRANYekanXFaNum';
|
|
232
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-ExtraBlack.woff') format('woff'),
|
|
233
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-ExtraBlack.woff2') format('woff2');
|
|
234
|
+
font-weight: 950;
|
|
235
|
+
font-style: normal;
|
|
236
|
+
font-display: swap;
|
|
237
|
+
}
|
|
238
|
+
@font-face {
|
|
239
|
+
font-family: 'IRANYekanXFaNum';
|
|
240
|
+
src: url('./IranYekan/Woff/IRANYekanXFaNum-Heavy.woff') format('woff'),
|
|
241
|
+
url('./IranYekan/Woff2/IRANYekanXFaNum-Heavy.woff2') format('woff2');
|
|
242
|
+
font-weight: 1000;
|
|
243
|
+
font-style: normal;
|
|
244
|
+
font-display: swap;
|
|
245
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/hooks/index.ts
|
|
4
|
+
import { useLocalStorage } from "@wojtekmaj/react-hooks";
|
|
5
|
+
import { useWindowHeight } from "@wojtekmaj/react-hooks";
|
|
6
|
+
import { useWindowWidth } from "@wojtekmaj/react-hooks";
|
|
7
|
+
import { useColorScheme } from "@mui/material/styles";
|
|
8
|
+
import { useTheme } from "@mui/material/styles";
|
|
9
|
+
|
|
10
|
+
// src/hooks/useErrorHandler.ts
|
|
11
|
+
import { useCallback, useState as useState2 } from "react";
|
|
12
|
+
|
|
13
|
+
// src/components/Toast.tsx
|
|
14
|
+
import { Alert, Snackbar } from "@mui/material";
|
|
15
|
+
import { CloseCircle, Danger, InfoCircle, TickCircle } from "iconsax-react";
|
|
16
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
17
|
+
|
|
18
|
+
// src/context/MessageHandler.tsx
|
|
19
|
+
import {
|
|
20
|
+
createContext,
|
|
21
|
+
useState
|
|
22
|
+
} from "react";
|
|
23
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
24
|
+
var MessageContext = createContext(
|
|
25
|
+
void 0
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
// src/hooks/useMessage.ts
|
|
29
|
+
import { useContext as useContext2 } from "react";
|
|
30
|
+
var useMessage = () => {
|
|
31
|
+
const context = useContext2(MessageContext);
|
|
32
|
+
if (!context) {
|
|
33
|
+
throw new Error("useMessage must be used within a MessageProvider");
|
|
34
|
+
}
|
|
35
|
+
return context;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// src/hooks/useErrorHandler.ts
|
|
39
|
+
var general_err_msg = "\u0645\u0634\u06A9\u0644\u06CC \u067E\u06CC\u0634 \u0627\u0648\u0645\u062F\u0647";
|
|
40
|
+
var errorHandler = (err) => {
|
|
41
|
+
if (err instanceof Error) {
|
|
42
|
+
console.log("\u{1F680} ~ err coooore:", err);
|
|
43
|
+
const errorData = JSON.parse(err.message);
|
|
44
|
+
console.log(errorData);
|
|
45
|
+
if (errorData?.message) return errorData.message;
|
|
46
|
+
else if (errorData?.meta?.error_fields) return errorData.meta.error_fields;
|
|
47
|
+
else return general_err_msg;
|
|
48
|
+
} else return general_err_msg;
|
|
49
|
+
};
|
|
50
|
+
var useErrorHandler = () => {
|
|
51
|
+
const { showMessage } = useMessage();
|
|
52
|
+
const [errFields, setErrFields] = useState2();
|
|
53
|
+
const [errorMessage, setErrorMessage] = useState2();
|
|
54
|
+
const handleError = useCallback(
|
|
55
|
+
(error, fieldHandler, isWide = false) => {
|
|
56
|
+
const err = errorHandler(error);
|
|
57
|
+
if (typeof err === "string") {
|
|
58
|
+
setErrorMessage(err);
|
|
59
|
+
showMessage(err, "error", false, isWide);
|
|
60
|
+
} else {
|
|
61
|
+
setErrFields(err);
|
|
62
|
+
if (fieldHandler) {
|
|
63
|
+
err.forEach((err2) => {
|
|
64
|
+
fieldHandler(err2.field, { message: err2.message });
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
[setErrFields]
|
|
70
|
+
);
|
|
71
|
+
return { handleError, errFields, errorMessage };
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// src/hooks/useWebOtpListener.ts
|
|
75
|
+
import { useEffect as useEffect2 } from "react";
|
|
76
|
+
function useWebOtpListener(setOtp) {
|
|
77
|
+
useEffect2(() => {
|
|
78
|
+
const ac = new AbortController();
|
|
79
|
+
if (typeof window !== "undefined" && "OTPCredential" in window && navigator.credentials) {
|
|
80
|
+
navigator.credentials.get({
|
|
81
|
+
otp: { transport: ["sms"] },
|
|
82
|
+
signal: ac.signal
|
|
83
|
+
}).then((credential) => {
|
|
84
|
+
if (credential?.code) {
|
|
85
|
+
setOtp(credential.code);
|
|
86
|
+
}
|
|
87
|
+
ac.abort();
|
|
88
|
+
}).catch((err) => {
|
|
89
|
+
console.error("WebOTP failed:", err);
|
|
90
|
+
ac.abort();
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return () => {
|
|
94
|
+
ac.abort();
|
|
95
|
+
};
|
|
96
|
+
}, [setOtp]);
|
|
97
|
+
}
|
|
98
|
+
export {
|
|
99
|
+
useColorScheme,
|
|
100
|
+
useErrorHandler,
|
|
101
|
+
useLocalStorage,
|
|
102
|
+
useMessage,
|
|
103
|
+
useTheme,
|
|
104
|
+
useWebOtpListener,
|
|
105
|
+
useWindowHeight,
|
|
106
|
+
useWindowWidth
|
|
107
|
+
};
|