@contember/react-form 2.1.0-alpha.3 → 2.1.0-alpha.35
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/package.json +10 -10
- package/src/components/FormCheckbox.tsx +2 -1
- package/src/components/FormError.tsx +1 -1
- package/src/components/FormFieldStateProvider.tsx +0 -2
- package/src/components/FormInput.tsx +35 -32
- package/src/components/FormRadioInput.tsx +1 -1
- package/src/contexts.tsx +0 -2
- package/src/hooks/useFormInputValidationHandler.tsx +1 -1
- package/src/internal/useFormInputHandler.ts +6 -6
- package/dist/development/index.cjs +0 -30
- package/dist/development/index.cjs.map +0 -1
- package/dist/development/index.js +0 -30
- package/dist/development/index.js.map +0 -1
- package/dist/development/src/components/FormCheckbox.cjs +0 -83
- package/dist/development/src/components/FormCheckbox.cjs.map +0 -1
- package/dist/development/src/components/FormCheckbox.js +0 -67
- package/dist/development/src/components/FormCheckbox.js.map +0 -1
- package/dist/development/src/components/FormError.cjs +0 -22
- package/dist/development/src/components/FormError.cjs.map +0 -1
- package/dist/development/src/components/FormError.js +0 -22
- package/dist/development/src/components/FormError.js.map +0 -1
- package/dist/development/src/components/FormFieldScope.cjs +0 -33
- package/dist/development/src/components/FormFieldScope.cjs.map +0 -1
- package/dist/development/src/components/FormFieldScope.js +0 -33
- package/dist/development/src/components/FormFieldScope.js.map +0 -1
- package/dist/development/src/components/FormFieldStateProvider.cjs +0 -56
- package/dist/development/src/components/FormFieldStateProvider.cjs.map +0 -1
- package/dist/development/src/components/FormFieldStateProvider.js +0 -56
- package/dist/development/src/components/FormFieldStateProvider.js.map +0 -1
- package/dist/development/src/components/FormHasManyRelationScope.cjs +0 -33
- package/dist/development/src/components/FormHasManyRelationScope.cjs.map +0 -1
- package/dist/development/src/components/FormHasManyRelationScope.js +0 -33
- package/dist/development/src/components/FormHasManyRelationScope.js.map +0 -1
- package/dist/development/src/components/FormHasOneRelationScope.cjs +0 -33
- package/dist/development/src/components/FormHasOneRelationScope.cjs.map +0 -1
- package/dist/development/src/components/FormHasOneRelationScope.js +0 -33
- package/dist/development/src/components/FormHasOneRelationScope.js.map +0 -1
- package/dist/development/src/components/FormInput.cjs +0 -59
- package/dist/development/src/components/FormInput.cjs.map +0 -1
- package/dist/development/src/components/FormInput.js +0 -59
- package/dist/development/src/components/FormInput.js.map +0 -1
- package/dist/development/src/components/FormLabel.cjs +0 -34
- package/dist/development/src/components/FormLabel.cjs.map +0 -1
- package/dist/development/src/components/FormLabel.js +0 -34
- package/dist/development/src/components/FormLabel.js.map +0 -1
- package/dist/development/src/components/FormRadioInput.cjs +0 -55
- package/dist/development/src/components/FormRadioInput.cjs.map +0 -1
- package/dist/development/src/components/FormRadioInput.js +0 -55
- package/dist/development/src/components/FormRadioInput.js.map +0 -1
- package/dist/development/src/contexts.cjs +0 -13
- package/dist/development/src/contexts.cjs.map +0 -1
- package/dist/development/src/contexts.js +0 -13
- package/dist/development/src/contexts.js.map +0 -1
- package/dist/development/src/hooks/useFormInputValidationHandler.cjs +0 -80
- package/dist/development/src/hooks/useFormInputValidationHandler.cjs.map +0 -1
- package/dist/development/src/hooks/useFormInputValidationHandler.js +0 -64
- package/dist/development/src/hooks/useFormInputValidationHandler.js.map +0 -1
- package/dist/development/src/internal/useFormInputHandler.cjs +0 -122
- package/dist/development/src/internal/useFormInputHandler.cjs.map +0 -1
- package/dist/development/src/internal/useFormInputHandler.js +0 -122
- package/dist/development/src/internal/useFormInputHandler.js.map +0 -1
- package/dist/production/index.cjs +0 -30
- package/dist/production/index.cjs.map +0 -1
- package/dist/production/index.js +0 -30
- package/dist/production/index.js.map +0 -1
- package/dist/production/src/components/FormCheckbox.cjs +0 -71
- package/dist/production/src/components/FormCheckbox.cjs.map +0 -1
- package/dist/production/src/components/FormCheckbox.js +0 -55
- package/dist/production/src/components/FormCheckbox.js.map +0 -1
- package/dist/production/src/components/FormError.cjs +0 -22
- package/dist/production/src/components/FormError.cjs.map +0 -1
- package/dist/production/src/components/FormError.js +0 -22
- package/dist/production/src/components/FormError.js.map +0 -1
- package/dist/production/src/components/FormFieldScope.cjs +0 -25
- package/dist/production/src/components/FormFieldScope.cjs.map +0 -1
- package/dist/production/src/components/FormFieldScope.js +0 -25
- package/dist/production/src/components/FormFieldScope.js.map +0 -1
- package/dist/production/src/components/FormFieldStateProvider.cjs +0 -34
- package/dist/production/src/components/FormFieldStateProvider.cjs.map +0 -1
- package/dist/production/src/components/FormFieldStateProvider.js +0 -34
- package/dist/production/src/components/FormFieldStateProvider.js.map +0 -1
- package/dist/production/src/components/FormHasManyRelationScope.cjs +0 -25
- package/dist/production/src/components/FormHasManyRelationScope.cjs.map +0 -1
- package/dist/production/src/components/FormHasManyRelationScope.js +0 -25
- package/dist/production/src/components/FormHasManyRelationScope.js.map +0 -1
- package/dist/production/src/components/FormHasOneRelationScope.cjs +0 -25
- package/dist/production/src/components/FormHasOneRelationScope.cjs.map +0 -1
- package/dist/production/src/components/FormHasOneRelationScope.js +0 -25
- package/dist/production/src/components/FormHasOneRelationScope.js.map +0 -1
- package/dist/production/src/components/FormInput.cjs +0 -47
- package/dist/production/src/components/FormInput.cjs.map +0 -1
- package/dist/production/src/components/FormInput.js +0 -47
- package/dist/production/src/components/FormInput.js.map +0 -1
- package/dist/production/src/components/FormLabel.cjs +0 -26
- package/dist/production/src/components/FormLabel.cjs.map +0 -1
- package/dist/production/src/components/FormLabel.js +0 -26
- package/dist/production/src/components/FormLabel.js.map +0 -1
- package/dist/production/src/components/FormRadioInput.cjs +0 -43
- package/dist/production/src/components/FormRadioInput.cjs.map +0 -1
- package/dist/production/src/components/FormRadioInput.js +0 -43
- package/dist/production/src/components/FormRadioInput.js.map +0 -1
- package/dist/production/src/contexts.cjs +0 -13
- package/dist/production/src/contexts.cjs.map +0 -1
- package/dist/production/src/contexts.js +0 -13
- package/dist/production/src/contexts.js.map +0 -1
- package/dist/production/src/hooks/useFormInputValidationHandler.cjs +0 -80
- package/dist/production/src/hooks/useFormInputValidationHandler.cjs.map +0 -1
- package/dist/production/src/hooks/useFormInputValidationHandler.js +0 -64
- package/dist/production/src/hooks/useFormInputValidationHandler.js.map +0 -1
- package/dist/production/src/internal/useFormInputHandler.cjs +0 -122
- package/dist/production/src/internal/useFormInputHandler.cjs.map +0 -1
- package/dist/production/src/internal/useFormInputHandler.js +0 -122
- package/dist/production/src/internal/useFormInputHandler.js.map +0 -1
- package/dist/types/components/FormCheckbox.d.ts +0 -11
- package/dist/types/components/FormCheckbox.d.ts.map +0 -1
- package/dist/types/components/FormError.d.ts +0 -7
- package/dist/types/components/FormError.d.ts.map +0 -1
- package/dist/types/components/FormFieldScope.d.ts +0 -9
- package/dist/types/components/FormFieldScope.d.ts.map +0 -1
- package/dist/types/components/FormFieldStateProvider.d.ts +0 -36
- package/dist/types/components/FormFieldStateProvider.d.ts.map +0 -1
- package/dist/types/components/FormHasManyRelationScope.d.ts +0 -12
- package/dist/types/components/FormHasManyRelationScope.d.ts.map +0 -1
- package/dist/types/components/FormHasOneRelationScope.d.ts +0 -9
- package/dist/types/components/FormHasOneRelationScope.d.ts.map +0 -1
- package/dist/types/components/FormInput.d.ts +0 -13
- package/dist/types/components/FormInput.d.ts.map +0 -1
- package/dist/types/components/FormLabel.d.ts +0 -5
- package/dist/types/components/FormLabel.d.ts.map +0 -1
- package/dist/types/components/FormRadioInput.d.ts +0 -11
- package/dist/types/components/FormRadioInput.d.ts.map +0 -1
- package/dist/types/components/index.d.ts +0 -10
- package/dist/types/components/index.d.ts.map +0 -1
- package/dist/types/contexts.d.ts +0 -12
- package/dist/types/contexts.d.ts.map +0 -1
- package/dist/types/hooks/index.d.ts +0 -2
- package/dist/types/hooks/index.d.ts.map +0 -1
- package/dist/types/hooks/useFormInputValidationHandler.d.ts +0 -8
- package/dist/types/hooks/useFormInputValidationHandler.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -5
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/internal/useFormInputHandler.d.ts +0 -4
- package/dist/types/internal/useFormInputHandler.d.ts.map +0 -1
- package/dist/types/tsconfig.tsbuildinfo +0 -1
- package/dist/types/types/index.d.ts +0 -23
- package/dist/types/types/index.d.ts.map +0 -1
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
|
-
const React = require("react");
|
|
5
|
-
const contexts = require("../contexts.cjs");
|
|
6
|
-
const emptyArr = [];
|
|
7
|
-
const FormFieldStateProvider = ({ children, required = false, errors = emptyArr, dirty = false, htmlId, field }) => {
|
|
8
|
-
const generatedId = React.useId();
|
|
9
|
-
htmlId ?? (htmlId = generatedId);
|
|
10
|
-
const value = React.useMemo(() => ({ htmlId, required, errors, dirty, field }), [htmlId, required, errors, dirty, field]);
|
|
11
|
-
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(contexts.FormFieldStateContext.Provider, { value, children }, void 0, false, {
|
|
12
|
-
fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormFieldStateProvider.tsx",
|
|
13
|
-
lineNumber: 18,
|
|
14
|
-
columnNumber: 9
|
|
15
|
-
}, void 0);
|
|
16
|
-
};
|
|
17
|
-
const FormFieldIdContext = {
|
|
18
|
-
/**
|
|
19
|
-
* @deprecated use `FormFieldStateProvider` instead
|
|
20
|
-
*/
|
|
21
|
-
Provider: ({ children, value }) => {
|
|
22
|
-
const state = contexts.useFormFieldState();
|
|
23
|
-
{
|
|
24
|
-
React.useEffect(() => {
|
|
25
|
-
console.warn("FormFieldIdContext.Provider is deprecated, use FormFieldStateProvider instead");
|
|
26
|
-
}, []);
|
|
27
|
-
}
|
|
28
|
-
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(FormFieldStateProvider, { ...state, htmlId: value, children }, void 0, false, {
|
|
29
|
-
fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormFieldStateProvider.tsx",
|
|
30
|
-
lineNumber: 43,
|
|
31
|
-
columnNumber: 4
|
|
32
|
-
}, void 0);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const FormErrorContext = {
|
|
36
|
-
/**
|
|
37
|
-
* @deprecated use `FormFieldStateProvider` instead
|
|
38
|
-
*/
|
|
39
|
-
Provider: ({ children, value }) => {
|
|
40
|
-
const state = contexts.useFormFieldState();
|
|
41
|
-
{
|
|
42
|
-
React.useEffect(() => {
|
|
43
|
-
console.warn("FormErrorContext.Provider is deprecated, use FormFieldStateProvider instead");
|
|
44
|
-
}, []);
|
|
45
|
-
}
|
|
46
|
-
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(FormFieldStateProvider, { ...state, errors: value, children }, void 0, false, {
|
|
47
|
-
fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormFieldStateProvider.tsx",
|
|
48
|
-
lineNumber: 66,
|
|
49
|
-
columnNumber: 4
|
|
50
|
-
}, void 0);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
exports.FormErrorContext = FormErrorContext;
|
|
54
|
-
exports.FormFieldIdContext = FormFieldIdContext;
|
|
55
|
-
exports.FormFieldStateProvider = FormFieldStateProvider;
|
|
56
|
-
//# sourceMappingURL=FormFieldStateProvider.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormFieldStateProvider.cjs","sources":["../../../../../packages/react-form/src/components/FormFieldStateProvider.tsx"],"sourcesContent":["import { ErrorAccessor } from '@contember/react-binding'\nimport { useEffect, useId, useMemo } from 'react'\nimport { FormFieldStateContext, useFormFieldState } from '../contexts'\nimport { FormFieldState } from '../types'\n\nconst emptyArr: [] = []\n\nexport type FormFieldStateProvider =\n\t& Partial<FormFieldState>\n\t& {\n\t\tchildren: React.ReactNode\n\t}\n\nexport const FormFieldStateProvider = ({ children, required = false, errors = emptyArr, dirty = false, htmlId, field }: FormFieldStateProvider) => {\n\tconst generatedId = useId()\n\thtmlId ??= generatedId\n\tconst value = useMemo(() => ({ htmlId, required, errors, dirty, field }), [htmlId, required, errors, dirty, field])\n\treturn <FormFieldStateContext.Provider value={value}>{children}</FormFieldStateContext.Provider>\n}\n\n/**\n * BC for\n * \t<FormFieldIdContext.Provider value={id}>\n * \t<FormErrorContext.Provider value={[]}>\n */\n\n/**\n * @deprecated use `FormFieldStateProvider` instead\n */\nexport const FormFieldIdContext = {\n\t/**\n\t * @deprecated use `FormFieldStateProvider` instead\n\t */\n\tProvider: ({ children, value }: { children: React.ReactNode; value: string }) => {\n\t\tconst state = useFormFieldState()\n\t\tif (import.meta.env.DEV) {\n\t\t\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\t\t\tuseEffect(() => {\n\t\t\t\tconsole.warn('FormFieldIdContext.Provider is deprecated, use FormFieldStateProvider instead')\n\t\t\t}, [])\n\t\t}\n\t\treturn (\n\t\t\t<FormFieldStateProvider {...state} htmlId={value}>\n\t\t\t\t{children}\n\t\t\t</FormFieldStateProvider>\n\t\t)\n\t},\n}\n\n/**\n * @deprecated use `FormFieldStateProvider` instead\n */\nexport const FormErrorContext = {\n\t/**\n\t * @deprecated use `FormFieldStateProvider` instead\n\t */\n\tProvider: ({ children, value }: { children: React.ReactNode; value: ErrorAccessor.Error[] }) => {\n\t\tconst state = useFormFieldState()\n\t\tif (import.meta.env.DEV) {\n\t\t\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\t\t\tuseEffect(() => {\n\t\t\t\tconsole.warn('FormErrorContext.Provider is deprecated, use FormFieldStateProvider instead')\n\t\t\t}, [])\n\t\t}\n\t\treturn (\n\t\t\t<FormFieldStateProvider {...state} errors={value}>\n\t\t\t\t{children}\n\t\t\t</FormFieldStateProvider>\n\t\t)\n\t},\n}\n"],"names":["useId","useMemo","jsxDEV","FormFieldStateContext","useFormFieldState","useEffect"],"mappings":";;;;;AAKA,MAAM,WAAe,CAAC;AAQf,MAAM,yBAAyB,CAAC,EAAE,UAAU,WAAW,OAAO,SAAS,UAAU,QAAQ,OAAO,QAAQ,MAAA,MAAoC;AAClJ,QAAM,cAAcA,MAAAA,MAAM;AACf,aAAA,SAAA;AACX,QAAM,QAAQC,MAAAA,QAAQ,OAAO,EAAE,QAAQ,UAAU,QAAQ,OAAO,MAAM,IAAI,CAAC,QAAQ,UAAU,QAAQ,OAAO,KAAK,CAAC;AAC1G,SAAAC,8BAAA,OAAAC,+BAAsB,UAAtB,EAA+B,OAAe,SAA/C,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,KAAwD,MAAA;AAChE;AAWO,MAAM,qBAAqB;AAAA;AAAA;AAAA;AAAA,EAIjC,UAAU,CAAC,EAAE,UAAU,YAA0D;AAChF,UAAM,QAAQC,SAAAA,kBAAkB;AACP;AAExBC,YAAAA,UAAU,MAAM;AACf,gBAAQ,KAAK,+EAA+E;AAAA,MAC7F,GAAG,EAAE;AAAA,IAAA;gDAGJ,wBAAwB,EAAA,GAAG,OAAO,QAAQ,OACzC,SADF,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,OAEA,MAAA;AAAA,EAAA;AAGH;AAKO,MAAM,mBAAmB;AAAA;AAAA;AAAA;AAAA,EAI/B,UAAU,CAAC,EAAE,UAAU,YAAyE;AAC/F,UAAM,QAAQD,SAAAA,kBAAkB;AACP;AAExBC,YAAAA,UAAU,MAAM;AACf,gBAAQ,KAAK,6EAA6E;AAAA,MAC3F,GAAG,EAAE;AAAA,IAAA;gDAGJ,wBAAwB,EAAA,GAAG,OAAO,QAAQ,OACzC,SADF,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,OAEA,MAAA;AAAA,EAAA;AAGH;;;;"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
|
-
import { useId, useMemo, useEffect } from "react";
|
|
3
|
-
import { FormFieldStateContext, useFormFieldState } from "../contexts.js";
|
|
4
|
-
const emptyArr = [];
|
|
5
|
-
const FormFieldStateProvider = ({ children, required = false, errors = emptyArr, dirty = false, htmlId, field }) => {
|
|
6
|
-
const generatedId = useId();
|
|
7
|
-
htmlId ?? (htmlId = generatedId);
|
|
8
|
-
const value = useMemo(() => ({ htmlId, required, errors, dirty, field }), [htmlId, required, errors, dirty, field]);
|
|
9
|
-
return /* @__PURE__ */ jsxDEV(FormFieldStateContext.Provider, { value, children }, void 0, false, {
|
|
10
|
-
fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormFieldStateProvider.tsx",
|
|
11
|
-
lineNumber: 18,
|
|
12
|
-
columnNumber: 9
|
|
13
|
-
}, void 0);
|
|
14
|
-
};
|
|
15
|
-
const FormFieldIdContext = {
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated use `FormFieldStateProvider` instead
|
|
18
|
-
*/
|
|
19
|
-
Provider: ({ children, value }) => {
|
|
20
|
-
const state = useFormFieldState();
|
|
21
|
-
{
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
console.warn("FormFieldIdContext.Provider is deprecated, use FormFieldStateProvider instead");
|
|
24
|
-
}, []);
|
|
25
|
-
}
|
|
26
|
-
return /* @__PURE__ */ jsxDEV(FormFieldStateProvider, { ...state, htmlId: value, children }, void 0, false, {
|
|
27
|
-
fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormFieldStateProvider.tsx",
|
|
28
|
-
lineNumber: 43,
|
|
29
|
-
columnNumber: 4
|
|
30
|
-
}, void 0);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
const FormErrorContext = {
|
|
34
|
-
/**
|
|
35
|
-
* @deprecated use `FormFieldStateProvider` instead
|
|
36
|
-
*/
|
|
37
|
-
Provider: ({ children, value }) => {
|
|
38
|
-
const state = useFormFieldState();
|
|
39
|
-
{
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
console.warn("FormErrorContext.Provider is deprecated, use FormFieldStateProvider instead");
|
|
42
|
-
}, []);
|
|
43
|
-
}
|
|
44
|
-
return /* @__PURE__ */ jsxDEV(FormFieldStateProvider, { ...state, errors: value, children }, void 0, false, {
|
|
45
|
-
fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormFieldStateProvider.tsx",
|
|
46
|
-
lineNumber: 66,
|
|
47
|
-
columnNumber: 4
|
|
48
|
-
}, void 0);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
export {
|
|
52
|
-
FormErrorContext,
|
|
53
|
-
FormFieldIdContext,
|
|
54
|
-
FormFieldStateProvider
|
|
55
|
-
};
|
|
56
|
-
//# sourceMappingURL=FormFieldStateProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormFieldStateProvider.js","sources":["../../../../../packages/react-form/src/components/FormFieldStateProvider.tsx"],"sourcesContent":["import { ErrorAccessor } from '@contember/react-binding'\nimport { useEffect, useId, useMemo } from 'react'\nimport { FormFieldStateContext, useFormFieldState } from '../contexts'\nimport { FormFieldState } from '../types'\n\nconst emptyArr: [] = []\n\nexport type FormFieldStateProvider =\n\t& Partial<FormFieldState>\n\t& {\n\t\tchildren: React.ReactNode\n\t}\n\nexport const FormFieldStateProvider = ({ children, required = false, errors = emptyArr, dirty = false, htmlId, field }: FormFieldStateProvider) => {\n\tconst generatedId = useId()\n\thtmlId ??= generatedId\n\tconst value = useMemo(() => ({ htmlId, required, errors, dirty, field }), [htmlId, required, errors, dirty, field])\n\treturn <FormFieldStateContext.Provider value={value}>{children}</FormFieldStateContext.Provider>\n}\n\n/**\n * BC for\n * \t<FormFieldIdContext.Provider value={id}>\n * \t<FormErrorContext.Provider value={[]}>\n */\n\n/**\n * @deprecated use `FormFieldStateProvider` instead\n */\nexport const FormFieldIdContext = {\n\t/**\n\t * @deprecated use `FormFieldStateProvider` instead\n\t */\n\tProvider: ({ children, value }: { children: React.ReactNode; value: string }) => {\n\t\tconst state = useFormFieldState()\n\t\tif (import.meta.env.DEV) {\n\t\t\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\t\t\tuseEffect(() => {\n\t\t\t\tconsole.warn('FormFieldIdContext.Provider is deprecated, use FormFieldStateProvider instead')\n\t\t\t}, [])\n\t\t}\n\t\treturn (\n\t\t\t<FormFieldStateProvider {...state} htmlId={value}>\n\t\t\t\t{children}\n\t\t\t</FormFieldStateProvider>\n\t\t)\n\t},\n}\n\n/**\n * @deprecated use `FormFieldStateProvider` instead\n */\nexport const FormErrorContext = {\n\t/**\n\t * @deprecated use `FormFieldStateProvider` instead\n\t */\n\tProvider: ({ children, value }: { children: React.ReactNode; value: ErrorAccessor.Error[] }) => {\n\t\tconst state = useFormFieldState()\n\t\tif (import.meta.env.DEV) {\n\t\t\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\t\t\tuseEffect(() => {\n\t\t\t\tconsole.warn('FormErrorContext.Provider is deprecated, use FormFieldStateProvider instead')\n\t\t\t}, [])\n\t\t}\n\t\treturn (\n\t\t\t<FormFieldStateProvider {...state} errors={value}>\n\t\t\t\t{children}\n\t\t\t</FormFieldStateProvider>\n\t\t)\n\t},\n}\n"],"names":[],"mappings":";;;AAKA,MAAM,WAAe,CAAC;AAQf,MAAM,yBAAyB,CAAC,EAAE,UAAU,WAAW,OAAO,SAAS,UAAU,QAAQ,OAAO,QAAQ,MAAA,MAAoC;AAClJ,QAAM,cAAc,MAAM;AACf,aAAA,SAAA;AACX,QAAM,QAAQ,QAAQ,OAAO,EAAE,QAAQ,UAAU,QAAQ,OAAO,MAAM,IAAI,CAAC,QAAQ,UAAU,QAAQ,OAAO,KAAK,CAAC;AAC1G,SAAA,uBAAA,sBAAsB,UAAtB,EAA+B,OAAe,SAA/C,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,KAAwD,MAAA;AAChE;AAWO,MAAM,qBAAqB;AAAA;AAAA;AAAA;AAAA,EAIjC,UAAU,CAAC,EAAE,UAAU,YAA0D;AAChF,UAAM,QAAQ,kBAAkB;AACP;AAExB,gBAAU,MAAM;AACf,gBAAQ,KAAK,+EAA+E;AAAA,MAC7F,GAAG,EAAE;AAAA,IAAA;kCAGJ,wBAAwB,EAAA,GAAG,OAAO,QAAQ,OACzC,SADF,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,OAEA,MAAA;AAAA,EAAA;AAGH;AAKO,MAAM,mBAAmB;AAAA;AAAA;AAAA;AAAA,EAI/B,UAAU,CAAC,EAAE,UAAU,YAAyE;AAC/F,UAAM,QAAQ,kBAAkB;AACP;AAExB,gBAAU,MAAM;AACf,gBAAQ,KAAK,6EAA6E;AAAA,MAC3F,GAAG,EAAE;AAAA,IAAA;kCAGJ,wBAAwB,EAAA,GAAG,OAAO,QAAQ,OACzC,SADF,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,OAEA,MAAA;AAAA,EAAA;AAGH;"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
|
-
const reactBinding = require("@contember/react-binding");
|
|
5
|
-
const FormFieldStateProvider = require("./FormFieldStateProvider.cjs");
|
|
6
|
-
const React = require("react");
|
|
7
|
-
const FormHasManyRelationScope = ({ children, required, ...props }) => {
|
|
8
|
-
const entityRelation = reactBinding.useEntityList(props);
|
|
9
|
-
const entityName = entityRelation.getParent().name;
|
|
10
|
-
const marker = entityRelation.getMarker();
|
|
11
|
-
const fieldName = marker.parameters.field;
|
|
12
|
-
const fieldInfo = React.useMemo(() => ({ entityName, fieldName }), [entityName, fieldName]);
|
|
13
|
-
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(
|
|
14
|
-
FormFieldStateProvider.FormFieldStateProvider,
|
|
15
|
-
{
|
|
16
|
-
errors: entityRelation.errors?.errors,
|
|
17
|
-
dirty: entityRelation.hasUnpersistedChanges,
|
|
18
|
-
required,
|
|
19
|
-
field: fieldInfo,
|
|
20
|
-
children
|
|
21
|
-
},
|
|
22
|
-
void 0,
|
|
23
|
-
false,
|
|
24
|
-
{
|
|
25
|
-
fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormHasManyRelationScope.tsx",
|
|
26
|
-
lineNumber: 23,
|
|
27
|
-
columnNumber: 3
|
|
28
|
-
},
|
|
29
|
-
void 0
|
|
30
|
-
);
|
|
31
|
-
};
|
|
32
|
-
exports.FormHasManyRelationScope = FormHasManyRelationScope;
|
|
33
|
-
//# sourceMappingURL=FormHasManyRelationScope.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormHasManyRelationScope.cjs","sources":["../../../../../packages/react-form/src/components/FormHasManyRelationScope.tsx"],"sourcesContent":["import { HasManyRelationMarker, SugaredRelativeEntityList, useEntityList } from '@contember/react-binding'\nimport * as React from 'react'\nimport { FormFieldStateProvider } from './FormFieldStateProvider'\nimport { useMemo } from 'react'\n\nexport type FormHasManyRelationScopeProps = {\n\tfield: SugaredRelativeEntityList['field']\n\torderBy?: SugaredRelativeEntityList['orderBy']\n\tlimit?: SugaredRelativeEntityList['limit']\n\toffset?: SugaredRelativeEntityList['offset']\n\tchildren: React.ReactNode\n\trequired?: boolean\n}\n\nexport const FormHasManyRelationScope = ({ children, required, ...props }: FormHasManyRelationScopeProps) => {\n\tconst entityRelation = useEntityList(props)\n\tconst entityName = entityRelation.getParent()!.name\n\tconst marker = entityRelation.getMarker() as HasManyRelationMarker\n\tconst fieldName = marker.parameters.field\n\tconst fieldInfo = useMemo(() => ({ entityName, fieldName }), [entityName, fieldName])\n\n\treturn (\n\t\t<FormFieldStateProvider\n\t\t\terrors={entityRelation.errors?.errors}\n\t\t\tdirty={entityRelation.hasUnpersistedChanges}\n\t\t\trequired={required}\n\t\t\tfield={fieldInfo}\n\t\t>\n\t\t\t{children}\n\t\t</FormFieldStateProvider>\n\t)\n}\n"],"names":["useEntityList","useMemo","jsxDEV","FormFieldStateProvider","this"],"mappings":";;;;;;AAcO,MAAM,2BAA2B,CAAC,EAAE,UAAU,UAAU,GAAG,YAA2C;AACtG,QAAA,iBAAiBA,2BAAc,KAAK;AACpC,QAAA,aAAa,eAAe,UAAA,EAAa;AACzC,QAAA,SAAS,eAAe,UAAU;AAClC,QAAA,YAAY,OAAO,WAAW;AAC9B,QAAA,YAAYC,cAAQ,OAAO,EAAE,YAAY,cAAc,CAAC,YAAY,SAAS,CAAC;AAGnF,SAAAC,8BAAA;AAAA,IAACC,uBAAA;AAAA,IAAA;AAAA,MACA,QAAQ,eAAe,QAAQ;AAAA,MAC/B,OAAO,eAAe;AAAA,MACtB;AAAA,MACA,OAAO;AAAA,MAEN;AAAA,IAAA;AAAA,IANF;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAC;AAAAA,EAOA;AAEF;;"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
|
-
import { useEntityList } from "@contember/react-binding";
|
|
3
|
-
import { FormFieldStateProvider } from "./FormFieldStateProvider.js";
|
|
4
|
-
import { useMemo } from "react";
|
|
5
|
-
const FormHasManyRelationScope = ({ children, required, ...props }) => {
|
|
6
|
-
const entityRelation = useEntityList(props);
|
|
7
|
-
const entityName = entityRelation.getParent().name;
|
|
8
|
-
const marker = entityRelation.getMarker();
|
|
9
|
-
const fieldName = marker.parameters.field;
|
|
10
|
-
const fieldInfo = useMemo(() => ({ entityName, fieldName }), [entityName, fieldName]);
|
|
11
|
-
return /* @__PURE__ */ jsxDEV(
|
|
12
|
-
FormFieldStateProvider,
|
|
13
|
-
{
|
|
14
|
-
errors: entityRelation.errors?.errors,
|
|
15
|
-
dirty: entityRelation.hasUnpersistedChanges,
|
|
16
|
-
required,
|
|
17
|
-
field: fieldInfo,
|
|
18
|
-
children
|
|
19
|
-
},
|
|
20
|
-
void 0,
|
|
21
|
-
false,
|
|
22
|
-
{
|
|
23
|
-
fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormHasManyRelationScope.tsx",
|
|
24
|
-
lineNumber: 23,
|
|
25
|
-
columnNumber: 3
|
|
26
|
-
},
|
|
27
|
-
void 0
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
export {
|
|
31
|
-
FormHasManyRelationScope
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=FormHasManyRelationScope.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormHasManyRelationScope.js","sources":["../../../../../packages/react-form/src/components/FormHasManyRelationScope.tsx"],"sourcesContent":["import { HasManyRelationMarker, SugaredRelativeEntityList, useEntityList } from '@contember/react-binding'\nimport * as React from 'react'\nimport { FormFieldStateProvider } from './FormFieldStateProvider'\nimport { useMemo } from 'react'\n\nexport type FormHasManyRelationScopeProps = {\n\tfield: SugaredRelativeEntityList['field']\n\torderBy?: SugaredRelativeEntityList['orderBy']\n\tlimit?: SugaredRelativeEntityList['limit']\n\toffset?: SugaredRelativeEntityList['offset']\n\tchildren: React.ReactNode\n\trequired?: boolean\n}\n\nexport const FormHasManyRelationScope = ({ children, required, ...props }: FormHasManyRelationScopeProps) => {\n\tconst entityRelation = useEntityList(props)\n\tconst entityName = entityRelation.getParent()!.name\n\tconst marker = entityRelation.getMarker() as HasManyRelationMarker\n\tconst fieldName = marker.parameters.field\n\tconst fieldInfo = useMemo(() => ({ entityName, fieldName }), [entityName, fieldName])\n\n\treturn (\n\t\t<FormFieldStateProvider\n\t\t\terrors={entityRelation.errors?.errors}\n\t\t\tdirty={entityRelation.hasUnpersistedChanges}\n\t\t\trequired={required}\n\t\t\tfield={fieldInfo}\n\t\t>\n\t\t\t{children}\n\t\t</FormFieldStateProvider>\n\t)\n}\n"],"names":["this"],"mappings":";;;;AAcO,MAAM,2BAA2B,CAAC,EAAE,UAAU,UAAU,GAAG,YAA2C;AACtG,QAAA,iBAAiB,cAAc,KAAK;AACpC,QAAA,aAAa,eAAe,UAAA,EAAa;AACzC,QAAA,SAAS,eAAe,UAAU;AAClC,QAAA,YAAY,OAAO,WAAW;AAC9B,QAAA,YAAY,QAAQ,OAAO,EAAE,YAAY,cAAc,CAAC,YAAY,SAAS,CAAC;AAGnF,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,QAAQ,eAAe,QAAQ;AAAA,MAC/B,OAAO,eAAe;AAAA,MACtB;AAAA,MACA,OAAO;AAAA,MAEN;AAAA,IAAA;AAAA,IANF;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAA;AAAAA,EAOA;AAEF;"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
|
-
const reactBinding = require("@contember/react-binding");
|
|
5
|
-
const FormFieldStateProvider = require("./FormFieldStateProvider.cjs");
|
|
6
|
-
const React = require("react");
|
|
7
|
-
const FormHasOneRelationScope = ({ field, children, required }) => {
|
|
8
|
-
const entityRelation = reactBinding.useEntity({ field });
|
|
9
|
-
const marker = entityRelation.getMarker();
|
|
10
|
-
const fieldName = marker.parameters.field;
|
|
11
|
-
const entityName = entityRelation.getParent().name;
|
|
12
|
-
const fieldInfo = React.useMemo(() => ({ entityName, fieldName }), [entityName, fieldName]);
|
|
13
|
-
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(
|
|
14
|
-
FormFieldStateProvider.FormFieldStateProvider,
|
|
15
|
-
{
|
|
16
|
-
errors: entityRelation.errors?.errors,
|
|
17
|
-
dirty: entityRelation.hasUnpersistedChanges,
|
|
18
|
-
required,
|
|
19
|
-
field: fieldInfo,
|
|
20
|
-
children
|
|
21
|
-
},
|
|
22
|
-
void 0,
|
|
23
|
-
false,
|
|
24
|
-
{
|
|
25
|
-
fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormHasOneRelationScope.tsx",
|
|
26
|
-
lineNumber: 19,
|
|
27
|
-
columnNumber: 3
|
|
28
|
-
},
|
|
29
|
-
void 0
|
|
30
|
-
);
|
|
31
|
-
};
|
|
32
|
-
exports.FormHasOneRelationScope = FormHasOneRelationScope;
|
|
33
|
-
//# sourceMappingURL=FormHasOneRelationScope.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormHasOneRelationScope.cjs","sources":["../../../../../packages/react-form/src/components/FormHasOneRelationScope.tsx"],"sourcesContent":["import * as React from 'react'\nimport { HasOneRelationMarker, SugaredRelativeSingleEntity, useEntity } from '@contember/react-binding'\nimport { FormFieldStateProvider } from './FormFieldStateProvider'\nimport { useMemo } from 'react'\n\nexport type FormHasOneRelationScopeProps = {\n\tfield: SugaredRelativeSingleEntity['field']\n\tchildren: React.ReactNode\n\trequired?: boolean\n}\n\nexport const FormHasOneRelationScope = ({ field, children, required }: FormHasOneRelationScopeProps) => {\n\tconst entityRelation = useEntity({ field })\n\tconst marker = entityRelation.getMarker() as HasOneRelationMarker\n\tconst fieldName = marker.parameters.field\n\tconst entityName = entityRelation.getParent()!.name\n\tconst fieldInfo = useMemo(() => ({ entityName, fieldName }), [entityName, fieldName])\n\treturn (\n\t\t<FormFieldStateProvider\n\t\t\terrors={entityRelation.errors?.errors}\n\t\t\tdirty={entityRelation.hasUnpersistedChanges}\n\t\t\trequired={required}\n\t\t\tfield={fieldInfo}\n\t\t>\n\t\t\t{children}\n\t\t</FormFieldStateProvider>\n\t)\n}\n"],"names":["useEntity","useMemo","jsxDEV","FormFieldStateProvider","this"],"mappings":";;;;;;AAWO,MAAM,0BAA0B,CAAC,EAAE,OAAO,UAAU,eAA6C;AACvG,QAAM,iBAAiBA,aAAAA,UAAU,EAAE,OAAO;AACpC,QAAA,SAAS,eAAe,UAAU;AAClC,QAAA,YAAY,OAAO,WAAW;AAC9B,QAAA,aAAa,eAAe,UAAA,EAAa;AACzC,QAAA,YAAYC,cAAQ,OAAO,EAAE,YAAY,cAAc,CAAC,YAAY,SAAS,CAAC;AAEnF,SAAAC,8BAAA;AAAA,IAACC,uBAAA;AAAA,IAAA;AAAA,MACA,QAAQ,eAAe,QAAQ;AAAA,MAC/B,OAAO,eAAe;AAAA,MACtB;AAAA,MACA,OAAO;AAAA,MAEN;AAAA,IAAA;AAAA,IANF;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAC;AAAAA,EAOA;AAEF;;"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
|
-
import { useEntity } from "@contember/react-binding";
|
|
3
|
-
import { FormFieldStateProvider } from "./FormFieldStateProvider.js";
|
|
4
|
-
import { useMemo } from "react";
|
|
5
|
-
const FormHasOneRelationScope = ({ field, children, required }) => {
|
|
6
|
-
const entityRelation = useEntity({ field });
|
|
7
|
-
const marker = entityRelation.getMarker();
|
|
8
|
-
const fieldName = marker.parameters.field;
|
|
9
|
-
const entityName = entityRelation.getParent().name;
|
|
10
|
-
const fieldInfo = useMemo(() => ({ entityName, fieldName }), [entityName, fieldName]);
|
|
11
|
-
return /* @__PURE__ */ jsxDEV(
|
|
12
|
-
FormFieldStateProvider,
|
|
13
|
-
{
|
|
14
|
-
errors: entityRelation.errors?.errors,
|
|
15
|
-
dirty: entityRelation.hasUnpersistedChanges,
|
|
16
|
-
required,
|
|
17
|
-
field: fieldInfo,
|
|
18
|
-
children
|
|
19
|
-
},
|
|
20
|
-
void 0,
|
|
21
|
-
false,
|
|
22
|
-
{
|
|
23
|
-
fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormHasOneRelationScope.tsx",
|
|
24
|
-
lineNumber: 19,
|
|
25
|
-
columnNumber: 3
|
|
26
|
-
},
|
|
27
|
-
void 0
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
export {
|
|
31
|
-
FormHasOneRelationScope
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=FormHasOneRelationScope.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormHasOneRelationScope.js","sources":["../../../../../packages/react-form/src/components/FormHasOneRelationScope.tsx"],"sourcesContent":["import * as React from 'react'\nimport { HasOneRelationMarker, SugaredRelativeSingleEntity, useEntity } from '@contember/react-binding'\nimport { FormFieldStateProvider } from './FormFieldStateProvider'\nimport { useMemo } from 'react'\n\nexport type FormHasOneRelationScopeProps = {\n\tfield: SugaredRelativeSingleEntity['field']\n\tchildren: React.ReactNode\n\trequired?: boolean\n}\n\nexport const FormHasOneRelationScope = ({ field, children, required }: FormHasOneRelationScopeProps) => {\n\tconst entityRelation = useEntity({ field })\n\tconst marker = entityRelation.getMarker() as HasOneRelationMarker\n\tconst fieldName = marker.parameters.field\n\tconst entityName = entityRelation.getParent()!.name\n\tconst fieldInfo = useMemo(() => ({ entityName, fieldName }), [entityName, fieldName])\n\treturn (\n\t\t<FormFieldStateProvider\n\t\t\terrors={entityRelation.errors?.errors}\n\t\t\tdirty={entityRelation.hasUnpersistedChanges}\n\t\t\trequired={required}\n\t\t\tfield={fieldInfo}\n\t\t>\n\t\t\t{children}\n\t\t</FormFieldStateProvider>\n\t)\n}\n"],"names":["this"],"mappings":";;;;AAWO,MAAM,0BAA0B,CAAC,EAAE,OAAO,UAAU,eAA6C;AACvG,QAAM,iBAAiB,UAAU,EAAE,OAAO;AACpC,QAAA,SAAS,eAAe,UAAU;AAClC,QAAA,YAAY,OAAO,WAAW;AAC9B,QAAA,aAAa,eAAe,UAAA,EAAa;AACzC,QAAA,YAAY,QAAQ,OAAO,EAAE,YAAY,cAAc,CAAC,YAAY,SAAS,CAAC;AAEnF,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,QAAQ,eAAe,QAAQ;AAAA,MAC/B,OAAO,eAAe;AAAA,MACtB;AAAA,MACA,OAAO;AAAA,MAEN;AAAA,IAAA;AAAA,IANF;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAA;AAAAA,EAOA;AAEF;"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
|
-
const React = require("react");
|
|
5
|
-
const reactSlot = require("@radix-ui/react-slot");
|
|
6
|
-
const reactBinding = require("@contember/react-binding");
|
|
7
|
-
const utilities = require("@contember/utilities");
|
|
8
|
-
const useFormInputHandler = require("../internal/useFormInputHandler.cjs");
|
|
9
|
-
const contexts = require("../contexts.cjs");
|
|
10
|
-
const useFormInputValidationHandler = require("../hooks/useFormInputValidationHandler.cjs");
|
|
11
|
-
const reactUtils = require("@contember/react-utils");
|
|
12
|
-
const SlotInput = reactSlot.Slot;
|
|
13
|
-
const FormInput = reactBinding.Component(({ field, isNonbearing, defaultValue, formatValue: formatValueIn, parseValue: parseValueIn, ...props }) => {
|
|
14
|
-
const accessor = reactBinding.useField(field);
|
|
15
|
-
const formState = contexts.useFormFieldState();
|
|
16
|
-
const id = formState?.htmlId;
|
|
17
|
-
const hasErrors = (formState?.errors.length ?? accessor.errors?.errors?.length ?? 0) > 0;
|
|
18
|
-
const dirty = formState?.dirty ?? accessor.hasUnpersistedChanges;
|
|
19
|
-
const required = formState?.required ?? !accessor.schema.nullable;
|
|
20
|
-
const [state, setState] = React.useState(void 0);
|
|
21
|
-
const { parseValue, formatValue, defaultInputProps } = useFormInputHandler.useFormInputHandler(accessor, { formatValue: formatValueIn, parseValue: parseValueIn });
|
|
22
|
-
const accessorGetter = accessor.getAccessor;
|
|
23
|
-
const { ref, onFocus, onBlur } = useFormInputValidationHandler.useFormInputValidationHandler(accessor);
|
|
24
|
-
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(
|
|
25
|
-
SlotInput,
|
|
26
|
-
{
|
|
27
|
-
ref,
|
|
28
|
-
value: formatValue(accessor.value, { state, setState }),
|
|
29
|
-
"data-invalid": utilities.dataAttribute(hasErrors),
|
|
30
|
-
"data-dirty": utilities.dataAttribute(dirty),
|
|
31
|
-
"data-required": utilities.dataAttribute(required),
|
|
32
|
-
onFocus,
|
|
33
|
-
onBlur,
|
|
34
|
-
onChange: reactUtils.useReferentiallyStableCallback((e) => {
|
|
35
|
-
accessorGetter().updateValue(parseValue(e.target.value, { state, setState }));
|
|
36
|
-
}),
|
|
37
|
-
...defaultInputProps,
|
|
38
|
-
id: id ? `${id}-input` : void 0,
|
|
39
|
-
required,
|
|
40
|
-
...props
|
|
41
|
-
},
|
|
42
|
-
void 0,
|
|
43
|
-
false,
|
|
44
|
-
{
|
|
45
|
-
fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormInput.tsx",
|
|
46
|
-
lineNumber: 40,
|
|
47
|
-
columnNumber: 3
|
|
48
|
-
},
|
|
49
|
-
void 0
|
|
50
|
-
);
|
|
51
|
-
}, ({ field, isNonbearing, defaultValue }) => {
|
|
52
|
-
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.Field, { field, isNonbearing, defaultValue }, void 0, false, {
|
|
53
|
-
fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormInput.tsx",
|
|
54
|
-
lineNumber: 58,
|
|
55
|
-
columnNumber: 9
|
|
56
|
-
}, void 0);
|
|
57
|
-
});
|
|
58
|
-
exports.FormInput = FormInput;
|
|
59
|
-
//# sourceMappingURL=FormInput.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormInput.cjs","sources":["../../../../../packages/react-form/src/components/FormInput.tsx"],"sourcesContent":["import * as React from 'react'\nimport { ChangeEventHandler, ComponentType, useCallback, useState } from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { Component, Field, OptionallyVariableFieldValue, SugaredRelativeSingleField, useField } from '@contember/react-binding'\nimport { dataAttribute } from '@contember/utilities'\nimport { useFormInputHandler } from '../internal/useFormInputHandler'\nimport { useFormFieldState } from '../contexts'\nimport { useFormInputValidationHandler } from '../hooks/useFormInputValidationHandler'\nimport { FormInputHandler } from '../types'\nimport { useReferentiallyStableCallback } from '@contember/react-utils'\n\ntype InputProps = React.JSX.IntrinsicElements['input']\nconst SlotInput = Slot as ComponentType<InputProps>\n\nexport interface FormInputProps {\n\tfield: SugaredRelativeSingleField['field']\n\tisNonbearing?: boolean\n\tdefaultValue?: OptionallyVariableFieldValue\n\tchildren: React.ReactElement\n\tformatValue?: FormInputHandler['formatValue']\n\tparseValue?: FormInputHandler['parseValue']\n}\n\nexport const FormInput = Component<FormInputProps>(({ field, isNonbearing, defaultValue, formatValue: formatValueIn, parseValue: parseValueIn, ...props }) => {\n\tconst accessor = useField(field)\n\n\tconst formState = useFormFieldState()\n\tconst id = formState?.htmlId\n\tconst hasErrors = (formState?.errors.length ?? accessor.errors?.errors?.length ?? 0) > 0\n\tconst dirty = formState?.dirty ?? accessor.hasUnpersistedChanges\n\tconst required = formState?.required ?? !accessor.schema.nullable\n\n\tconst [state, setState] = useState<any>(undefined)\n\n\tconst { parseValue, formatValue, defaultInputProps } = useFormInputHandler(accessor, { formatValue: formatValueIn, parseValue: parseValueIn })\n\tconst accessorGetter = accessor.getAccessor\n\tconst { ref, onFocus, onBlur } = useFormInputValidationHandler(accessor)\n\n\treturn (\n\t\t<SlotInput\n\t\t\tref={ref}\n\t\t\tvalue={formatValue(accessor.value, { state, setState })}\n\t\t\tdata-invalid={dataAttribute(hasErrors)}\n\t\t\tdata-dirty={dataAttribute(dirty)}\n\t\t\tdata-required={dataAttribute(required)}\n\t\t\tonFocus={onFocus}\n\t\t\tonBlur={onBlur}\n\t\t\tonChange={useReferentiallyStableCallback<ChangeEventHandler<HTMLInputElement>>(e => {\n\t\t\t\taccessorGetter().updateValue(parseValue(e.target.value, { state, setState }))\n\t\t\t})}\n\t\t\t{...defaultInputProps}\n\t\t\tid={id ? `${id}-input` : undefined}\n\t\t\trequired={required}\n\t\t\t{...props}\n\t\t/>\n\t)\n}, ({ field, isNonbearing, defaultValue }) => {\n\treturn <Field field={field} isNonbearing={isNonbearing} defaultValue={defaultValue} />\n})\n"],"names":["Slot","Component","useField","useFormFieldState","useState","useFormInputHandler","useFormInputValidationHandler","jsxDEV","dataAttribute","useReferentiallyStableCallback","this","Field"],"mappings":";;;;;;;;;;;AAYA,MAAM,YAAYA,UAAA;AAWX,MAAM,YAAYC,aAAA,UAA0B,CAAC,EAAE,OAAO,cAAc,cAAc,aAAa,eAAe,YAAY,cAAc,GAAG,YAAY;AACvJ,QAAA,WAAWC,sBAAS,KAAK;AAE/B,QAAM,YAAYC,SAAAA,kBAAkB;AACpC,QAAM,KAAK,WAAW;AAChB,QAAA,aAAa,WAAW,OAAO,UAAU,SAAS,QAAQ,QAAQ,UAAU,KAAK;AACjF,QAAA,QAAQ,WAAW,SAAS,SAAS;AAC3C,QAAM,WAAW,WAAW,YAAY,CAAC,SAAS,OAAO;AAEzD,QAAM,CAAC,OAAO,QAAQ,IAAIC,eAAc,MAAS;AAEjD,QAAM,EAAE,YAAY,aAAa,kBAAsB,IAAAC,oBAAA,oBAAoB,UAAU,EAAE,aAAa,eAAe,YAAY,aAAA,CAAc;AAC7I,QAAM,iBAAiB,SAAS;AAChC,QAAM,EAAE,KAAK,SAAS,OAAO,IAAIC,8BAAAA,8BAA8B,QAAQ;AAGtE,SAAAC,8BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,OAAO,YAAY,SAAS,OAAO,EAAE,OAAO,UAAU;AAAA,MACtD,gBAAcC,wBAAc,SAAS;AAAA,MACrC,cAAYA,wBAAc,KAAK;AAAA,MAC/B,iBAAeA,wBAAc,QAAQ;AAAA,MACrC;AAAA,MACA;AAAA,MACA,UAAUC,WAAAA,+BAAqE,CAAK,MAAA;AACpE,uBAAA,EAAE,YAAY,WAAW,EAAE,OAAO,OAAO,EAAE,OAAO,SAAS,CAAC,CAAC;AAAA,MAAA,CAC5E;AAAA,MACA,GAAG;AAAA,MACJ,IAAI,KAAK,GAAG,EAAE,WAAW;AAAA,MACzB;AAAA,MACC,GAAG;AAAA,IAAA;AAAA,IAdL;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAC;AAAAA,EAeA;AAEF,GAAG,CAAC,EAAE,OAAO,cAAc,mBAAmB;AAC7C,SAAQH,8BAAA,OAAAI,aAAA,OAAA,EAAM,OAAc,cAA4B,aAAjD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAA6E,GAAAD,MAAA;AACrF,CAAC;;"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
4
|
-
import { Component, useField, Field } from "@contember/react-binding";
|
|
5
|
-
import { dataAttribute } from "@contember/utilities";
|
|
6
|
-
import { useFormInputHandler } from "../internal/useFormInputHandler.js";
|
|
7
|
-
import { useFormFieldState } from "../contexts.js";
|
|
8
|
-
import { useFormInputValidationHandler } from "../hooks/useFormInputValidationHandler.js";
|
|
9
|
-
import { useReferentiallyStableCallback } from "@contember/react-utils";
|
|
10
|
-
const SlotInput = Slot;
|
|
11
|
-
const FormInput = Component(({ field, isNonbearing, defaultValue, formatValue: formatValueIn, parseValue: parseValueIn, ...props }) => {
|
|
12
|
-
const accessor = useField(field);
|
|
13
|
-
const formState = useFormFieldState();
|
|
14
|
-
const id = formState?.htmlId;
|
|
15
|
-
const hasErrors = (formState?.errors.length ?? accessor.errors?.errors?.length ?? 0) > 0;
|
|
16
|
-
const dirty = formState?.dirty ?? accessor.hasUnpersistedChanges;
|
|
17
|
-
const required = formState?.required ?? !accessor.schema.nullable;
|
|
18
|
-
const [state, setState] = useState(void 0);
|
|
19
|
-
const { parseValue, formatValue, defaultInputProps } = useFormInputHandler(accessor, { formatValue: formatValueIn, parseValue: parseValueIn });
|
|
20
|
-
const accessorGetter = accessor.getAccessor;
|
|
21
|
-
const { ref, onFocus, onBlur } = useFormInputValidationHandler(accessor);
|
|
22
|
-
return /* @__PURE__ */ jsxDEV(
|
|
23
|
-
SlotInput,
|
|
24
|
-
{
|
|
25
|
-
ref,
|
|
26
|
-
value: formatValue(accessor.value, { state, setState }),
|
|
27
|
-
"data-invalid": dataAttribute(hasErrors),
|
|
28
|
-
"data-dirty": dataAttribute(dirty),
|
|
29
|
-
"data-required": dataAttribute(required),
|
|
30
|
-
onFocus,
|
|
31
|
-
onBlur,
|
|
32
|
-
onChange: useReferentiallyStableCallback((e) => {
|
|
33
|
-
accessorGetter().updateValue(parseValue(e.target.value, { state, setState }));
|
|
34
|
-
}),
|
|
35
|
-
...defaultInputProps,
|
|
36
|
-
id: id ? `${id}-input` : void 0,
|
|
37
|
-
required,
|
|
38
|
-
...props
|
|
39
|
-
},
|
|
40
|
-
void 0,
|
|
41
|
-
false,
|
|
42
|
-
{
|
|
43
|
-
fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormInput.tsx",
|
|
44
|
-
lineNumber: 40,
|
|
45
|
-
columnNumber: 3
|
|
46
|
-
},
|
|
47
|
-
void 0
|
|
48
|
-
);
|
|
49
|
-
}, ({ field, isNonbearing, defaultValue }) => {
|
|
50
|
-
return /* @__PURE__ */ jsxDEV(Field, { field, isNonbearing, defaultValue }, void 0, false, {
|
|
51
|
-
fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormInput.tsx",
|
|
52
|
-
lineNumber: 58,
|
|
53
|
-
columnNumber: 9
|
|
54
|
-
}, void 0);
|
|
55
|
-
});
|
|
56
|
-
export {
|
|
57
|
-
FormInput
|
|
58
|
-
};
|
|
59
|
-
//# sourceMappingURL=FormInput.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormInput.js","sources":["../../../../../packages/react-form/src/components/FormInput.tsx"],"sourcesContent":["import * as React from 'react'\nimport { ChangeEventHandler, ComponentType, useCallback, useState } from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { Component, Field, OptionallyVariableFieldValue, SugaredRelativeSingleField, useField } from '@contember/react-binding'\nimport { dataAttribute } from '@contember/utilities'\nimport { useFormInputHandler } from '../internal/useFormInputHandler'\nimport { useFormFieldState } from '../contexts'\nimport { useFormInputValidationHandler } from '../hooks/useFormInputValidationHandler'\nimport { FormInputHandler } from '../types'\nimport { useReferentiallyStableCallback } from '@contember/react-utils'\n\ntype InputProps = React.JSX.IntrinsicElements['input']\nconst SlotInput = Slot as ComponentType<InputProps>\n\nexport interface FormInputProps {\n\tfield: SugaredRelativeSingleField['field']\n\tisNonbearing?: boolean\n\tdefaultValue?: OptionallyVariableFieldValue\n\tchildren: React.ReactElement\n\tformatValue?: FormInputHandler['formatValue']\n\tparseValue?: FormInputHandler['parseValue']\n}\n\nexport const FormInput = Component<FormInputProps>(({ field, isNonbearing, defaultValue, formatValue: formatValueIn, parseValue: parseValueIn, ...props }) => {\n\tconst accessor = useField(field)\n\n\tconst formState = useFormFieldState()\n\tconst id = formState?.htmlId\n\tconst hasErrors = (formState?.errors.length ?? accessor.errors?.errors?.length ?? 0) > 0\n\tconst dirty = formState?.dirty ?? accessor.hasUnpersistedChanges\n\tconst required = formState?.required ?? !accessor.schema.nullable\n\n\tconst [state, setState] = useState<any>(undefined)\n\n\tconst { parseValue, formatValue, defaultInputProps } = useFormInputHandler(accessor, { formatValue: formatValueIn, parseValue: parseValueIn })\n\tconst accessorGetter = accessor.getAccessor\n\tconst { ref, onFocus, onBlur } = useFormInputValidationHandler(accessor)\n\n\treturn (\n\t\t<SlotInput\n\t\t\tref={ref}\n\t\t\tvalue={formatValue(accessor.value, { state, setState })}\n\t\t\tdata-invalid={dataAttribute(hasErrors)}\n\t\t\tdata-dirty={dataAttribute(dirty)}\n\t\t\tdata-required={dataAttribute(required)}\n\t\t\tonFocus={onFocus}\n\t\t\tonBlur={onBlur}\n\t\t\tonChange={useReferentiallyStableCallback<ChangeEventHandler<HTMLInputElement>>(e => {\n\t\t\t\taccessorGetter().updateValue(parseValue(e.target.value, { state, setState }))\n\t\t\t})}\n\t\t\t{...defaultInputProps}\n\t\t\tid={id ? `${id}-input` : undefined}\n\t\t\trequired={required}\n\t\t\t{...props}\n\t\t/>\n\t)\n}, ({ field, isNonbearing, defaultValue }) => {\n\treturn <Field field={field} isNonbearing={isNonbearing} defaultValue={defaultValue} />\n})\n"],"names":["this"],"mappings":";;;;;;;;;AAYA,MAAM,YAAY;AAWX,MAAM,YAAY,UAA0B,CAAC,EAAE,OAAO,cAAc,cAAc,aAAa,eAAe,YAAY,cAAc,GAAG,YAAY;AACvJ,QAAA,WAAW,SAAS,KAAK;AAE/B,QAAM,YAAY,kBAAkB;AACpC,QAAM,KAAK,WAAW;AAChB,QAAA,aAAa,WAAW,OAAO,UAAU,SAAS,QAAQ,QAAQ,UAAU,KAAK;AACjF,QAAA,QAAQ,WAAW,SAAS,SAAS;AAC3C,QAAM,WAAW,WAAW,YAAY,CAAC,SAAS,OAAO;AAEzD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAc,MAAS;AAEjD,QAAM,EAAE,YAAY,aAAa,kBAAsB,IAAA,oBAAoB,UAAU,EAAE,aAAa,eAAe,YAAY,aAAA,CAAc;AAC7I,QAAM,iBAAiB,SAAS;AAChC,QAAM,EAAE,KAAK,SAAS,OAAO,IAAI,8BAA8B,QAAQ;AAGtE,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,OAAO,YAAY,SAAS,OAAO,EAAE,OAAO,UAAU;AAAA,MACtD,gBAAc,cAAc,SAAS;AAAA,MACrC,cAAY,cAAc,KAAK;AAAA,MAC/B,iBAAe,cAAc,QAAQ;AAAA,MACrC;AAAA,MACA;AAAA,MACA,UAAU,+BAAqE,CAAK,MAAA;AACpE,uBAAA,EAAE,YAAY,WAAW,EAAE,OAAO,OAAO,EAAE,OAAO,SAAS,CAAC,CAAC;AAAA,MAAA,CAC5E;AAAA,MACA,GAAG;AAAA,MACJ,IAAI,KAAK,GAAG,EAAE,WAAW;AAAA,MACzB;AAAA,MACC,GAAG;AAAA,IAAA;AAAA,IAdL;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAA;AAAAA,EAeA;AAEF,GAAG,CAAC,EAAE,OAAO,cAAc,mBAAmB;AAC7C,SAAQ,uBAAA,OAAA,EAAM,OAAc,cAA4B,aAAjD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAA6E,GAAAA,MAAA;AACrF,CAAC;"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
|
-
const reactSlot = require("@radix-ui/react-slot");
|
|
5
|
-
const utilities = require("@contember/utilities");
|
|
6
|
-
const contexts = require("../contexts.cjs");
|
|
7
|
-
const reactBinding = require("@contember/react-binding");
|
|
8
|
-
const FormLabel = (props) => {
|
|
9
|
-
const formState = contexts.useFormFieldState();
|
|
10
|
-
if (!formState) {
|
|
11
|
-
throw new reactBinding.BindingError("FormError must be used inside a FormField");
|
|
12
|
-
}
|
|
13
|
-
const { errors, htmlId, dirty, required } = formState;
|
|
14
|
-
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(
|
|
15
|
-
reactSlot.Slot,
|
|
16
|
-
{
|
|
17
|
-
"data-invalid": utilities.dataAttribute(errors.length > 0),
|
|
18
|
-
"data-dirty": utilities.dataAttribute(dirty),
|
|
19
|
-
"data-required": utilities.dataAttribute(required),
|
|
20
|
-
...htmlId ? { htmlFor: `${htmlId}-input` } : {},
|
|
21
|
-
...props
|
|
22
|
-
},
|
|
23
|
-
void 0,
|
|
24
|
-
false,
|
|
25
|
-
{
|
|
26
|
-
fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormLabel.tsx",
|
|
27
|
-
lineNumber: 16,
|
|
28
|
-
columnNumber: 3
|
|
29
|
-
},
|
|
30
|
-
void 0
|
|
31
|
-
);
|
|
32
|
-
};
|
|
33
|
-
exports.FormLabel = FormLabel;
|
|
34
|
-
//# sourceMappingURL=FormLabel.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormLabel.cjs","sources":["../../../../../packages/react-form/src/components/FormLabel.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { dataAttribute } from '@contember/utilities'\nimport { useFormFieldState } from '../contexts'\nimport { BindingError } from '@contember/react-binding'\n\nexport const FormLabel = (props: {\n\tchildren: React.ReactElement\n}) => {\n\tconst formState = useFormFieldState()\n\tif (!formState) {\n\t\tthrow new BindingError('FormError must be used inside a FormField')\n\t}\n\tconst { errors, htmlId, dirty, required } = formState\n\treturn (\n\t\t<Slot\n\t\t\tdata-invalid={dataAttribute(errors.length > 0)}\n\t\t\tdata-dirty={dataAttribute(dirty)}\n\t\t\tdata-required={dataAttribute(required)}\n\t\t\t{...(htmlId ? { htmlFor: `${htmlId}-input` } : {})}\n\t\t\t{...props}\n\t\t/>\n\t)\n}\n"],"names":["useFormFieldState","BindingError","jsxDEV","Slot","dataAttribute","this"],"mappings":";;;;;;;AAMa,MAAA,YAAY,CAAC,UAEpB;AACL,QAAM,YAAYA,SAAAA,kBAAkB;AACpC,MAAI,CAAC,WAAW;AACT,UAAA,IAAIC,0BAAa,2CAA2C;AAAA,EAAA;AAEnE,QAAM,EAAE,QAAQ,QAAQ,OAAO,SAAa,IAAA;AAE3C,SAAAC,8BAAA;AAAA,IAACC,UAAA;AAAA,IAAA;AAAA,MACA,gBAAcC,UAAA,cAAc,OAAO,SAAS,CAAC;AAAA,MAC7C,cAAYA,wBAAc,KAAK;AAAA,MAC/B,iBAAeA,wBAAc,QAAQ;AAAA,MACpC,GAAI,SAAS,EAAE,SAAS,GAAG,MAAM,SAAA,IAAa,CAAC;AAAA,MAC/C,GAAG;AAAA,IAAA;AAAA,IALL;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAC;AAAAA,EAMA;AAEF;;"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
-
import { dataAttribute } from "@contember/utilities";
|
|
4
|
-
import { useFormFieldState } from "../contexts.js";
|
|
5
|
-
import { BindingError } from "@contember/react-binding";
|
|
6
|
-
const FormLabel = (props) => {
|
|
7
|
-
const formState = useFormFieldState();
|
|
8
|
-
if (!formState) {
|
|
9
|
-
throw new BindingError("FormError must be used inside a FormField");
|
|
10
|
-
}
|
|
11
|
-
const { errors, htmlId, dirty, required } = formState;
|
|
12
|
-
return /* @__PURE__ */ jsxDEV(
|
|
13
|
-
Slot,
|
|
14
|
-
{
|
|
15
|
-
"data-invalid": dataAttribute(errors.length > 0),
|
|
16
|
-
"data-dirty": dataAttribute(dirty),
|
|
17
|
-
"data-required": dataAttribute(required),
|
|
18
|
-
...htmlId ? { htmlFor: `${htmlId}-input` } : {},
|
|
19
|
-
...props
|
|
20
|
-
},
|
|
21
|
-
void 0,
|
|
22
|
-
false,
|
|
23
|
-
{
|
|
24
|
-
fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormLabel.tsx",
|
|
25
|
-
lineNumber: 16,
|
|
26
|
-
columnNumber: 3
|
|
27
|
-
},
|
|
28
|
-
void 0
|
|
29
|
-
);
|
|
30
|
-
};
|
|
31
|
-
export {
|
|
32
|
-
FormLabel
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=FormLabel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormLabel.js","sources":["../../../../../packages/react-form/src/components/FormLabel.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { dataAttribute } from '@contember/utilities'\nimport { useFormFieldState } from '../contexts'\nimport { BindingError } from '@contember/react-binding'\n\nexport const FormLabel = (props: {\n\tchildren: React.ReactElement\n}) => {\n\tconst formState = useFormFieldState()\n\tif (!formState) {\n\t\tthrow new BindingError('FormError must be used inside a FormField')\n\t}\n\tconst { errors, htmlId, dirty, required } = formState\n\treturn (\n\t\t<Slot\n\t\t\tdata-invalid={dataAttribute(errors.length > 0)}\n\t\t\tdata-dirty={dataAttribute(dirty)}\n\t\t\tdata-required={dataAttribute(required)}\n\t\t\t{...(htmlId ? { htmlFor: `${htmlId}-input` } : {})}\n\t\t\t{...props}\n\t\t/>\n\t)\n}\n"],"names":["this"],"mappings":";;;;;AAMa,MAAA,YAAY,CAAC,UAEpB;AACL,QAAM,YAAY,kBAAkB;AACpC,MAAI,CAAC,WAAW;AACT,UAAA,IAAI,aAAa,2CAA2C;AAAA,EAAA;AAEnE,QAAM,EAAE,QAAQ,QAAQ,OAAO,SAAa,IAAA;AAE3C,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,gBAAc,cAAc,OAAO,SAAS,CAAC;AAAA,MAC7C,cAAY,cAAc,KAAK;AAAA,MAC/B,iBAAe,cAAc,QAAQ;AAAA,MACpC,GAAI,SAAS,EAAE,SAAS,GAAG,MAAM,SAAA,IAAa,CAAC;AAAA,MAC/C,GAAG;AAAA,IAAA;AAAA,IALL;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAA;AAAAA,EAMA;AAEF;"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
|
-
const reactBinding = require("@contember/react-binding");
|
|
5
|
-
const utilities = require("@contember/utilities");
|
|
6
|
-
const reactSlot = require("@radix-ui/react-slot");
|
|
7
|
-
const React = require("react");
|
|
8
|
-
const contexts = require("../contexts.cjs");
|
|
9
|
-
const useFormInputValidationHandler = require("../hooks/useFormInputValidationHandler.cjs");
|
|
10
|
-
const SlotInput = reactSlot.Slot;
|
|
11
|
-
const FormRadioInput = reactBinding.Component(({ field, value, defaultValue, isNonbearing, ...props }) => {
|
|
12
|
-
const accessor = reactBinding.useField(field);
|
|
13
|
-
const formState = contexts.useFormFieldState();
|
|
14
|
-
const id = formState?.htmlId;
|
|
15
|
-
const hasErrors = (formState?.errors.length ?? accessor.errors?.errors?.length ?? 0) > 0;
|
|
16
|
-
const dirty = formState?.dirty ?? accessor.hasUnpersistedChanges;
|
|
17
|
-
const accessorGetter = accessor.getAccessor;
|
|
18
|
-
const { ref, onFocus, onBlur } = useFormInputValidationHandler.useFormInputValidationHandler(accessor);
|
|
19
|
-
const handleChange = React.useCallback((e) => {
|
|
20
|
-
accessorGetter().updateValue(value);
|
|
21
|
-
}, [accessorGetter, value]);
|
|
22
|
-
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(
|
|
23
|
-
SlotInput,
|
|
24
|
-
{
|
|
25
|
-
ref,
|
|
26
|
-
type: "radio",
|
|
27
|
-
value: typeof value === "string" ? value : void 0,
|
|
28
|
-
checked: accessor.value === value,
|
|
29
|
-
"data-invalid": utilities.dataAttribute(hasErrors),
|
|
30
|
-
"data-dirty": utilities.dataAttribute(dirty),
|
|
31
|
-
name: id ? id + "-input" : void 0,
|
|
32
|
-
id: id ? `${id}-input` : void 0,
|
|
33
|
-
onFocus,
|
|
34
|
-
onBlur,
|
|
35
|
-
onChange: handleChange,
|
|
36
|
-
...props
|
|
37
|
-
},
|
|
38
|
-
void 0,
|
|
39
|
-
false,
|
|
40
|
-
{
|
|
41
|
-
fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormRadioInput.tsx",
|
|
42
|
-
lineNumber: 35,
|
|
43
|
-
columnNumber: 3
|
|
44
|
-
},
|
|
45
|
-
void 0
|
|
46
|
-
);
|
|
47
|
-
}, ({ field, isNonbearing, defaultValue }) => {
|
|
48
|
-
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.Field, { field, isNonbearing, defaultValue }, void 0, false, {
|
|
49
|
-
fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormRadioInput.tsx",
|
|
50
|
-
lineNumber: 51,
|
|
51
|
-
columnNumber: 9
|
|
52
|
-
}, void 0);
|
|
53
|
-
});
|
|
54
|
-
exports.FormRadioInput = FormRadioInput;
|
|
55
|
-
//# sourceMappingURL=FormRadioInput.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormRadioInput.cjs","sources":["../../../../../packages/react-form/src/components/FormRadioInput.tsx"],"sourcesContent":["import { Component, Field, OptionallyVariableFieldValue, SugaredRelativeSingleField, useField } from '@contember/react-binding'\nimport { dataAttribute } from '@contember/utilities'\nimport { Slot } from '@radix-ui/react-slot'\nimport * as React from 'react'\nimport { ChangeEventHandler, useCallback } from 'react'\nimport { useFormFieldState } from '../contexts'\nimport { useFormInputValidationHandler } from '../hooks'\n\nconst SlotInput = Slot as React.ForwardRefExoticComponent<React.RefAttributes<HTMLInputElement> & React.InputHTMLAttributes<HTMLInputElement>>\n\nexport interface FormRadioItemProps {\n\tfield: SugaredRelativeSingleField['field']\n\tvalue: string | null | number | boolean\n\tisNonbearing?: boolean\n\tdefaultValue?: OptionallyVariableFieldValue\n\tchildren: React.ReactNode\n}\n\nexport const FormRadioInput = Component<FormRadioItemProps>(({ field, value, defaultValue, isNonbearing, ...props }) => {\n\tconst accessor = useField(field)\n\n\tconst formState = useFormFieldState()\n\tconst id = formState?.htmlId\n\tconst hasErrors = (formState?.errors.length ?? accessor.errors?.errors?.length ?? 0) > 0\n\tconst dirty = formState?.dirty ?? accessor.hasUnpersistedChanges\n\n\tconst accessorGetter = accessor.getAccessor\n\tconst { ref, onFocus, onBlur } = useFormInputValidationHandler(accessor)\n\n\tconst handleChange = useCallback<ChangeEventHandler<HTMLInputElement>>(e => {\n\t\taccessorGetter().updateValue(value)\n\t}, [accessorGetter, value])\n\n\treturn (\n\t\t<SlotInput\n\t\t\tref={ref}\n\t\t\ttype=\"radio\"\n\t\t\tvalue={typeof value === 'string' ? value : undefined}\n\t\t\tchecked={accessor.value === value}\n\t\t\tdata-invalid={dataAttribute(hasErrors)}\n\t\t\tdata-dirty={dataAttribute(dirty)}\n\t\t\tname={id ? id + '-input' : undefined}\n\t\t\tid={id ? `${id}-input` : undefined}\n\t\t\tonFocus={onFocus}\n\t\t\tonBlur={onBlur}\n\t\t\tonChange={handleChange}\n\t\t\t{...props}\n\t\t/>\n\t)\n}, ({ field, isNonbearing, defaultValue }) => {\n\treturn <Field field={field} isNonbearing={isNonbearing} defaultValue={defaultValue}/>\n})\n"],"names":["Slot","Component","useField","useFormFieldState","useFormInputValidationHandler","useCallback","jsxDEV","dataAttribute","this","Field"],"mappings":";;;;;;;;;AAQA,MAAM,YAAYA,UAAA;AAUL,MAAA,iBAAiBC,aAAAA,UAA8B,CAAC,EAAE,OAAO,OAAO,cAAc,cAAc,GAAG,YAAY;AACjH,QAAA,WAAWC,sBAAS,KAAK;AAE/B,QAAM,YAAYC,SAAAA,kBAAkB;AACpC,QAAM,KAAK,WAAW;AAChB,QAAA,aAAa,WAAW,OAAO,UAAU,SAAS,QAAQ,QAAQ,UAAU,KAAK;AACjF,QAAA,QAAQ,WAAW,SAAS,SAAS;AAE3C,QAAM,iBAAiB,SAAS;AAChC,QAAM,EAAE,KAAK,SAAS,OAAO,IAAIC,8BAAAA,8BAA8B,QAAQ;AAEjE,QAAA,eAAeC,kBAAkD,CAAK,MAAA;AAC5D,mBAAA,EAAE,YAAY,KAAK;AAAA,EAAA,GAChC,CAAC,gBAAgB,KAAK,CAAC;AAGzB,SAAAC,8BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,MAAK;AAAA,MACL,OAAO,OAAO,UAAU,WAAW,QAAQ;AAAA,MAC3C,SAAS,SAAS,UAAU;AAAA,MAC5B,gBAAcC,wBAAc,SAAS;AAAA,MACrC,cAAYA,wBAAc,KAAK;AAAA,MAC/B,MAAM,KAAK,KAAK,WAAW;AAAA,MAC3B,IAAI,KAAK,GAAG,EAAE,WAAW;AAAA,MACzB;AAAA,MACA;AAAA,MACA,UAAU;AAAA,MACT,GAAG;AAAA,IAAA;AAAA,IAZL;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAC;AAAAA,EAaA;AAEF,GAAG,CAAC,EAAE,OAAO,cAAc,mBAAmB;AAC7C,SAAQF,8BAAA,OAAAG,aAAA,OAAA,EAAM,OAAc,cAA4B,aAAjD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAA4E,GAAAD,MAAA;AACpF,CAAC;;"}
|