@licklist/design 0.58.4-dev.0 → 0.58.4-dev.1
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/index.js +1 -1
- package/dist/product-set/card/ProductSetCard.d.ts +2 -1
- package/dist/product-set/card/ProductSetCard.d.ts.map +1 -1
- package/dist/product-set/card/ProductSetCard.js +1 -1
- package/dist/product-set/control/DateInput.d.ts +17 -0
- package/dist/product-set/control/DateInput.d.ts.map +1 -0
- package/dist/product-set/control/DateInput.js +1 -0
- package/dist/product-set/control/ProductSetControl.d.ts +2 -1
- package/dist/product-set/control/ProductSetControl.d.ts.map +1 -1
- package/dist/product-set/control/ProductSetControl.js +1 -1
- package/dist/product-set/control/ProductSetRecurrenceOverridesControl.d.ts +11 -0
- package/dist/product-set/control/ProductSetRecurrenceOverridesControl.d.ts.map +1 -0
- package/dist/product-set/control/ProductSetRecurrenceOverridesControl.js +1 -0
- package/dist/product-set/control/TutorialGifCard.d.ts +2 -1
- package/dist/product-set/control/TutorialGifCard.d.ts.map +1 -1
- package/dist/product-set/control/TutorialGifCard.js +1 -1
- package/dist/product-set/form/ProductCategoriesControl.d.ts +2 -1
- package/dist/product-set/form/ProductCategoriesControl.d.ts.map +1 -1
- package/dist/product-set/form/ProductCategoriesControl.js +1 -1
- package/dist/product-set/form/ProductSetForm.d.ts +3 -1
- package/dist/product-set/form/ProductSetForm.d.ts.map +1 -1
- package/dist/product-set/form/ProductSetForm.js +1 -1
- package/dist/product-set/form/ProductsControl.d.ts +2 -1
- package/dist/product-set/form/ProductsControl.d.ts.map +1 -1
- package/dist/product-set/form/ProductsControl.js +1 -1
- package/dist/product-set/form/StepsControl.d.ts +2 -1
- package/dist/product-set/form/StepsControl.d.ts.map +1 -1
- package/dist/product-set/form/StepsControl.js +1 -1
- package/dist/product-set/form/SubProductsControl.d.ts +2 -1
- package/dist/product-set/form/SubProductsControl.d.ts.map +1 -1
- package/dist/product-set/form/SubProductsControl.js +1 -1
- package/dist/product-set/hooks/useSortableTreeFunctions.d.ts +2 -1
- package/dist/product-set/hooks/useSortableTreeFunctions.d.ts.map +1 -1
- package/dist/product-set/hooks/useSortableTreeFunctions.js +1 -1
- package/dist/product-set/item/CreateProductSetItem.d.ts +2 -1
- package/dist/product-set/item/CreateProductSetItem.d.ts.map +1 -1
- package/dist/product-set/item/CreateProductSetItem.js +1 -1
- package/dist/product-set/product/ProductControl.d.ts +2 -1
- package/dist/product-set/product/ProductControl.d.ts.map +1 -1
- package/dist/product-set/product/ProductControl.js +1 -1
- package/dist/product-set/product/fixed-duration-fields/FixedDurationOptions.d.ts +4 -2
- package/dist/product-set/product/fixed-duration-fields/FixedDurationOptions.d.ts.map +1 -1
- package/dist/product-set/product/fixed-duration-fields/FixedDurationOptions.js +1 -1
- package/dist/product-set/product/quantity/ProductQuantityControl.d.ts +1 -0
- package/dist/product-set/product/quantity/ProductQuantityControl.d.ts.map +1 -1
- package/dist/product-set/product/quantity/ProductQuantityControl.js +1 -1
- package/dist/product-set/product-category/ProductCategoryControl.d.ts +2 -1
- package/dist/product-set/product-category/ProductCategoryControl.d.ts.map +1 -1
- package/dist/product-set/product-category/ProductCategoryControl.js +1 -1
- package/dist/recurring-date-picker-input/DatePickerInput.d.ts +19 -0
- package/dist/recurring-date-picker-input/DatePickerInput.d.ts.map +1 -0
- package/dist/recurring-date-picker-input/DatePickerInput.js +1 -0
- package/dist/recurring-date-picker-input/RecurrenceAndFrequencyInput.d.ts +15 -0
- package/dist/recurring-date-picker-input/RecurrenceAndFrequencyInput.d.ts.map +1 -0
- package/dist/recurring-date-picker-input/RecurrenceAndFrequencyInput.js +1 -0
- package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts +2 -0
- package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts.map +1 -1
- package/dist/recurring-date-picker-input/RecurringDatePickerInput.js +1 -1
- package/dist/sortable-list/SortableList.d.ts +2 -1
- package/dist/sortable-list/SortableList.d.ts.map +1 -1
- package/dist/sortable-list/SortableList.js +1 -1
- package/dist/sortable-tree/SortableTreeItem.d.ts +3 -1
- package/dist/sortable-tree/SortableTreeItem.d.ts.map +1 -1
- package/dist/sortable-tree/SortableTreeItem.js +1 -1
- package/dist/styles/product-set/EditVenueMapSetModal.scss +1 -1
- package/package.json +1 -1
- package/src/product-set/card/ProductSetCard.tsx +10 -1
- package/src/product-set/control/DateInput.tsx +311 -0
- package/src/product-set/control/ProductSetControl.tsx +46 -24
- package/src/product-set/control/ProductSetRecurrenceOverridesControl.tsx +63 -0
- package/src/product-set/control/TutorialGifCard.tsx +11 -3
- package/src/product-set/form/ProductCategoriesControl.tsx +12 -1
- package/src/product-set/form/ProductSetForm.tsx +5 -0
- package/src/product-set/form/ProductsControl.tsx +10 -0
- package/src/product-set/form/StepsControl.tsx +8 -2
- package/src/product-set/form/SubProductsControl.tsx +3 -0
- package/src/product-set/hooks/useSortableTreeFunctions.ts +4 -0
- package/src/product-set/item/CreateProductSetItem.tsx +3 -0
- package/src/product-set/product/ProductControl.tsx +23 -12
- package/src/product-set/product/fixed-duration-fields/FixedDurationOptions.tsx +10 -2
- package/src/product-set/product/quantity/ProductQuantityControl.tsx +4 -3
- package/src/product-set/product-category/ProductCategoryControl.tsx +12 -8
- package/src/recurring-date-picker-input/DatePickerInput.tsx +93 -0
- package/src/recurring-date-picker-input/RecurrenceAndFrequencyInput.tsx +137 -0
- package/src/recurring-date-picker-input/RecurringDatePickerInput.tsx +4 -1
- package/src/sortable-list/SortableList.tsx +3 -0
- package/src/sortable-tree/SortableTreeItem.tsx +7 -1
- package/src/styles/product-set/EditVenueMapSetModal.scss +1 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
|
+
import { DateTime } from "luxon";
|
|
3
|
+
import { Col, Form, Row } from "react-bootstrap";
|
|
4
|
+
import { useTranslation } from "react-i18next";
|
|
5
|
+
import { RegisterOptions, useFormContext } from "react-hook-form";
|
|
6
|
+
import { RecurringDatePickerInputValues } from "./RecurringDatePickerInput";
|
|
7
|
+
|
|
8
|
+
interface RecurrenceIntervalAndFrequencyInputProps {
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
minDate?: string;
|
|
11
|
+
startDateLabel?: string;
|
|
12
|
+
startTimeLabel?: string;
|
|
13
|
+
endDateLabel?: string;
|
|
14
|
+
endTimeLabel?: string;
|
|
15
|
+
startTimeRules?: Pick<
|
|
16
|
+
RegisterOptions,
|
|
17
|
+
"max" | "min" | "validate" | "required" | "pattern"
|
|
18
|
+
>;
|
|
19
|
+
endTimeRules?: Pick<
|
|
20
|
+
RegisterOptions,
|
|
21
|
+
"max" | "min" | "validate" | "required" | "pattern"
|
|
22
|
+
>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function RecurrenceAndFrequencyInput({
|
|
26
|
+
disabled = false,
|
|
27
|
+
minDate,
|
|
28
|
+
startDateLabel,
|
|
29
|
+
startTimeLabel,
|
|
30
|
+
endTimeLabel,
|
|
31
|
+
startTimeRules,
|
|
32
|
+
endTimeRules,
|
|
33
|
+
}: RecurrenceIntervalAndFrequencyInputProps) {
|
|
34
|
+
const { t } = useTranslation(["Design", "Notification", "App"]);
|
|
35
|
+
|
|
36
|
+
const {
|
|
37
|
+
getValues,
|
|
38
|
+
formState: { errors },
|
|
39
|
+
register,
|
|
40
|
+
trigger,
|
|
41
|
+
} = useFormContext<RecurringDatePickerInputValues>();
|
|
42
|
+
|
|
43
|
+
const startDate = getValues("startDate");
|
|
44
|
+
const startTime = getValues("startTime");
|
|
45
|
+
const endTime = getValues("endTime");
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (!startTime || !endTime) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
trigger("endTime");
|
|
52
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
53
|
+
}, [startTime]);
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<>
|
|
57
|
+
<Row>
|
|
58
|
+
<Col xs={12} sm={6}>
|
|
59
|
+
<Form.Group>
|
|
60
|
+
<Form.Label>{startDateLabel ?? t("Design:fromDate")}</Form.Label>
|
|
61
|
+
<Form.Control
|
|
62
|
+
type="date"
|
|
63
|
+
{...register("startDate", { required: true })}
|
|
64
|
+
defaultValue={startDate}
|
|
65
|
+
className={startDate && "date-input-with-value"}
|
|
66
|
+
disabled={disabled}
|
|
67
|
+
min={minDate}
|
|
68
|
+
isInvalid={Boolean(errors.startDate)}
|
|
69
|
+
/>
|
|
70
|
+
<Form.Control.Feedback type="invalid">
|
|
71
|
+
{errors.startDate?.message}
|
|
72
|
+
</Form.Control.Feedback>
|
|
73
|
+
</Form.Group>
|
|
74
|
+
</Col>
|
|
75
|
+
|
|
76
|
+
</Row>
|
|
77
|
+
|
|
78
|
+
<Row>
|
|
79
|
+
<Col xs={12} sm={6}>
|
|
80
|
+
<Form.Group>
|
|
81
|
+
<Form.Label>
|
|
82
|
+
{startTimeLabel ?? t("Design:availableFrom")}
|
|
83
|
+
</Form.Label>
|
|
84
|
+
<Form.Control
|
|
85
|
+
type="time"
|
|
86
|
+
{...register("startTime", { required: false, ...startTimeRules })}
|
|
87
|
+
placeholder="hh:mm"
|
|
88
|
+
defaultValue={startTime}
|
|
89
|
+
disabled={disabled}
|
|
90
|
+
isInvalid={Boolean(errors.startTime)}
|
|
91
|
+
/>
|
|
92
|
+
<Form.Control.Feedback type="invalid">
|
|
93
|
+
{errors.startTime?.message}
|
|
94
|
+
</Form.Control.Feedback>
|
|
95
|
+
</Form.Group>
|
|
96
|
+
</Col>
|
|
97
|
+
|
|
98
|
+
<Col xs={12} sm={6}>
|
|
99
|
+
<Form.Group>
|
|
100
|
+
<Form.Label>{endTimeLabel ?? t("Design:availableTo")}</Form.Label>
|
|
101
|
+
<Form.Control
|
|
102
|
+
type="time"
|
|
103
|
+
{...register("endTime", {
|
|
104
|
+
required: false,
|
|
105
|
+
validate: (time) => {
|
|
106
|
+
if (!startTime || !time) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
const currentStartTime = DateTime.fromISO(startTime);
|
|
110
|
+
const currentEndTime = DateTime.fromISO(time);
|
|
111
|
+
|
|
112
|
+
return currentEndTime?.diff(currentStartTime, ["minutes"])
|
|
113
|
+
?.minutes >= 0
|
|
114
|
+
? true
|
|
115
|
+
: `${t(`Validation:fieldLaterDate`, {
|
|
116
|
+
attribute: t("Design:endTimeSmall"),
|
|
117
|
+
min: t("Design:startTimeSmall"),
|
|
118
|
+
})}`;
|
|
119
|
+
},
|
|
120
|
+
...endTimeRules,
|
|
121
|
+
})}
|
|
122
|
+
placeholder="hh:mm"
|
|
123
|
+
defaultValue={endTime}
|
|
124
|
+
disabled={disabled}
|
|
125
|
+
isInvalid={Boolean(errors.endTime)}
|
|
126
|
+
/>
|
|
127
|
+
<Form.Control.Feedback type="invalid">
|
|
128
|
+
{errors.endTime?.message}
|
|
129
|
+
</Form.Control.Feedback>
|
|
130
|
+
</Form.Group>
|
|
131
|
+
</Col>
|
|
132
|
+
</Row>
|
|
133
|
+
</>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export default RecurrenceAndFrequencyInput;
|
|
@@ -336,7 +336,10 @@ const useFormattedDuration = ({
|
|
|
336
336
|
}, [start, end, byWeekDay, formatList, formatNumber]);
|
|
337
337
|
};
|
|
338
338
|
|
|
339
|
-
const getDateTimeObject = (
|
|
339
|
+
export const getDateTimeObject = (
|
|
340
|
+
date: string,
|
|
341
|
+
time: string
|
|
342
|
+
): DateTime | string => {
|
|
340
343
|
const dateTime = DateTime.fromFormat(`${date} ${time}`, DATE_TIME_FORMAT);
|
|
341
344
|
|
|
342
345
|
if (dateTime.isValid) {
|
|
@@ -33,6 +33,7 @@ type SortableListProps<T> = {
|
|
|
33
33
|
renderItemContent: (args: RenderItemContentArgs<T>) => ReactNode;
|
|
34
34
|
setItems?: Dispatch<SetStateAction<SortableItem<T>[]>>;
|
|
35
35
|
isExpandNewItem?: boolean;
|
|
36
|
+
isOverrides?: boolean;
|
|
36
37
|
};
|
|
37
38
|
|
|
38
39
|
export const SORTABLE_ID_KEY = "_sortableId";
|
|
@@ -44,6 +45,7 @@ export function SortableList<T>({
|
|
|
44
45
|
renderItemContent,
|
|
45
46
|
setItems,
|
|
46
47
|
isExpandNewItem = false,
|
|
48
|
+
isOverrides = false,
|
|
47
49
|
}: SortableListProps<T>) {
|
|
48
50
|
const [sortedItems, setSortedItems] = useState(items);
|
|
49
51
|
|
|
@@ -97,6 +99,7 @@ export function SortableList<T>({
|
|
|
97
99
|
);
|
|
98
100
|
|
|
99
101
|
function handleDragEnd(event) {
|
|
102
|
+
if (isOverrides) return;
|
|
100
103
|
const { active, over } = event;
|
|
101
104
|
|
|
102
105
|
if (active.id !== over.id) {
|
|
@@ -52,6 +52,8 @@ export interface SortableTreeItemProps {
|
|
|
52
52
|
className: string;
|
|
53
53
|
};
|
|
54
54
|
setIsExpanded?: () => void;
|
|
55
|
+
isOverride?: boolean;
|
|
56
|
+
isProduct?: boolean;
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
export function SortableTreeItem({
|
|
@@ -78,6 +80,8 @@ export function SortableTreeItem({
|
|
|
78
80
|
edit,
|
|
79
81
|
secondaryBadge,
|
|
80
82
|
setIsExpanded,
|
|
83
|
+
isOverride,
|
|
84
|
+
isProduct = false,
|
|
81
85
|
}: SortableTreeItemProps) {
|
|
82
86
|
const [expanded, setExpanded] = useState(isExpanded);
|
|
83
87
|
const [isModalVisible, setIsModalVisible] = useState(isNewAdded);
|
|
@@ -98,6 +102,7 @@ export function SortableTreeItem({
|
|
|
98
102
|
transform: dragTransform,
|
|
99
103
|
} = useDraggable({
|
|
100
104
|
id,
|
|
105
|
+
disabled: isOverride,
|
|
101
106
|
});
|
|
102
107
|
|
|
103
108
|
const onHandleExpand = useCallback(
|
|
@@ -145,6 +150,7 @@ export function SortableTreeItem({
|
|
|
145
150
|
};
|
|
146
151
|
|
|
147
152
|
const onEdit = (e) => {
|
|
153
|
+
if (isOverride && !isProduct) return;
|
|
148
154
|
e.stopPropagation();
|
|
149
155
|
if (edit && !isModalVisible) edit();
|
|
150
156
|
setIsModalVisible(true);
|
|
@@ -366,7 +372,7 @@ export function SortableTreeItem({
|
|
|
366
372
|
items={sortableItems}
|
|
367
373
|
strategy={verticalListSortingStrategy}
|
|
368
374
|
>
|
|
369
|
-
<Collapse
|
|
375
|
+
<Collapse in={expanded}>
|
|
370
376
|
<div className="ml-0">{children}</div>
|
|
371
377
|
</Collapse>
|
|
372
378
|
</SortableContext>
|