@headless-adminapp/fluent 1.1.10 → 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.
@@ -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("./AttributeController");
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, { form: form, attributeName: "title", attribute: baseEventAttributes_1.baseEventAttributes.title, readOnly: readOnly }), (0, jsx_runtime_1.jsx)(AttributeController_1.AttributeController, { form: form, attributeName: "start", attribute: {
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, { form: form, attributeName: "end", attribute: {
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, { form: form, 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, { form: form, attributeName: attributeName, attribute: attribute, readOnly: readOnly }, attributeName));
24
- }), (0, jsx_runtime_1.jsx)(AttributeController_1.AttributeController, { form: form, 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, { form: form, attributeName: attributeName, attribute: attribute, readOnly: readOnly }, attributeName));
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
  }
@@ -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.10",
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": "3920cedff7216fb37b07dff95c50499c0f56f57c"
53
+ "gitHead": "e88cae2cc31abaf6852549e3fbc3235eec84cc8c"
54
54
  }