@headless-adminapp/fluent 1.2.2 → 1.2.4

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.
@@ -4,7 +4,9 @@ exports.NavItemComponent = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_components_1 = require("@fluentui/react-components");
6
6
  const react_nav_preview_1 = require("@fluentui/react-nav-preview");
7
+ const usePrefetch_1 = require("./usePrefetch");
7
8
  const NavItemComponent = ({ item, onClick, isMini, }) => {
9
+ (0, usePrefetch_1.usePrefetch)(item);
8
10
  return ((0, jsx_runtime_1.jsx)(react_nav_preview_1.NavItem, { href: item.link, onClick: (event) => {
9
11
  event.preventDefault();
10
12
  onClick(item);
@@ -4,6 +4,7 @@ exports.NavMiniCategoryMenu = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_components_1 = require("@fluentui/react-components");
6
6
  const NavItemComponent_1 = require("./NavItemComponent");
7
+ const usePrefetch_1 = require("./usePrefetch");
7
8
  const NavMiniCategoryMenu = ({ item, isActive, onSelect, }) => {
8
9
  return ((0, jsx_runtime_1.jsxs)(react_components_1.Menu, { positioning: "after-top", children: [(0, jsx_runtime_1.jsx)(react_components_1.MenuTrigger, { children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(NavItemComponent_1.NavItemComponent, { item: {
9
10
  key: item.key,
@@ -14,6 +15,10 @@ const NavMiniCategoryMenu = ({ item, isActive, onSelect, }) => {
14
15
  isExternal: false,
15
16
  RightComponent: undefined,
16
17
  type: 'item',
17
- }, onClick: () => { }, isMini: true }, item.key) }) }), (0, jsx_runtime_1.jsx)(react_components_1.MenuPopover, { children: (0, jsx_runtime_1.jsx)(react_components_1.MenuList, { children: item.items.map((subItem) => ((0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { onClick: () => onSelect(subItem), children: subItem.label }, subItem.key))) }) })] }));
18
+ }, onClick: () => { }, isMini: true }, item.key) }) }), (0, jsx_runtime_1.jsx)(react_components_1.MenuPopover, { children: (0, jsx_runtime_1.jsx)(react_components_1.MenuList, { children: item.items.map((subItem) => ((0, jsx_runtime_1.jsx)(NavMenuItem, { item: subItem, onSelect: onSelect }, subItem.key))) }) })] }));
18
19
  };
19
20
  exports.NavMiniCategoryMenu = NavMiniCategoryMenu;
21
+ const NavMenuItem = ({ item, onSelect }) => {
22
+ (0, usePrefetch_1.usePrefetch)(item);
23
+ return (0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { onClick: () => onSelect(item), children: item.label });
24
+ };
@@ -4,7 +4,9 @@ exports.NavSubItemComponent = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_components_1 = require("@fluentui/react-components");
6
6
  const react_nav_preview_1 = require("@fluentui/react-nav-preview");
7
+ const usePrefetch_1 = require("./usePrefetch");
7
8
  const NavSubItemComponent = ({ item, onClick, }) => {
9
+ (0, usePrefetch_1.usePrefetch)(item);
8
10
  return ((0, jsx_runtime_1.jsx)(react_nav_preview_1.NavSubItem, { href: item.link, onClick: (event) => {
9
11
  event.preventDefault();
10
12
  onClick(item);
@@ -0,0 +1,2 @@
1
+ import { NavItemInfo, NavSubItemInfo } from './types';
2
+ export declare function usePrefetch(item: NavItemInfo | NavSubItemInfo): void;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePrefetch = usePrefetch;
4
+ const route_1 = require("@headless-adminapp/app/route");
5
+ const react_1 = require("react");
6
+ function usePrefetch(item) {
7
+ const router = (0, route_1.useRouter)();
8
+ (0, react_1.useEffect)(() => {
9
+ if (!item.isExternal) {
10
+ router.prefetch(item.link);
11
+ }
12
+ }, [item.isExternal, item.link, router]);
13
+ }
@@ -53,34 +53,28 @@ const CalendarSection = ({ startDate, endDate, viewType, onRangeChange, events,
53
53
  switch (props.view.type) {
54
54
  case types_1.ViewType.Month:
55
55
  onRangeChange?.({
56
- currentStart: currentStart, //dayjs(currentStart).tz(timezone).startOf('month').toDate(),
57
- currentEnd: currentEnd, // dayjs(currentEnd).tz(timezone).endOf('month').toDate(),
58
- activeStart: activeStart, // dayjs(activeStart).tz(timezone).startOf('day').toDate(),
59
- activeEnd: activeEnd, // dayjs(activeEnd).tz(timezone).endOf('day').toDate(),
56
+ currentStart: currentStart,
57
+ currentEnd: currentEnd,
58
+ activeStart: activeStart,
59
+ activeEnd: activeEnd,
60
60
  viewType: types_1.ViewType.Month,
61
61
  });
62
62
  break;
63
63
  case types_1.ViewType.Week:
64
64
  onRangeChange?.({
65
- currentStart: (0, dayjs_1.default)(currentStart)
66
- .tz(timezone)
67
- .startOf('isoWeek')
68
- .toDate(),
69
- currentEnd: (0, dayjs_1.default)(currentEnd).tz(timezone).endOf('isoWeek').toDate(),
70
- activeStart: (0, dayjs_1.default)(activeStart).tz(timezone).startOf('day').toDate(),
71
- activeEnd: (0, dayjs_1.default)(activeEnd).tz(timezone).endOf('day').toDate(),
65
+ currentStart: currentStart,
66
+ currentEnd: currentEnd,
67
+ activeStart: activeStart,
68
+ activeEnd: activeEnd,
72
69
  viewType: types_1.ViewType.Week,
73
70
  });
74
71
  break;
75
72
  case types_1.ViewType.Day:
76
73
  onRangeChange?.({
77
- currentStart: (0, dayjs_1.default)(currentStart)
78
- .tz(timezone)
79
- .startOf('day')
80
- .toDate(),
81
- currentEnd: (0, dayjs_1.default)(currentEnd).tz(timezone).endOf('day').toDate(),
82
- activeStart: (0, dayjs_1.default)(activeStart).tz(timezone).startOf('day').toDate(),
83
- activeEnd: (0, dayjs_1.default)(activeEnd).tz(timezone).endOf('day').toDate(),
74
+ currentStart: currentStart,
75
+ currentEnd: currentEnd,
76
+ activeStart: activeStart,
77
+ activeEnd: activeEnd,
84
78
  viewType: types_1.ViewType.Day,
85
79
  });
86
80
  break;
@@ -4,12 +4,14 @@ exports.Header = Header;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_components_1 = require("@fluentui/react-components");
6
6
  const useConfig_1 = require("@headless-adminapp/app/calendar/hooks/useConfig");
7
- const icons_fluent_1 = require("@headless-adminapp/icons-fluent");
7
+ const icons_1 = require("@headless-adminapp/icons");
8
+ const react_query_1 = require("@tanstack/react-query");
8
9
  const react_1 = require("react");
9
10
  const react_hook_form_1 = require("react-hook-form");
10
11
  const StandardControl_1 = require("../PageEntityForm/StandardControl");
11
12
  function Header({ filterForm, onCreateButtonClick, }) {
12
13
  const config = (0, useConfig_1.useConfig)();
14
+ const queryClient = (0, react_query_1.useQueryClient)();
13
15
  return ((0, jsx_runtime_1.jsxs)("div", { style: {
14
16
  display: 'flex',
15
17
  flexDirection: 'column',
@@ -23,11 +25,15 @@ function Header({ filterForm, onCreateButtonClick, }) {
23
25
  display: 'flex',
24
26
  alignItems: 'center',
25
27
  gap: react_components_1.tokens.spacingHorizontalM,
26
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: { flex: 1 }, children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Subtitle2, { style: { color: react_components_1.tokens.colorNeutralForeground1 }, children: config.title }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground2 }, children: config.description })] }) }) }), (0, jsx_runtime_1.jsx)("div", { style: {
28
+ }, children: [(0, jsx_runtime_1.jsx)("div", { style: { flex: 1 }, children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Subtitle2, { style: { color: react_components_1.tokens.colorNeutralForeground1 }, children: config.title }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground2 }, children: config.description })] }) }) }), (0, jsx_runtime_1.jsxs)("div", { style: {
27
29
  display: 'flex',
28
30
  alignItems: 'center',
29
31
  gap: react_components_1.tokens.spacingHorizontalS,
30
- }, children: !!config.createOptions && ((0, jsx_runtime_1.jsx)(react_components_1.Button, { style: { fontWeight: react_components_1.tokens.fontWeightMedium }, icon: (0, jsx_runtime_1.jsx)(icons_fluent_1.iconSet.Add, {}), appearance: "primary", onClick: onCreateButtonClick, children: "Create" })) })] }), !!config.filterAttributes &&
32
+ }, children: [!!config.createOptions && ((0, jsx_runtime_1.jsx)(react_components_1.Button, { style: { fontWeight: react_components_1.tokens.fontWeightMedium }, icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.Add, {}), appearance: "primary", onClick: onCreateButtonClick, children: "Create" })), (0, jsx_runtime_1.jsx)(react_components_1.Button, { icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.Refresh, {}), appearance: "subtle", style: { fontWeight: react_components_1.tokens.fontWeightRegular }, onClick: async () => {
33
+ await queryClient.invalidateQueries({
34
+ queryKey: ['calendar-events', 'list'],
35
+ });
36
+ } })] })] }), !!config.filterAttributes &&
31
37
  Object.keys(config.filterAttributes).length > 0 && ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_components_1.Divider, { style: { opacity: 0.2 } }), (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', gap: react_components_1.tokens.spacingHorizontalS }, children: Object.entries(config.filterAttributes).map(([attributeName, attribute]) => {
32
38
  return ((0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { control: filterForm.control, name: attributeName, render: ({ field }) => {
33
39
  return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(StandardControl_1.StandardControl, { attribute: attribute, name: attributeName, value: field.value, onChange: field.onChange, onBlur: field.onBlur }) }));
@@ -28,17 +28,27 @@ const TitleSelector = ({ start, end, onChange, viewType, }) => {
28
28
  }
29
29
  switch (viewType) {
30
30
  case types_1.ViewType.Day:
31
- return (0, dayjs_1.default)(start).format(isMobile ? 'MMM D' : 'MMM D, YYYY');
31
+ return (0, dayjs_1.default)(start)
32
+ .tz(timezone)
33
+ .format(isMobile ? 'MMM D' : 'MMM D, YYYY');
32
34
  case types_1.ViewType.Week:
33
35
  if (isMobile) {
34
- return `${(0, dayjs_1.default)(start).format('MMM D')} - ${(0, dayjs_1.default)(end).format('D')}`;
36
+ return `${(0, dayjs_1.default)(start).tz(timezone).format('MMM D')} - ${(0, dayjs_1.default)(end)
37
+ .tz(timezone)
38
+ .subtract(1, 'millisecond')
39
+ .format('D')}`;
35
40
  }
36
- return `${(0, dayjs_1.default)(start).format('MMM D')} - ${(0, dayjs_1.default)(end).format('MMM D, YYYY')}`;
41
+ return `${(0, dayjs_1.default)(start).tz(timezone).format('MMM D')} - ${(0, dayjs_1.default)(end)
42
+ .tz(timezone)
43
+ .subtract(1, 'millisecond')
44
+ .format('MMM D, YYYY')}`;
37
45
  case types_1.ViewType.Month:
38
- return (0, dayjs_1.default)(start).format(isMobile ? 'MMM YYYY' : 'MMMM YYYY');
46
+ return (0, dayjs_1.default)(start)
47
+ .tz(timezone)
48
+ .format(isMobile ? 'MMM YYYY' : 'MMMM YYYY');
39
49
  }
40
50
  return '';
41
- }, [start, end, viewType, isMobile]);
51
+ }, [start, end, viewType, timezone, isMobile]);
42
52
  if (!start || !end) {
43
53
  return null;
44
54
  }
@@ -23,22 +23,32 @@ dayjs_1.default.extend(timezone_1.default);
23
23
  function renderEventContent(eventInfo) {
24
24
  return (0, jsx_runtime_1.jsx)(EventContent, { eventInfo: eventInfo });
25
25
  }
26
+ const EventItemPreviewComponent = ({ eventInfo, }) => {
27
+ return ((0, jsx_runtime_1.jsxs)("div", { style: {
28
+ display: 'flex',
29
+ backgroundColor: react_components_1.tokens.colorBrandBackground2,
30
+ color: react_components_1.tokens.colorNeutralForeground1,
31
+ borderRadius: react_components_1.tokens.borderRadiusMedium,
32
+ paddingBlock: react_components_1.tokens.spacingVerticalXXS,
33
+ paddingInline: react_components_1.tokens.spacingHorizontalS,
34
+ border: `1px solid ${react_components_1.tokens.colorBrandStroke2}`,
35
+ gap: react_components_1.tokens.spacingHorizontalS,
36
+ overflow: 'hidden',
37
+ textOverflow: 'ellipsis',
38
+ width: '100%',
39
+ height: '100%',
40
+ cursor: 'pointer',
41
+ }, 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 })] }));
42
+ };
26
43
  const EventContent = ({ eventInfo }) => {
27
44
  const [open, setOpen] = (0, react_1.useState)(false);
28
- return ((0, jsx_runtime_1.jsx)("div", { style: { height: '100%', display: 'flex' }, children: (0, jsx_runtime_1.jsxs)(react_components_1.Popover, { positioning: "after", withArrow: true, open: open, onOpenChange: (e, data) => setOpen(data.open), children: [(0, jsx_runtime_1.jsx)(react_components_1.PopoverTrigger, { children: (0, jsx_runtime_1.jsxs)("div", { style: {
29
- display: 'flex',
30
- backgroundColor: react_components_1.tokens.colorBrandBackground2,
31
- color: react_components_1.tokens.colorNeutralForeground1,
32
- borderRadius: react_components_1.tokens.borderRadiusMedium,
33
- paddingBlock: react_components_1.tokens.spacingVerticalXXS,
34
- paddingInline: react_components_1.tokens.spacingHorizontalS,
35
- border: `1px solid ${react_components_1.tokens.colorBrandStroke2}`,
36
- gap: react_components_1.tokens.spacingHorizontalS,
37
- overflow: 'hidden',
38
- textOverflow: 'ellipsis',
39
- height: '100%',
40
- cursor: 'pointer',
41
- }, 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 })] }) }), (0, jsx_runtime_1.jsx)(react_components_1.PopoverSurface, { style: { maxWidth: 480 }, children: (0, jsx_runtime_1.jsx)(PopoverContent, { eventInfo: eventInfo, onClose: () => setOpen(false) }) })] }) }));
45
+ const config = (0, useConfig_1.useConfig)();
46
+ const EventItemPreview = config.EventItemPreviewComponent ?? EventItemPreviewComponent;
47
+ return ((0, jsx_runtime_1.jsxs)(react_components_1.Popover, { positioning: {
48
+ // coverTarget: true,
49
+ position: 'after',
50
+ shiftToCoverTarget: true,
51
+ }, withArrow: true, open: open, onOpenChange: (e, data) => setOpen(data.open), children: [(0, jsx_runtime_1.jsx)(react_components_1.PopoverTrigger, { children: (0, jsx_runtime_1.jsx)("div", { style: { width: '100%', height: '100%' }, children: (0, jsx_runtime_1.jsx)(EventItemPreview, { eventInfo: eventInfo }) }) }), (0, jsx_runtime_1.jsx)(react_components_1.PopoverSurface, { style: { maxWidth: 480 }, children: (0, jsx_runtime_1.jsx)(PopoverContent, { eventInfo: eventInfo, onClose: () => setOpen(false) }) })] }));
42
52
  };
43
53
  const PopoverContent = ({ eventInfo, onClose }) => {
44
54
  const config = (0, useConfig_1.useConfig)();
@@ -101,5 +111,5 @@ const PopoverContent = ({ eventInfo, onClose }) => {
101
111
  .tz(timezone)
102
112
  .format(timeFormats.short) +
103
113
  ' - ' +
104
- (0, dayjs_1.default)(eventInfo.event.end).tz(timezone).format(timeFormats.short)] }), (0, jsx_runtime_1.jsx)("div", { children: eventInfo.event.extendedProps.description })] })] }));
114
+ (0, dayjs_1.default)(eventInfo.event.end).tz(timezone).format(timeFormats.short)] }), !!eventInfo.event.extendedProps.description && ((0, jsx_runtime_1.jsx)("div", { children: eventInfo.event.extendedProps.description })), !!config.EventExtendedDetailComponent && ((0, jsx_runtime_1.jsx)(config.EventExtendedDetailComponent, { eventInfo: eventInfo }))] })] }));
105
115
  };
@@ -33,7 +33,6 @@ function TimeControl({ value, onChange, id, name, onBlur, placeholder, disabled,
33
33
  }
34
34
  return (0, dayjs_1.default)().startOf('day').add(value, 'minutes').toDate();
35
35
  }, [value]);
36
- console.log('TimeControl', value, selectedTime);
37
36
  return ((0, jsx_runtime_1.jsx)("div", { style: {
38
37
  display: 'flex',
39
38
  alignItems: 'center',
@@ -45,7 +44,6 @@ function TimeControl({ value, onChange, id, name, onBlur, placeholder, disabled,
45
44
  }, placeholder: placeholder, id: id, name: name, input: {
46
45
  style: { minWidth: 0 },
47
46
  }, readOnly: isReadonly, selectedTime: selectedTime, freeform: true, value: internalTimeValue, onTimeChange: (_, data) => {
48
- console.log('onTimeChange', data);
49
47
  if (data.selectedTime) {
50
48
  onChange?.((0, dayjs_1.default)(data.selectedTime).diff((0, dayjs_1.default)().startOf('day'), 'minutes'));
51
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@headless-adminapp/fluent",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -42,6 +42,7 @@
42
42
  "dnd-core": "^16.0.1",
43
43
  "immutability-helper": "^3.1.1",
44
44
  "lodash": "^4.17.21",
45
+ "moment-timezone": "0.5.46",
45
46
  "react-dnd": "^16.0.1",
46
47
  "react-dnd-html5-backend": "^16.0.1",
47
48
  "react-hook-form": "7.52.2",
@@ -51,5 +52,5 @@
51
52
  "uuid": "11.0.3",
52
53
  "yup": "^1.4.0"
53
54
  },
54
- "gitHead": "ae232366aacd1153ee983d09b24f2f3e20548a68"
55
+ "gitHead": "776239a44a2e6d53c3f92665f516feff4e8a83b6"
55
56
  }