@headless-adminapp/fluent 1.4.42 → 1.4.44

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.
@@ -0,0 +1 @@
1
+ export declare const NavigationContainer: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NavigationContainer = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_components_1 = require("@fluentui/react-components");
6
+ const react_nav_preview_1 = require("@fluentui/react-nav-preview");
7
+ const app_1 = require("@headless-adminapp/app/app");
8
+ const locale_1 = require("@headless-adminapp/app/locale");
9
+ const hooks_1 = require("@headless-adminapp/app/route/hooks");
10
+ const icons_1 = require("@headless-adminapp/icons");
11
+ const react_1 = require("react");
12
+ const utils_1 = require("./utils");
13
+ const useStyles = (0, react_components_1.makeStyles)({
14
+ root: {
15
+ overflow: 'hidden',
16
+ display: 'flex',
17
+ flexShrink: 0,
18
+ },
19
+ content: {
20
+ flex: '1',
21
+ padding: '16px',
22
+ display: 'grid',
23
+ justifyContent: 'flex-start',
24
+ alignItems: 'flex-start',
25
+ },
26
+ field: {
27
+ display: 'flex',
28
+ marginTop: '4px',
29
+ marginLeft: '8px',
30
+ flexDirection: 'column',
31
+ gridRowGap: react_components_1.tokens.spacingVerticalS,
32
+ },
33
+ });
34
+ const NavigationContainer = () => {
35
+ const styles = useStyles();
36
+ const { app, schemaMetadataDic } = (0, app_1.useAppContext)();
37
+ const [isOpen] = (0, react_1.useState)(true);
38
+ const [type] = (0, react_1.useState)('inline');
39
+ const router = (0, hooks_1.useRouter)();
40
+ const pathname = (0, hooks_1.usePathname)();
41
+ const selectedPath = pathname;
42
+ const { language } = (0, locale_1.useLocale)();
43
+ const isRouteActive = (0, hooks_1.useIsRouteActive)();
44
+ const routeResolver = (0, hooks_1.useRouteResolver)();
45
+ return ((0, jsx_runtime_1.jsx)("div", { className: styles.root, children: (0, jsx_runtime_1.jsx)(react_nav_preview_1.NavDrawer, { selectedValue: "active", open: isOpen, type: type, children: (0, jsx_runtime_1.jsx)(react_nav_preview_1.NavDrawerBody, { style: { paddingTop: 8 }, children: app.navItems.map((area) => ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: area.groups.map((group) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [!group.hideLabel && ((0, jsx_runtime_1.jsx)(react_nav_preview_1.NavSectionHeader, { children: group.label })), group.items.map((item, index) => {
46
+ var _a;
47
+ const navItem = (0, utils_1.transformNavPageItem)({
48
+ item,
49
+ schemaMetadataDic: schemaMetadataDic,
50
+ language,
51
+ routeResolver,
52
+ });
53
+ const Icon = (_a = navItem.icon) !== null && _a !== void 0 ? _a : icons_1.IconPlaceholder;
54
+ const isActive = isRouteActive(selectedPath, item);
55
+ return ((0, jsx_runtime_1.jsx)(react_nav_preview_1.NavItem, { href: navItem.link, onClick: (event) => {
56
+ event.preventDefault();
57
+ router.push(navItem.link);
58
+ }, icon: (0, jsx_runtime_1.jsx)(Icon, { size: 20, filled: isActive, color: isActive
59
+ ? 'var(--colorNeutralForeground2BrandSelected)'
60
+ : undefined }), value: isActive ? 'active' : '', children: navItem.label }, index));
61
+ })] }, group.label))) }, area.label))) }) }) }));
62
+ };
63
+ exports.NavigationContainer = NavigationContainer;
package/App/utils.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ import { InternalRouteResolver } from '@headless-adminapp/app/route/context';
2
+ import { NavPageItem } from '@headless-adminapp/core/experience/app';
3
+ import { SchemaExperienceMetadata } from '@headless-adminapp/core/experience/schema';
4
+ export declare function transformNavPageItem({ item, schemaMetadataDic: schemaMetadataObject, language, routeResolver, }: {
5
+ item: NavPageItem;
6
+ schemaMetadataDic: Record<string, SchemaExperienceMetadata>;
7
+ language: string;
8
+ routeResolver: InternalRouteResolver;
9
+ }): {
10
+ label: string | undefined;
11
+ icon: import("@headless-adminapp/icons").Icon | undefined;
12
+ link: string;
13
+ isExternal: boolean;
14
+ };
package/App/utils.js ADDED
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformNavPageItem = transformNavPageItem;
4
+ function transformNavPageItem({ item, schemaMetadataDic: schemaMetadataObject, language, routeResolver, }) {
5
+ var _a, _b, _c, _d;
6
+ let icon = item.icon;
7
+ let label = (_b = (_a = item.localizedLabel) === null || _a === void 0 ? void 0 : _a[language]) !== null && _b !== void 0 ? _b : item.label;
8
+ let link = routeResolver(item);
9
+ if (item.type === 'entityview') {
10
+ const metadata = schemaMetadataObject === null || schemaMetadataObject === void 0 ? void 0 : schemaMetadataObject[item.logicalName];
11
+ if (metadata) {
12
+ if (!label) {
13
+ label =
14
+ (_d = (_c = metadata.localizedPluralLabels) === null || _c === void 0 ? void 0 : _c[language]) !== null && _d !== void 0 ? _d : metadata.pluralLabel;
15
+ }
16
+ if (!icon) {
17
+ icon = metadata.icon;
18
+ }
19
+ }
20
+ }
21
+ return {
22
+ label,
23
+ icon,
24
+ link,
25
+ isExternal: item.type === 'external',
26
+ };
27
+ }
@@ -0,0 +1,9 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+ interface ScrollbarWithMoreDataRequest {
3
+ data: any;
4
+ hasMore: boolean;
5
+ onRequestMore: () => void;
6
+ rtl?: boolean;
7
+ }
8
+ export declare const ScrollbarWithMoreDataRequest: FC<PropsWithChildren<ScrollbarWithMoreDataRequest>>;
9
+ export {};
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScrollbarWithMoreDataRequest = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const ScrollView_1 = require("@headless-adminapp/app/components/ScrollView");
6
+ const react_1 = require("react");
7
+ function getReaminingSpace(div) {
8
+ return div.scrollHeight - div.scrollTop - div.clientHeight;
9
+ }
10
+ const ScrollbarWithMoreDataRequest = ({ data, onRequestMore, hasMore, children, rtl }) => {
11
+ const divRef = (0, react_1.useRef)(null);
12
+ const onRequestMoreRef = (0, react_1.useRef)(onRequestMore);
13
+ onRequestMoreRef.current = onRequestMore;
14
+ (0, react_1.useEffect)(() => {
15
+ var _a;
16
+ const div = (_a = divRef.current) === null || _a === void 0 ? void 0 : _a.parentElement;
17
+ if (!div) {
18
+ return;
19
+ }
20
+ const remainingSpace = getReaminingSpace(div);
21
+ if (remainingSpace <= 0 && hasMore) {
22
+ onRequestMoreRef.current();
23
+ }
24
+ }, [data, hasMore]);
25
+ return ((0, jsx_runtime_1.jsx)(ScrollView_1.ScrollView, { autoHide: true, rtl: rtl, onScroll: (e) => {
26
+ const div = e.target;
27
+ const remainingSpace = getReaminingSpace(div);
28
+ if (remainingSpace <= 0 && hasMore) {
29
+ onRequestMoreRef.current();
30
+ }
31
+ }, children: (0, jsx_runtime_1.jsx)("div", { ref: divRef, children: children }) }));
32
+ };
33
+ exports.ScrollbarWithMoreDataRequest = ScrollbarWithMoreDataRequest;
package/README.md CHANGED
@@ -25,7 +25,7 @@ Peer dependencies:
25
25
  Use this package when you want a Fluent UI experience. See the docs and examples for recommended setup:
26
26
 
27
27
  - https://headless-adminapp.github.io/
28
- - https://github.com/kishanmundha/headless-adminapp-examples
28
+ - https://headless-adminapp-examples.vercel.app/
29
29
 
30
30
  ## Development
31
31
 
@@ -0,0 +1,6 @@
1
+ import { ControlProps } from './types';
2
+ export interface DateRangeControlProps extends ControlProps<[string | null, string | null]> {
3
+ maxDate?: Date;
4
+ minDate?: Date;
5
+ }
6
+ export declare function DateRangeControl({ value, onChange, id, name, onBlur, onFocus, disabled, maxDate, minDate, readOnly, }: DateRangeControlProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,49 @@
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.DateRangeControl = DateRangeControl;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const react_datepicker_compat_1 = require("@fluentui/react-datepicker-compat");
9
+ const locale_1 = require("@headless-adminapp/app/locale");
10
+ const dayjs_1 = __importDefault(require("dayjs"));
11
+ const react_1 = require("react");
12
+ const AppStringContext_1 = require("../../App/AppStringContext");
13
+ function DateRangeControl({ value, onChange, id, name, onBlur, onFocus, disabled, maxDate, minDate, readOnly, }) {
14
+ const [from, setFrom] = (0, react_1.useState)(value ? value[0] : null);
15
+ const [to, setTo] = (0, react_1.useState)(value ? value[1] : null);
16
+ const { datePickerStrings } = (0, AppStringContext_1.useAppStrings)();
17
+ const { dateFormats } = (0, locale_1.useLocale)();
18
+ (0, react_1.useEffect)(() => {
19
+ if (value) {
20
+ setFrom(value[0]);
21
+ setTo(value[1]);
22
+ }
23
+ }, [value]);
24
+ const _minDate = minDate
25
+ ? new Date(minDate)
26
+ : from
27
+ ? new Date(from)
28
+ : undefined;
29
+ const _maxDate = maxDate ? new Date(maxDate) : to ? new Date(to) : undefined;
30
+ const handleChangeFrom = (date) => {
31
+ var _a;
32
+ setFrom(date ? date.toISOString() : null);
33
+ // if (date && to) {
34
+ onChange === null || onChange === void 0 ? void 0 : onChange([(_a = date === null || date === void 0 ? void 0 : date.toISOString()) !== null && _a !== void 0 ? _a : null, to]);
35
+ // }
36
+ };
37
+ const handleChangeTo = (date) => {
38
+ var _a;
39
+ setTo(date ? date.toISOString() : null);
40
+ // if (date && from) {
41
+ onChange === null || onChange === void 0 ? void 0 : onChange([from, (_a = date === null || date === void 0 ? void 0 : date.toISOString()) !== null && _a !== void 0 ? _a : null]);
42
+ // }
43
+ };
44
+ return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', gap: 8 }, children: [(0, jsx_runtime_1.jsx)(react_datepicker_compat_1.DatePicker, { id: id, name: name, onFocus: () => onFocus === null || onFocus === void 0 ? void 0 : onFocus(), onBlur: () => onBlur === null || onBlur === void 0 ? void 0 : onBlur(), placeholder: "From", appearance: "filled-darker", disabled: disabled, readOnly: readOnly, formatDate: (date) => date ? (0, dayjs_1.default)(date).format(dateFormats.short) : '', value: from ? new Date(from) : null, onSelectDate: (date) => handleChangeFrom(date), strings: datePickerStrings, minDate: minDate, maxDate: _maxDate, style: { flex: 1 }, input: {
45
+ style: { width: '100%' },
46
+ } }), (0, jsx_runtime_1.jsx)(react_datepicker_compat_1.DatePicker, { id: id, name: name, onFocus: () => onFocus === null || onFocus === void 0 ? void 0 : onFocus(), onBlur: () => onBlur === null || onBlur === void 0 ? void 0 : onBlur(), placeholder: "To", appearance: "filled-darker", disabled: disabled, readOnly: readOnly, formatDate: (date) => (date ? (0, dayjs_1.default)(date).format('YYYY-MM-DD') : ''), value: to ? new Date(to) : null, onSelectDate: (date) => handleChangeTo(date), strings: datePickerStrings, minDate: _minDate, maxDate: maxDate, style: { flex: 1 }, input: {
47
+ style: { width: '100%' },
48
+ } })] }));
49
+ }
@@ -0,0 +1,4 @@
1
+ import { ControlProps } from './types';
2
+ export interface NumberControlProps extends ControlProps<number> {
3
+ }
4
+ export declare function NumberControl({ value, onChange, id, name, onBlur, onFocus, error, disabled, placeholder, borderOnFocusOnly, readOnly, }: NumberControlProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NumberControl = NumberControl;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_components_1 = require("@fluentui/react-components");
6
+ function NumberControl({ value, onChange, id, name, onBlur, onFocus, error, disabled, placeholder, borderOnFocusOnly, readOnly, }) {
7
+ return ((0, jsx_runtime_1.jsx)(react_components_1.Input, { type: "number", placeholder: placeholder, id: id, appearance: "filled-darker", name: name,
8
+ // value={value ?? ''}
9
+ onChange: (e) => onChange === null || onChange === void 0 ? void 0 : onChange(e.target.value ? Number(e.target.value) : null), onBlur: () => onBlur === null || onBlur === void 0 ? void 0 : onBlur(), onFocus: () => onFocus === null || onFocus === void 0 ? void 0 : onFocus(),
10
+ // invalid={error}
11
+ // size="sm"
12
+ disabled: disabled, readOnly: readOnly, style: {
13
+ width: '100%',
14
+ } }));
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@headless-adminapp/fluent",
3
- "version": "1.4.42",
3
+ "version": "1.4.44",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -54,5 +54,5 @@
54
54
  "devDependencies": {
55
55
  "@types/lodash": "4.17.20"
56
56
  },
57
- "gitHead": "ab95b45e2c1098d0524b19ba32cce202be8e7439"
57
+ "gitHead": "b61cc3933fdf461afd3e59859ea1a89469d4523a"
58
58
  }