@headless-adminapp/fluent 1.2.2 → 1.2.3

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
+ }
@@ -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)] }), (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.3",
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": "8d3c42183ed245a59d5200b4f0d4d271ebfe2160"
55
56
  }