@headless-adminapp/fluent 1.1.9 → 1.1.11
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/DataGrid/GridColumnHeader/TableHeaderFilterCell.js +5 -2
- package/DataGrid/useTableColumns.js +4 -1
- package/PageCalendar/EventDialog/EventFormContent.js +7 -7
- package/components/DialogLogin.d.ts +4 -1
- package/components/DialogLogin.js +1 -1
- package/form/AttributeController.d.ts +10 -0
- package/form/AttributeController.js +17 -0
- package/form/useFormForAttributes.d.ts +8 -0
- package/form/useFormForAttributes.js +23 -0
- package/package.json +2 -2
|
@@ -78,11 +78,14 @@ column, onResetSize, resizeHandler, resizable, disableFilter, disableSort, }) =>
|
|
|
78
78
|
switch (attribute.type) {
|
|
79
79
|
case 'money':
|
|
80
80
|
case 'number':
|
|
81
|
-
return '
|
|
81
|
+
return attribute.type === 'number' &&
|
|
82
|
+
['duration', 'time'].includes(attribute.format)
|
|
83
|
+
? 'left'
|
|
84
|
+
: 'right';
|
|
82
85
|
default:
|
|
83
86
|
return 'left';
|
|
84
87
|
}
|
|
85
|
-
}, [attribute
|
|
88
|
+
}, [attribute]);
|
|
86
89
|
const styles = useStyles();
|
|
87
90
|
const isResizingRef = (0, react_1.useRef)(false);
|
|
88
91
|
const [columnFilters, setColumnFilters] = (0, hooks_1.useGridColumnFilter)();
|
|
@@ -306,7 +306,10 @@ function renderCellContent({ info, column, schema, schemaStore, locale, routeRes
|
|
|
306
306
|
switch (attribute?.type) {
|
|
307
307
|
case 'money':
|
|
308
308
|
case 'number':
|
|
309
|
-
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: formattedValue, width: info.column.getSize(), textAlignment:
|
|
309
|
+
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: formattedValue, width: info.column.getSize(), textAlignment: attribute.type === 'number' &&
|
|
310
|
+
['duration', 'time'].includes(attribute.format)
|
|
311
|
+
? 'left'
|
|
312
|
+
: 'right' }, column.id));
|
|
310
313
|
case 'lookup': {
|
|
311
314
|
return renderLookupAttribute({
|
|
312
315
|
info,
|
|
@@ -4,7 +4,7 @@ exports.EventFormContent = EventFormContent;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
6
|
const baseEventAttributes_1 = require("@headless-adminapp/app/calendar/baseEventAttributes");
|
|
7
|
-
const AttributeController_1 = require("
|
|
7
|
+
const AttributeController_1 = require("../../form/AttributeController");
|
|
8
8
|
function EventFormContent({ form, afterDescriptionAttributes, beforeDescriptionAttributes, readOnly, config, }) {
|
|
9
9
|
const allDay = form.watch('allDay');
|
|
10
10
|
return ((0, jsx_runtime_1.jsx)(react_components_1.DialogContent, { children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
@@ -13,15 +13,15 @@ function EventFormContent({ form, afterDescriptionAttributes, beforeDescriptionA
|
|
|
13
13
|
gap: react_components_1.tokens.spacingVerticalM,
|
|
14
14
|
marginTop: react_components_1.tokens.spacingVerticalL,
|
|
15
15
|
marginBottom: react_components_1.tokens.spacingVerticalL,
|
|
16
|
-
}, children: [(0, jsx_runtime_1.jsx)(AttributeController_1.AttributeController, {
|
|
16
|
+
}, children: [(0, jsx_runtime_1.jsx)(AttributeController_1.AttributeController, { control: form.control, attributeName: "title", attribute: baseEventAttributes_1.baseEventAttributes.title, readOnly: readOnly }), (0, jsx_runtime_1.jsx)(AttributeController_1.AttributeController, { control: form.control, attributeName: "start", attribute: {
|
|
17
17
|
...baseEventAttributes_1.baseEventAttributes.start,
|
|
18
18
|
...(allDay ? { format: 'date' } : { format: 'datetime' }),
|
|
19
|
-
}, readOnly: readOnly }), (0, jsx_runtime_1.jsx)(AttributeController_1.AttributeController, {
|
|
19
|
+
}, readOnly: readOnly }), (0, jsx_runtime_1.jsx)(AttributeController_1.AttributeController, { control: form.control, attributeName: "end", attribute: {
|
|
20
20
|
...baseEventAttributes_1.baseEventAttributes.end,
|
|
21
21
|
...(allDay ? { format: 'date' } : { format: 'datetime' }),
|
|
22
|
-
}, readOnly: readOnly }), !config.disableAllDay && ((0, jsx_runtime_1.jsx)(AttributeController_1.AttributeController, {
|
|
23
|
-
return ((0, jsx_runtime_1.jsx)(AttributeController_1.AttributeController, {
|
|
24
|
-
}), (0, jsx_runtime_1.jsx)(AttributeController_1.AttributeController, {
|
|
25
|
-
return ((0, jsx_runtime_1.jsx)(AttributeController_1.AttributeController, {
|
|
22
|
+
}, readOnly: readOnly }), !config.disableAllDay && ((0, jsx_runtime_1.jsx)(AttributeController_1.AttributeController, { control: form.control, attributeName: "allDay", attribute: baseEventAttributes_1.baseEventAttributes.allDay, readOnly: readOnly })), Object.entries(beforeDescriptionAttributes ?? {}).map(([attributeName, attribute]) => {
|
|
23
|
+
return ((0, jsx_runtime_1.jsx)(AttributeController_1.AttributeController, { control: form.control, attributeName: attributeName, attribute: attribute, readOnly: readOnly }, attributeName));
|
|
24
|
+
}), (0, jsx_runtime_1.jsx)(AttributeController_1.AttributeController, { control: form.control, attributeName: "description", attribute: baseEventAttributes_1.baseEventAttributes.description, readOnly: readOnly }), Object.entries(afterDescriptionAttributes ?? {}).map(([attributeName, attribute]) => {
|
|
25
|
+
return ((0, jsx_runtime_1.jsx)(AttributeController_1.AttributeController, { control: form.control, attributeName: attributeName, attribute: attribute, readOnly: readOnly }, attributeName));
|
|
26
26
|
})] }) }));
|
|
27
27
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
interface LoginFormProps {
|
|
2
2
|
logoImageUrl?: string;
|
|
3
3
|
onLogin: (username: string, password: string) => Promise<void>;
|
|
4
|
+
beforeLoginContent?: React.ReactNode;
|
|
5
|
+
afterLoginContent?: React.ReactNode;
|
|
6
|
+
subtitle?: string;
|
|
4
7
|
}
|
|
5
|
-
export declare function DialogLogin(props: LoginFormProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function DialogLogin(props: Readonly<LoginFormProps>): import("react/jsx-runtime").JSX.Element;
|
|
6
9
|
export {};
|
|
@@ -5,5 +5,5 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
6
|
const LoginForm_1 = require("./LoginForm");
|
|
7
7
|
function DialogLogin(props) {
|
|
8
|
-
return ((0, jsx_runtime_1.jsx)(react_components_1.Dialog, { open: true, onOpenChange: () => { }, modalType: "non-modal", children: (0, jsx_runtime_1.jsx)(react_components_1.DialogSurface, { style: { maxWidth: 360 }, children: (0, jsx_runtime_1.jsx)(react_components_1.DialogBody, { children: (0, jsx_runtime_1.jsx)(react_components_1.DialogContent, { children: (0, jsx_runtime_1.jsx)(LoginForm_1.LoginForm, { onLogin: props.onLogin, logoImageUrl: props.logoImageUrl }) }) }) }) }));
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.Dialog, { open: true, onOpenChange: () => { }, modalType: "non-modal", children: (0, jsx_runtime_1.jsx)(react_components_1.DialogSurface, { style: { maxWidth: 360 }, children: (0, jsx_runtime_1.jsx)(react_components_1.DialogBody, { children: (0, jsx_runtime_1.jsx)(react_components_1.DialogContent, { children: (0, jsx_runtime_1.jsx)(LoginForm_1.LoginForm, { onLogin: props.onLogin, logoImageUrl: props.logoImageUrl, afterLoginContent: props.afterLoginContent, beforeLoginContent: props.beforeLoginContent, subtitle: props.subtitle }) }) }) }) }));
|
|
9
9
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Attribute } from '@headless-adminapp/core';
|
|
2
|
+
import { Control, FieldPath, FieldValues } from 'react-hook-form';
|
|
3
|
+
interface AttributeControllerProps<TFieldValues extends FieldValues = FieldValues> {
|
|
4
|
+
attribute: Attribute;
|
|
5
|
+
attributeName: FieldPath<TFieldValues>;
|
|
6
|
+
control: Control<TFieldValues>;
|
|
7
|
+
readOnly?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function AttributeController<TFieldValues extends FieldValues = FieldValues>({ attribute, attributeName, control, readOnly, }: Readonly<AttributeControllerProps<TFieldValues>>): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AttributeController = AttributeController;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
6
|
+
const SectionControl_1 = require("../DataForm/SectionControl");
|
|
7
|
+
const StandardControl_1 = require("../PageEntityForm/StandardControl");
|
|
8
|
+
function AttributeController({ attribute, attributeName, control, readOnly, }) {
|
|
9
|
+
return ((0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { control: control, name: attributeName, render: ({ field, fieldState, formState }) => {
|
|
10
|
+
const isError = (fieldState.isTouched || formState.isSubmitted) &&
|
|
11
|
+
!!fieldState.error?.message;
|
|
12
|
+
const errorMessage = fieldState.isTouched || formState.isSubmitted
|
|
13
|
+
? fieldState.error?.message
|
|
14
|
+
: '';
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(SectionControl_1.SectionControlWrapper, { label: attribute.label, labelPosition: "left", required: attribute.required, isError: isError, errorMessage: errorMessage, children: (0, jsx_runtime_1.jsx)(StandardControl_1.StandardControl, { attribute: attribute, name: attributeName, value: field.value, onChange: field.onChange, onBlur: field.onBlur, errorMessage: errorMessage, isError: isError, readOnly: readOnly || attribute.readonly }) }));
|
|
16
|
+
} }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InferredSchemaType, SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
2
|
+
import { Nullable } from '@headless-adminapp/core/types';
|
|
3
|
+
interface UseFormForAttributesProps<SA extends SchemaAttributes = SchemaAttributes> {
|
|
4
|
+
attributes: SA;
|
|
5
|
+
defaultValues: Partial<Nullable<InferredSchemaType<SA>>>;
|
|
6
|
+
}
|
|
7
|
+
export declare function useFormForAttributes<SA extends SchemaAttributes = SchemaAttributes>(props: UseFormForAttributesProps<SA>): import("react-hook-form").UseFormReturn<Nullable<InferredSchemaType<SA>>, any, undefined>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFormForAttributes = useFormForAttributes;
|
|
4
|
+
const form_1 = require("@headless-adminapp/app/form");
|
|
5
|
+
const locale_1 = require("@headless-adminapp/app/locale");
|
|
6
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
7
|
+
const PromptDialog_1 = require("../DialogContainer/PromptDialog");
|
|
8
|
+
function useFormForAttributes(props) {
|
|
9
|
+
const { language, region } = (0, locale_1.useLocale)();
|
|
10
|
+
const formValidationStrings = (0, form_1.useFormValidationStrings)();
|
|
11
|
+
const form = (0, react_hook_form_1.useForm)({
|
|
12
|
+
mode: 'all',
|
|
13
|
+
defaultValues: props.defaultValues,
|
|
14
|
+
shouldUnregister: false,
|
|
15
|
+
resolver: (0, PromptDialog_1.formValidator)({
|
|
16
|
+
attributes: props.attributes,
|
|
17
|
+
language,
|
|
18
|
+
strings: formValidationStrings,
|
|
19
|
+
region,
|
|
20
|
+
}),
|
|
21
|
+
});
|
|
22
|
+
return form;
|
|
23
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@headless-adminapp/fluent",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"uuid": "11.0.3",
|
|
51
51
|
"yup": "^1.4.0"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "e88cae2cc31abaf6852549e3fbc3235eec84cc8c"
|
|
54
54
|
}
|