@digigov/form 2.0.0-85c27c19 → 2.0.0-aefd0709
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/Field/FieldBase/index.js +1 -0
- package/Field/FieldBase.js.map +2 -2
- package/Field/FieldBaseContainer/index.js +2 -2
- package/Field/FieldBaseContainer.js.map +2 -2
- package/Field/FieldConditional/index.js +7 -3
- package/Field/FieldConditional.js.map +2 -2
- package/Field/index.js +5 -2
- package/Field/index.js.map +2 -2
- package/Field/types.d.ts +10 -8
- package/Field/utils/index.d.ts +1 -0
- package/Field/utils/index.js +18 -1
- package/Field/utils/index.js.map +2 -2
- package/FieldArray/index.d.ts +1 -0
- package/FieldArray/index.js +7 -6
- package/FieldArray/index.js.map +2 -2
- package/FieldObject/index.d.ts +2 -0
- package/FieldObject/index.js +9 -5
- package/FieldObject/index.js.map +2 -2
- package/Fieldset/index.d.ts +1 -1
- package/Fieldset/index.js +5 -5
- package/Fieldset/index.js.map +2 -2
- package/Fieldset/types.d.ts +2 -3
- package/FormBuilder/index.d.ts +8 -2
- package/FormBuilder/index.js +150 -6
- package/FormBuilder/index.js.map +3 -3
- package/FormContext.js.map +2 -2
- package/MultiplicityField/add-objects/index.js +11 -7
- package/MultiplicityField/add-objects.js.map +2 -2
- package/MultiplicityField/index.js +16 -12
- package/MultiplicityField/index.js.map +2 -2
- package/MultiplicityField/types.d.ts +1 -2
- package/Questions/Questions/index.js +5 -4
- package/Questions/Questions.js.map +2 -2
- package/Questions/QuestionsContext.d.ts +0 -1
- package/Questions/Step/StepArrayReview.js.map +2 -2
- package/Questions/Step/StepContext.d.ts +0 -1
- package/Questions/Step/StepTitle/index.js +4 -3
- package/Questions/Step/StepTitle.d.ts +1 -1
- package/Questions/Step/StepTitle.js.map +2 -2
- package/Questions/Step/types.d.ts +0 -1
- package/Questions/types.d.ts +0 -1
- package/cjs/Field/FieldBase/index.js +1 -0
- package/cjs/Field/FieldBase.js.map +2 -2
- package/cjs/Field/FieldBaseContainer/index.js +4 -4
- package/cjs/Field/FieldBaseContainer.js.map +3 -3
- package/cjs/Field/FieldConditional/index.js +7 -3
- package/cjs/Field/FieldConditional.js.map +2 -2
- package/cjs/Field/index.js +5 -2
- package/cjs/Field/index.js.map +2 -2
- package/cjs/Field/types.js.map +1 -1
- package/cjs/Field/utils/index.js +18 -0
- package/cjs/Field/utils/index.js.map +2 -2
- package/cjs/FieldArray/index.js +8 -7
- package/cjs/FieldArray/index.js.map +3 -3
- package/cjs/FieldObject/index.js +10 -6
- package/cjs/FieldObject/index.js.map +3 -3
- package/cjs/Fieldset/index.js +10 -10
- package/cjs/Fieldset/index.js.map +3 -3
- package/cjs/Fieldset/types.js.map +1 -1
- package/cjs/FormBuilder/index.js +165 -5
- package/cjs/FormBuilder/index.js.map +3 -3
- package/cjs/FormContext/index.js +2 -2
- package/cjs/FormContext.js.map +3 -3
- package/cjs/MultiplicityField/add-objects/index.js +15 -11
- package/cjs/MultiplicityField/add-objects.js.map +3 -3
- package/cjs/MultiplicityField/index.js +15 -16
- package/cjs/MultiplicityField/index.js.map +3 -3
- package/cjs/MultiplicityField/types.js.map +1 -1
- package/cjs/Questions/Questions/index.js +5 -4
- package/cjs/Questions/Questions.js.map +2 -2
- package/cjs/Questions/Step/StepArrayReview.js.map +2 -2
- package/cjs/Questions/Step/StepTitle/index.js +5 -5
- package/cjs/Questions/Step/StepTitle.js.map +3 -3
- package/cjs/index.js +11 -155
- package/cjs/index.js.map +4 -4
- package/cjs/inputs/AutoCompleteInput/__stories__/Default/index.js +1 -7
- package/cjs/inputs/AutoCompleteInput/__stories__/Default.js.map +2 -2
- package/cjs/inputs/AutoCompleteInput/__stories__/Multiple/index.js +1 -8
- package/cjs/inputs/AutoCompleteInput/__stories__/Multiple.js.map +2 -2
- package/cjs/inputs/AutoCompleteInput/index.js +10 -8
- package/cjs/inputs/AutoCompleteInput/index.js.map +3 -3
- package/cjs/inputs/Checkboxes/index.js +7 -9
- package/cjs/inputs/Checkboxes/index.js.map +3 -3
- package/cjs/inputs/DateInput/__stories__/Default/index.js +3 -8
- package/cjs/inputs/DateInput/__stories__/Default.js.map +2 -2
- package/cjs/inputs/DateInput/index.js +4 -5
- package/cjs/inputs/DateInput/index.js.map +3 -3
- package/cjs/inputs/FileInput/index.js +8 -9
- package/cjs/inputs/FileInput/index.js.map +3 -3
- package/cjs/inputs/ImageInput/ImageInput.stories/index.js +4 -4
- package/cjs/inputs/ImageInput/ImageInput.stories.js.map +2 -2
- package/cjs/inputs/ImageInput/__stories__/MaxSize/index.js +69 -0
- package/cjs/inputs/ImageInput/__stories__/MaxSize.js.map +7 -0
- package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +2 -1
- package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension.js.map +2 -2
- package/cjs/inputs/ImageInput/index.js +9 -9
- package/cjs/inputs/ImageInput/index.js.map +3 -3
- package/cjs/inputs/Input/__stories__/LandlineNumber/index.js +1 -0
- package/cjs/inputs/Input/__stories__/LandlineNumber.js.map +2 -2
- package/cjs/inputs/Input/__stories__/MobilePhone/index.js +1 -0
- package/cjs/inputs/Input/__stories__/MobilePhone.js.map +2 -2
- package/cjs/inputs/Input/__stories__/PhoneNumber/index.js +1 -0
- package/cjs/inputs/Input/__stories__/PhoneNumber.js.map +2 -2
- package/cjs/inputs/Input/__stories__/PostalCode/index.js +1 -0
- package/cjs/inputs/Input/__stories__/PostalCode.js.map +2 -2
- package/cjs/inputs/Input/index.js +19 -6
- package/cjs/inputs/Input/index.js.map +3 -3
- package/cjs/inputs/Input/inputsInputScenarios.js.map +2 -2
- package/cjs/inputs/Label/index.js +3 -3
- package/cjs/inputs/Label/index.js.map +3 -3
- package/cjs/inputs/OtpInput/index.js.map +2 -2
- package/cjs/inputs/Radio/__stories__/Conditional.js.map +2 -2
- package/cjs/inputs/Radio/index.js +56 -10
- package/cjs/inputs/Radio/index.js.map +3 -3
- package/cjs/inputs/Select/index.js +3 -4
- package/cjs/inputs/Select/index.js.map +3 -3
- package/cjs/inputs/inputsScenarios/index.js +4 -11
- package/cjs/inputs/inputsScenarios.js.map +2 -2
- package/cjs/lazy/index.js +320 -59
- package/cjs/lazy.js.map +2 -2
- package/cjs/locales/el.js.map +1 -1
- package/cjs/registry/index.js +118 -38
- package/cjs/registry.js.map +2 -2
- package/cjs/types.js.map +1 -1
- package/cjs/utils/index.js +2 -1
- package/cjs/utils.js.map +2 -2
- package/cjs/validators/index.js +16 -66
- package/cjs/validators/index.js.map +3 -3
- package/cjs/validators/utils/date/index.js +138 -0
- package/cjs/validators/utils/date.js.map +7 -0
- package/cjs/validators/utils/file/index.js +1 -1
- package/cjs/validators/utils/file.js.map +2 -2
- package/cjs/validators/utils/index.js +3 -1
- package/cjs/validators/utils/index.js.map +2 -2
- package/cjs/validators/utils/phone.js.map +2 -2
- package/cjs/validators/utils/postal_code.js.map +1 -1
- package/cjs/validators/utils/uuid4.js.map +2 -2
- package/index.d.ts +5 -8
- package/index.js +9 -152
- package/index.js.map +4 -4
- package/inputs/AutoCompleteInput/__stories__/Default/index.js +1 -7
- package/inputs/AutoCompleteInput/__stories__/Default.js.map +2 -2
- package/inputs/AutoCompleteInput/__stories__/Multiple/index.js +1 -8
- package/inputs/AutoCompleteInput/__stories__/Multiple.js.map +2 -2
- package/inputs/AutoCompleteInput/index.d.ts +1 -1
- package/inputs/AutoCompleteInput/index.js +12 -8
- package/inputs/AutoCompleteInput/index.js.map +2 -2
- package/inputs/Checkboxes/index.d.ts +1 -1
- package/inputs/Checkboxes/index.js +8 -6
- package/inputs/Checkboxes/index.js.map +2 -2
- package/inputs/DateInput/__stories__/Default/index.js +3 -8
- package/inputs/DateInput/__stories__/Default.js.map +2 -2
- package/inputs/DateInput/index.d.ts +1 -2
- package/inputs/DateInput/index.js +6 -4
- package/inputs/DateInput/index.js.map +2 -2
- package/inputs/FileInput/index.js +6 -7
- package/inputs/FileInput/index.js.map +2 -2
- package/inputs/ImageInput/ImageInput.stories/index.js +2 -2
- package/inputs/ImageInput/ImageInput.stories.d.ts +1 -1
- package/inputs/ImageInput/ImageInput.stories.js.map +2 -2
- package/inputs/ImageInput/__stories__/MaxSize/index.js +36 -0
- package/inputs/ImageInput/__stories__/MaxSize/package.json +6 -0
- package/inputs/ImageInput/__stories__/MaxSize.d.ts +3 -0
- package/inputs/ImageInput/__stories__/MaxSize.js.map +7 -0
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +2 -1
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension.js.map +2 -2
- package/inputs/ImageInput/index.js +8 -8
- package/inputs/ImageInput/index.js.map +2 -2
- package/inputs/Input/__stories__/LandlineNumber/index.js +1 -0
- package/inputs/Input/__stories__/LandlineNumber.js.map +2 -2
- package/inputs/Input/__stories__/MobilePhone/index.js +1 -0
- package/inputs/Input/__stories__/MobilePhone.js.map +2 -2
- package/inputs/Input/__stories__/PhoneNumber/index.js +1 -0
- package/inputs/Input/__stories__/PhoneNumber.js.map +2 -2
- package/inputs/Input/__stories__/PostalCode/index.js +1 -0
- package/inputs/Input/__stories__/PostalCode.js.map +2 -2
- package/inputs/Input/index.js +17 -4
- package/inputs/Input/index.js.map +3 -3
- package/inputs/Input/inputsInputScenarios.js.map +2 -2
- package/inputs/Label/index.d.ts +0 -2
- package/inputs/Label/index.js +2 -2
- package/inputs/Label/index.js.map +2 -2
- package/inputs/OtpInput/index.js.map +2 -2
- package/inputs/Radio/__stories__/Conditional.js.map +2 -2
- package/inputs/Radio/index.d.ts +5 -1
- package/inputs/Radio/index.js +57 -8
- package/inputs/Radio/index.js.map +2 -2
- package/inputs/Select/index.d.ts +1 -1
- package/inputs/Select/index.js +4 -2
- package/inputs/Select/index.js.map +2 -2
- package/inputs/inputsScenarios/index.js +4 -11
- package/inputs/inputsScenarios.d.ts +0 -42
- package/inputs/inputsScenarios.js.map +2 -2
- package/lazy/index.js +320 -59
- package/lazy.d.ts +17 -10
- package/lazy.js.map +2 -2
- package/locales/el.js.map +1 -1
- package/package.json +4 -4
- package/registry/index.js +118 -38
- package/registry.d.ts +1 -0
- package/registry.js.map +2 -2
- package/src/Field/FieldBase.tsx +1 -0
- package/src/Field/FieldBaseContainer.tsx +2 -2
- package/src/Field/FieldConditional.tsx +4 -0
- package/src/Field/index.tsx +4 -1
- package/src/Field/types.tsx +10 -8
- package/src/Field/utils/index.ts +18 -1
- package/src/FieldArray/index.test.tsx +14 -13
- package/src/FieldArray/index.tsx +9 -6
- package/src/FieldObject/index.tsx +8 -2
- package/src/Fieldset/index.tsx +5 -5
- package/src/Fieldset/types.tsx +2 -2
- package/src/FormBuilder/{FormBuilder.mdx → doc.mdx} +20 -33
- package/src/FormBuilder/index.test.tsx +11 -10
- package/src/FormBuilder/index.tsx +178 -7
- package/src/FormBuilder/scenarios.test.tsx +2 -2
- package/src/FormContext.tsx +1 -2
- package/src/MultiplicityField/add-objects.tsx +10 -8
- package/src/MultiplicityField/{MultiplicityField.mdx → doc.mdx} +12 -16
- package/src/MultiplicityField/index.test.tsx +26 -25
- package/src/MultiplicityField/index.tsx +15 -12
- package/src/MultiplicityField/types.ts +1 -2
- package/src/Questions/Questions.tsx +4 -4
- package/src/Questions/Step/StepArrayReview.tsx +1 -1
- package/src/Questions/Step/StepTitle.tsx +4 -3
- package/src/Questions/__snapshots__/index.spec.tsx.snap +8 -4
- package/src/Questions/{index.mdx → doc.mdx} +9 -12
- package/src/Questions/index.spec.tsx +6 -2
- package/src/Questions/index.test.tsx +11 -10
- package/src/create-simple-form.mdx +2 -6
- package/src/{index.mdx → doc.mdx} +4 -8
- package/src/index.ts +6 -0
- package/src/inputs/AutoCompleteInput/__stories__/Default.tsx +2 -10
- package/src/inputs/AutoCompleteInput/__stories__/Multiple.tsx +1 -8
- package/src/inputs/AutoCompleteInput/{index.mdx → doc.mdx} +2 -13
- package/src/inputs/AutoCompleteInput/index.test.tsx +14 -13
- package/src/inputs/AutoCompleteInput/index.tsx +36 -31
- package/src/inputs/Checkboxes/{index.mdx → doc.mdx} +5 -15
- package/src/inputs/Checkboxes/index.test.tsx +17 -16
- package/src/inputs/Checkboxes/index.tsx +10 -8
- package/src/inputs/DateInput/__stories__/Default.tsx +7 -12
- package/src/inputs/DateInput/{index.mdx → doc.mdx} +1 -8
- package/src/inputs/DateInput/index.test.tsx +11 -10
- package/src/inputs/DateInput/index.tsx +6 -4
- package/src/inputs/FileInput/{index.mdx → doc.mdx} +1 -5
- package/src/inputs/FileInput/index.test.tsx +11 -10
- package/src/inputs/FileInput/index.tsx +7 -8
- package/src/inputs/ImageInput/ImageInput.stories.js +1 -1
- package/src/inputs/ImageInput/__stories__/MaxSize.tsx +37 -0
- package/src/inputs/ImageInput/__stories__/WithInvalidImageDimension.tsx +2 -0
- package/src/inputs/ImageInput/doc.mdx +23 -0
- package/src/inputs/ImageInput/index.test.tsx +21 -16
- package/src/inputs/ImageInput/index.tsx +10 -15
- package/src/inputs/Input/__stories__/LandlineNumber.tsx +2 -1
- package/src/inputs/Input/__stories__/MobilePhone.tsx +1 -0
- package/src/inputs/Input/__stories__/PhoneNumber.tsx +1 -0
- package/src/inputs/Input/__stories__/PostalCode.tsx +1 -0
- package/src/inputs/Input/doc.mdx +56 -0
- package/src/inputs/Input/index.test.tsx +38 -37
- package/src/inputs/Input/index.tsx +32 -29
- package/src/inputs/Input/inputsInputScenarios.ts +244 -245
- package/src/inputs/Label/doc.mdx +14 -0
- package/src/inputs/Label/index.test.tsx +11 -10
- package/src/inputs/Label/index.tsx +2 -6
- package/src/inputs/OtpInput/{index.mdx → doc.mdx} +1 -8
- package/src/inputs/OtpInput/index.test.tsx +11 -10
- package/src/inputs/OtpInput/index.tsx +2 -1
- package/src/inputs/Radio/__stories__/Conditional.tsx +2 -1
- package/src/inputs/Radio/{index.mdx → doc.mdx} +5 -15
- package/src/inputs/Radio/index.test.tsx +17 -16
- package/src/inputs/Radio/index.tsx +76 -10
- package/src/inputs/Select/{index.mdx → doc.mdx} +1 -5
- package/src/inputs/Select/index.test.tsx +11 -10
- package/src/inputs/Select/index.tsx +5 -3
- package/src/inputs/inputsScenarios.ts +174 -181
- package/src/installation.mdx +2 -5
- package/src/lazy.js +322 -62
- package/src/locales/el.ts +1 -1
- package/src/registry.js +121 -45
- package/src/types.tsx +3 -2
- package/src/utils.ts +2 -2
- package/src/validators/index.ts +33 -71
- package/src/validators/utils/date.ts +107 -0
- package/src/validators/utils/file.ts +5 -3
- package/src/validators/utils/index.ts +1 -0
- package/src/validators/utils/phone.ts +1 -1
- package/src/validators/utils/postal_code.ts +1 -1
- package/src/validators/utils/uuid4.ts +2 -1
- package/src/validators/validators.spec.ts +3 -3
- package/types.d.ts +3 -3
- package/types.js.map +1 -1
- package/utils/index.js +2 -1
- package/utils.js.map +2 -2
- package/validators/index.js +20 -67
- package/validators/index.js.map +2 -2
- package/validators/utils/date/index.js +103 -0
- package/validators/utils/date/package.json +6 -0
- package/validators/utils/date.d.ts +9 -0
- package/validators/utils/date.js.map +7 -0
- package/validators/utils/file/index.js +1 -1
- package/validators/utils/file.js.map +2 -2
- package/validators/utils/index.d.ts +1 -0
- package/validators/utils/index.js +1 -0
- package/validators/utils/index.js.map +2 -2
- package/validators/utils/phone.d.ts +1 -1
- package/validators/utils/phone.js.map +2 -2
- package/validators/utils/postal_code.d.ts +1 -1
- package/validators/utils/postal_code.js.map +1 -1
- package/validators/utils/uuid4.js.map +2 -2
- package/src/index.tsx +0 -178
- package/src/inputs/ImageInput/index.mdx +0 -19
- package/src/inputs/Input/index.mdx +0 -95
- package/src/inputs/Label/index.mdx +0 -0
- /package/src/Field/{index.mdx → doc.mdx} +0 -0
|
@@ -33,13 +33,13 @@ __export(FieldBaseContainer_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(FieldBaseContainer_exports);
|
|
34
34
|
var import_react = __toESM(require("react"));
|
|
35
35
|
var import_Label = __toESM(require("@digigov/form/inputs/Label"));
|
|
36
|
-
var import_ErrorMessage =
|
|
36
|
+
var import_ErrorMessage = require("@digigov/react-core/ErrorMessage");
|
|
37
37
|
var import_FieldContainer = __toESM(require("@digigov/react-core/FieldContainer"));
|
|
38
38
|
var import_Fieldset = __toESM(require("@digigov/react-core/Fieldset"));
|
|
39
39
|
var import_FieldsetLegend = __toESM(require("@digigov/react-core/FieldsetLegend"));
|
|
40
|
-
var import_Hint = __toESM(require("@digigov/react-core/Hint"));
|
|
41
40
|
var import_LabelContainer = __toESM(require("@digigov/react-core/LabelContainer"));
|
|
42
41
|
var import_i18n = require("@digigov/ui/i18n");
|
|
42
|
+
var import_Hint = require("@digigov/ui/typography/Hint");
|
|
43
43
|
const FieldBaseContainer = ({
|
|
44
44
|
name,
|
|
45
45
|
wrapper,
|
|
@@ -52,9 +52,9 @@ const FieldBaseContainer = ({
|
|
|
52
52
|
const errorMessage = error?.message.key ? error.message.key : error?.message || "";
|
|
53
53
|
const errorContext = error?.message.context || {};
|
|
54
54
|
if (wrapper === "fieldset") {
|
|
55
|
-
return /* @__PURE__ */ import_react.default.createElement(import_FieldContainer.default, { error: !!error, ...layout }, /* @__PURE__ */ import_react.default.createElement(import_Fieldset.default, null, /* @__PURE__ */ import_react.default.createElement(import_FieldsetLegend.default, { size: "sm" }, label && label.primary), label && label.secondary && /* @__PURE__ */ import_react.default.createElement(import_Hint.
|
|
55
|
+
return /* @__PURE__ */ import_react.default.createElement(import_FieldContainer.default, { error: !!error, ...layout }, /* @__PURE__ */ import_react.default.createElement(import_Fieldset.default, null, /* @__PURE__ */ import_react.default.createElement(import_FieldsetLegend.default, { size: "sm" }, label && label.primary), label && label.secondary && /* @__PURE__ */ import_react.default.createElement(import_Hint.Hint, null, t(label.secondary)), error && /* @__PURE__ */ import_react.default.createElement(import_ErrorMessage.ErrorMessage, { id: `${name}-error` }, t(errorMessage, errorContext)), children));
|
|
56
56
|
} else {
|
|
57
|
-
return /* @__PURE__ */ import_react.default.createElement(import_FieldContainer.default, { error: !!error, ...layout }, /* @__PURE__ */ import_react.default.createElement(import_LabelContainer.default, null, label && /* @__PURE__ */ import_react.default.createElement(import_Label.default, { label }), error && /* @__PURE__ */ import_react.default.createElement(import_ErrorMessage.
|
|
57
|
+
return /* @__PURE__ */ import_react.default.createElement(import_FieldContainer.default, { error: !!error, ...layout }, /* @__PURE__ */ import_react.default.createElement(import_LabelContainer.default, null, label && /* @__PURE__ */ import_react.default.createElement(import_Label.default, { label }), error && /* @__PURE__ */ import_react.default.createElement(import_ErrorMessage.ErrorMessage, { id: `${name}-error` }, t(errorMessage, errorContext)), children));
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
var FieldBaseContainer_default = FieldBaseContainer;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Field/FieldBaseContainer.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport { FieldContainerProps } from '@digigov/form/Field/types';\nimport Label from '@digigov/form/inputs/Label';\nimport ErrorMessage from '@digigov/react-core/ErrorMessage';\nimport FieldContainer from '@digigov/react-core/FieldContainer';\nimport CoreFieldset from '@digigov/react-core/Fieldset';\nimport FieldsetLegend from '@digigov/react-core/FieldsetLegend';\nimport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,mBAAkB;AAClB,
|
|
6
|
-
"names": ["React", "FieldContainer", "CoreFieldset", "FieldsetLegend", "
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { FieldContainerProps } from '@digigov/form/Field/types';\nimport Label from '@digigov/form/inputs/Label';\nimport { ErrorMessage } from '@digigov/react-core/ErrorMessage';\nimport FieldContainer from '@digigov/react-core/FieldContainer';\nimport CoreFieldset from '@digigov/react-core/Fieldset';\nimport FieldsetLegend from '@digigov/react-core/FieldsetLegend';\nimport LabelContainer from '@digigov/react-core/LabelContainer';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport { Hint } from '@digigov/ui/typography/Hint';\n\nexport const FieldBaseContainer: React.FC<FieldContainerProps> = ({\n name,\n wrapper,\n label,\n children,\n error,\n layout,\n}) => {\n const { t } = useTranslation();\n const errorMessage = error?.message.key\n ? error.message.key\n : error?.message || '';\n const errorContext = error?.message.context || {};\n if (wrapper === 'fieldset') {\n return (\n <FieldContainer error={!!error} {...layout}>\n <CoreFieldset>\n <FieldsetLegend size=\"sm\">{label && label.primary}</FieldsetLegend>\n {label && label.secondary && <Hint>{t(label.secondary)}</Hint>}\n {error && (\n <ErrorMessage id={`${name}-error`}>\n {t(errorMessage, errorContext)}\n </ErrorMessage>\n )}\n {children}\n </CoreFieldset>\n </FieldContainer>\n );\n } else {\n return (\n <FieldContainer error={!!error} {...layout}>\n <LabelContainer>\n {label && <Label label={label} />}\n {error && (\n <ErrorMessage id={`${name}-error`}>\n {t(errorMessage, errorContext)}\n </ErrorMessage>\n )}\n {children}\n </LabelContainer>\n </FieldContainer>\n );\n }\n};\n\nexport default FieldBaseContainer;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,mBAAkB;AAClB,0BAA6B;AAC7B,4BAA2B;AAC3B,sBAAyB;AACzB,4BAA2B;AAC3B,4BAA2B;AAC3B,kBAA+B;AAC/B,kBAAqB;AAEd,MAAM,qBAAoD,CAAC;AAAA,EAChE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,EAAE,QAAI,4BAAe;AAC7B,QAAM,eAAe,OAAO,QAAQ,MAChC,MAAM,QAAQ,MACd,OAAO,WAAW;AACtB,QAAM,eAAe,OAAO,QAAQ,WAAW,CAAC;AAChD,MAAI,YAAY,YAAY;AAC1B,WACE,6BAAAA,QAAA,cAAC,sBAAAC,SAAA,EAAe,OAAO,CAAC,CAAC,OAAQ,GAAG,UAClC,6BAAAD,QAAA,cAAC,gBAAAE,SAAA,MACC,6BAAAF,QAAA,cAAC,sBAAAG,SAAA,EAAe,MAAK,QAAM,SAAS,MAAM,OAAQ,GACjD,SAAS,MAAM,aAAa,6BAAAH,QAAA,cAAC,wBAAM,EAAE,MAAM,SAAS,CAAE,GACtD,SACC,6BAAAA,QAAA,cAAC,oCAAa,IAAI,GAAG,IAAI,YACtB,EAAE,cAAc,YAAY,CAC/B,GAED,QACH,CACF;AAAA,EAEJ,OAAO;AACL,WACE,6BAAAA,QAAA,cAAC,sBAAAC,SAAA,EAAe,OAAO,CAAC,CAAC,OAAQ,GAAG,UAClC,6BAAAD,QAAA,cAAC,sBAAAI,SAAA,MACE,SAAS,6BAAAJ,QAAA,cAAC,aAAAK,SAAA,EAAM,OAAc,GAC9B,SACC,6BAAAL,QAAA,cAAC,oCAAa,IAAI,GAAG,IAAI,YACtB,EAAE,cAAc,YAAY,CAC/B,GAED,QACH,CACF;AAAA,EAEJ;AACF;AAEA,IAAO,6BAAQ;",
|
|
6
|
+
"names": ["React", "FieldContainer", "CoreFieldset", "FieldsetLegend", "LabelContainer", "Label"]
|
|
7
7
|
}
|
|
@@ -42,7 +42,8 @@ const ChildFieldMemo = import_react.default.memo(
|
|
|
42
42
|
control,
|
|
43
43
|
reset,
|
|
44
44
|
register,
|
|
45
|
-
error
|
|
45
|
+
error,
|
|
46
|
+
Field
|
|
46
47
|
}) {
|
|
47
48
|
const newField = (0, import_evaluateFieldWithConditions.evaluateFieldWithConditions)(
|
|
48
49
|
field,
|
|
@@ -52,6 +53,7 @@ const ChildFieldMemo = import_react.default.memo(
|
|
|
52
53
|
import_FieldBase.FieldBase,
|
|
53
54
|
{
|
|
54
55
|
...newField,
|
|
56
|
+
Field,
|
|
55
57
|
name: newField.key,
|
|
56
58
|
reset,
|
|
57
59
|
control,
|
|
@@ -80,7 +82,8 @@ const FieldConditional = ({
|
|
|
80
82
|
field,
|
|
81
83
|
register,
|
|
82
84
|
reset,
|
|
83
|
-
error
|
|
85
|
+
error,
|
|
86
|
+
Field
|
|
84
87
|
}) => {
|
|
85
88
|
const dependencyKeys = Object.keys(field.condition);
|
|
86
89
|
const dependencyValues = (0, import_react_hook_form.useWatch)({
|
|
@@ -102,7 +105,8 @@ const FieldConditional = ({
|
|
|
102
105
|
control,
|
|
103
106
|
register,
|
|
104
107
|
reset,
|
|
105
|
-
error
|
|
108
|
+
error,
|
|
109
|
+
Field
|
|
106
110
|
}
|
|
107
111
|
);
|
|
108
112
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Field/FieldConditional.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport { useWatch } from 'react-hook-form';\nimport { FieldBase } from '@digigov/form/Field/FieldBase';\nimport {\n ChildFieldMemoProps,\n FieldConditionalProps,\n} from '@digigov/form/Field/types';\nimport { evaluateFieldWithConditions } from '@digigov/form/Field/utils/evaluateFieldWithConditions';\n\nconst ChildFieldMemo = React.memo(\n function ChildField({\n dependencies,\n field,\n control,\n reset,\n register,\n error,\n }: ChildFieldMemoProps) {\n const newField = evaluateFieldWithConditions(\n field,\n dependencies as FormData\n );\n return (\n <FieldBase\n {...newField}\n name={newField.key}\n reset={reset}\n control={control}\n register={register}\n error={error}\n />\n );\n },\n (prev, next) => {\n if (!prev || !prev.dependencies) {\n return false;\n }\n if (prev.error !== next.error) {\n return false;\n }\n for (const dep in next.dependencies) {\n if (next.dependencies[dep] !== prev.dependencies[dep]) {\n return false;\n }\n }\n return true;\n }\n);\n\nexport const FieldConditional: React.FC<FieldConditionalProps> = ({\n control,\n field,\n register,\n reset,\n error,\n}) => {\n const dependencyKeys = Object.keys(field.condition);\n const dependencyValues = useWatch({\n name: dependencyKeys,\n control,\n });\n const variables = dependencyKeys.reduce(\n (data, fieldKey, index) => ({\n ...data,\n [fieldKey]: dependencyValues[index],\n }),\n {}\n );\n return (\n <ChildFieldMemo\n dependencies={variables}\n field={field}\n control={control}\n register={register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SACE,6BAAAA,QAAA;AAAA,IAAC;AAAA;AAAA,MACC,cAAc;AAAA,MACd;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,2BAAQ;",
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { useWatch } from 'react-hook-form';\nimport { FieldBase } from '@digigov/form/Field/FieldBase';\nimport {\n ChildFieldMemoProps,\n FieldConditionalProps,\n} from '@digigov/form/Field/types';\nimport { evaluateFieldWithConditions } from '@digigov/form/Field/utils/evaluateFieldWithConditions';\n\nconst ChildFieldMemo = React.memo(\n function ChildField({\n dependencies,\n field,\n control,\n reset,\n register,\n error,\n Field,\n }: ChildFieldMemoProps) {\n const newField = evaluateFieldWithConditions(\n field,\n dependencies as FormData\n );\n return (\n <FieldBase\n {...newField}\n Field={Field}\n name={newField.key}\n reset={reset}\n control={control}\n register={register}\n error={error}\n />\n );\n },\n (prev, next) => {\n if (!prev || !prev.dependencies) {\n return false;\n }\n if (prev.error !== next.error) {\n return false;\n }\n for (const dep in next.dependencies) {\n if (next.dependencies[dep] !== prev.dependencies[dep]) {\n return false;\n }\n }\n return true;\n }\n);\n\nexport const FieldConditional: React.FC<FieldConditionalProps> = ({\n control,\n field,\n register,\n reset,\n error,\n Field,\n}) => {\n const dependencyKeys = Object.keys(field.condition);\n const dependencyValues = useWatch({\n name: dependencyKeys,\n control,\n });\n const variables = dependencyKeys.reduce(\n (data, fieldKey, index) => ({\n ...data,\n [fieldKey]: dependencyValues[index],\n }),\n {}\n );\n return (\n <ChildFieldMemo\n dependencies={variables}\n field={field}\n control={control}\n register={register}\n reset={reset}\n error={error}\n Field={Field}\n />\n );\n};\n\nexport default FieldConditional;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,6BAAyB;AACzB,uBAA0B;AAK1B,yCAA4C;AAE5C,M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
|
"names": ["React"]
|
|
7
7
|
}
|
package/cjs/Field/index.js
CHANGED
|
@@ -79,7 +79,8 @@ const Field = ({
|
|
|
79
79
|
reset,
|
|
80
80
|
register,
|
|
81
81
|
field: calculatedField,
|
|
82
|
-
error
|
|
82
|
+
error,
|
|
83
|
+
Field
|
|
83
84
|
}
|
|
84
85
|
);
|
|
85
86
|
}
|
|
@@ -92,6 +93,7 @@ const Field = ({
|
|
|
92
93
|
register,
|
|
93
94
|
error,
|
|
94
95
|
formState,
|
|
96
|
+
Field,
|
|
95
97
|
...calculatedField
|
|
96
98
|
}
|
|
97
99
|
);
|
|
@@ -110,6 +112,7 @@ const Field = ({
|
|
|
110
112
|
setValue,
|
|
111
113
|
getValues,
|
|
112
114
|
unregister,
|
|
115
|
+
Field,
|
|
113
116
|
...calculatedField
|
|
114
117
|
}
|
|
115
118
|
);
|
|
@@ -124,7 +127,7 @@ const Field = ({
|
|
|
124
127
|
register,
|
|
125
128
|
reset,
|
|
126
129
|
error,
|
|
127
|
-
|
|
130
|
+
Field
|
|
128
131
|
}
|
|
129
132
|
);
|
|
130
133
|
};
|
package/cjs/Field/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Field/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useMemo } from 'react';\nimport { FieldBase } from '@digigov/form/Field/FieldBase';\nimport FieldConditional from '@digigov/form/Field/FieldConditional';\nimport {\n FieldWithCondition,\n CalculatedField,\n FieldProps,\n} from '@digigov/form/Field/types';\nimport {\n FIELD_COMPONENTS,\n ALTERNATIVE_COMPONENTS,\n} from '@digigov/form/Field/utils';\nimport { calculateField } from '@digigov/form/Field/utils/calculateField';\nimport { useField } from '@digigov/form/Field/utils/useField';\nimport FieldArray from '@digigov/form/FieldArray';\nimport Multiplicity from '@digigov/form/MultiplicityField';\nexport const Field: React.FC<FieldProps> = ({\n name,\n disabled,\n children,\n ...customField\n}) => {\n const {\n field,\n control,\n register,\n reset,\n error,\n componentRegistry,\n formState,\n setValue,\n getValues,\n unregister,\n trigger,\n clearErrors,\n } = useField(name, customField?.type ? customField : null);\n const calculatedField: CalculatedField = useMemo(\n () =>\n calculateField(\n children,\n field,\n {\n ...FIELD_COMPONENTS,\n ...componentRegistry,\n },\n ALTERNATIVE_COMPONENTS\n ),\n [field]\n );\n\n if (calculatedField.condition) {\n return (\n <FieldConditional\n control={control}\n reset={reset}\n register={register}\n field={calculatedField as FieldWithCondition}\n error={error}\n />\n );\n }\n if (calculatedField.type === 'array' && !calculatedField.multiplicity) {\n calculatedField.name = name;\n return (\n <FieldArray\n control={control}\n register={register}\n error={error}\n formState={formState}\n {...calculatedField}\n />\n );\n }\n if (\n calculatedField.type === 'array' &&\n calculatedField.multiplicity === true\n ) {\n calculatedField.name = name;\n return (\n <Multiplicity\n control={control}\n register={register}\n trigger={trigger}\n clearErrors={clearErrors}\n error={error}\n formState={formState}\n setValue={setValue}\n getValues={getValues}\n unregister={unregister}\n {...calculatedField}\n />\n );\n }\n return (\n <FieldBase\n {...calculatedField}\n name={name}\n disabled={disabled}\n control={control}\n register={register}\n reset={reset}\n error={error}\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA+B;AAC/B,uBAA0B;AAC1B,8BAA6B;AAM7B,mBAGO;AACP,4BAA+B;AAC/B,sBAAyB;AACzB,wBAAuB;AACvB,+BAAyB;AAClB,MAAM,QAA8B,CAAC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,0BAAS,MAAM,aAAa,OAAO,cAAc,IAAI;AACzD,QAAM,sBAAmC;AAAA,IACvC,UACE;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,QACE,GAAG;AAAA,QACH,GAAG;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,IACF,CAAC,KAAK;AAAA,EACR;AAEA,MAAI,gBAAgB,WAAW;AAC7B,WACE,6BAAAA,QAAA;AAAA,MAAC,wBAAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAO;AAAA,QACP;AAAA;AAAA,IACF;AAAA,EAEJ;AACA,MAAI,gBAAgB,SAAS,WAAW,CAAC,gBAAgB,cAAc;AACrE,oBAAgB,OAAO;AACvB,WACE,6BAAAD,QAAA;AAAA,MAAC,kBAAAE;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACC,GAAG;AAAA;AAAA,IACN;AAAA,EAEJ;AACA,MACE,gBAAgB,SAAS,WACzB,gBAAgB,iBAAiB,MACjC;AACA,oBAAgB,OAAO;AACvB,WACE,6BAAAF,QAAA;AAAA,MAAC,yBAAAG;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACC,GAAG;AAAA;AAAA,IACN;AAAA,EAEJ;AACA,SACE,6BAAAH,QAAA;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA
|
|
4
|
+
"sourcesContent": ["import React, { useMemo } from 'react';\nimport { FieldBase } from '@digigov/form/Field/FieldBase';\nimport FieldConditional from '@digigov/form/Field/FieldConditional';\nimport {\n FieldWithCondition,\n CalculatedField,\n FieldProps,\n} from '@digigov/form/Field/types';\nimport {\n FIELD_COMPONENTS,\n ALTERNATIVE_COMPONENTS,\n} from '@digigov/form/Field/utils';\nimport { calculateField } from '@digigov/form/Field/utils/calculateField';\nimport { useField } from '@digigov/form/Field/utils/useField';\nimport FieldArray from '@digigov/form/FieldArray';\nimport Multiplicity from '@digigov/form/MultiplicityField';\nexport const Field: React.FC<FieldProps> = ({\n name,\n disabled,\n children,\n ...customField\n}) => {\n const {\n field,\n control,\n register,\n reset,\n error,\n componentRegistry,\n formState,\n setValue,\n getValues,\n unregister,\n trigger,\n clearErrors,\n } = useField(name, customField?.type ? customField : null);\n const calculatedField: CalculatedField = useMemo(\n () =>\n calculateField(\n children,\n field,\n {\n ...FIELD_COMPONENTS,\n ...componentRegistry,\n },\n ALTERNATIVE_COMPONENTS\n ),\n [field]\n );\n\n if (calculatedField.condition) {\n return (\n <FieldConditional\n control={control}\n reset={reset}\n register={register}\n field={calculatedField as FieldWithCondition}\n error={error}\n Field={Field}\n />\n );\n }\n if (calculatedField.type === 'array' && !calculatedField.multiplicity) {\n calculatedField.name = name;\n return (\n <FieldArray\n control={control}\n register={register}\n error={error}\n formState={formState}\n Field={Field}\n {...calculatedField}\n />\n );\n }\n if (\n calculatedField.type === 'array' &&\n calculatedField.multiplicity === true\n ) {\n calculatedField.name = name;\n return (\n <Multiplicity\n control={control}\n register={register}\n trigger={trigger}\n clearErrors={clearErrors}\n error={error}\n formState={formState}\n setValue={setValue}\n getValues={getValues}\n unregister={unregister}\n Field={Field}\n {...calculatedField}\n />\n );\n }\n return (\n <FieldBase\n {...calculatedField}\n name={name}\n disabled={disabled}\n control={control}\n register={register}\n reset={reset}\n error={error}\n Field={Field}\n />\n );\n};\n\nexport default Field;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA+B;AAC/B,uBAA0B;AAC1B,8BAA6B;AAM7B,mBAGO;AACP,4BAA+B;AAC/B,sBAAyB;AACzB,wBAAuB;AACvB,+BAAyB;AAClB,MAAM,QAA8B,CAAC;AAAA,EAC1C;AAAA,EACA;A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AAAA,MACA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,gBAAQ;",
|
|
6
6
|
"names": ["React", "FieldConditional", "FieldArray", "Multiplicity"]
|
|
7
7
|
}
|
package/cjs/Field/types.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Field/types.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport { ErrorOption, UseFormReturn, UseFormProps } from 'react-hook-form';\nimport { ValidatorSchema } from '@digigov/form/validators/types';\nimport { GridProps } from '@digigov/ui/layouts/Grid';\n\nexport
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { ErrorOption, UseFormReturn, UseFormProps } from 'react-hook-form';\nimport { ValidatorSchema } from '@digigov/form/validators/types';\nimport { GridProps } from '@digigov/ui/layouts/Grid';\n\nexport interface FieldLabelProps {\n primary?: string;\n secondary?: string;\n}\n\nexport interface FieldSpec {\n key: string; // !TODO rename key to name;\n type?:\n | 'int'\n | 'string'\n | 'text'\n | 'boolean'\n | 'email'\n | 'uuid4'\n | 'choice:multiple'\n | 'choice:single'\n | 'mobile_phone'\n | 'date'\n | 'otp'\n | 'afm'\n | 'iban'\n | 'file'\n | 'image'\n | 'postal_code'\n | 'phone_number'\n | 'array'\n | 'object';\n component?: any;\n autoComplete?: string;\n maxLength?: number;\n condition?: Record<string, FieldCondition>;\n controlled?: boolean;\n label?: FieldLabelProps;\n extra?: Record<string, any>;\n editable?: boolean;\n required?: boolean;\n enabled?: boolean;\n disabled?: boolean;\n layout?: Record<\n string,\n | GridProps['xs']\n | GridProps['sm']\n | GridProps['md']\n | GridProps['lg']\n | GridProps['xl']\n >;\n validators?: ValidatorSchema[];\n wrapper?: 'label' | 'fieldset';\n maxWidth?: string;\n maxHeight?: string;\n width?: string;\n}\n\nexport interface FieldCondition {\n is: string | string[] | number | number[] | boolean | boolean[];\n then?: Partial<FieldSpec>;\n else?: Partial<FieldSpec>;\n}\nexport interface ChildFieldMemoProps extends FieldConditionalProps {\n dependencies: FormData;\n}\nexport type FormData = UseFormProps['defaultValues'];\n\nexport interface FieldWithCondition extends Omit<CalculatedField, 'condition'> {\n condition: Record<string, FieldCondition>;\n}\n\nexport interface FieldConditionalProps {\n field: FieldWithCondition;\n control: UseFormReturn['control'];\n register: UseFormReturn['register'];\n reset: UseFormReturn['reset'];\n error?: ErrorOption;\n Field: React.FC<FieldProps>;\n}\n\nexport interface FieldComponentItem {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n component: any;\n controlled?: boolean;\n wrapper?: FieldSpec['wrapper'];\n}\n\nexport interface FieldContainerProps {\n name?: FieldSpec['key'];\n layout?: FieldSpec['layout'];\n label?: FieldSpec['label'];\n error?: ErrorOption | Record<string, any>;\n children?: React.ReactNode;\n wrapper?: FieldSpec['wrapper'];\n}\n\nexport type FieldComponentRegistry = Record<string, FieldComponentItem>;\n\nexport type OmittedFieldSpec = Omit<FieldSpec, 'component'>;\n\nexport type UnknownValue = never | never[];\n\nexport interface ControlledFieldProps {\n type?: string;\n value: UnknownValue;\n onChange: (v: UnknownValue) => void;\n defaultValue?: UnknownValue;\n onBlur?: (e: Event) => void;\n extra?: never;\n error?: boolean;\n name?: string;\n disabled?: boolean;\n Field: React.FC<FieldProps>;\n}\n\nexport interface UncontrolledFieldProps {\n name: string;\n register: FieldBaseProps['register'];\n control?: FieldBaseProps['control'];\n error?: boolean;\n extra?: Record<string, never>;\n type?: string;\n disabled?: boolean;\n Field: React.FC<FieldProps>;\n}\n\nexport interface CalculatedField extends OmittedFieldSpec {\n name: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n component: any;\n defaultValue?: never;\n error?: ErrorOption;\n wrapper?: FieldComponentItem['wrapper'];\n multiplicity?: boolean;\n}\n\nexport interface FieldBaseProps extends CalculatedField {\n control: UseFormReturn['control'];\n register: UseFormReturn['register'];\n reset: UseFormReturn['reset'];\n Field: React.FC<FieldProps>;\n}\n\nexport interface FieldProps extends FieldSpec {\n name: string;\n children?: React.ReactNode;\n}\n\nexport interface UseFieldProps {\n field: FieldSpec;\n control: FieldBaseProps['control'];\n register: FieldBaseProps['register'];\n reset: FieldBaseProps['reset'];\n watch: UseFormReturn['watch'];\n formState: UseFormReturn['formState'];\n getFieldState: UseFormReturn['getFieldState'];\n setValue: UseFormReturn['setValue'];\n getValues: UseFormReturn['getValues'];\n unregister: UseFormReturn['unregister'];\n trigger: UseFormReturn['trigger'];\n clearErrors: UseFormReturn['clearErrors'];\n error?: ErrorOption;\n componentRegistry?: FieldComponentRegistry;\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/cjs/Field/utils/index.js
CHANGED
|
@@ -28,6 +28,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
28
28
|
var utils_exports = {};
|
|
29
29
|
__export(utils_exports, {
|
|
30
30
|
ALTERNATIVE_COMPONENTS: () => ALTERNATIVE_COMPONENTS,
|
|
31
|
+
CONTROLLED_FIELD_COMPONENTS: () => CONTROLLED_FIELD_COMPONENTS,
|
|
31
32
|
FIELD_COMPONENTS: () => FIELD_COMPONENTS
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(utils_exports);
|
|
@@ -87,9 +88,26 @@ const ALTERNATIVE_COMPONENTS = {
|
|
|
87
88
|
wrapper: "fieldset"
|
|
88
89
|
}
|
|
89
90
|
};
|
|
91
|
+
const CONTROLLED_FIELD_COMPONENTS = {
|
|
92
|
+
...FIELD_COMPONENTS,
|
|
93
|
+
"choice:single": {
|
|
94
|
+
wrapper: "fieldset",
|
|
95
|
+
controlled: true,
|
|
96
|
+
component: import_Radio.ControlledRadioButtonsGroup
|
|
97
|
+
},
|
|
98
|
+
text: {
|
|
99
|
+
component: import_Input.default,
|
|
100
|
+
controlled: true
|
|
101
|
+
},
|
|
102
|
+
string: {
|
|
103
|
+
component: import_Input.default,
|
|
104
|
+
controlled: true
|
|
105
|
+
}
|
|
106
|
+
};
|
|
90
107
|
// Annotate the CommonJS export names for ESM import in node:
|
|
91
108
|
0 && (module.exports = {
|
|
92
109
|
ALTERNATIVE_COMPONENTS,
|
|
110
|
+
CONTROLLED_FIELD_COMPONENTS,
|
|
93
111
|
FIELD_COMPONENTS
|
|
94
112
|
});
|
|
95
113
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/Field/utils/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { FieldComponentRegistry } from '@digigov/form/Field/types';\nimport AutoCompleteInput from '@digigov/form/inputs/AutoCompleteInput';\nimport Checkboxes from '@digigov/form/inputs/Checkboxes';\nimport DateInput from '@digigov/form/inputs/DateInput';\nimport FileInput from '@digigov/form/inputs/FileInput';\nimport ImageInput from '@digigov/form/inputs/ImageInput';\nimport Input from '@digigov/form/inputs/Input';\nimport OtpInput from '@digigov/form/inputs/OtpInput';\nimport Radio from '@digigov/form/inputs/Radio';\nimport Select from '@digigov/form/inputs/Select';\n\nexport const FIELD_COMPONENTS: FieldComponentRegistry = {\n text: {\n component: Input,\n },\n string: {\n component: Input,\n },\n file: {\n wrapper: 'fieldset',\n component: FileInput,\n },\n image: {\n wrapper: 'fieldset',\n component: ImageInput,\n },\n date: {\n wrapper: 'fieldset',\n controlled: true,\n component: DateInput,\n },\n otp: {\n wrapper: 'fieldset',\n controlled: true,\n component: OtpInput,\n },\n 'choice:multiple': {\n wrapper: 'fieldset',\n controlled: true,\n component: Checkboxes,\n },\n 'choice:single': {\n wrapper: 'fieldset',\n controlled: false,\n component: Radio,\n },\n};\n\nexport const ALTERNATIVE_COMPONENTS: FieldComponentRegistry = {\n Select: {\n component: Select,\n controlled: false,\n },\n AutoComplete: {\n component: AutoCompleteInput,\n controlled: true,\n wrapper: 'fieldset',\n },\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,+BAA8B;AAC9B,wBAAuB;AACvB,uBAAsB;AACtB,uBAAsB;AACtB,wBAAuB;AACvB,mBAAkB;AAClB,sBAAqB;AACrB,
|
|
4
|
+
"sourcesContent": ["import { FieldComponentRegistry } from '@digigov/form/Field/types';\nimport AutoCompleteInput from '@digigov/form/inputs/AutoCompleteInput';\nimport Checkboxes from '@digigov/form/inputs/Checkboxes';\nimport DateInput from '@digigov/form/inputs/DateInput';\nimport FileInput from '@digigov/form/inputs/FileInput';\nimport ImageInput from '@digigov/form/inputs/ImageInput';\nimport Input from '@digigov/form/inputs/Input';\nimport OtpInput from '@digigov/form/inputs/OtpInput';\nimport Radio, { ControlledRadioButtonsGroup } from '@digigov/form/inputs/Radio';\nimport Select from '@digigov/form/inputs/Select';\n\nexport const FIELD_COMPONENTS: FieldComponentRegistry = {\n text: {\n component: Input,\n },\n string: {\n component: Input,\n },\n file: {\n wrapper: 'fieldset',\n component: FileInput,\n },\n image: {\n wrapper: 'fieldset',\n component: ImageInput,\n },\n date: {\n wrapper: 'fieldset',\n controlled: true,\n component: DateInput,\n },\n otp: {\n wrapper: 'fieldset',\n controlled: true,\n component: OtpInput,\n },\n 'choice:multiple': {\n wrapper: 'fieldset',\n controlled: true,\n component: Checkboxes,\n },\n 'choice:single': {\n wrapper: 'fieldset',\n controlled: false,\n component: Radio,\n },\n};\n\nexport const ALTERNATIVE_COMPONENTS: FieldComponentRegistry = {\n Select: {\n component: Select,\n controlled: false,\n },\n AutoComplete: {\n component: AutoCompleteInput,\n controlled: true,\n wrapper: 'fieldset',\n },\n};\n\nexport const CONTROLLED_FIELD_COMPONENTS: FieldComponentRegistry = {\n ...FIELD_COMPONENTS,\n 'choice:single': {\n wrapper: 'fieldset',\n controlled: true,\n component: ControlledRadioButtonsGroup,\n },\n text: {\n component: Input,\n controlled: true,\n },\n string: {\n component: Input,\n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ACX,YAAY;AAAA,EACd;AAAA,EACA,QAAQ;AAAA,IACN,WAAW,aAAAA;AAAA,IACX,YAAY;AAAA,EACd;AACF;",
|
|
6
6
|
"names": ["Input", "FileInput", "ImageInput", "DateInput", "OtpInput", "Checkboxes", "Radio", "Select", "AutoCompleteInput"]
|
|
7
7
|
}
|
package/cjs/FieldArray/index.js
CHANGED
|
@@ -33,10 +33,9 @@ __export(FieldArray_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(FieldArray_exports);
|
|
34
34
|
var import_react = __toESM(require("react"));
|
|
35
35
|
var import_react_hook_form = require("react-hook-form");
|
|
36
|
-
var import_FieldBaseContainer =
|
|
37
|
-
var import_FieldObject =
|
|
36
|
+
var import_FieldBaseContainer = require("@digigov/form/Field/FieldBaseContainer");
|
|
37
|
+
var import_FieldObject = require("@digigov/form/FieldObject");
|
|
38
38
|
var import_Fieldset = require("@digigov/form/Fieldset");
|
|
39
|
-
var import_Fieldset2 = __toESM(require("@digigov/react-core/Fieldset"));
|
|
40
39
|
var import_Card = require("@digigov/ui/content/Card");
|
|
41
40
|
var import_Button = require("@digigov/ui/form/Button");
|
|
42
41
|
var import_Hint = require("@digigov/ui/typography/Hint");
|
|
@@ -48,6 +47,7 @@ const FieldArray = ({
|
|
|
48
47
|
error,
|
|
49
48
|
layout,
|
|
50
49
|
label,
|
|
50
|
+
Field,
|
|
51
51
|
...customField
|
|
52
52
|
}) => {
|
|
53
53
|
const { fields, append, remove } = (0, import_react_hook_form.useFieldArray)({
|
|
@@ -55,7 +55,7 @@ const FieldArray = ({
|
|
|
55
55
|
name
|
|
56
56
|
});
|
|
57
57
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
58
|
-
import_FieldBaseContainer.
|
|
58
|
+
import_FieldBaseContainer.FieldBaseContainer,
|
|
59
59
|
{
|
|
60
60
|
label,
|
|
61
61
|
layout,
|
|
@@ -64,15 +64,16 @@ const FieldArray = ({
|
|
|
64
64
|
name
|
|
65
65
|
},
|
|
66
66
|
fields.length === 0 && /* @__PURE__ */ import_react.default.createElement(import_Hint.Hint, null, customField.extra?.label.object?.nothing_added),
|
|
67
|
-
fields.map((field, index) => /* @__PURE__ */ import_react.default.createElement(import_Card.Card, { variant: "border", key: field.id }, /* @__PURE__ */ import_react.default.createElement(
|
|
68
|
-
import_FieldObject.
|
|
67
|
+
fields.map((field, index) => /* @__PURE__ */ import_react.default.createElement(import_Card.Card, { variant: "border", key: field.id }, /* @__PURE__ */ import_react.default.createElement(import_Fieldset.Fieldset, null, /* @__PURE__ */ import_react.default.createElement(import_Fieldset.FieldsetLabel, null, customField.extra?.label.object.title, " ", index + 1), /* @__PURE__ */ import_react.default.createElement(
|
|
68
|
+
import_FieldObject.FieldObject,
|
|
69
69
|
{
|
|
70
70
|
name: `${name}.${index}`,
|
|
71
71
|
error: Array.isArray(error) && error[index],
|
|
72
72
|
formState,
|
|
73
73
|
register,
|
|
74
74
|
control,
|
|
75
|
-
...customField.extra?.of
|
|
75
|
+
...customField.extra?.of,
|
|
76
|
+
Field
|
|
76
77
|
}
|
|
77
78
|
), /* @__PURE__ */ import_react.default.createElement(
|
|
78
79
|
import_Button.Button,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/FieldArray/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport { ErrorOption, useFieldArray, UseFormReturn } from 'react-hook-form';\nimport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,6BAA0D;AAC1D,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { ErrorOption, useFieldArray, UseFormReturn } from 'react-hook-form';\nimport { FieldBaseContainer } from '@digigov/form/Field/FieldBaseContainer';\nimport { FieldProps } from '@digigov/form/Field/types';\nimport { FieldObject } from '@digigov/form/FieldObject';\nimport { FieldsetLabel, Fieldset } from '@digigov/form/Fieldset';\nimport { Card } from '@digigov/ui/content/Card';\nimport { Button } from '@digigov/ui/form/Button';\nimport { Hint } from '@digigov/ui/typography/Hint';\n\nexport interface FieldArrayProps extends FieldProps {\n control: UseFormReturn['control'];\n register: UseFormReturn['register'];\n formState: UseFormReturn['formState'];\n error?: ErrorOption;\n Field: React.FC<FieldProps>;\n}\nexport const FieldArray: React.FC<FieldArrayProps> = ({\n name,\n register,\n control,\n formState,\n error,\n layout,\n label,\n Field,\n ...customField\n}) => {\n const { fields, append, remove } = useFieldArray({\n control,\n name,\n });\n\n return (\n <FieldBaseContainer\n label={label}\n layout={layout}\n error={\n formState.isSubmitted &&\n !formState.isSubmitting &&\n error?.message &&\n error\n ? error\n : undefined\n }\n wrapper=\"fieldset\"\n name={name}\n >\n {fields.length === 0 && (\n <Hint>{customField.extra?.label.object?.nothing_added}</Hint>\n )}\n {fields.map((field, index) => (\n <Card variant=\"border\" key={field.id}>\n <Fieldset>\n <FieldsetLabel>\n {customField.extra?.label.object.title} {index + 1}\n </FieldsetLabel>\n <FieldObject\n name={`${name}.${index}`}\n error={Array.isArray(error) && error[index]}\n formState={formState}\n register={register}\n control={control}\n {...customField.extra?.of}\n Field={Field}\n />\n <Button\n name={`${name}-object-remove`}\n type=\"button\"\n color=\"warning\"\n onClick={() => remove(index)}\n >\n {customField.extra?.label.object?.delete}\n </Button>\n </Fieldset>\n </Card>\n ))}\n\n <Button\n type=\"button\"\n name={`${name}-add-object`}\n color=\"secondary\"\n onClick={(ev) => {\n ev.preventDefault();\n append({});\n }}\n >\n {customField.extra?.label.object?.add}\n </Button>\n </FieldBaseContainer>\n );\n};\n\nexport default FieldArray;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,6BAA0D;AAC1D,gCAAmC;AAEnC,yBAA4B;AAC5B,sBAAwC;AACxC,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AAM,GAAG,IAAI;AAAA,QACb,OAAM;AAAA,QACN,SAAS,CAAC,OAAO;AACf,aAAG,eAAe;AAClB,iBAAO,CAAC,CAAC;AAAA,QACX;AAAA;AAAA,MAEC,YAAY,OAAO,MAAM,QAAQ;AAAA,IACpC;AAAA,EACF;AAEJ;AAEA,IAAO,qBAAQ;",
|
|
6
|
+
"names": ["React"]
|
|
7
7
|
}
|
package/cjs/FieldObject/index.js
CHANGED
|
@@ -35,8 +35,8 @@ var import_react = __toESM(require("react"));
|
|
|
35
35
|
var import_FieldBase = require("@digigov/form/Field/FieldBase");
|
|
36
36
|
var import_utils = require("@digigov/form/Field/utils");
|
|
37
37
|
var import_calculateField = require("@digigov/form/Field/utils/calculateField");
|
|
38
|
-
var import_Fieldset =
|
|
39
|
-
var
|
|
38
|
+
var import_Fieldset = require("@digigov/form/Fieldset");
|
|
39
|
+
var import_FieldContainer = require("@digigov/ui/form/FieldContainer");
|
|
40
40
|
var import_i18n = require("@digigov/ui/i18n");
|
|
41
41
|
const FieldObject = ({
|
|
42
42
|
name,
|
|
@@ -46,10 +46,11 @@ const FieldObject = ({
|
|
|
46
46
|
register,
|
|
47
47
|
reset,
|
|
48
48
|
formState,
|
|
49
|
-
error
|
|
49
|
+
error,
|
|
50
|
+
Field
|
|
50
51
|
}) => {
|
|
51
52
|
const { t } = (0, import_i18n.useTranslation)();
|
|
52
|
-
return /* @__PURE__ */ import_react.default.createElement(import_Fieldset.
|
|
53
|
+
return /* @__PURE__ */ import_react.default.createElement(import_Fieldset.Fieldset, null, label?.primary && /* @__PURE__ */ import_react.default.createElement(import_FieldContainer.FieldsetLegend, { size: "sm" }, t(label.primary)), label?.secondary && /* @__PURE__ */ import_react.default.createElement(import_Fieldset.FieldsetCaption, null, t(label.secondary)), extra?.fields.map((field) => /* @__PURE__ */ import_react.default.createElement(
|
|
53
54
|
FieldObjectItem,
|
|
54
55
|
{
|
|
55
56
|
key: `${name}.${field.key}`,
|
|
@@ -59,7 +60,8 @@ const FieldObject = ({
|
|
|
59
60
|
reset,
|
|
60
61
|
field,
|
|
61
62
|
error: error && error[field.key],
|
|
62
|
-
formState
|
|
63
|
+
formState,
|
|
64
|
+
Field
|
|
63
65
|
}
|
|
64
66
|
)));
|
|
65
67
|
};
|
|
@@ -71,7 +73,8 @@ const FieldObjectItem = ({
|
|
|
71
73
|
control,
|
|
72
74
|
formState,
|
|
73
75
|
reset,
|
|
74
|
-
register
|
|
76
|
+
register,
|
|
77
|
+
Field
|
|
75
78
|
}) => {
|
|
76
79
|
const calculatedField = (0, import_react.useMemo)(
|
|
77
80
|
() => (0, import_calculateField.calculateField)(children, field, import_utils.FIELD_COMPONENTS, import_utils.ALTERNATIVE_COMPONENTS),
|
|
@@ -83,6 +86,7 @@ const FieldObjectItem = ({
|
|
|
83
86
|
{
|
|
84
87
|
...calculatedField,
|
|
85
88
|
name,
|
|
89
|
+
Field,
|
|
86
90
|
control,
|
|
87
91
|
reset,
|
|
88
92
|
register,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/FieldObject/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useMemo } from 'react';\nimport { ErrorOption, UseFormReturn } from 'react-hook-form';\nimport { FieldBase } from '@digigov/form/Field/FieldBase';\nimport { CalculatedField, FieldProps } from '@digigov/form/Field/types';\nimport {\n FIELD_COMPONENTS,\n ALTERNATIVE_COMPONENTS,\n} from '@digigov/form/Field/utils';\nimport { calculateField } from '@digigov/form/Field/utils/calculateField';\nimport Fieldset,
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA+B;AAE/B,uBAA0B;AAE1B,mBAGO;AACP,4BAA+B;AAC/B,sBAA0C;AAE1C,4BAA+B;AAC/B,kBAA+B;
|
|
6
|
-
"names": ["React"
|
|
4
|
+
"sourcesContent": ["import React, { useMemo } from 'react';\nimport { ErrorOption, UseFormReturn } from 'react-hook-form';\nimport { FieldBase } from '@digigov/form/Field/FieldBase';\nimport { CalculatedField, FieldProps } from '@digigov/form/Field/types';\nimport {\n FIELD_COMPONENTS,\n ALTERNATIVE_COMPONENTS,\n} from '@digigov/form/Field/utils';\nimport { calculateField } from '@digigov/form/Field/utils/calculateField';\nimport { Fieldset, FieldsetCaption } from '@digigov/form/Fieldset';\nimport { FieldSpec } from '@digigov/form/types';\nimport { FieldsetLegend } from '@digigov/ui/form/FieldContainer';\nimport { useTranslation } from '@digigov/ui/i18n';\n\nexport interface FieldObjectProps extends Omit<FieldProps, 'key'> {\n control: UseFormReturn['control'];\n register: UseFormReturn['register'];\n reset: UseFormReturn['reset'];\n formState: UseFormReturn['formState'];\n error?: ErrorOption;\n Field: React.FC<FieldProps>;\n}\n\nexport const FieldObject: React.FC<FieldObjectProps> = ({\n name,\n label,\n extra,\n control,\n register,\n reset,\n formState,\n error,\n Field,\n}) => {\n const { t } = useTranslation();\n\n return (\n <Fieldset>\n {label?.primary && (\n <FieldsetLegend size=\"sm\">{t(label.primary)}</FieldsetLegend>\n )}\n {label?.secondary && (\n <FieldsetCaption>{t(label.secondary)}</FieldsetCaption>\n )}\n {extra?.fields.map((field) => (\n <FieldObjectItem\n key={`${name}.${field.key}`}\n name={`${name}.${field.key}`}\n control={control}\n register={register}\n reset={reset}\n field={field}\n error={error && error[field.key]}\n formState={formState}\n Field={Field}\n />\n ))}\n </Fieldset>\n );\n};\n\nexport interface FieldObjectItemProps {\n name: string;\n field: FieldSpec;\n control: UseFormReturn['control'];\n register: UseFormReturn['register'];\n reset: UseFormReturn['reset'];\n formState: UseFormReturn['formState'];\n error?: ErrorOption;\n children?: React.ReactNode;\n Field: React.FC<FieldProps>;\n}\n\nconst FieldObjectItem: React.FC<FieldObjectItemProps> = ({\n name,\n children,\n field,\n error,\n control,\n formState,\n reset,\n register,\n Field,\n}) => {\n const calculatedField: CalculatedField = useMemo(\n () =>\n calculateField(children, field, FIELD_COMPONENTS, ALTERNATIVE_COMPONENTS),\n [field]\n );\n\n const customError = error ? error : formState?.errors[name];\n return (\n <FieldBase\n {...calculatedField}\n name={name}\n Field={Field}\n control={control}\n reset={reset}\n register={register}\n error={customError}\n />\n );\n};\n\nexport default FieldObject;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA+B;AAE/B,uBAA0B;AAE1B,mBAGO;AACP,4BAA+B;AAC/B,sBAA0C;AAE1C,4BAA+B;AAC/B,kBAA+B;AAWxB,MAAM,cAA0C,CAAC;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,EAAE,QAAI,4BAAe;AAE7B,SACE,6BAAAA,QAAA,cAAC,gCACE,OAAO,WACN,6BAAAA,QAAA,cAAC,wCAAe,MAAK,QAAM,EAAE,MAAM,OAAO,CAAE,GAE7C,OAAO,aACN,6BAAAA,QAAA,cAAC,uCAAiB,EAAE,MAAM,SAAS,CAAE,GAEtC,OAAO,OAAO,IAAI,CAAC,UAClB,6BAAAA,QAAA;AAAA,IAAC;AAAA;AAAA,MACC,KAAK,GAAG,IAAI,IAAI,MAAM,GAAG;AAAA,MACzB,MAAM,GAAG,IAAI,IAAI,MAAM,GAAG;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO,SAAS,MAAM,MAAM,GAAG;AAAA,MAC/B;AAAA,MACA;AAAA;AAAA,EACF,CACD,CACH;AAEJ;AAcA,MAAM,kBAAkD,CAAC;AAAA,EACvD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,sBAAmC;AAAA,IACvC,UACE,sCAAe,UAAU,OAAO,+BAAkB,mCAAsB;AAAA,IAC1E,CAAC,KAAK;AAAA,EACR;AAEA,QAAM,cAAc,QAAQ,QAAQ,WAAW,OAAO,IAAI;AAC1D,SACE,6BAAAA,QAAA;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO;AAAA;AAAA,EACT;AAEJ;AAEA,IAAO,sBAAQ;",
|
|
6
|
+
"names": ["React"]
|
|
7
7
|
}
|
package/cjs/Fieldset/index.js
CHANGED
|
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
var Fieldset_exports = {};
|
|
29
29
|
__export(Fieldset_exports, {
|
|
30
|
-
Fieldset: () => import_Fieldset.
|
|
30
|
+
Fieldset: () => import_Fieldset.Fieldset,
|
|
31
31
|
FieldsetBody: () => FieldsetBody,
|
|
32
32
|
FieldsetCaption: () => FieldsetCaption,
|
|
33
33
|
FieldsetLabel: () => FieldsetLabel,
|
|
@@ -35,27 +35,27 @@ __export(Fieldset_exports, {
|
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(Fieldset_exports);
|
|
37
37
|
var import_react = __toESM(require("react"));
|
|
38
|
-
var import_Fieldset =
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var import_NormalText =
|
|
38
|
+
var import_Fieldset = require("@digigov/react-core/Fieldset");
|
|
39
|
+
var import_FieldContainer = require("@digigov/ui/form/FieldContainer");
|
|
40
|
+
var import_Grid = require("@digigov/ui/layouts/Grid");
|
|
41
|
+
var import_Hint = require("@digigov/ui/typography/Hint");
|
|
42
|
+
var import_NormalText = require("@digigov/ui/typography/NormalText");
|
|
43
43
|
const FieldsetLabel = ({
|
|
44
44
|
children,
|
|
45
45
|
...props
|
|
46
46
|
}) => {
|
|
47
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
47
|
+
return /* @__PURE__ */ import_react.default.createElement(import_FieldContainer.FieldsetLegend, { heading: true, size: "xl", ...props }, children);
|
|
48
48
|
};
|
|
49
49
|
const FieldsetCaption = ({
|
|
50
50
|
children,
|
|
51
51
|
...props
|
|
52
52
|
}) => {
|
|
53
|
-
return /* @__PURE__ */ import_react.default.createElement(import_Hint.
|
|
53
|
+
return /* @__PURE__ */ import_react.default.createElement(import_Hint.Hint, { ...props }, children);
|
|
54
54
|
};
|
|
55
55
|
const FieldsetBody = ({ children }) => {
|
|
56
|
-
return /* @__PURE__ */ import_react.default.createElement(import_Grid.
|
|
56
|
+
return /* @__PURE__ */ import_react.default.createElement(import_Grid.Grid, { item: true, xs: 12 }, /* @__PURE__ */ import_react.default.createElement(import_NormalText.NormalText, null, children));
|
|
57
57
|
};
|
|
58
|
-
var Fieldset_default = import_Fieldset.
|
|
58
|
+
var Fieldset_default = import_Fieldset.Fieldset;
|
|
59
59
|
// Annotate the CommonJS export names for ESM import in node:
|
|
60
60
|
0 && (module.exports = {
|
|
61
61
|
Fieldset,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Fieldset/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport {\n FieldsetLabelProps,\n FieldsetCaptionProps,\n FieldsetBodyProps,\n} from '@digigov/form/Fieldset/types';\nimport Fieldset from '@digigov/react-core/Fieldset';\nimport FieldsetLegend from '@digigov/
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport {\n FieldsetLabelProps,\n FieldsetCaptionProps,\n FieldsetBodyProps,\n} from '@digigov/form/Fieldset/types';\nimport { Fieldset } from '@digigov/react-core/Fieldset';\nimport { FieldsetLegend } from '@digigov/ui/form/FieldContainer';\nimport { Grid } from '@digigov/ui/layouts/Grid';\nimport { Hint } from '@digigov/ui/typography/Hint';\nimport { NormalText } from '@digigov/ui/typography/NormalText';\n\nexport const FieldsetLabel: React.FC<FieldsetLabelProps> = ({\n children,\n ...props\n}) => {\n return (\n <FieldsetLegend heading size=\"xl\" {...props}>\n {children}\n </FieldsetLegend>\n );\n};\n\nexport const FieldsetCaption: React.FC<FieldsetCaptionProps> = ({\n children,\n ...props\n}) => {\n return <Hint {...props}>{children}</Hint>;\n};\n\nexport const FieldsetBody: React.FC<FieldsetBodyProps> = ({ children }) => {\n return (\n <Grid item xs={12}>\n <NormalText>{children}</NormalText>\n </Grid>\n );\n};\n\nexport { Fieldset };\nexport default Fieldset;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAMlB,sBAAyB;AACzB,4BAA+B;AAC/B,kBAAqB;AACrB,kBAAqB;AACrB,wBAA2B;AAEpB,MAAM,gBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA,GAAG;AACL,MAAM;AACJ,SACE,6BAAAA,QAAA,cAAC,wCAAe,SAAO,MAAC,MAAK,MAAM,GAAG,SACnC,QACH;AAEJ;AAEO,MAAM,kBAAkD,CAAC;AAAA,EAC9D;AAAA,EACA,GAAG;AACL,MAAM;AACJ,SAAO,6BAAAA,QAAA,cAAC,oBAAM,GAAG,SAAQ,QAAS;AACpC;AAEO,MAAM,eAA4C,CAAC,EAAE,SAAS,MAAM;AACzE,SACE,6BAAAA,QAAA,cAAC,oBAAK,MAAI,MAAC,IAAI,MACb,6BAAAA,QAAA,cAAC,oCAAY,QAAS,CACxB;AAEJ;AAGA,IAAO,mBAAQ;",
|
|
6
|
+
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Fieldset/types.tsx"],
|
|
4
|
-
"sourcesContent": ["import { FieldsetLegendProps } from '@digigov/
|
|
4
|
+
"sourcesContent": ["import { FieldsetLegendProps } from '@digigov/ui/form/FieldContainer';\nimport { HintProps } from '@digigov/ui/typography/Hint';\n\nexport interface FieldsetLabelProps extends FieldsetLegendProps {}\nexport interface FieldsetCaptionProps extends HintProps {}\nexport interface FieldsetBodyProps {\n children?: React.ReactNode;\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|