@licklist/design 0.78.5-dev.16 → 0.78.5-dev.2
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/dist/auth/Layout/UserNavDropDownToggle.js +0 -3
- package/dist/events/edit-recurrent-event-modal/EditRecurrentEventModal.d.ts.map +1 -1
- package/dist/events/event-statistic-modal/EventStatisticModal.d.ts.map +1 -1
- package/dist/iframe/payment/order-items-table/hooks/useTableData.d.ts.map +1 -1
- package/dist/iframe/payment/order-items-table/hooks/useTableData.js +80 -81
- package/dist/modals/dialog/Dialog.d.ts.map +1 -1
- package/dist/modals/dialog/Dialog.js +41 -39
- package/dist/notification/email-template/card/EmailTemplateCard.d.ts.map +1 -1
- package/dist/notification/email-template/control/EmailTemplateControl.d.ts +0 -1
- package/dist/notification/email-template/control/EmailTemplateControl.d.ts.map +1 -1
- package/dist/notification/email-template/control/EmailTemplateControl.js +4 -4
- package/dist/notification/email-template/form/EmailTemplateForm.d.ts +1 -2
- package/dist/notification/email-template/form/EmailTemplateForm.d.ts.map +1 -1
- package/dist/notification/email-template/form/EmailTemplateForm.js +1 -2
- package/dist/product-set/product/advanced-options/AdvancedOptions.js +1 -1
- package/dist/recurrence-input/RecurrenceInput.d.ts.map +1 -1
- package/dist/recurrence-input/RecurrenceInput.js +1 -1
- package/dist/setting/dashboard/payments/payments-modal/PaymentsModal.d.ts.map +1 -1
- package/dist/snippet/snippet-template/preview/Preview.d.ts.map +1 -1
- package/dist/snippet/snippet-template/preview/Preview.js +20 -14
- package/package.json +6 -6
- package/src/auth/Layout/UserNavDropDownToggle.tsx +1 -1
- package/src/events/edit-recurrent-event-modal/EditRecurrentEventModal.tsx +0 -1
- package/src/events/event-statistic-modal/EventStatisticModal.tsx +0 -1
- package/src/iframe/payment/order-items-table/hooks/useTableData.tsx +109 -103
- package/src/modals/dialog/Dialog.tsx +36 -35
- package/src/notification/email-template/card/EmailTemplateCard.tsx +2 -0
- package/src/notification/email-template/control/EmailTemplateControl.tsx +5 -7
- package/src/notification/email-template/form/EmailTemplateForm.tsx +0 -3
- package/src/recurrence-input/RecurrenceInput.tsx +3 -4
- package/src/setting/dashboard/payments/payments-modal/PaymentsModal.tsx +0 -1
- package/src/snippet/snippet-template/preview/Preview.tsx +9 -6
- package/yarn.lock +479 -473
- package/dist/CustomDatePicker/CustomDatePicker.d.ts +0 -10
- package/dist/CustomDatePicker/CustomDatePicker.d.ts.map +0 -1
- package/src/CustomDatePicker/CustomDatePicker.tsx +0 -252
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
type CustomDatePickerProps = {
|
|
2
|
-
name: string;
|
|
3
|
-
error?: string;
|
|
4
|
-
label?: string;
|
|
5
|
-
showAge?: boolean;
|
|
6
|
-
required?: boolean;
|
|
7
|
-
};
|
|
8
|
-
export declare function CustomDatePicker({ name, error, showAge, required }: CustomDatePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=CustomDatePicker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CustomDatePicker.d.ts","sourceRoot":"","sources":["../../src/CustomDatePicker/CustomDatePicker.tsx"],"names":[],"mappings":"AAMA,KAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,IAAI,EACJ,KAAK,EACL,OAAc,EACd,QAAe,EAChB,EAAE,qBAAqB,2CAwOvB"}
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import { TextInput } from '@mantine/core'
|
|
2
|
-
import { useEffect, useState } from 'react'
|
|
3
|
-
import { Controller, useFormContext } from 'react-hook-form'
|
|
4
|
-
import { DateTime } from 'luxon'
|
|
5
|
-
import { useTranslation } from 'react-i18next'
|
|
6
|
-
|
|
7
|
-
type CustomDatePickerProps = {
|
|
8
|
-
name: string
|
|
9
|
-
error?: string
|
|
10
|
-
label?: string
|
|
11
|
-
showAge?: boolean
|
|
12
|
-
required?: boolean
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function CustomDatePicker({
|
|
16
|
-
name,
|
|
17
|
-
error,
|
|
18
|
-
showAge = true,
|
|
19
|
-
required = true
|
|
20
|
-
}: CustomDatePickerProps) {
|
|
21
|
-
const { t } = useTranslation()
|
|
22
|
-
const { control, setValue, watch, getValues, trigger, formState } = useFormContext()
|
|
23
|
-
const [age, setAge] = useState<number | null>(null)
|
|
24
|
-
const [localError, setLocalError] = useState<string | null>(null)
|
|
25
|
-
|
|
26
|
-
// Get current field values
|
|
27
|
-
const day = watch(`${name}_day`) || ''
|
|
28
|
-
const month = watch(`${name}_month`) || ''
|
|
29
|
-
const year = watch(`${name}_year`) || ''
|
|
30
|
-
|
|
31
|
-
// Initialize values from existing date
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
const existingDate = getValues(name)
|
|
34
|
-
|
|
35
|
-
if (existingDate instanceof Date && !day && !month && !year) {
|
|
36
|
-
const dateTime = DateTime.fromJSDate(existingDate)
|
|
37
|
-
if (dateTime.isValid) {
|
|
38
|
-
setValue(`${name}_day`, dateTime.day.toString().padStart(2, '0'))
|
|
39
|
-
setValue(`${name}_month`, dateTime.month.toString().padStart(2, '0'))
|
|
40
|
-
setValue(`${name}_year`, dateTime.year.toString())
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}, [name, setValue, getValues, day, month, year])
|
|
44
|
-
|
|
45
|
-
// Check for empty fields after submit attempt
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (formState.isSubmitted && required) {
|
|
48
|
-
const hasEmptyFields = !day || !month || !year
|
|
49
|
-
|
|
50
|
-
if (hasEmptyFields) {
|
|
51
|
-
setLocalError(t('Validation:fieldRequired', { attribute: t('App:dateOfBirth') }))
|
|
52
|
-
// Set the main field to null to trigger form validation
|
|
53
|
-
setValue(name, null, { shouldValidate: true })
|
|
54
|
-
} else {
|
|
55
|
-
setLocalError(null)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}, [formState.isSubmitted, day, month, year, required, name, setValue, t])
|
|
59
|
-
|
|
60
|
-
// Calculate age and validate date when all fields are filled
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
if (day && month && year) {
|
|
63
|
-
try {
|
|
64
|
-
// Create a date object
|
|
65
|
-
const dateObj = DateTime.fromObject({
|
|
66
|
-
day: parseInt(day, 10),
|
|
67
|
-
month: parseInt(month, 10),
|
|
68
|
-
year: parseInt(year, 10)
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
// Only proceed if date is valid
|
|
72
|
-
if (dateObj.isValid) {
|
|
73
|
-
// Set the main field value
|
|
74
|
-
setValue(name, dateObj.toJSDate(), { shouldValidate: true })
|
|
75
|
-
setLocalError(null)
|
|
76
|
-
|
|
77
|
-
// Calculate age
|
|
78
|
-
if (showAge) {
|
|
79
|
-
const now = DateTime.now()
|
|
80
|
-
const diff = now.diff(dateObj, 'years')
|
|
81
|
-
setAge(Math.floor(diff.years))
|
|
82
|
-
}
|
|
83
|
-
} else {
|
|
84
|
-
setLocalError(t('Validation:fieldInvalid', { attribute: t('App:dateOfBirth') }))
|
|
85
|
-
setValue(name, null, { shouldValidate: true })
|
|
86
|
-
setAge(null)
|
|
87
|
-
}
|
|
88
|
-
} catch (err) {
|
|
89
|
-
// If any parsing fails, just reset the age display
|
|
90
|
-
setLocalError(t('Validation:fieldInvalid', { attribute: t('App:dateOfBirth') }))
|
|
91
|
-
setValue(name, null, { shouldValidate: true })
|
|
92
|
-
setAge(null)
|
|
93
|
-
}
|
|
94
|
-
} else if (formState.isSubmitted && required) {
|
|
95
|
-
// If form was submitted and fields are required but not all filled
|
|
96
|
-
setLocalError(t('Validation:fieldRequired', { attribute: t('App:dateOfBirth') }))
|
|
97
|
-
setValue(name, null, { shouldValidate: true })
|
|
98
|
-
setAge(null)
|
|
99
|
-
} else {
|
|
100
|
-
// Reset if not all fields are filled but not submitted yet
|
|
101
|
-
setValue(name, null, { shouldValidate: false })
|
|
102
|
-
setAge(null)
|
|
103
|
-
}
|
|
104
|
-
}, [day, month, year, name, setValue, showAge, formState.isSubmitted, required, t])
|
|
105
|
-
|
|
106
|
-
// After user completes all fields, validate the form
|
|
107
|
-
useEffect(() => {
|
|
108
|
-
if (day && month && year) {
|
|
109
|
-
trigger(name)
|
|
110
|
-
}
|
|
111
|
-
}, [day, month, year, name, trigger])
|
|
112
|
-
|
|
113
|
-
// Display either the form error or our local error
|
|
114
|
-
const displayError = error || localError
|
|
115
|
-
|
|
116
|
-
return (
|
|
117
|
-
<div className="tw-w-full">
|
|
118
|
-
<div className="tw-flex tw-flex-col">
|
|
119
|
-
<div className="tw-mb-2 tw-flex tw-items-center tw-justify-between">
|
|
120
|
-
<label className="tw-font-semibold">
|
|
121
|
-
{t('App:dateOfBirth')}
|
|
122
|
-
{required && <span className="tw-ml-1 tw-text-red-500"></span>}
|
|
123
|
-
</label>
|
|
124
|
-
{age !== null && (
|
|
125
|
-
<span className="tw-text-sm tw-text-gray-600">
|
|
126
|
-
{t('App:Age')}: {age}
|
|
127
|
-
</span>
|
|
128
|
-
)}
|
|
129
|
-
</div>
|
|
130
|
-
|
|
131
|
-
<div className="tw-flex tw-flex-row tw-gap-4">
|
|
132
|
-
<div className="tw-w-1/3">
|
|
133
|
-
<label className="tw-mb-1 tw-block tw-text-sm">{t('App:Day')}</label>
|
|
134
|
-
<Controller
|
|
135
|
-
control={control}
|
|
136
|
-
name={`${name}_day`}
|
|
137
|
-
defaultValue=""
|
|
138
|
-
render={({ field }) => (
|
|
139
|
-
<TextInput
|
|
140
|
-
{...field}
|
|
141
|
-
value={field.value || ''}
|
|
142
|
-
placeholder="DD"
|
|
143
|
-
maxLength={2}
|
|
144
|
-
error={!!displayError}
|
|
145
|
-
onChange={(e) => {
|
|
146
|
-
const value = e.target.value.replace(/[^0-9]/g, '')
|
|
147
|
-
field.onChange(value)
|
|
148
|
-
}}
|
|
149
|
-
onBlur={(e) => {
|
|
150
|
-
// Validate and format on blur
|
|
151
|
-
let value = e.target.value.replace(/[^0-9]/g, '')
|
|
152
|
-
if (value) {
|
|
153
|
-
const num = parseInt(value, 10)
|
|
154
|
-
if (num < 1) value = '01'
|
|
155
|
-
else if (num > 31) value = '31'
|
|
156
|
-
else value = num.toString().padStart(2, '0')
|
|
157
|
-
}
|
|
158
|
-
field.onChange(value)
|
|
159
|
-
}}
|
|
160
|
-
/>
|
|
161
|
-
)}
|
|
162
|
-
/>
|
|
163
|
-
</div>
|
|
164
|
-
|
|
165
|
-
<div className="tw-w-1/3">
|
|
166
|
-
<label className="tw-mb-1 tw-block tw-text-sm">{t('App:Month')}</label>
|
|
167
|
-
<Controller
|
|
168
|
-
control={control}
|
|
169
|
-
name={`${name}_month`}
|
|
170
|
-
defaultValue=""
|
|
171
|
-
render={({ field }) => (
|
|
172
|
-
<TextInput
|
|
173
|
-
{...field}
|
|
174
|
-
value={field.value || ''}
|
|
175
|
-
placeholder="MM"
|
|
176
|
-
maxLength={2}
|
|
177
|
-
error={!!displayError}
|
|
178
|
-
onChange={(e) => {
|
|
179
|
-
const value = e.target.value.replace(/[^0-9]/g, '')
|
|
180
|
-
field.onChange(value)
|
|
181
|
-
}}
|
|
182
|
-
onBlur={(e) => {
|
|
183
|
-
// Validate and format on blur
|
|
184
|
-
let value = e.target.value.replace(/[^0-9]/g, '')
|
|
185
|
-
if (value) {
|
|
186
|
-
const num = parseInt(value, 10)
|
|
187
|
-
if (num < 1) value = '01'
|
|
188
|
-
else if (num > 12) value = '12'
|
|
189
|
-
else value = num.toString().padStart(2, '0')
|
|
190
|
-
}
|
|
191
|
-
field.onChange(value)
|
|
192
|
-
}}
|
|
193
|
-
/>
|
|
194
|
-
)}
|
|
195
|
-
/>
|
|
196
|
-
</div>
|
|
197
|
-
|
|
198
|
-
<div className="tw-w-1/3">
|
|
199
|
-
<label className="tw-mb-1 tw-block tw-text-sm">{t('App:Year')}</label>
|
|
200
|
-
<Controller
|
|
201
|
-
control={control}
|
|
202
|
-
name={`${name}_year`}
|
|
203
|
-
defaultValue=""
|
|
204
|
-
render={({ field }) => (
|
|
205
|
-
<TextInput
|
|
206
|
-
{...field}
|
|
207
|
-
value={field.value || ''}
|
|
208
|
-
placeholder="YYYY"
|
|
209
|
-
maxLength={4}
|
|
210
|
-
error={!!displayError}
|
|
211
|
-
onChange={(e) => {
|
|
212
|
-
const value = e.target.value.replace(/[^0-9]/g, '')
|
|
213
|
-
field.onChange(value)
|
|
214
|
-
}}
|
|
215
|
-
onBlur={(e) => {
|
|
216
|
-
// Validate on blur
|
|
217
|
-
const value = e.target.value.replace(/[^0-9]/g, '')
|
|
218
|
-
if (value) {
|
|
219
|
-
const num = parseInt(value, 10)
|
|
220
|
-
const currentYear = new Date().getFullYear()
|
|
221
|
-
if (num > currentYear) {
|
|
222
|
-
field.onChange(currentYear.toString())
|
|
223
|
-
} else if (num < 1900) {
|
|
224
|
-
field.onChange('1900')
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}}
|
|
228
|
-
/>
|
|
229
|
-
)}
|
|
230
|
-
/>
|
|
231
|
-
</div>
|
|
232
|
-
</div>
|
|
233
|
-
</div>
|
|
234
|
-
|
|
235
|
-
{/* Hidden field to store the actual date value */}
|
|
236
|
-
<Controller
|
|
237
|
-
control={control}
|
|
238
|
-
name={name}
|
|
239
|
-
defaultValue={null}
|
|
240
|
-
rules={{
|
|
241
|
-
validate: value => {
|
|
242
|
-
if (required && !value) {
|
|
243
|
-
return t('Validation:fieldRequired', { attribute: t('App:dateOfBirth') })
|
|
244
|
-
}
|
|
245
|
-
return true
|
|
246
|
-
}
|
|
247
|
-
}}
|
|
248
|
-
render={() => <input type="hidden" />}
|
|
249
|
-
/>
|
|
250
|
-
</div>
|
|
251
|
-
)
|
|
252
|
-
}
|