@headless-adminapp/fluent 0.0.17-alpha.63 → 0.0.17-alpha.65
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/PageCalendar/CalendarSection.d.ts +20 -0
- package/PageCalendar/CalendarSection.js +108 -0
- package/PageCalendar/EventDialog/AttributeController.d.ts +10 -0
- package/PageCalendar/EventDialog/AttributeController.js +17 -0
- package/PageCalendar/EventDialog/EventDialog.d.ts +25 -0
- package/PageCalendar/EventDialog/EventDialog.js +21 -0
- package/PageCalendar/EventDialog/EventFormBody.d.ts +18 -0
- package/PageCalendar/EventDialog/EventFormBody.js +69 -0
- package/PageCalendar/EventDialog/EventFormContent.d.ts +10 -0
- package/PageCalendar/EventDialog/EventFormContent.js +27 -0
- package/PageCalendar/EventDialog/types.d.ts +3 -0
- package/PageCalendar/EventDialog/types.js +2 -0
- package/PageCalendar/EventDialog/utils.d.ts +23 -0
- package/PageCalendar/EventDialog/utils.js +57 -0
- package/PageCalendar/Header.d.ts +8 -0
- package/PageCalendar/Header.js +35 -0
- package/PageCalendar/PageCalendar.d.ts +7 -0
- package/PageCalendar/PageCalendar.js +231 -0
- package/PageCalendar/TitleSelector.d.ts +10 -0
- package/PageCalendar/TitleSelector.js +73 -0
- package/PageCalendar/ViewSelector.d.ts +8 -0
- package/PageCalendar/ViewSelector.js +52 -0
- package/PageCalendar/baseEventAttributes.d.ts +35 -0
- package/PageCalendar/baseEventAttributes.js +38 -0
- package/PageCalendar/context.d.ts +20 -0
- package/PageCalendar/context.js +5 -0
- package/PageCalendar/hooks/index.d.ts +1 -0
- package/PageCalendar/hooks/index.js +17 -0
- package/PageCalendar/hooks/useConfig.d.ts +3 -0
- package/PageCalendar/hooks/useConfig.js +8 -0
- package/PageCalendar/index.d.ts +1 -0
- package/PageCalendar/index.js +5 -0
- package/PageCalendar/renderEventContent.d.ts +2 -0
- package/PageCalendar/renderEventContent.js +22 -0
- package/PageCalendar/types.d.ts +5 -0
- package/PageCalendar/types.js +9 -0
- package/PageCalendar/utils.d.ts +3 -0
- package/PageCalendar/utils.js +17 -0
- package/PageEntityForm/PageCustomEntityForm.d.ts +4 -0
- package/PageEntityForm/PageCustomEntityForm.js +2 -2
- package/components/BodyLoading.d.ts +1 -1
- package/components/BodyLoading.js +1 -0
- package/form/controls/DateControl.d.ts +1 -1
- package/form/controls/DateTimeControl.js +11 -3
- package/package.json +8 -2
- package/styles.css +49 -0
- package/types/index.d.ts +2 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.PageCalendar = PageCalendar;
|
|
30
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
31
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
32
|
+
const auth_1 = require("@headless-adminapp/app/auth");
|
|
33
|
+
const context_1 = require("@headless-adminapp/app/calendar/context");
|
|
34
|
+
const dialog_1 = require("@headless-adminapp/app/dialog");
|
|
35
|
+
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
36
|
+
const progress_indicator_1 = require("@headless-adminapp/app/progress-indicator");
|
|
37
|
+
const toast_notification_1 = require("@headless-adminapp/app/toast-notification");
|
|
38
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
39
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
40
|
+
const isoWeek_1 = __importDefault(require("dayjs/plugin/isoWeek"));
|
|
41
|
+
const timezone_1 = __importDefault(require("dayjs/plugin/timezone"));
|
|
42
|
+
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
43
|
+
const react_1 = require("react");
|
|
44
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
45
|
+
const EventDialog_1 = require("./EventDialog/EventDialog");
|
|
46
|
+
const Header_1 = require("./Header");
|
|
47
|
+
const types_1 = require("./types");
|
|
48
|
+
const utils_1 = require("./utils");
|
|
49
|
+
const CalendarSection = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./CalendarSection'))).then((mod) => ({ default: mod.CalendarSection })));
|
|
50
|
+
dayjs_1.default.extend(utc_1.default);
|
|
51
|
+
dayjs_1.default.extend(timezone_1.default);
|
|
52
|
+
dayjs_1.default.extend(isoWeek_1.default);
|
|
53
|
+
function PageCalendar(props) {
|
|
54
|
+
const contextValue = (0, mutable_1.useCreateContextStore)({
|
|
55
|
+
config: props.config,
|
|
56
|
+
});
|
|
57
|
+
(0, react_1.useEffect)(() => {
|
|
58
|
+
contextValue.setValue({
|
|
59
|
+
config: props.config,
|
|
60
|
+
});
|
|
61
|
+
}, [contextValue, props.config]);
|
|
62
|
+
const config = props.config;
|
|
63
|
+
const openDialog = (0, dialog_1.useOpenDialog)();
|
|
64
|
+
const openConfirmDialog = (0, dialog_1.useOpenConfirmDialog)();
|
|
65
|
+
const openToastNotification = (0, toast_notification_1.useOpenToastNotification)();
|
|
66
|
+
const { hideProgressIndicator, showProgressIndicator } = (0, progress_indicator_1.useProgressIndicator)();
|
|
67
|
+
const [activeStartDate, setActiveStartDate] = (0, react_1.useState)(null);
|
|
68
|
+
const [activeEndDate, setActiveEndDate] = (0, react_1.useState)(null);
|
|
69
|
+
const [currentStartDate, setCurrentStartDate] = (0, react_1.useState)(null);
|
|
70
|
+
const [currentEndDate, setCurrentEndDate] = (0, react_1.useState)(null);
|
|
71
|
+
const [viewType, setViewType] = (0, react_1.useState)(types_1.ViewType.Month);
|
|
72
|
+
const queryClient = (0, react_query_1.useQueryClient)();
|
|
73
|
+
const filterForm = (0, react_hook_form_1.useForm)({
|
|
74
|
+
mode: 'all',
|
|
75
|
+
defaultValues: config.defaultFilter,
|
|
76
|
+
shouldUnregister: false,
|
|
77
|
+
});
|
|
78
|
+
const filterValues = filterForm.watch();
|
|
79
|
+
const auth = (0, auth_1.useAuthSession)();
|
|
80
|
+
const { data: events, isPending: loading } = (0, react_query_1.useQuery)({
|
|
81
|
+
queryKey: [
|
|
82
|
+
'calendar-events',
|
|
83
|
+
'list',
|
|
84
|
+
activeStartDate,
|
|
85
|
+
activeEndDate,
|
|
86
|
+
filterValues,
|
|
87
|
+
auth,
|
|
88
|
+
],
|
|
89
|
+
queryFn: async () => {
|
|
90
|
+
if (!activeStartDate || !activeEndDate) {
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
const result = await config.eventsResolver({
|
|
95
|
+
start: activeStartDate,
|
|
96
|
+
end: activeEndDate,
|
|
97
|
+
filter: filterValues,
|
|
98
|
+
auth,
|
|
99
|
+
});
|
|
100
|
+
return result.map(utils_1.transformEvent);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
openToastNotification({
|
|
104
|
+
title: 'Error',
|
|
105
|
+
text: error.message,
|
|
106
|
+
type: 'error',
|
|
107
|
+
});
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
staleTime: 1000 * 60 * 5, // 5 minutes
|
|
112
|
+
});
|
|
113
|
+
function openEventDetailModel(values) {
|
|
114
|
+
const { close } = openDialog({
|
|
115
|
+
type: 'custom',
|
|
116
|
+
Component: EventDialog_1.EventDialog,
|
|
117
|
+
props: {
|
|
118
|
+
onDismiss: () => {
|
|
119
|
+
close();
|
|
120
|
+
},
|
|
121
|
+
config,
|
|
122
|
+
values,
|
|
123
|
+
onSubmit: async (data) => {
|
|
124
|
+
try {
|
|
125
|
+
const { id, end, start, title, allDay, description, ...rest } = data.values;
|
|
126
|
+
await config.saveEvent({
|
|
127
|
+
event: {
|
|
128
|
+
id,
|
|
129
|
+
title,
|
|
130
|
+
start: start ? new Date(start) : null,
|
|
131
|
+
end: end ? new Date(end) : null,
|
|
132
|
+
allDay: allDay ?? false,
|
|
133
|
+
description,
|
|
134
|
+
...rest,
|
|
135
|
+
},
|
|
136
|
+
modifiedValues: data.modifiedValues,
|
|
137
|
+
});
|
|
138
|
+
await queryClient.invalidateQueries({
|
|
139
|
+
queryKey: ['calendar-events'],
|
|
140
|
+
});
|
|
141
|
+
close();
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
openToastNotification({
|
|
145
|
+
title: 'Error',
|
|
146
|
+
text: error.message,
|
|
147
|
+
type: 'error',
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
onDelete: async (id) => {
|
|
152
|
+
try {
|
|
153
|
+
const confirmResult = await openConfirmDialog({
|
|
154
|
+
title: 'Delete Event',
|
|
155
|
+
text: 'Are you sure you want to delete this event?',
|
|
156
|
+
});
|
|
157
|
+
if (!confirmResult?.confirmed) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
showProgressIndicator('Deleting event...');
|
|
161
|
+
await config.deleteEvent(id);
|
|
162
|
+
await queryClient.invalidateQueries({
|
|
163
|
+
queryKey: ['calendar-events'],
|
|
164
|
+
});
|
|
165
|
+
close();
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
openToastNotification({
|
|
169
|
+
title: 'Error',
|
|
170
|
+
text: error.message,
|
|
171
|
+
type: 'error',
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
finally {
|
|
175
|
+
hideProgressIndicator();
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
allowOpenRecord: !!config.openRecord,
|
|
179
|
+
onOpenRecord: config.openRecord,
|
|
180
|
+
onCancel: () => {
|
|
181
|
+
close();
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
function handleDateSelect(selectInfo) {
|
|
187
|
+
openEventDetailModel({
|
|
188
|
+
title: '',
|
|
189
|
+
start: selectInfo.start.toISOString(),
|
|
190
|
+
end: selectInfo.end.toISOString(),
|
|
191
|
+
allDay: selectInfo.allDay,
|
|
192
|
+
customer: null,
|
|
193
|
+
description: '',
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
function handleEventClick(clickInfo) {
|
|
197
|
+
openEventDetailModel({
|
|
198
|
+
id: clickInfo.event.id,
|
|
199
|
+
title: clickInfo.event.title,
|
|
200
|
+
start: clickInfo.event.start?.toISOString(),
|
|
201
|
+
end: clickInfo.event.end?.toISOString(),
|
|
202
|
+
allDay: clickInfo.event.allDay,
|
|
203
|
+
description: '',
|
|
204
|
+
...clickInfo.event.extendedProps,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
function handleCreateButtonClick() {
|
|
208
|
+
openEventDetailModel({
|
|
209
|
+
title: '',
|
|
210
|
+
start: null,
|
|
211
|
+
end: null,
|
|
212
|
+
allDay: false,
|
|
213
|
+
description: '',
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
const onRangeChange = ({ currentStart, currentEnd, activeStart, activeEnd, viewType, }) => {
|
|
217
|
+
setCurrentStartDate(currentStart);
|
|
218
|
+
setCurrentEndDate(currentEnd);
|
|
219
|
+
setActiveStartDate(activeStart);
|
|
220
|
+
setActiveEndDate(activeEnd);
|
|
221
|
+
setViewType(viewType);
|
|
222
|
+
};
|
|
223
|
+
return ((0, jsx_runtime_1.jsx)(context_1.CalendarContext.Provider, { value: contextValue, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
224
|
+
display: 'flex',
|
|
225
|
+
flexDirection: 'column',
|
|
226
|
+
flex: 1,
|
|
227
|
+
gap: react_components_1.tokens.spacingVerticalM,
|
|
228
|
+
padding: react_components_1.tokens.spacingHorizontalL,
|
|
229
|
+
background: react_components_1.tokens.colorNeutralBackground3,
|
|
230
|
+
}, children: [(0, jsx_runtime_1.jsx)(Header_1.Header, { filterForm: filterForm, onCreateButtonClick: handleCreateButtonClick }), (0, jsx_runtime_1.jsx)(CalendarSection, { startDate: currentStartDate, endDate: currentEndDate, viewType: viewType, onRangeChange: onRangeChange, events: events ?? [], onEventClick: handleEventClick, onDateSelect: handleDateSelect, loading: loading })] }) }));
|
|
231
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ViewType } from './types';
|
|
3
|
+
interface TitleSelectorProps {
|
|
4
|
+
start?: Date | null;
|
|
5
|
+
end?: Date | null;
|
|
6
|
+
viewType: ViewType;
|
|
7
|
+
onChange: (start: Date, end: Date) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const TitleSelector: FC<TitleSelectorProps>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TitleSelector = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_calendar_compat_1 = require("@fluentui/react-calendar-compat");
|
|
9
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
10
|
+
const locale_1 = require("@headless-adminapp/app/locale");
|
|
11
|
+
const icons_fluent_1 = require("@headless-adminapp/icons-fluent");
|
|
12
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
13
|
+
const isoWeek_1 = __importDefault(require("dayjs/plugin/isoWeek"));
|
|
14
|
+
const timezone_1 = __importDefault(require("dayjs/plugin/timezone"));
|
|
15
|
+
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
16
|
+
const react_1 = require("react");
|
|
17
|
+
const types_1 = require("./types");
|
|
18
|
+
dayjs_1.default.extend(utc_1.default);
|
|
19
|
+
dayjs_1.default.extend(timezone_1.default);
|
|
20
|
+
dayjs_1.default.extend(isoWeek_1.default);
|
|
21
|
+
const TitleSelector = ({ start, end, onChange, viewType, }) => {
|
|
22
|
+
const { timezone } = (0, locale_1.useLocale)();
|
|
23
|
+
const label = (0, react_1.useMemo)(() => {
|
|
24
|
+
if (!start || !end) {
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
switch (viewType) {
|
|
28
|
+
case types_1.ViewType.Day:
|
|
29
|
+
return (0, dayjs_1.default)(start).format('MMM D, YYYY');
|
|
30
|
+
case types_1.ViewType.Week:
|
|
31
|
+
return `${(0, dayjs_1.default)(start).format('MMM D')} - ${(0, dayjs_1.default)(end).format('MMM D, YYYY')}`;
|
|
32
|
+
case types_1.ViewType.Month:
|
|
33
|
+
return (0, dayjs_1.default)(start).format('MMMM YYYY');
|
|
34
|
+
}
|
|
35
|
+
return '';
|
|
36
|
+
}, [start, end, viewType]);
|
|
37
|
+
if (!start || !end) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return ((0, jsx_runtime_1.jsxs)(react_components_1.Popover, { positioning: "below", children: [(0, jsx_runtime_1.jsx)(react_components_1.PopoverTrigger, { children: (0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "subtle", style: {
|
|
41
|
+
fontWeight: react_components_1.tokens.fontWeightMedium,
|
|
42
|
+
fontSize: react_components_1.tokens.fontSizeBase400,
|
|
43
|
+
}, icon: (0, jsx_runtime_1.jsx)(icons_fluent_1.iconSet.ChevronDown, { size: 16 }), iconPosition: "after", children: label }) }), (0, jsx_runtime_1.jsxs)(react_components_1.PopoverSurface, { tabIndex: -1, style: { padding: 0 }, children: [viewType === types_1.ViewType.Month && ((0, jsx_runtime_1.jsx)(react_calendar_compat_1.Calendar, { dateRangeType: react_calendar_compat_1.DateRangeType.Month, highlightSelectedMonth: true, isDayPickerVisible: false, value: start ? (0, dayjs_1.default)(start).toDate() : new Date(), onSelectDate: (date) => {
|
|
44
|
+
const start = (0, dayjs_1.default)(date)
|
|
45
|
+
.tz(timezone, true)
|
|
46
|
+
.startOf('month')
|
|
47
|
+
.toDate();
|
|
48
|
+
const end = (0, dayjs_1.default)(date)
|
|
49
|
+
.tz(timezone, true)
|
|
50
|
+
.endOf('month')
|
|
51
|
+
.toDate();
|
|
52
|
+
onChange(start, end);
|
|
53
|
+
} })), viewType === types_1.ViewType.Week && ((0, jsx_runtime_1.jsx)(react_calendar_compat_1.Calendar, { dateRangeType: react_calendar_compat_1.DateRangeType.Week, firstDayOfWeek: 1, value: start ? (0, dayjs_1.default)(start).toDate() : new Date(), onSelectDate: (date) => {
|
|
54
|
+
const start = (0, dayjs_1.default)(date)
|
|
55
|
+
.tz(timezone, true)
|
|
56
|
+
.startOf('isoWeek')
|
|
57
|
+
.toDate();
|
|
58
|
+
const end = (0, dayjs_1.default)(date)
|
|
59
|
+
.tz(timezone, true)
|
|
60
|
+
.endOf('isoWeek')
|
|
61
|
+
.toDate();
|
|
62
|
+
onChange(start, end);
|
|
63
|
+
} })), viewType === types_1.ViewType.Day && ((0, jsx_runtime_1.jsx)(react_calendar_compat_1.Calendar, { dateRangeType: react_calendar_compat_1.DateRangeType.Day, firstDayOfWeek: 1, value: start ? (0, dayjs_1.default)(start).toDate() : new Date(), onSelectDate: (date) => {
|
|
64
|
+
console.log('d', date);
|
|
65
|
+
const start = (0, dayjs_1.default)(date)
|
|
66
|
+
.tz(timezone, true)
|
|
67
|
+
.startOf('day')
|
|
68
|
+
.toDate();
|
|
69
|
+
const end = (0, dayjs_1.default)(date).tz(timezone, true).endOf('day').toDate();
|
|
70
|
+
onChange(start, end);
|
|
71
|
+
} }))] })] }));
|
|
72
|
+
};
|
|
73
|
+
exports.TitleSelector = TitleSelector;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ViewSelector = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const types_1 = require("./types");
|
|
8
|
+
const viewItems = [
|
|
9
|
+
{
|
|
10
|
+
label: 'Month',
|
|
11
|
+
value: types_1.ViewType.Month,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
label: 'Week',
|
|
15
|
+
value: types_1.ViewType.Week,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
label: 'Day',
|
|
19
|
+
value: types_1.ViewType.Day,
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
const useStyles = (0, react_components_1.makeStyles)({
|
|
23
|
+
root: {},
|
|
24
|
+
button: {
|
|
25
|
+
'&:not(:first-of-type)': {
|
|
26
|
+
// borderLeftWidth: 0,
|
|
27
|
+
borderTopLeftRadius: 0,
|
|
28
|
+
borderBottomLeftRadius: 0,
|
|
29
|
+
},
|
|
30
|
+
'&:not(:last-of-type)': {
|
|
31
|
+
borderRightWidth: 0,
|
|
32
|
+
borderTopRightRadius: 0,
|
|
33
|
+
borderBottomRightRadius: 0,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
active: {
|
|
37
|
+
'&+button': {
|
|
38
|
+
borderLeftColor: 'transparent !important',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
const ViewSelector = ({ viewType, onChange }) => {
|
|
43
|
+
const styles = useStyles();
|
|
44
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
45
|
+
display: 'inline-flex',
|
|
46
|
+
overflow: 'hidden',
|
|
47
|
+
}, className: styles.root, children: viewItems.map((item) => ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: (0, jsx_runtime_1.jsx)(react_components_1.Button, { className: (0, react_components_1.mergeClasses)(styles.button, item.value === viewType && styles.active), appearance: item.value === viewType ? 'primary' : 'secondary', onClick: () => onChange(item.value), style: {
|
|
48
|
+
fontWeight: react_components_1.tokens.fontWeightRegular,
|
|
49
|
+
minWidth: 60,
|
|
50
|
+
}, children: item.label }, item.value) }, item.value))) }));
|
|
51
|
+
};
|
|
52
|
+
exports.ViewSelector = ViewSelector;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare const baseEventAttributes: {
|
|
2
|
+
id: {
|
|
3
|
+
type: "id";
|
|
4
|
+
label: string;
|
|
5
|
+
string: true;
|
|
6
|
+
};
|
|
7
|
+
title: {
|
|
8
|
+
type: "string";
|
|
9
|
+
format: "text";
|
|
10
|
+
label: string;
|
|
11
|
+
required: true;
|
|
12
|
+
};
|
|
13
|
+
start: {
|
|
14
|
+
type: "date";
|
|
15
|
+
format: "datetime";
|
|
16
|
+
label: string;
|
|
17
|
+
required: true;
|
|
18
|
+
};
|
|
19
|
+
end: {
|
|
20
|
+
type: "date";
|
|
21
|
+
format: "datetime";
|
|
22
|
+
label: string;
|
|
23
|
+
required: true;
|
|
24
|
+
};
|
|
25
|
+
allDay: {
|
|
26
|
+
type: "boolean";
|
|
27
|
+
label: string;
|
|
28
|
+
};
|
|
29
|
+
description: {
|
|
30
|
+
type: "string";
|
|
31
|
+
format: "textarea";
|
|
32
|
+
label: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export type BaseEventAttributes = typeof baseEventAttributes;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.baseEventAttributes = void 0;
|
|
4
|
+
const utils_1 = require("@headless-adminapp/core/schema/utils");
|
|
5
|
+
exports.baseEventAttributes = (0, utils_1.defineSchemaAttributes)({
|
|
6
|
+
id: {
|
|
7
|
+
type: 'id',
|
|
8
|
+
label: 'ID',
|
|
9
|
+
string: true,
|
|
10
|
+
},
|
|
11
|
+
title: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
format: 'text',
|
|
14
|
+
label: 'Title',
|
|
15
|
+
required: true,
|
|
16
|
+
},
|
|
17
|
+
start: {
|
|
18
|
+
type: 'date',
|
|
19
|
+
format: 'datetime',
|
|
20
|
+
label: 'Start',
|
|
21
|
+
required: true,
|
|
22
|
+
},
|
|
23
|
+
end: {
|
|
24
|
+
type: 'date',
|
|
25
|
+
format: 'datetime',
|
|
26
|
+
label: 'End',
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
allDay: {
|
|
30
|
+
type: 'boolean',
|
|
31
|
+
label: 'All day',
|
|
32
|
+
},
|
|
33
|
+
description: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
format: 'textarea',
|
|
36
|
+
label: 'Description',
|
|
37
|
+
},
|
|
38
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { InferredSchemaType, SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
2
|
+
import { CalendarEventResolverFn, CalendarEventSaveFn, CalendarEventsResolverFn } from './types';
|
|
3
|
+
export interface CalendarConfig<SA1 extends SchemaAttributes = SchemaAttributes, SA2 extends SchemaAttributes = SchemaAttributes, SA3 extends SchemaAttributes = SchemaAttributes> {
|
|
4
|
+
eventsResolver: CalendarEventsResolverFn<SA3>;
|
|
5
|
+
eventResolver?: CalendarEventResolverFn;
|
|
6
|
+
saveEvent: CalendarEventSaveFn<SA1, SA2>;
|
|
7
|
+
beforeDescriptionAttributes?: SA1;
|
|
8
|
+
afterDescriptionAttributes?: SA2;
|
|
9
|
+
filterAttributes?: SA3;
|
|
10
|
+
defaultFilter?: InferredSchemaType<SA3>;
|
|
11
|
+
openRecord?: (id: string) => void;
|
|
12
|
+
deleteEvent: (id: string) => Promise<void>;
|
|
13
|
+
title: string;
|
|
14
|
+
description: string;
|
|
15
|
+
eventLabel: string;
|
|
16
|
+
}
|
|
17
|
+
export interface CalendarContextState<SA1 extends SchemaAttributes = SchemaAttributes, SA2 extends SchemaAttributes = SchemaAttributes, SA3 extends SchemaAttributes = SchemaAttributes> {
|
|
18
|
+
config: CalendarConfig<SA1, SA2, SA3>;
|
|
19
|
+
}
|
|
20
|
+
export declare const CalendarContext: import("react").Context<import("@headless-adminapp/app/mutable").ContextValue<CalendarContextState<SchemaAttributes, SchemaAttributes, SchemaAttributes>>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useConfig';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useConfig"), exports);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
2
|
+
import { CalendarConfig } from '../context';
|
|
3
|
+
export declare function useConfig<SA1 extends SchemaAttributes = SchemaAttributes, SA2 extends SchemaAttributes = SchemaAttributes, SA3 extends SchemaAttributes = SchemaAttributes>(): CalendarConfig<SA1, SA2, SA3>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useConfig = useConfig;
|
|
4
|
+
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
5
|
+
const context_1 = require("../context");
|
|
6
|
+
function useConfig() {
|
|
7
|
+
return (0, mutable_1.useContextSelector)(context_1.CalendarContext, (state) => state.config);
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PageCalendar } from './PageCalendar';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PageCalendar = void 0;
|
|
4
|
+
var PageCalendar_1 = require("./PageCalendar");
|
|
5
|
+
Object.defineProperty(exports, "PageCalendar", { enumerable: true, get: function () { return PageCalendar_1.PageCalendar; } });
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderEventContent = renderEventContent;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
function renderEventContent(eventInfo) {
|
|
7
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
8
|
+
display: 'flex',
|
|
9
|
+
backgroundColor: react_components_1.tokens.colorBrandBackground2,
|
|
10
|
+
color: react_components_1.tokens.colorNeutralForeground1,
|
|
11
|
+
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
12
|
+
paddingBlock: react_components_1.tokens.spacingVerticalXXS,
|
|
13
|
+
paddingInline: react_components_1.tokens.spacingHorizontalS,
|
|
14
|
+
border: `1px solid ${react_components_1.tokens.colorBrandStroke2}`,
|
|
15
|
+
gap: react_components_1.tokens.spacingHorizontalS,
|
|
16
|
+
width: '100%',
|
|
17
|
+
overflow: 'hidden',
|
|
18
|
+
textOverflow: 'ellipsis',
|
|
19
|
+
height: '100%',
|
|
20
|
+
cursor: 'pointer',
|
|
21
|
+
}, children: [eventInfo.timeText && (0, jsx_runtime_1.jsx)("span", { children: eventInfo.timeText }), (0, jsx_runtime_1.jsx)("span", { style: { fontWeight: react_components_1.tokens.fontWeightSemibold }, children: eventInfo.event.title })] }));
|
|
22
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ViewType = void 0;
|
|
4
|
+
var ViewType;
|
|
5
|
+
(function (ViewType) {
|
|
6
|
+
ViewType["Month"] = "dayGridMonth";
|
|
7
|
+
ViewType["Week"] = "timeGridWeek";
|
|
8
|
+
ViewType["Day"] = "timeGridDay";
|
|
9
|
+
})(ViewType || (exports.ViewType = ViewType = {}));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformEvent = transformEvent;
|
|
4
|
+
function transformEvent(event) {
|
|
5
|
+
const { id, title, description, end, start, ...rest } = event;
|
|
6
|
+
return {
|
|
7
|
+
id,
|
|
8
|
+
title,
|
|
9
|
+
description,
|
|
10
|
+
start: start ?? undefined,
|
|
11
|
+
end: end ?? undefined,
|
|
12
|
+
allDay: event.allDay ?? false,
|
|
13
|
+
backgroundColor: 'transparent',
|
|
14
|
+
borderColor: 'transparent',
|
|
15
|
+
extendedProps: rest,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { RetriveRecordFn } from '@headless-adminapp/app/dataform/DataFormProvider/types';
|
|
2
|
+
import { SaveRecordFn } from '@headless-adminapp/app/dataform/utils/saveRecord';
|
|
1
3
|
import { EntityMainFormCommandItemExperience, Form } from '@headless-adminapp/core/experience/form';
|
|
2
4
|
import { Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
3
5
|
import { FC } from 'react';
|
|
@@ -6,6 +8,8 @@ interface PageCustomEntityFormProps<SA extends SchemaAttributes = SchemaAttribut
|
|
|
6
8
|
schema: Schema<SA>;
|
|
7
9
|
form: Form<SA>;
|
|
8
10
|
commands: EntityMainFormCommandItemExperience[][];
|
|
11
|
+
retriveRecordFn?: RetriveRecordFn<SA>;
|
|
12
|
+
saveRecordFn?: SaveRecordFn;
|
|
9
13
|
}
|
|
10
14
|
export declare const PageCustomEntityForm: FC<PageCustomEntityFormProps>;
|
|
11
15
|
export {};
|
|
@@ -5,8 +5,8 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
6
|
const PageEntityFormProvider_1 = require("@headless-adminapp/app/providers/PageEntityFormProvider");
|
|
7
7
|
const PageEntityFormDesktopContainer_1 = require("./PageEntityFormDesktopContainer");
|
|
8
|
-
const PageCustomEntityForm = ({ recordId, commands, form, schema, }) => {
|
|
9
|
-
return ((0, jsx_runtime_1.jsx)(PageEntityFormProvider_1.PageEntityFormProvider, { schema: schema, form: form, recordId: recordId, commands: commands, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
8
|
+
const PageCustomEntityForm = ({ recordId, commands, form, schema, retriveRecordFn, saveRecordFn, }) => {
|
|
9
|
+
return ((0, jsx_runtime_1.jsx)(PageEntityFormProvider_1.PageEntityFormProvider, { schema: schema, form: form, recordId: recordId, commands: commands, retriveRecordFn: retriveRecordFn, saveRecordFn: saveRecordFn, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
10
10
|
display: 'flex',
|
|
11
11
|
flex: 1,
|
|
12
12
|
flexDirection: 'row',
|
|
@@ -3,4 +3,4 @@ export interface DateControlProps extends ControlProps<string> {
|
|
|
3
3
|
maxDate?: Date;
|
|
4
4
|
minDate?: Date;
|
|
5
5
|
}
|
|
6
|
-
export declare function DateControl({ value, onChange, id, name, onBlur, onFocus, placeholder, disabled, readOnly, }: DateControlProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function DateControl({ value, onChange, id, name, onBlur, onFocus, placeholder, disabled, readOnly, }: Readonly<DateControlProps>): import("react/jsx-runtime").JSX.Element;
|