@wordpress/dataviews 7.0.1-next.0f6f9d12c.0 → 7.0.1-next.f34ab90e9.0
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/CHANGELOG.md +4 -1
- package/build/components/dataviews-item-actions/index.js +1 -10
- package/build/components/dataviews-item-actions/index.js.map +1 -1
- package/build/dataform-controls/boolean.js +15 -7
- package/build/dataform-controls/boolean.js.map +1 -1
- package/build/dataform-controls/email.js +14 -7
- package/build/dataform-controls/email.js.map +1 -1
- package/build/dataform-controls/integer.js +14 -7
- package/build/dataform-controls/integer.js.map +1 -1
- package/build/dataform-controls/text.js +14 -7
- package/build/dataform-controls/text.js.map +1 -1
- package/build/dataforms-layouts/panel/dropdown.js +124 -0
- package/build/dataforms-layouts/panel/dropdown.js.map +1 -0
- package/build/dataforms-layouts/panel/index.js +19 -127
- package/build/dataforms-layouts/panel/index.js.map +1 -1
- package/build/dataforms-layouts/panel/modal.js +125 -0
- package/build/dataforms-layouts/panel/modal.js.map +1 -0
- package/build/normalize-form-fields.js +3 -2
- package/build/normalize-form-fields.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build-module/components/dataviews-item-actions/index.js +1 -10
- package/build-module/components/dataviews-item-actions/index.js.map +1 -1
- package/build-module/dataform-controls/boolean.js +15 -7
- package/build-module/dataform-controls/boolean.js.map +1 -1
- package/build-module/dataform-controls/email.js +15 -8
- package/build-module/dataform-controls/email.js.map +1 -1
- package/build-module/dataform-controls/integer.js +15 -8
- package/build-module/dataform-controls/integer.js.map +1 -1
- package/build-module/dataform-controls/text.js +15 -8
- package/build-module/dataform-controls/text.js.map +1 -1
- package/build-module/dataforms-layouts/panel/dropdown.js +118 -0
- package/build-module/dataforms-layouts/panel/dropdown.js.map +1 -0
- package/build-module/dataforms-layouts/panel/index.js +23 -131
- package/build-module/dataforms-layouts/panel/index.js.map +1 -1
- package/build-module/dataforms-layouts/panel/modal.js +119 -0
- package/build-module/dataforms-layouts/panel/modal.js.map +1 -0
- package/build-module/normalize-form-fields.js +3 -2
- package/build-module/normalize-form-fields.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-style/style-rtl.css +4 -0
- package/build-style/style.css +4 -0
- package/build-types/components/dataform/stories/index.story.d.ts +58 -25
- package/build-types/components/dataform/stories/index.story.d.ts.map +1 -1
- package/build-types/components/dataviews-item-actions/index.d.ts.map +1 -1
- package/build-types/dataform-controls/boolean.d.ts.map +1 -1
- package/build-types/dataform-controls/email.d.ts.map +1 -1
- package/build-types/dataform-controls/integer.d.ts.map +1 -1
- package/build-types/dataform-controls/text.d.ts.map +1 -1
- package/build-types/dataforms-layouts/panel/dropdown.d.ts +14 -0
- package/build-types/dataforms-layouts/panel/dropdown.d.ts.map +1 -0
- package/build-types/dataforms-layouts/panel/index.d.ts.map +1 -1
- package/build-types/dataforms-layouts/panel/modal.d.ts +13 -0
- package/build-types/dataforms-layouts/panel/modal.d.ts.map +1 -0
- package/build-types/normalize-form-fields.d.ts.map +1 -1
- package/build-types/types.d.ts +2 -0
- package/build-types/types.d.ts.map +1 -1
- package/build-wp/index.js +394 -178
- package/package.json +15 -15
- package/src/components/dataform/stories/index.story.tsx +354 -219
- package/src/components/dataviews-item-actions/index.tsx +7 -16
- package/src/dataform-controls/boolean.tsx +24 -10
- package/src/dataform-controls/email.tsx +24 -11
- package/src/dataform-controls/integer.tsx +27 -13
- package/src/dataform-controls/text.tsx +24 -11
- package/src/dataforms-layouts/panel/dropdown.tsx +160 -0
- package/src/dataforms-layouts/panel/index.tsx +28 -172
- package/src/dataforms-layouts/panel/modal.tsx +165 -0
- package/src/dataforms-layouts/panel/style.scss +4 -0
- package/src/normalize-form-fields.ts +1 -0
- package/src/test/dataform.tsx +169 -0
- package/src/test/normalize-form-fields.ts +15 -3
- package/src/types.ts +2 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { privateApis } from '@wordpress/components';
|
|
5
|
+
import { useState } from '@wordpress/element';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
@@ -23,17 +24,24 @@ export default function Boolean({
|
|
|
23
24
|
getValue,
|
|
24
25
|
label
|
|
25
26
|
} = field;
|
|
27
|
+
const [customValidity, setCustomValidity] = useState(undefined);
|
|
26
28
|
return /*#__PURE__*/_jsx(ValidatedToggleControl, {
|
|
27
29
|
required: !!field.isValid.required,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
onValidate: newValue => {
|
|
31
|
+
const message = field.isValid?.custom?.({
|
|
32
|
+
...data,
|
|
33
|
+
[id]: newValue
|
|
34
|
+
}, field);
|
|
35
|
+
if (message) {
|
|
36
|
+
setCustomValidity({
|
|
37
|
+
type: 'invalid',
|
|
38
|
+
message
|
|
39
|
+
});
|
|
40
|
+
return;
|
|
34
41
|
}
|
|
35
|
-
|
|
42
|
+
setCustomValidity(undefined);
|
|
36
43
|
},
|
|
44
|
+
customValidity: customValidity,
|
|
37
45
|
hidden: hideLabelFromVision,
|
|
38
46
|
__nextHasNoMarginBottom: true,
|
|
39
47
|
label: label,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["privateApis","unlock","jsx","_jsx","ValidatedToggleControl","Boolean","field","onChange","data","hideLabelFromVision","id","getValue","label","required","isValid","
|
|
1
|
+
{"version":3,"names":["privateApis","useState","unlock","jsx","_jsx","ValidatedToggleControl","Boolean","field","onChange","data","hideLabelFromVision","id","getValue","label","customValidity","setCustomValidity","undefined","required","isValid","onValidate","newValue","message","custom","type","hidden","__nextHasNoMarginBottom","checked","item"],"sources":["@wordpress/dataviews/src/dataform-controls/boolean.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { DataFormControlProps } from '../types';\nimport { unlock } from '../lock-unlock';\n\nconst { ValidatedToggleControl } = unlock( privateApis );\n\nexport default function Boolean< Item >( {\n\tfield,\n\tonChange,\n\tdata,\n\thideLabelFromVision,\n}: DataFormControlProps< Item > ) {\n\tconst { id, getValue, label } = field;\n\tconst [ customValidity, setCustomValidity ] =\n\t\tuseState<\n\t\t\tReact.ComponentProps<\n\t\t\t\ttypeof ValidatedToggleControl\n\t\t\t>[ 'customValidity' ]\n\t\t>( undefined );\n\n\treturn (\n\t\t<ValidatedToggleControl\n\t\t\trequired={ !! field.isValid.required }\n\t\t\tonValidate={ ( newValue: any ) => {\n\t\t\t\tconst message = field.isValid?.custom?.(\n\t\t\t\t\t{\n\t\t\t\t\t\t...data,\n\t\t\t\t\t\t[ id ]: newValue,\n\t\t\t\t\t},\n\t\t\t\t\tfield\n\t\t\t\t);\n\n\t\t\t\tif ( message ) {\n\t\t\t\t\tsetCustomValidity( {\n\t\t\t\t\t\ttype: 'invalid',\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t} );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsetCustomValidity( undefined );\n\t\t\t} }\n\t\t\tcustomValidity={ customValidity }\n\t\t\thidden={ hideLabelFromVision }\n\t\t\t__nextHasNoMarginBottom\n\t\t\tlabel={ label }\n\t\t\tchecked={ getValue( { item: data } ) }\n\t\t\tonChange={ () =>\n\t\t\t\tonChange( { [ id ]: ! getValue( { item: data } ) } )\n\t\t\t}\n\t\t/>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,QAAQ,uBAAuB;AACnD,SAASC,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;;AAEA,SAASC,MAAM,QAAQ,gBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAExC,MAAM;EAAEC;AAAuB,CAAC,GAAGH,MAAM,CAAEF,WAAY,CAAC;AAExD,eAAe,SAASM,OAAOA,CAAU;EACxCC,KAAK;EACLC,QAAQ;EACRC,IAAI;EACJC;AAC6B,CAAC,EAAG;EACjC,MAAM;IAAEC,EAAE;IAAEC,QAAQ;IAAEC;EAAM,CAAC,GAAGN,KAAK;EACrC,MAAM,CAAEO,cAAc,EAAEC,iBAAiB,CAAE,GAC1Cd,QAAQ,CAILe,SAAU,CAAC;EAEf,oBACCZ,IAAA,CAACC,sBAAsB;IACtBY,QAAQ,EAAG,CAAC,CAAEV,KAAK,CAACW,OAAO,CAACD,QAAU;IACtCE,UAAU,EAAKC,QAAa,IAAM;MACjC,MAAMC,OAAO,GAAGd,KAAK,CAACW,OAAO,EAAEI,MAAM,GACpC;QACC,GAAGb,IAAI;QACP,CAAEE,EAAE,GAAIS;MACT,CAAC,EACDb,KACD,CAAC;MAED,IAAKc,OAAO,EAAG;QACdN,iBAAiB,CAAE;UAClBQ,IAAI,EAAE,SAAS;UACfF;QACD,CAAE,CAAC;QACH;MACD;MAEAN,iBAAiB,CAAEC,SAAU,CAAC;IAC/B,CAAG;IACHF,cAAc,EAAGA,cAAgB;IACjCU,MAAM,EAAGd,mBAAqB;IAC9Be,uBAAuB;IACvBZ,KAAK,EAAGA,KAAO;IACfa,OAAO,EAAGd,QAAQ,CAAE;MAAEe,IAAI,EAAElB;IAAK,CAAE,CAAG;IACtCD,QAAQ,EAAGA,CAAA,KACVA,QAAQ,CAAE;MAAE,CAAEG,EAAE,GAAI,CAAEC,QAAQ,CAAE;QAAEe,IAAI,EAAElB;MAAK,CAAE;IAAE,CAAE;EACnD,CACD,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { privateApis } from '@wordpress/components';
|
|
5
|
-
import { useCallback } from '@wordpress/element';
|
|
5
|
+
import { useCallback, useState } from '@wordpress/element';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
@@ -28,20 +28,27 @@ export default function Email({
|
|
|
28
28
|
const value = field.getValue({
|
|
29
29
|
item: data
|
|
30
30
|
});
|
|
31
|
+
const [customValidity, setCustomValidity] = useState(undefined);
|
|
31
32
|
const onChangeControl = useCallback(newValue => onChange({
|
|
32
33
|
[id]: newValue
|
|
33
34
|
}), [id, onChange]);
|
|
34
35
|
return /*#__PURE__*/_jsx(ValidatedTextControl, {
|
|
35
36
|
required: !!field.isValid?.required,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
onValidate: newValue => {
|
|
38
|
+
const message = field.isValid?.custom?.({
|
|
39
|
+
...data,
|
|
40
|
+
[id]: newValue
|
|
41
|
+
}, field);
|
|
42
|
+
if (message) {
|
|
43
|
+
setCustomValidity({
|
|
44
|
+
type: 'invalid',
|
|
45
|
+
message
|
|
46
|
+
});
|
|
47
|
+
return;
|
|
42
48
|
}
|
|
43
|
-
|
|
49
|
+
setCustomValidity(undefined);
|
|
44
50
|
},
|
|
51
|
+
customValidity: customValidity,
|
|
45
52
|
type: "email",
|
|
46
53
|
label: label,
|
|
47
54
|
placeholder: placeholder,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["privateApis","useCallback","unlock","jsx","_jsx","ValidatedTextControl","Email","data","field","onChange","hideLabelFromVision","id","label","placeholder","description","value","getValue","item","onChangeControl","newValue","required","isValid","
|
|
1
|
+
{"version":3,"names":["privateApis","useCallback","useState","unlock","jsx","_jsx","ValidatedTextControl","Email","data","field","onChange","hideLabelFromVision","id","label","placeholder","description","value","getValue","item","customValidity","setCustomValidity","undefined","onChangeControl","newValue","required","isValid","onValidate","message","custom","type","help","__next40pxDefaultSize","__nextHasNoMarginBottom"],"sources":["@wordpress/dataviews/src/dataform-controls/email.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis } from '@wordpress/components';\nimport { useCallback, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { DataFormControlProps } from '../types';\nimport { unlock } from '../lock-unlock';\n\nconst { ValidatedTextControl } = unlock( privateApis );\n\nexport default function Email< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n}: DataFormControlProps< Item > ) {\n\tconst { id, label, placeholder, description } = field;\n\tconst value = field.getValue( { item: data } );\n\tconst [ customValidity, setCustomValidity ] =\n\t\tuseState<\n\t\t\tReact.ComponentProps<\n\t\t\t\ttypeof ValidatedTextControl\n\t\t\t>[ 'customValidity' ]\n\t\t>( undefined );\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue: string ) =>\n\t\t\tonChange( {\n\t\t\t\t[ id ]: newValue,\n\t\t\t} ),\n\t\t[ id, onChange ]\n\t);\n\n\treturn (\n\t\t<ValidatedTextControl\n\t\t\trequired={ !! field.isValid?.required }\n\t\t\tonValidate={ ( newValue: any ) => {\n\t\t\t\tconst message = field.isValid?.custom?.(\n\t\t\t\t\t{\n\t\t\t\t\t\t...data,\n\t\t\t\t\t\t[ id ]: newValue,\n\t\t\t\t\t},\n\t\t\t\t\tfield\n\t\t\t\t);\n\n\t\t\t\tif ( message ) {\n\t\t\t\t\tsetCustomValidity( {\n\t\t\t\t\t\ttype: 'invalid',\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t} );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsetCustomValidity( undefined );\n\t\t\t} }\n\t\t\tcustomValidity={ customValidity }\n\t\t\ttype=\"email\"\n\t\t\tlabel={ label }\n\t\t\tplaceholder={ placeholder }\n\t\t\tvalue={ value ?? '' }\n\t\t\thelp={ description }\n\t\t\tonChange={ onChangeControl }\n\t\t\t__next40pxDefaultSize\n\t\t\t__nextHasNoMarginBottom\n\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t/>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,QAAQ,uBAAuB;AACnD,SAASC,WAAW,EAAEC,QAAQ,QAAQ,oBAAoB;;AAE1D;AACA;AACA;;A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ACrBc,IAAI,EAAGf,WAAa;IACpBL,QAAQ,EAAGY,eAAiB;IAC5BS,qBAAqB;IACrBC,uBAAuB;IACvBrB,mBAAmB,EAAGA;EAAqB,CAC3C,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { Flex, BaseControl, __experimentalNumberControl as NumberControl, privateApis } from '@wordpress/components';
|
|
5
|
-
import { useCallback } from '@wordpress/element';
|
|
5
|
+
import { useCallback, useState } from '@wordpress/element';
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -67,6 +67,7 @@ export default function Integer({
|
|
|
67
67
|
const value = (_field$getValue = field.getValue({
|
|
68
68
|
item: data
|
|
69
69
|
})) !== null && _field$getValue !== void 0 ? _field$getValue : '';
|
|
70
|
+
const [customValidity, setCustomValidity] = useState(undefined);
|
|
70
71
|
const onChangeControl = useCallback(newValue => {
|
|
71
72
|
onChange({
|
|
72
73
|
// Do not convert an empty string or undefined to a number,
|
|
@@ -85,15 +86,21 @@ export default function Integer({
|
|
|
85
86
|
}
|
|
86
87
|
return /*#__PURE__*/_jsx(ValidatedNumberControl, {
|
|
87
88
|
required: !!field.isValid?.required,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
onValidate: newValue => {
|
|
90
|
+
const message = field.isValid?.custom?.({
|
|
91
|
+
...data,
|
|
92
|
+
[id]: [undefined, '', null].includes(newValue) ? undefined : Number(newValue)
|
|
93
|
+
}, field);
|
|
94
|
+
if (message) {
|
|
95
|
+
setCustomValidity({
|
|
96
|
+
type: 'invalid',
|
|
97
|
+
message
|
|
98
|
+
});
|
|
99
|
+
return;
|
|
94
100
|
}
|
|
95
|
-
|
|
101
|
+
setCustomValidity(undefined);
|
|
96
102
|
},
|
|
103
|
+
customValidity: customValidity,
|
|
97
104
|
label: label,
|
|
98
105
|
help: description,
|
|
99
106
|
value: value,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Flex","BaseControl","__experimentalNumberControl","NumberControl","privateApis","useCallback","__","OPERATOR_BETWEEN","unlock","jsx","_jsx","jsxs","_jsxs","ValidatedNumberControl","BetweenControls","id","value","onChange","hideLabelFromVision","min","max","Array","isArray","onChangeMin","newValue","Number","onChangeMax","__nextHasNoMarginBottom","help","children","direction","gap","label","undefined","__next40pxDefaultSize","Integer","data","field","operator","_field$getValue","description","getValue","item","onChangeControl","includes","required","isValid","
|
|
1
|
+
{"version":3,"names":["Flex","BaseControl","__experimentalNumberControl","NumberControl","privateApis","useCallback","useState","__","OPERATOR_BETWEEN","unlock","jsx","_jsx","jsxs","_jsxs","ValidatedNumberControl","BetweenControls","id","value","onChange","hideLabelFromVision","min","max","Array","isArray","onChangeMin","newValue","Number","onChangeMax","__nextHasNoMarginBottom","help","children","direction","gap","label","undefined","__next40pxDefaultSize","Integer","data","field","operator","_field$getValue","description","getValue","item","customValidity","setCustomValidity","onChangeControl","includes","required","isValid","onValidate","message","custom","type"],"sources":["@wordpress/dataviews/src/dataform-controls/integer.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tFlex,\n\tBaseControl,\n\t__experimentalNumberControl as NumberControl,\n\tprivateApis,\n} from '@wordpress/components';\nimport { useCallback, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { OPERATOR_BETWEEN } from '../constants';\nimport type { DataFormControlProps } from '../types';\nimport { unlock } from '../lock-unlock';\n\nconst { ValidatedNumberControl } = unlock( privateApis );\n\nfunction BetweenControls< Item >( {\n\tid,\n\tvalue,\n\tonChange,\n\thideLabelFromVision,\n}: {\n\tid: string;\n\tvalue: any;\n\tonChange: DataFormControlProps< Item >[ 'onChange' ];\n\thideLabelFromVision?: boolean;\n} ) {\n\tconst [ min = '', max = '' ] = Array.isArray( value ) ? value : [];\n\n\tconst onChangeMin = useCallback(\n\t\t( newValue: string | undefined ) =>\n\t\t\tonChange( {\n\t\t\t\t[ id ]: [ Number( newValue ), max ],\n\t\t\t} ),\n\t\t[ id, onChange, max ]\n\t);\n\n\tconst onChangeMax = useCallback(\n\t\t( newValue: string | undefined ) =>\n\t\t\tonChange( {\n\t\t\t\t[ id ]: [ min, Number( newValue ) ],\n\t\t\t} ),\n\t\t[ id, onChange, min ]\n\t);\n\n\treturn (\n\t\t<BaseControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\thelp={ __( 'The max. value must be greater than the min. value.' ) }\n\t\t>\n\t\t\t<Flex direction=\"row\" gap={ 4 }>\n\t\t\t\t<NumberControl\n\t\t\t\t\tlabel={ __( 'Min.' ) }\n\t\t\t\t\tvalue={ min }\n\t\t\t\t\tmax={ max ? Number( max ) - 1 : undefined }\n\t\t\t\t\tonChange={ onChangeMin }\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t\t/>\n\t\t\t\t<NumberControl\n\t\t\t\t\tlabel={ __( 'Max.' ) }\n\t\t\t\t\tvalue={ max }\n\t\t\t\t\tmin={ min ? Number( min ) + 1 : undefined }\n\t\t\t\t\tonChange={ onChangeMax }\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t\t/>\n\t\t\t</Flex>\n\t\t</BaseControl>\n\t);\n}\n\nexport default function Integer< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n\toperator,\n}: DataFormControlProps< Item > ) {\n\tconst { id, label, description } = field;\n\tconst value = field.getValue( { item: data } ) ?? '';\n\tconst [ customValidity, setCustomValidity ] =\n\t\tuseState<\n\t\t\tReact.ComponentProps<\n\t\t\t\ttypeof ValidatedNumberControl\n\t\t\t>[ 'customValidity' ]\n\t\t>( undefined );\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue: string | undefined ) => {\n\t\t\tonChange( {\n\t\t\t\t// Do not convert an empty string or undefined to a number,\n\t\t\t\t// otherwise there's a mismatch between the UI control (empty)\n\t\t\t\t// and the data relied by onChange (0).\n\t\t\t\t[ id ]: [ '', undefined ].includes( newValue )\n\t\t\t\t\t? undefined\n\t\t\t\t\t: Number( newValue ),\n\t\t\t} );\n\t\t},\n\t\t[ id, onChange ]\n\t);\n\n\tif ( operator === OPERATOR_BETWEEN ) {\n\t\treturn (\n\t\t\t<BetweenControls\n\t\t\t\tid={ id }\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ onChange }\n\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<ValidatedNumberControl\n\t\t\trequired={ !! field.isValid?.required }\n\t\t\tonValidate={ ( newValue: any ) => {\n\t\t\t\tconst message = field.isValid?.custom?.(\n\t\t\t\t\t{\n\t\t\t\t\t\t...data,\n\t\t\t\t\t\t[ id ]: [ undefined, '', null ].includes( newValue )\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: Number( newValue ),\n\t\t\t\t\t},\n\t\t\t\t\tfield\n\t\t\t\t);\n\n\t\t\t\tif ( message ) {\n\t\t\t\t\tsetCustomValidity( {\n\t\t\t\t\t\ttype: 'invalid',\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t} );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsetCustomValidity( undefined );\n\t\t\t} }\n\t\t\tcustomValidity={ customValidity }\n\t\t\tlabel={ label }\n\t\t\thelp={ description }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChangeControl }\n\t\t\t__next40pxDefaultSize\n\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t/>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,IAAI,EACJC,WAAW,EACXC,2BAA2B,IAAIC,aAAa,EAC5CC,WAAW,QACL,uBAAuB;AAC9B,SAASC,WAAW,E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/B,gBAAgB,EAAG;IACpC,oBACCG,IAAA,CAACI,eAAe;MACfC,EAAE,EAAGA,EAAI;MACTC,KAAK,EAAGA,KAAO;MACfC,QAAQ,EAAGA,QAAU;MACrBC,mBAAmB,EAAGA;IAAqB,CAC3C,CAAC;EAEJ;EAEA,oBACCR,IAAA,CAACG,sBAAsB;IACtBkC,QAAQ,EAAG,CAAC,CAAEV,KAAK,CAACW,OAAO,EAAED,QAAU;IACvCE,UAAU,EAAKzB,QAAa,IAAM;MACjC,MAAM0B,OAAO,GAAGb,KAAK,CAACW,OAAO,EAAEG,MAAM,GACpC;QACC,GAAGf,IAAI;QACP,CAAErB,EAAE,GAAI,CAAEkB,SAAS,EAAE,EAAE,EAAE,IAAI,CAAE,CAACa,QAAQ,CAAEtB,QAAS,CAAC,GACjDS,SAAS,GACTR,MAAM,CAAED,QAAS;MACrB,CAAC,EACDa,KACD,CAAC;MAED,IAAKa,OAAO,EAAG;QACdN,iBAAiB,CAAE;UAClBQ,IAAI,EAAE,SAAS;UACfF;QACD,CAAE,CAAC;QACH;MACD;MAEAN,iBAAiB,CAAEX,SAAU,CAAC;IAC/B,CAAG;IACHU,cAAc,EAAGA,cAAgB;IACjCX,KAAK,EAAGA,KAAO;IACfJ,IAAI,EAAGY,WAAa;IACpBxB,KAAK,EAAGA,KAAO;IACfC,QAAQ,EAAG4B,eAAiB;IAC5BX,qBAAqB;IACrBhB,mBAAmB,EAAGA;EAAqB,CAC3C,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { privateApis } from '@wordpress/components';
|
|
5
|
-
import { useCallback } from '@wordpress/element';
|
|
5
|
+
import { useCallback, useState } from '@wordpress/element';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
@@ -28,20 +28,27 @@ export default function Text({
|
|
|
28
28
|
const value = field.getValue({
|
|
29
29
|
item: data
|
|
30
30
|
});
|
|
31
|
+
const [customValidity, setCustomValidity] = useState(undefined);
|
|
31
32
|
const onChangeControl = useCallback(newValue => onChange({
|
|
32
33
|
[id]: newValue
|
|
33
34
|
}), [id, onChange]);
|
|
34
35
|
return /*#__PURE__*/_jsx(ValidatedTextControl, {
|
|
35
36
|
required: !!field.isValid?.required,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
onValidate: newValue => {
|
|
38
|
+
const message = field.isValid?.custom?.({
|
|
39
|
+
...data,
|
|
40
|
+
[id]: newValue
|
|
41
|
+
}, field);
|
|
42
|
+
if (message) {
|
|
43
|
+
setCustomValidity({
|
|
44
|
+
type: 'invalid',
|
|
45
|
+
message
|
|
46
|
+
});
|
|
47
|
+
return;
|
|
42
48
|
}
|
|
43
|
-
|
|
49
|
+
setCustomValidity(undefined);
|
|
44
50
|
},
|
|
51
|
+
customValidity: customValidity,
|
|
45
52
|
label: label,
|
|
46
53
|
placeholder: placeholder,
|
|
47
54
|
value: value !== null && value !== void 0 ? value : '',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["privateApis","useCallback","unlock","jsx","_jsx","ValidatedTextControl","Text","data","field","onChange","hideLabelFromVision","id","label","placeholder","description","value","getValue","item","onChangeControl","newValue","required","isValid","
|
|
1
|
+
{"version":3,"names":["privateApis","useCallback","useState","unlock","jsx","_jsx","ValidatedTextControl","Text","data","field","onChange","hideLabelFromVision","id","label","placeholder","description","value","getValue","item","customValidity","setCustomValidity","undefined","onChangeControl","newValue","required","isValid","onValidate","message","custom","type","help","__next40pxDefaultSize","__nextHasNoMarginBottom"],"sources":["@wordpress/dataviews/src/dataform-controls/text.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis } from '@wordpress/components';\nimport { useCallback, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { DataFormControlProps } from '../types';\nimport { unlock } from '../lock-unlock';\n\nconst { ValidatedTextControl } = unlock( privateApis );\n\nexport default function Text< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n}: DataFormControlProps< Item > ) {\n\tconst { id, label, placeholder, description } = field;\n\tconst value = field.getValue( { item: data } );\n\tconst [ customValidity, setCustomValidity ] =\n\t\tuseState<\n\t\t\tReact.ComponentProps<\n\t\t\t\ttypeof ValidatedTextControl\n\t\t\t>[ 'customValidity' ]\n\t\t>( undefined );\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue: string ) =>\n\t\t\tonChange( {\n\t\t\t\t[ id ]: newValue,\n\t\t\t} ),\n\t\t[ id, onChange ]\n\t);\n\n\treturn (\n\t\t<ValidatedTextControl\n\t\t\trequired={ !! field.isValid?.required }\n\t\t\tonValidate={ ( newValue: any ) => {\n\t\t\t\tconst message = field.isValid?.custom?.(\n\t\t\t\t\t{\n\t\t\t\t\t\t...data,\n\t\t\t\t\t\t[ id ]: newValue,\n\t\t\t\t\t},\n\t\t\t\t\tfield\n\t\t\t\t);\n\n\t\t\t\tif ( message ) {\n\t\t\t\t\tsetCustomValidity( {\n\t\t\t\t\t\ttype: 'invalid',\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t} );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsetCustomValidity( undefined );\n\t\t\t} }\n\t\t\tcustomValidity={ customValidity }\n\t\t\tlabel={ label }\n\t\t\tplaceholder={ placeholder }\n\t\t\tvalue={ value ?? '' }\n\t\t\thelp={ description }\n\t\t\tonChange={ onChangeControl }\n\t\t\t__next40pxDefaultSize\n\t\t\t__nextHasNoMarginBottom\n\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t/>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,QAAQ,uBAAuB;AACnD,SAASC,WAAW,EAAEC,QAAQ,QAAQ,oBAAoB;;AAE1D;AACA;AACA;;AAEA,SAASC,MAAM,QAAQ,gBAAgB;AAAC,S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AAqB;IACrBC,uBAAuB;IACvBrB,mBAAmB,EAAGA;EAAqB,CAC3C,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __experimentalVStack as VStack, __experimentalHStack as HStack, __experimentalHeading as Heading, __experimentalSpacer as Spacer, Dropdown, Button } from '@wordpress/components';
|
|
5
|
+
import { sprintf, __, _x } from '@wordpress/i18n';
|
|
6
|
+
import { useMemo } from '@wordpress/element';
|
|
7
|
+
import { closeSmall } from '@wordpress/icons';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { DataFormLayout } from '../data-form-layout';
|
|
14
|
+
import { isCombinedField } from '../is-combined-field';
|
|
15
|
+
import { DEFAULT_LAYOUT } from '../../normalize-form-fields';
|
|
16
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
17
|
+
function DropdownHeader({
|
|
18
|
+
title,
|
|
19
|
+
onClose
|
|
20
|
+
}) {
|
|
21
|
+
return /*#__PURE__*/_jsx(VStack, {
|
|
22
|
+
className: "dataforms-layouts-panel__dropdown-header",
|
|
23
|
+
spacing: 4,
|
|
24
|
+
children: /*#__PURE__*/_jsxs(HStack, {
|
|
25
|
+
alignment: "center",
|
|
26
|
+
children: [title && /*#__PURE__*/_jsx(Heading, {
|
|
27
|
+
level: 2,
|
|
28
|
+
size: 13,
|
|
29
|
+
children: title
|
|
30
|
+
}), /*#__PURE__*/_jsx(Spacer, {}), onClose && /*#__PURE__*/_jsx(Button, {
|
|
31
|
+
label: __('Close'),
|
|
32
|
+
icon: closeSmall,
|
|
33
|
+
onClick: onClose,
|
|
34
|
+
size: "small"
|
|
35
|
+
})]
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function PanelDropdown({
|
|
40
|
+
fieldDefinition,
|
|
41
|
+
popoverAnchor,
|
|
42
|
+
labelPosition = 'side',
|
|
43
|
+
data,
|
|
44
|
+
onChange,
|
|
45
|
+
field
|
|
46
|
+
}) {
|
|
47
|
+
const fieldLabel = isCombinedField(field) ? field.label : fieldDefinition?.label;
|
|
48
|
+
const form = useMemo(() => ({
|
|
49
|
+
layout: DEFAULT_LAYOUT,
|
|
50
|
+
fields: isCombinedField(field) ? field.children :
|
|
51
|
+
// If not explicit children return the field id itself.
|
|
52
|
+
[{
|
|
53
|
+
id: field.id
|
|
54
|
+
}]
|
|
55
|
+
}), [field]);
|
|
56
|
+
|
|
57
|
+
// Memoize popoverProps to avoid returning a new object every time.
|
|
58
|
+
const popoverProps = useMemo(() => ({
|
|
59
|
+
// Anchor the popover to the middle of the entire row so that it doesn't
|
|
60
|
+
// move around when the label changes.
|
|
61
|
+
anchor: popoverAnchor,
|
|
62
|
+
placement: 'left-start',
|
|
63
|
+
offset: 36,
|
|
64
|
+
shift: true
|
|
65
|
+
}), [popoverAnchor]);
|
|
66
|
+
return /*#__PURE__*/_jsx(Dropdown, {
|
|
67
|
+
contentClassName: "dataforms-layouts-panel__field-dropdown",
|
|
68
|
+
popoverProps: popoverProps,
|
|
69
|
+
focusOnMount: true,
|
|
70
|
+
toggleProps: {
|
|
71
|
+
size: 'compact',
|
|
72
|
+
variant: 'tertiary',
|
|
73
|
+
tooltipPosition: 'middle left'
|
|
74
|
+
},
|
|
75
|
+
renderToggle: ({
|
|
76
|
+
isOpen,
|
|
77
|
+
onToggle
|
|
78
|
+
}) => /*#__PURE__*/_jsx(Button, {
|
|
79
|
+
className: "dataforms-layouts-panel__field-control",
|
|
80
|
+
size: "compact",
|
|
81
|
+
variant: ['none', 'top'].includes(labelPosition) ? 'link' : 'tertiary',
|
|
82
|
+
"aria-expanded": isOpen,
|
|
83
|
+
"aria-label": sprintf(
|
|
84
|
+
// translators: %s: Field name.
|
|
85
|
+
_x('Edit %s', 'field'), fieldLabel || ''),
|
|
86
|
+
onClick: onToggle,
|
|
87
|
+
disabled: fieldDefinition.readOnly === true,
|
|
88
|
+
accessibleWhenDisabled: true,
|
|
89
|
+
children: /*#__PURE__*/_jsx(fieldDefinition.render, {
|
|
90
|
+
item: data,
|
|
91
|
+
field: fieldDefinition
|
|
92
|
+
})
|
|
93
|
+
}),
|
|
94
|
+
renderContent: ({
|
|
95
|
+
onClose
|
|
96
|
+
}) => /*#__PURE__*/_jsxs(_Fragment, {
|
|
97
|
+
children: [/*#__PURE__*/_jsx(DropdownHeader, {
|
|
98
|
+
title: fieldLabel,
|
|
99
|
+
onClose: onClose
|
|
100
|
+
}), /*#__PURE__*/_jsx(DataFormLayout, {
|
|
101
|
+
data: data,
|
|
102
|
+
form: form,
|
|
103
|
+
onChange: onChange,
|
|
104
|
+
children: (FieldLayout, nestedField) => {
|
|
105
|
+
var _form$fields;
|
|
106
|
+
return /*#__PURE__*/_jsx(FieldLayout, {
|
|
107
|
+
data: data,
|
|
108
|
+
field: nestedField,
|
|
109
|
+
onChange: onChange,
|
|
110
|
+
hideLabelFromVision: ((_form$fields = form?.fields) !== null && _form$fields !== void 0 ? _form$fields : []).length < 2
|
|
111
|
+
}, nestedField.id);
|
|
112
|
+
}
|
|
113
|
+
})]
|
|
114
|
+
})
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
export default PanelDropdown;
|
|
118
|
+
//# sourceMappingURL=dropdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__experimentalVStack","VStack","__experimentalHStack","HStack","__experimentalHeading","Heading","__experimentalSpacer","Spacer","Dropdown","Button","sprintf","__","_x","useMemo","closeSmall","DataFormLayout","isCombinedField","DEFAULT_LAYOUT","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","DropdownHeader","title","onClose","className","spacing","children","alignment","level","size","label","icon","onClick","PanelDropdown","fieldDefinition","popoverAnchor","labelPosition","data","onChange","field","fieldLabel","form","layout","fields","id","popoverProps","anchor","placement","offset","shift","contentClassName","focusOnMount","toggleProps","variant","tooltipPosition","renderToggle","isOpen","onToggle","includes","disabled","readOnly","accessibleWhenDisabled","render","item","renderContent","FieldLayout","nestedField","_form$fields","hideLabelFromVision","length"],"sources":["@wordpress/dataviews/src/dataforms-layouts/panel/dropdown.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n\t__experimentalHeading as Heading,\n\t__experimentalSpacer as Spacer,\n\tDropdown,\n\tButton,\n} from '@wordpress/components';\nimport { sprintf, __, _x } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { closeSmall } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport type { Form, FormField, NormalizedField } from '../../types';\nimport { DataFormLayout } from '../data-form-layout';\nimport { isCombinedField } from '../is-combined-field';\nimport { DEFAULT_LAYOUT } from '../../normalize-form-fields';\n\nfunction DropdownHeader( {\n\ttitle,\n\tonClose,\n}: {\n\ttitle?: string;\n\tonClose: () => void;\n} ) {\n\treturn (\n\t\t<VStack\n\t\t\tclassName=\"dataforms-layouts-panel__dropdown-header\"\n\t\t\tspacing={ 4 }\n\t\t>\n\t\t\t<HStack alignment=\"center\">\n\t\t\t\t{ title && (\n\t\t\t\t\t<Heading level={ 2 } size={ 13 }>\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</Heading>\n\t\t\t\t) }\n\t\t\t\t<Spacer />\n\t\t\t\t{ onClose && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tlabel={ __( 'Close' ) }\n\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t</VStack>\n\t);\n}\n\nfunction PanelDropdown< Item >( {\n\tfieldDefinition,\n\tpopoverAnchor,\n\tlabelPosition = 'side',\n\tdata,\n\tonChange,\n\tfield,\n}: {\n\tfieldDefinition: NormalizedField< Item >;\n\tpopoverAnchor: HTMLElement | null;\n\tlabelPosition: 'side' | 'top' | 'none';\n\tdata: Item;\n\tonChange: ( value: any ) => void;\n\tfield: FormField;\n} ) {\n\tconst fieldLabel = isCombinedField( field )\n\t\t? field.label\n\t\t: fieldDefinition?.label;\n\n\tconst form: Form = useMemo(\n\t\t(): Form => ( {\n\t\t\tlayout: DEFAULT_LAYOUT,\n\t\t\tfields: isCombinedField( field )\n\t\t\t\t? field.children\n\t\t\t\t: // If not explicit children return the field id itself.\n\t\t\t\t [ { id: field.id } ],\n\t\t} ),\n\t\t[ field ]\n\t);\n\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\n\treturn (\n\t\t<Dropdown\n\t\t\tcontentClassName=\"dataforms-layouts-panel__field-dropdown\"\n\t\t\tpopoverProps={ popoverProps }\n\t\t\tfocusOnMount\n\t\t\ttoggleProps={ {\n\t\t\t\tsize: 'compact',\n\t\t\t\tvariant: 'tertiary',\n\t\t\t\ttooltipPosition: 'middle left',\n\t\t\t} }\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"dataforms-layouts-panel__field-control\"\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\tvariant={\n\t\t\t\t\t\t[ 'none', 'top' ].includes( labelPosition )\n\t\t\t\t\t\t\t? 'link'\n\t\t\t\t\t\t\t: 'tertiary'\n\t\t\t\t\t}\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t// translators: %s: Field name.\n\t\t\t\t\t\t_x( 'Edit %s', 'field' ),\n\t\t\t\t\t\tfieldLabel || ''\n\t\t\t\t\t) }\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\tdisabled={ fieldDefinition.readOnly === true }\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t>\n\t\t\t\t\t<fieldDefinition.render\n\t\t\t\t\t\titem={ data }\n\t\t\t\t\t\tfield={ fieldDefinition }\n\t\t\t\t\t/>\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<DropdownHeader title={ fieldLabel } onClose={ onClose } />\n\t\t\t\t\t<DataFormLayout\n\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\tform={ form }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ( FieldLayout, nestedField ) => (\n\t\t\t\t\t\t\t<FieldLayout\n\t\t\t\t\t\t\t\tkey={ nestedField.id }\n\t\t\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\t\t\tfield={ nestedField }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\thideLabelFromVision={\n\t\t\t\t\t\t\t\t\t( form?.fields ?? [] ).length < 2\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</DataFormLayout>\n\t\t\t\t</>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default PanelDropdown;\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,qBAAqB,IAAIC,OAAO,EAChCC,oBAAoB,IAAIC,MAAM,EAC9BC,QAAQ,EACRC,MAAM,QACA,uBAAuB;AAC9B,SAASC,OAAO,EAAEC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACjD,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,UAAU,QAAQ,kBA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AO,EAAGA;MAAS,CAAE,CAAC,eAC3DP,IAAA,CAACJ,cAAc;QACdyB,IAAI,EAAGA,IAAM;QACbI,IAAI,EAAGA,IAAM;QACbH,QAAQ,EAAGA,QAAU;QAAAZ,QAAA,EAEnBA,CAAEuC,WAAW,EAAEC,WAAW;UAAA,IAAAC,YAAA;UAAA,oBAC3BnD,IAAA,CAACiD,WAAW;YAEX5B,IAAI,EAAGA,IAAM;YACbE,KAAK,EAAG2B,WAAa;YACrB5B,QAAQ,EAAGA,QAAU;YACrB8B,mBAAmB,EAClB,EAAAD,YAAA,GAAE1B,IAAI,EAAEE,MAAM,cAAAwB,YAAA,cAAAA,YAAA,GAAI,EAAE,EAAGE,MAAM,GAAG;UAChC,GANKH,WAAW,CAACtB,EAOlB,CAAC;QAAA;MACF,CACc,CAAC;IAAA,CAChB;EACA,CACH,CAAC;AAEJ;AAEA,eAAeX,aAAa","ignoreList":[]}
|
|
@@ -6,120 +6,19 @@ import clsx from 'clsx';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { __experimentalVStack as VStack, __experimentalHStack as HStack
|
|
10
|
-
import {
|
|
11
|
-
import { useState, useMemo, useContext } from '@wordpress/element';
|
|
12
|
-
import { closeSmall } from '@wordpress/icons';
|
|
9
|
+
import { __experimentalVStack as VStack, __experimentalHStack as HStack } from '@wordpress/components';
|
|
10
|
+
import { useState, useContext } from '@wordpress/element';
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
13
|
* Internal dependencies
|
|
16
14
|
*/
|
|
17
15
|
|
|
18
16
|
import DataFormContext from '../../components/dataform-context';
|
|
19
|
-
import { DataFormLayout } from '../data-form-layout';
|
|
20
17
|
import { isCombinedField } from '../is-combined-field';
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
onClose
|
|
26
|
-
}) {
|
|
27
|
-
return /*#__PURE__*/_jsx(VStack, {
|
|
28
|
-
className: "dataforms-layouts-panel__dropdown-header",
|
|
29
|
-
spacing: 4,
|
|
30
|
-
children: /*#__PURE__*/_jsxs(HStack, {
|
|
31
|
-
alignment: "center",
|
|
32
|
-
children: [title && /*#__PURE__*/_jsx(Heading, {
|
|
33
|
-
level: 2,
|
|
34
|
-
size: 13,
|
|
35
|
-
children: title
|
|
36
|
-
}), /*#__PURE__*/_jsx(Spacer, {}), onClose && /*#__PURE__*/_jsx(Button, {
|
|
37
|
-
label: __('Close'),
|
|
38
|
-
icon: closeSmall,
|
|
39
|
-
onClick: onClose,
|
|
40
|
-
size: "small"
|
|
41
|
-
})]
|
|
42
|
-
})
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
function PanelDropdown({
|
|
46
|
-
fieldDefinition,
|
|
47
|
-
popoverAnchor,
|
|
48
|
-
labelPosition = 'side',
|
|
49
|
-
data,
|
|
50
|
-
onChange,
|
|
51
|
-
field
|
|
52
|
-
}) {
|
|
53
|
-
const fieldLabel = isCombinedField(field) ? field.label : fieldDefinition?.label;
|
|
54
|
-
const form = useMemo(() => ({
|
|
55
|
-
layout: DEFAULT_LAYOUT,
|
|
56
|
-
fields: isCombinedField(field) ? field.children :
|
|
57
|
-
// If not explicit children return the field id itself.
|
|
58
|
-
[{
|
|
59
|
-
id: field.id
|
|
60
|
-
}]
|
|
61
|
-
}), [field]);
|
|
62
|
-
|
|
63
|
-
// Memoize popoverProps to avoid returning a new object every time.
|
|
64
|
-
const popoverProps = useMemo(() => ({
|
|
65
|
-
// Anchor the popover to the middle of the entire row so that it doesn't
|
|
66
|
-
// move around when the label changes.
|
|
67
|
-
anchor: popoverAnchor,
|
|
68
|
-
placement: 'left-start',
|
|
69
|
-
offset: 36,
|
|
70
|
-
shift: true
|
|
71
|
-
}), [popoverAnchor]);
|
|
72
|
-
return /*#__PURE__*/_jsx(Dropdown, {
|
|
73
|
-
contentClassName: "dataforms-layouts-panel__field-dropdown",
|
|
74
|
-
popoverProps: popoverProps,
|
|
75
|
-
focusOnMount: true,
|
|
76
|
-
toggleProps: {
|
|
77
|
-
size: 'compact',
|
|
78
|
-
variant: 'tertiary',
|
|
79
|
-
tooltipPosition: 'middle left'
|
|
80
|
-
},
|
|
81
|
-
renderToggle: ({
|
|
82
|
-
isOpen,
|
|
83
|
-
onToggle
|
|
84
|
-
}) => /*#__PURE__*/_jsx(Button, {
|
|
85
|
-
className: "dataforms-layouts-panel__field-control",
|
|
86
|
-
size: "compact",
|
|
87
|
-
variant: ['none', 'top'].includes(labelPosition) ? 'link' : 'tertiary',
|
|
88
|
-
"aria-expanded": isOpen,
|
|
89
|
-
"aria-label": sprintf(
|
|
90
|
-
// translators: %s: Field name.
|
|
91
|
-
_x('Edit %s', 'field'), fieldLabel || ''),
|
|
92
|
-
onClick: onToggle,
|
|
93
|
-
disabled: fieldDefinition.readOnly === true,
|
|
94
|
-
accessibleWhenDisabled: true,
|
|
95
|
-
children: /*#__PURE__*/_jsx(fieldDefinition.render, {
|
|
96
|
-
item: data,
|
|
97
|
-
field: fieldDefinition
|
|
98
|
-
})
|
|
99
|
-
}),
|
|
100
|
-
renderContent: ({
|
|
101
|
-
onClose
|
|
102
|
-
}) => /*#__PURE__*/_jsxs(_Fragment, {
|
|
103
|
-
children: [/*#__PURE__*/_jsx(DropdownHeader, {
|
|
104
|
-
title: fieldLabel,
|
|
105
|
-
onClose: onClose
|
|
106
|
-
}), /*#__PURE__*/_jsx(DataFormLayout, {
|
|
107
|
-
data: data,
|
|
108
|
-
form: form,
|
|
109
|
-
onChange: onChange,
|
|
110
|
-
children: (FieldLayout, nestedField) => {
|
|
111
|
-
var _form$fields;
|
|
112
|
-
return /*#__PURE__*/_jsx(FieldLayout, {
|
|
113
|
-
data: data,
|
|
114
|
-
field: nestedField,
|
|
115
|
-
onChange: onChange,
|
|
116
|
-
hideLabelFromVision: ((_form$fields = form?.fields) !== null && _form$fields !== void 0 ? _form$fields : []).length < 2
|
|
117
|
-
}, nestedField.id);
|
|
118
|
-
}
|
|
119
|
-
})]
|
|
120
|
-
})
|
|
121
|
-
});
|
|
122
|
-
}
|
|
18
|
+
import { normalizeLayout } from '../../normalize-form-fields';
|
|
19
|
+
import PanelDropdown from './dropdown';
|
|
20
|
+
import PanelModal from './modal';
|
|
21
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
123
22
|
export default function FormPanelField({
|
|
124
23
|
data,
|
|
125
24
|
field,
|
|
@@ -154,6 +53,20 @@ export default function FormPanelField({
|
|
|
154
53
|
const labelPosition = layout.labelPosition;
|
|
155
54
|
const labelClassName = clsx('dataforms-layouts-panel__field-label', `dataforms-layouts-panel__field-label--label-position-${labelPosition}`);
|
|
156
55
|
const fieldLabel = isCombinedField(field) ? field.label : fieldDefinition?.label;
|
|
56
|
+
const renderedControl = layout.openAs === 'modal' ? /*#__PURE__*/_jsx(PanelModal, {
|
|
57
|
+
field: field,
|
|
58
|
+
fieldDefinition: fieldDefinition,
|
|
59
|
+
data: data,
|
|
60
|
+
onChange: onChange,
|
|
61
|
+
labelPosition: labelPosition
|
|
62
|
+
}) : /*#__PURE__*/_jsx(PanelDropdown, {
|
|
63
|
+
field: field,
|
|
64
|
+
popoverAnchor: popoverAnchor,
|
|
65
|
+
fieldDefinition: fieldDefinition,
|
|
66
|
+
data: data,
|
|
67
|
+
onChange: onChange,
|
|
68
|
+
labelPosition: labelPosition
|
|
69
|
+
});
|
|
157
70
|
if (labelPosition === 'top') {
|
|
158
71
|
return /*#__PURE__*/_jsxs(VStack, {
|
|
159
72
|
className: "dataforms-layouts-panel__field",
|
|
@@ -166,28 +79,14 @@ export default function FormPanelField({
|
|
|
166
79
|
children: fieldLabel
|
|
167
80
|
}), /*#__PURE__*/_jsx("div", {
|
|
168
81
|
className: "dataforms-layouts-panel__field-control",
|
|
169
|
-
children:
|
|
170
|
-
field: field,
|
|
171
|
-
popoverAnchor: popoverAnchor,
|
|
172
|
-
fieldDefinition: fieldDefinition,
|
|
173
|
-
data: data,
|
|
174
|
-
onChange: onChange,
|
|
175
|
-
labelPosition: labelPosition
|
|
176
|
-
})
|
|
82
|
+
children: renderedControl
|
|
177
83
|
})]
|
|
178
84
|
});
|
|
179
85
|
}
|
|
180
86
|
if (labelPosition === 'none') {
|
|
181
87
|
return /*#__PURE__*/_jsx("div", {
|
|
182
88
|
className: "dataforms-layouts-panel__field",
|
|
183
|
-
children:
|
|
184
|
-
field: field,
|
|
185
|
-
popoverAnchor: popoverAnchor,
|
|
186
|
-
fieldDefinition: fieldDefinition,
|
|
187
|
-
data: data,
|
|
188
|
-
onChange: onChange,
|
|
189
|
-
labelPosition: labelPosition
|
|
190
|
-
})
|
|
89
|
+
children: renderedControl
|
|
191
90
|
});
|
|
192
91
|
}
|
|
193
92
|
|
|
@@ -200,14 +99,7 @@ export default function FormPanelField({
|
|
|
200
99
|
children: fieldLabel
|
|
201
100
|
}), /*#__PURE__*/_jsx("div", {
|
|
202
101
|
className: "dataforms-layouts-panel__field-control",
|
|
203
|
-
children:
|
|
204
|
-
field: field,
|
|
205
|
-
popoverAnchor: popoverAnchor,
|
|
206
|
-
fieldDefinition: fieldDefinition,
|
|
207
|
-
data: data,
|
|
208
|
-
onChange: onChange,
|
|
209
|
-
labelPosition: labelPosition
|
|
210
|
-
})
|
|
102
|
+
children: renderedControl
|
|
211
103
|
})]
|
|
212
104
|
});
|
|
213
105
|
}
|