@wordpress/dataviews 8.0.1-next.e256d081a.0 → 9.0.1-next.6870dfe5b.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 +24 -1
- package/README.md +96 -1
- package/build/components/dataform-context/index.js +1 -0
- package/build/components/dataform-context/index.js.map +1 -1
- package/build/components/dataviews/index.js +11 -1
- package/build/components/dataviews/index.js.map +1 -1
- package/build/components/dataviews-context/index.js +1 -0
- package/build/components/dataviews-context/index.js.map +1 -1
- package/build/components/dataviews-layout/index.js +2 -1
- package/build/components/dataviews-layout/index.js.map +1 -1
- package/build/components/dataviews-picker/footer.js +145 -0
- package/build/components/dataviews-picker/footer.js.map +1 -0
- package/build/components/dataviews-picker/index.js +201 -0
- package/build/components/dataviews-picker/index.js.map +1 -0
- package/build/components/dataviews-selection-checkbox/index.js +4 -2
- package/build/components/dataviews-selection-checkbox/index.js.map +1 -1
- package/build/components/dataviews-view-config/index.js +1 -0
- package/build/components/dataviews-view-config/index.js.map +1 -1
- package/build/constants.js +4 -1
- package/build/constants.js.map +1 -1
- package/build/dataform-controls/checkbox.js +23 -2
- package/build/dataform-controls/checkbox.js.map +1 -1
- package/build/dataform-controls/color.js +128 -0
- package/build/dataform-controls/color.js.map +1 -0
- package/build/dataform-controls/email.js +10 -45
- package/build/dataform-controls/email.js.map +1 -1
- package/build/dataform-controls/index.js +8 -2
- package/build/dataform-controls/index.js.map +1 -1
- package/build/dataform-controls/telephone.js +34 -0
- package/build/dataform-controls/telephone.js.map +1 -0
- package/build/dataform-controls/text.js +7 -48
- package/build/dataform-controls/text.js.map +1 -1
- package/build/dataform-controls/{boolean.js → toggle.js} +6 -4
- package/build/dataform-controls/toggle.js.map +1 -0
- package/build/dataform-controls/url.js +34 -0
- package/build/dataform-controls/url.js.map +1 -0
- package/build/dataform-controls/utils/validated-text.js +76 -0
- package/build/dataform-controls/utils/validated-text.js.map +1 -0
- package/build/dataforms-layouts/card/index.js +6 -7
- package/build/dataforms-layouts/card/index.js.map +1 -1
- package/build/dataforms-layouts/data-form-layout.js +16 -4
- package/build/dataforms-layouts/data-form-layout.js.map +1 -1
- package/build/dataforms-layouts/index.js +31 -1
- package/build/dataforms-layouts/index.js.map +1 -1
- package/build/dataforms-layouts/row/index.js +113 -0
- package/build/dataforms-layouts/row/index.js.map +1 -0
- package/build/dataviews-layouts/grid/index.js +16 -11
- package/build/dataviews-layouts/grid/index.js.map +1 -1
- package/build/dataviews-layouts/index.js +9 -1
- package/build/dataviews-layouts/index.js.map +1 -1
- package/build/dataviews-layouts/picker-grid/index.js +357 -0
- package/build/dataviews-layouts/picker-grid/index.js.map +1 -0
- package/build/dataviews-layouts/utils/grid-items.js +37 -0
- package/build/dataviews-layouts/utils/grid-items.js.map +1 -0
- package/build/dataviews-layouts/utils/preview-size-picker.js +81 -0
- package/build/dataviews-layouts/utils/preview-size-picker.js.map +1 -0
- package/build/field-types/boolean.js +1 -1
- package/build/field-types/boolean.js.map +1 -1
- package/build/field-types/color.js +113 -0
- package/build/field-types/color.js.map +1 -0
- package/build/field-types/index.js +12 -0
- package/build/field-types/index.js.map +1 -1
- package/build/field-types/telephone.js +57 -0
- package/build/field-types/telephone.js.map +1 -0
- package/build/field-types/url.js +57 -0
- package/build/field-types/url.js.map +1 -0
- package/build/normalize-form-fields.js +6 -0
- package/build/normalize-form-fields.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build/validation.js +1 -1
- package/build/validation.js.map +1 -1
- package/build-module/components/dataform-context/index.js +1 -0
- package/build-module/components/dataform-context/index.js.map +1 -1
- package/build-module/components/dataviews/index.js +11 -1
- package/build-module/components/dataviews/index.js.map +1 -1
- package/build-module/components/dataviews-context/index.js +1 -0
- package/build-module/components/dataviews-context/index.js.map +1 -1
- package/build-module/components/dataviews-layout/index.js +2 -1
- package/build-module/components/dataviews-layout/index.js.map +1 -1
- package/build-module/components/dataviews-picker/footer.js +136 -0
- package/build-module/components/dataviews-picker/footer.js.map +1 -0
- package/build-module/components/dataviews-picker/index.js +191 -0
- package/build-module/components/dataviews-picker/index.js.map +1 -0
- package/build-module/components/dataviews-selection-checkbox/index.js +4 -2
- package/build-module/components/dataviews-selection-checkbox/index.js.map +1 -1
- package/build-module/components/dataviews-view-config/index.js +1 -0
- package/build-module/components/dataviews-view-config/index.js.map +1 -1
- package/build-module/constants.js +3 -0
- package/build-module/constants.js.map +1 -1
- package/build-module/dataform-controls/checkbox.js +25 -3
- package/build-module/dataform-controls/checkbox.js.map +1 -1
- package/build-module/dataform-controls/color.js +122 -0
- package/build-module/dataform-controls/color.js.map +1 -0
- package/build-module/dataform-controls/email.js +9 -45
- package/build-module/dataform-controls/email.js.map +1 -1
- package/build-module/dataform-controls/index.js +8 -2
- package/build-module/dataform-controls/index.js.map +1 -1
- package/build-module/dataform-controls/telephone.js +27 -0
- package/build-module/dataform-controls/telephone.js.map +1 -0
- package/build-module/dataform-controls/text.js +6 -48
- package/build-module/dataform-controls/text.js.map +1 -1
- package/build-module/dataform-controls/{boolean.js → toggle.js} +5 -3
- package/build-module/dataform-controls/toggle.js.map +1 -0
- package/build-module/dataform-controls/url.js +27 -0
- package/build-module/dataform-controls/url.js.map +1 -0
- package/build-module/dataform-controls/utils/validated-text.js +70 -0
- package/build-module/dataform-controls/utils/validated-text.js.map +1 -0
- package/build-module/dataforms-layouts/card/index.js +6 -7
- package/build-module/dataforms-layouts/card/index.js.map +1 -1
- package/build-module/dataforms-layouts/data-form-layout.js +14 -4
- package/build-module/dataforms-layouts/data-form-layout.js.map +1 -1
- package/build-module/dataforms-layouts/index.js +32 -1
- package/build-module/dataforms-layouts/index.js.map +1 -1
- package/build-module/dataforms-layouts/row/index.js +106 -0
- package/build-module/dataforms-layouts/row/index.js.map +1 -0
- package/build-module/dataviews-layouts/grid/index.js +16 -11
- package/build-module/dataviews-layouts/grid/index.js.map +1 -1
- package/build-module/dataviews-layouts/index.js +10 -2
- package/build-module/dataviews-layouts/index.js.map +1 -1
- package/build-module/dataviews-layouts/picker-grid/index.js +348 -0
- package/build-module/dataviews-layouts/picker-grid/index.js.map +1 -0
- package/build-module/dataviews-layouts/utils/grid-items.js +29 -0
- package/build-module/dataviews-layouts/utils/grid-items.js.map +1 -0
- package/build-module/dataviews-layouts/utils/preview-size-picker.js +73 -0
- package/build-module/dataviews-layouts/utils/preview-size-picker.js.map +1 -0
- package/build-module/field-types/boolean.js +1 -1
- package/build-module/field-types/boolean.js.map +1 -1
- package/build-module/field-types/color.js +107 -0
- package/build-module/field-types/color.js.map +1 -0
- package/build-module/field-types/index.js +12 -0
- package/build-module/field-types/index.js.map +1 -1
- package/build-module/field-types/telephone.js +51 -0
- package/build-module/field-types/telephone.js.map +1 -0
- package/build-module/field-types/url.js +51 -0
- package/build-module/field-types/url.js.map +1 -0
- package/build-module/normalize-form-fields.js +6 -0
- package/build-module/normalize-form-fields.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-module/validation.js +1 -1
- package/build-module/validation.js.map +1 -1
- package/build-style/style-rtl.css +252 -12
- package/build-style/style.css +252 -12
- package/build-types/components/dataform/stories/index.story.d.ts +19 -4
- package/build-types/components/dataform/stories/index.story.d.ts.map +1 -1
- package/build-types/components/dataform-context/index.d.ts.map +1 -1
- package/build-types/components/dataviews/index.d.ts +1 -1
- package/build-types/components/dataviews/index.d.ts.map +1 -1
- package/build-types/components/dataviews/stories/index.story.d.ts.map +1 -1
- package/build-types/components/dataviews-context/index.d.ts +1 -0
- package/build-types/components/dataviews-context/index.d.ts.map +1 -1
- package/build-types/components/dataviews-layout/index.d.ts.map +1 -1
- package/build-types/components/dataviews-picker/footer.d.ts +4 -0
- package/build-types/components/dataviews-picker/footer.d.ts.map +1 -0
- package/build-types/components/dataviews-picker/index.d.ts +55 -0
- package/build-types/components/dataviews-picker/index.d.ts.map +1 -0
- package/build-types/components/dataviews-picker/stories/index.story.d.ts +42 -0
- package/build-types/components/dataviews-picker/stories/index.story.d.ts.map +1 -0
- package/build-types/components/dataviews-selection-checkbox/index.d.ts +2 -1
- package/build-types/components/dataviews-selection-checkbox/index.d.ts.map +1 -1
- package/build-types/components/dataviews-view-config/index.d.ts.map +1 -1
- package/build-types/constants.d.ts +1 -0
- package/build-types/constants.d.ts.map +1 -1
- package/build-types/dataform-controls/checkbox.d.ts.map +1 -1
- package/build-types/dataform-controls/color.d.ts +6 -0
- package/build-types/dataform-controls/color.d.ts.map +1 -0
- package/build-types/dataform-controls/email.d.ts.map +1 -1
- package/build-types/dataform-controls/index.d.ts.map +1 -1
- package/build-types/dataform-controls/telephone.d.ts +6 -0
- package/build-types/dataform-controls/telephone.d.ts.map +1 -0
- package/build-types/dataform-controls/text.d.ts.map +1 -1
- package/build-types/dataform-controls/toggle.d.ts +6 -0
- package/build-types/dataform-controls/toggle.d.ts.map +1 -0
- package/build-types/dataform-controls/url.d.ts +6 -0
- package/build-types/dataform-controls/url.d.ts.map +1 -0
- package/build-types/dataform-controls/utils/validated-text.d.ts +16 -0
- package/build-types/dataform-controls/utils/validated-text.d.ts.map +1 -0
- package/build-types/dataforms-layouts/card/index.d.ts +0 -3
- package/build-types/dataforms-layouts/card/index.d.ts.map +1 -1
- package/build-types/dataforms-layouts/data-form-layout.d.ts +4 -1
- package/build-types/dataforms-layouts/data-form-layout.d.ts.map +1 -1
- package/build-types/dataforms-layouts/index.d.ts +10 -0
- package/build-types/dataforms-layouts/index.d.ts.map +1 -1
- package/build-types/dataforms-layouts/row/index.d.ts +6 -0
- package/build-types/dataforms-layouts/row/index.d.ts.map +1 -0
- package/build-types/dataviews-layouts/grid/index.d.ts.map +1 -1
- package/build-types/dataviews-layouts/index.d.ts +12 -1
- package/build-types/dataviews-layouts/index.d.ts.map +1 -1
- package/build-types/dataviews-layouts/picker-grid/index.d.ts +4 -0
- package/build-types/dataviews-layouts/picker-grid/index.d.ts.map +1 -0
- package/build-types/dataviews-layouts/utils/grid-items.d.ts +5 -0
- package/build-types/dataviews-layouts/utils/grid-items.d.ts.map +1 -0
- package/build-types/dataviews-layouts/utils/preview-size-picker.d.ts +2 -0
- package/build-types/dataviews-layouts/utils/preview-size-picker.d.ts.map +1 -0
- package/build-types/field-types/color.d.ts +20 -0
- package/build-types/field-types/color.d.ts.map +1 -0
- package/build-types/field-types/index.d.ts.map +1 -1
- package/build-types/field-types/stories/index.story.d.ts +81 -0
- package/build-types/field-types/stories/index.story.d.ts.map +1 -0
- package/build-types/field-types/telephone.d.ts +20 -0
- package/build-types/field-types/telephone.d.ts.map +1 -0
- package/build-types/field-types/url.d.ts +20 -0
- package/build-types/field-types/url.d.ts.map +1 -0
- package/build-types/normalize-form-fields.d.ts.map +1 -1
- package/build-types/test/dataviews-picker.d.ts +2 -0
- package/build-types/test/dataviews-picker.d.ts.map +1 -0
- package/build-types/types.d.ts +36 -5
- package/build-types/types.d.ts.map +1 -1
- package/build-types/validation.d.ts.map +1 -1
- package/build-wp/index.js +5061 -4013
- package/package.json +16 -15
- package/src/components/dataform/stories/index.story.tsx +333 -11
- package/src/components/dataform-context/index.tsx +1 -0
- package/src/components/dataviews/index.tsx +25 -1
- package/src/components/dataviews/stories/fixtures.tsx +1 -1
- package/src/components/dataviews/stories/index.story.tsx +14 -0
- package/src/components/dataviews/style.scss +4 -2
- package/src/components/dataviews-context/index.ts +3 -0
- package/src/components/dataviews-layout/index.tsx +4 -2
- package/src/components/dataviews-picker/footer.tsx +207 -0
- package/src/components/dataviews-picker/index.tsx +284 -0
- package/src/components/dataviews-picker/stories/index.story.tsx +251 -0
- package/src/components/dataviews-picker/style.scss +10 -0
- package/src/components/dataviews-selection-checkbox/index.tsx +3 -0
- package/src/components/dataviews-view-config/index.tsx +1 -0
- package/src/constants.ts +3 -0
- package/src/dataform-controls/checkbox.tsx +33 -3
- package/src/dataform-controls/color.tsx +139 -0
- package/src/dataform-controls/email.tsx +10 -52
- package/src/dataform-controls/index.tsx +8 -2
- package/src/dataform-controls/telephone.tsx +30 -0
- package/src/dataform-controls/text.tsx +2 -57
- package/src/dataform-controls/{boolean.tsx → toggle.tsx} +3 -2
- package/src/dataform-controls/url.tsx +30 -0
- package/src/dataform-controls/utils/validated-text.tsx +96 -0
- package/src/dataforms-layouts/card/index.tsx +5 -4
- package/src/dataforms-layouts/card/style.scss +7 -0
- package/src/dataforms-layouts/data-form-layout.tsx +15 -3
- package/src/dataforms-layouts/index.tsx +35 -0
- package/src/dataforms-layouts/row/index.tsx +115 -0
- package/src/dataforms-layouts/row/style.scss +3 -0
- package/src/dataviews-layouts/grid/index.tsx +38 -33
- package/src/dataviews-layouts/grid/style.scss +42 -20
- package/src/dataviews-layouts/index.ts +16 -2
- package/src/dataviews-layouts/picker-grid/index.tsx +490 -0
- package/src/dataviews-layouts/picker-grid/style.scss +171 -0
- package/src/dataviews-layouts/utils/grid-items.scss +21 -0
- package/src/dataviews-layouts/utils/grid-items.tsx +35 -0
- package/src/dataviews-layouts/utils/preview-size-picker.tsx +87 -0
- package/src/field-types/boolean.tsx +1 -1
- package/src/field-types/color.tsx +115 -0
- package/src/field-types/index.tsx +15 -0
- package/src/field-types/stories/index.story.tsx +719 -0
- package/src/field-types/telephone.tsx +71 -0
- package/src/field-types/url.tsx +71 -0
- package/src/normalize-form-fields.ts +6 -0
- package/src/style.scss +4 -0
- package/src/test/dataform.tsx +2 -2
- package/src/test/dataviews-picker.tsx +478 -0
- package/src/test/dataviews.tsx +86 -0
- package/src/types.ts +56 -4
- package/src/validation.ts +3 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/dataform-controls/boolean.js.map +0 -1
- package/build-module/dataform-controls/boolean.js.map +0 -1
- package/build-types/components/stories/index.story.d.ts +0 -63
- package/build-types/components/stories/index.story.d.ts.map +0 -1
- package/build-types/dataform-controls/boolean.d.ts +0 -6
- package/build-types/dataform-controls/boolean.d.ts.map +0 -1
- package/src/components/stories/index.story.tsx +0 -372
|
@@ -10,24 +10,30 @@ import checkbox from './checkbox';
|
|
|
10
10
|
import datetime from './datetime';
|
|
11
11
|
import date from './date';
|
|
12
12
|
import email from './email';
|
|
13
|
+
import telephone from './telephone';
|
|
14
|
+
import url from './url';
|
|
13
15
|
import integer from './integer';
|
|
14
16
|
import radio from './radio';
|
|
15
17
|
import select from './select';
|
|
16
18
|
import text from './text';
|
|
19
|
+
import toggle from './toggle';
|
|
17
20
|
import toggleGroup from './toggle-group';
|
|
18
|
-
import boolean from './boolean';
|
|
19
21
|
import array from './array';
|
|
22
|
+
import color from './color';
|
|
20
23
|
const FORM_CONTROLS = {
|
|
21
24
|
array,
|
|
22
|
-
boolean,
|
|
23
25
|
checkbox,
|
|
26
|
+
color,
|
|
24
27
|
datetime,
|
|
25
28
|
date,
|
|
26
29
|
email,
|
|
30
|
+
telephone,
|
|
31
|
+
url,
|
|
27
32
|
integer,
|
|
28
33
|
radio,
|
|
29
34
|
select,
|
|
30
35
|
text,
|
|
36
|
+
toggle,
|
|
31
37
|
toggleGroup
|
|
32
38
|
};
|
|
33
39
|
export function getControl(field, fieldTypeDefinition) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["checkbox","datetime","date","email","integer","radio","select","text","
|
|
1
|
+
{"version":3,"names":["checkbox","datetime","date","email","telephone","url","integer","radio","select","text","toggle","toggleGroup","array","color","FORM_CONTROLS","getControl","field","fieldTypeDefinition","Edit","getControlByType","elements","type","Object","keys","includes"],"sources":["@wordpress/dataviews/src/dataform-controls/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ComponentType } from 'react';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tDataFormControlProps,\n\tField,\n\tFieldTypeDefinition,\n} from '../types';\nimport checkbox from './checkbox';\nimport datetime from './datetime';\nimport date from './date';\nimport email from './email';\nimport telephone from './telephone';\nimport url from './url';\nimport integer from './integer';\nimport radio from './radio';\nimport select from './select';\nimport text from './text';\nimport toggle from './toggle';\nimport toggleGroup from './toggle-group';\nimport array from './array';\nimport color from './color';\n\ninterface FormControls {\n\t[ key: string ]: ComponentType< DataFormControlProps< any > >;\n}\n\nconst FORM_CONTROLS: FormControls = {\n\tarray,\n\tcheckbox,\n\tcolor,\n\tdatetime,\n\tdate,\n\temail,\n\ttelephone,\n\turl,\n\tinteger,\n\tradio,\n\tselect,\n\ttext,\n\ttoggle,\n\ttoggleGroup,\n};\n\nexport function getControl< Item >(\n\tfield: Field< Item >,\n\tfieldTypeDefinition: FieldTypeDefinition< Item >\n) {\n\tif ( typeof field.Edit === 'function' ) {\n\t\treturn field.Edit;\n\t}\n\n\tif ( typeof field.Edit === 'string' ) {\n\t\treturn getControlByType( field.Edit );\n\t}\n\n\tif ( field.elements && field.type !== 'array' ) {\n\t\treturn getControlByType( 'select' );\n\t}\n\n\tif ( typeof fieldTypeDefinition.Edit === 'string' ) {\n\t\treturn getControlByType( fieldTypeDefinition.Edit );\n\t}\n\n\treturn fieldTypeDefinition.Edit;\n}\n\nexport function getControlByType( type: string ) {\n\tif ( Object.keys( FORM_CONTROLS ).includes( type ) ) {\n\t\treturn FORM_CONTROLS[ type ];\n\t}\n\n\tthrow 'Control ' + type + ' not found';\n}\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;;AAMA,OAAOA,QAAQ,MAAM,YAAY;AACjC,OAAOC,QAAQ,MAAM,YAAY;AACjC,OAAOC,IAAI,MAAM,QAAQ;AACzB,OAAOC,KAAK,MAAM,SAAS;AAC3B,OAAOC,SAAS,MAAM,aAAa;AACnC,OAAOC,GAAG,MAAM,OAAO;AACvB,OAAOC,OAAO,MAAM,WAAW;AAC/B,OAAOC,KAAK,MAAM,SAAS;AAC3B,OAAOC,MAAM,MAAM,UAAU;AAC7B,OAAOC,IAAI,MAAM,QAAQ;AACzB,OAAOC,MAAM,MAAM,UAAU;AAC7B,OAAOC,WAAW,MAAM,gBAAgB;AACxC,OAAOC,KAAK,MAAM,SAAS;AAC3B,OAAOC,KAAK,MAAM,SAAS;AAM3B,MAAMC,aAA2B,GAAG;EACnCF,KAAK;EACLZ,QAAQ;EACRa,KAAK;EACLZ,QAAQ;EACRC,IAAI;EACJC,KAAK;EACLC,SAAS;EACTC,GAAG;EACHC,OAAO;EACPC,KAAK;EACLC,MAAM;EACNC,IAAI;EACJC,MAAM;EACNC;AACD,CAAC;AAED,OAAO,SAASI,UAAUA,CACzBC,KAAoB,EACpBC,mBAAgD,EAC/C;EACD,IAAK,OAAOD,KAAK,CAACE,IAAI,KAAK,UAAU,EAAG;IACvC,OAAOF,KAAK,CAACE,IAAI;EAClB;EAEA,IAAK,OAAOF,KAAK,CAACE,IAAI,KAAK,QAAQ,EAAG;IACrC,OAAOC,gBAAgB,CAAEH,KAAK,CAACE,IAAK,CAAC;EACtC;EAEA,IAAKF,KAAK,CAACI,QAAQ,IAAIJ,KAAK,CAACK,IAAI,KAAK,OAAO,EAAG;IAC/C,OAAOF,gBAAgB,CAAE,QAAS,CAAC;EACpC;EAEA,IAAK,OAAOF,mBAAmB,CAACC,IAAI,KAAK,QAAQ,EAAG;IACnD,OAAOC,gBAAgB,CAAEF,mBAAmB,CAACC,IAAK,CAAC;EACpD;EAEA,OAAOD,mBAAmB,CAACC,IAAI;AAChC;AAEA,OAAO,SAASC,gBAAgBA,CAAEE,IAAY,EAAG;EAChD,IAAKC,MAAM,CAACC,IAAI,CAAET,aAAc,CAAC,CAACU,QAAQ,CAAEH,IAAK,CAAC,EAAG;IACpD,OAAOP,aAAa,CAAEO,IAAI,CAAE;EAC7B;EAEA,MAAM,UAAU,GAAGA,IAAI,GAAG,YAAY;AACvC","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { mobile } from '@wordpress/icons';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import ValidatedText from './utils/validated-text';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
export default function Telephone({
|
|
13
|
+
data,
|
|
14
|
+
field,
|
|
15
|
+
onChange,
|
|
16
|
+
hideLabelFromVision
|
|
17
|
+
}) {
|
|
18
|
+
return /*#__PURE__*/_jsx(ValidatedText, {
|
|
19
|
+
data,
|
|
20
|
+
field,
|
|
21
|
+
onChange,
|
|
22
|
+
hideLabelFromVision,
|
|
23
|
+
type: 'tel',
|
|
24
|
+
icon: mobile
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=telephone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["mobile","ValidatedText","jsx","_jsx","Telephone","data","field","onChange","hideLabelFromVision","type","icon"],"sources":["@wordpress/dataviews/src/dataform-controls/telephone.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { mobile } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport type { DataFormControlProps } from '../types';\nimport ValidatedText from './utils/validated-text';\n\nexport default function Telephone< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n}: DataFormControlProps< Item > ) {\n\treturn (\n\t\t<ValidatedText\n\t\t\t{ ...{\n\t\t\t\tdata,\n\t\t\t\tfield,\n\t\t\t\tonChange,\n\t\t\t\thideLabelFromVision,\n\t\t\t\ttype: 'tel',\n\t\t\t\ticon: mobile,\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,kBAAkB;;AAEzC;AACA;AACA;;AAEA,OAAOC,aAAa,MAAM,wBAAwB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEnD,eAAe,SAASC,SAASA,CAAU;EAC1CC,IAAI;EACJC,KAAK;EACLC,QAAQ;EACRC;AAC6B,CAAC,EAAG;EACjC,oBACCL,IAAA,CAACF,aAAa;IAEZI,IAAI;IACJC,KAAK;IACLC,QAAQ;IACRC,mBAAmB;IACnBC,IAAI,EAAE,KAAK;IACXC,IAAI,EAAEV;EAAM,CAEb,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -1,62 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { privateApis } from '@wordpress/components';
|
|
5
|
-
import { useCallback, useState } from '@wordpress/element';
|
|
6
|
-
|
|
7
1
|
/**
|
|
8
2
|
* Internal dependencies
|
|
9
3
|
*/
|
|
10
4
|
|
|
11
|
-
import
|
|
5
|
+
import ValidatedText from './utils/validated-text';
|
|
12
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
const {
|
|
14
|
-
ValidatedTextControl
|
|
15
|
-
} = unlock(privateApis);
|
|
16
7
|
export default function Text({
|
|
17
8
|
data,
|
|
18
9
|
field,
|
|
19
10
|
onChange,
|
|
20
11
|
hideLabelFromVision
|
|
21
12
|
}) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
} = field;
|
|
28
|
-
const value = field.getValue({
|
|
29
|
-
item: data
|
|
30
|
-
});
|
|
31
|
-
const [customValidity, setCustomValidity] = useState(undefined);
|
|
32
|
-
const onChangeControl = useCallback(newValue => onChange({
|
|
33
|
-
[id]: newValue
|
|
34
|
-
}), [id, onChange]);
|
|
35
|
-
return /*#__PURE__*/_jsx(ValidatedTextControl, {
|
|
36
|
-
required: !!field.isValid?.required,
|
|
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;
|
|
48
|
-
}
|
|
49
|
-
setCustomValidity(undefined);
|
|
50
|
-
},
|
|
51
|
-
customValidity: customValidity,
|
|
52
|
-
label: label,
|
|
53
|
-
placeholder: placeholder,
|
|
54
|
-
value: value !== null && value !== void 0 ? value : '',
|
|
55
|
-
help: description,
|
|
56
|
-
onChange: onChangeControl,
|
|
57
|
-
__next40pxDefaultSize: true,
|
|
58
|
-
__nextHasNoMarginBottom: true,
|
|
59
|
-
hideLabelFromVision: hideLabelFromVision
|
|
13
|
+
return /*#__PURE__*/_jsx(ValidatedText, {
|
|
14
|
+
data,
|
|
15
|
+
field,
|
|
16
|
+
onChange,
|
|
17
|
+
hideLabelFromVision
|
|
60
18
|
});
|
|
61
19
|
}
|
|
62
20
|
//# sourceMappingURL=text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["ValidatedText","jsx","_jsx","Text","data","field","onChange","hideLabelFromVision"],"sources":["@wordpress/dataviews/src/dataform-controls/text.tsx"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { DataFormControlProps } from '../types';\nimport ValidatedText from './utils/validated-text';\n\nexport default function Text< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n}: DataFormControlProps< Item > ) {\n\treturn (\n\t\t<ValidatedText { ...{ data, field, onChange, hideLabelFromVision } } />\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;;AAEA,OAAOA,aAAa,MAAM,wBAAwB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEnD,eAAe,SAASC,IAAIA,CAAU;EACrCC,IAAI;EACJC,KAAK;EACLC,QAAQ;EACRC;AAC6B,CAAC,EAAG;EACjC,oBACCL,IAAA,CAACF,aAAa;IAAQI,IAAI;IAAEC,KAAK;IAAEC,QAAQ;IAAEC;EAAmB,CAAM,CAAC;AAEzE","ignoreList":[]}
|
|
@@ -13,7 +13,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
13
13
|
const {
|
|
14
14
|
ValidatedToggleControl
|
|
15
15
|
} = unlock(privateApis);
|
|
16
|
-
export default function
|
|
16
|
+
export default function Toggle({
|
|
17
17
|
field,
|
|
18
18
|
onChange,
|
|
19
19
|
data,
|
|
@@ -22,7 +22,8 @@ export default function Boolean({
|
|
|
22
22
|
const {
|
|
23
23
|
id,
|
|
24
24
|
getValue,
|
|
25
|
-
label
|
|
25
|
+
label,
|
|
26
|
+
description
|
|
26
27
|
} = field;
|
|
27
28
|
const [customValidity, setCustomValidity] = useState(undefined);
|
|
28
29
|
return /*#__PURE__*/_jsx(ValidatedToggleControl, {
|
|
@@ -45,6 +46,7 @@ export default function Boolean({
|
|
|
45
46
|
hidden: hideLabelFromVision,
|
|
46
47
|
__nextHasNoMarginBottom: true,
|
|
47
48
|
label: label,
|
|
49
|
+
help: description,
|
|
48
50
|
checked: getValue({
|
|
49
51
|
item: data
|
|
50
52
|
}),
|
|
@@ -55,4 +57,4 @@ export default function Boolean({
|
|
|
55
57
|
})
|
|
56
58
|
});
|
|
57
59
|
}
|
|
58
|
-
//# sourceMappingURL=
|
|
60
|
+
//# sourceMappingURL=toggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["privateApis","useState","unlock","jsx","_jsx","ValidatedToggleControl","Toggle","field","onChange","data","hideLabelFromVision","id","getValue","label","description","customValidity","setCustomValidity","undefined","required","isValid","onValidate","newValue","message","custom","type","hidden","__nextHasNoMarginBottom","help","checked","item"],"sources":["@wordpress/dataviews/src/dataform-controls/toggle.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 Toggle< Item >( {\n\tfield,\n\tonChange,\n\tdata,\n\thideLabelFromVision,\n}: DataFormControlProps< Item > ) {\n\tconst { id, getValue, label, description } = 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\thelp={ description }\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,MAAMA,CAAU;EACvCC,KAAK;EACLC,QAAQ;EACRC,IAAI;EACJC;AAC6B,CAAC,EAAG;EACjC,MAAM;IAAEC,EAAE;IAAEC,QAAQ;IAAEC,KAAK;IAAEC;EAAY,CAAC,GAAGP,KAAK;EAClD,MAAM,CAAEQ,cAAc,EAAEC,iBAAiB,CAAE,GAC1Cf,QAAQ,CAILgB,SAAU,CAAC;EAEf,oBACCb,IAAA,CAACC,sBAAsB;IACtBa,QAAQ,EAAG,CAAC,CAAEX,KAAK,CAACY,OAAO,CAACD,QAAU;IACtCE,UAAU,EAAKC,QAAa,IAAM;MACjC,MAAMC,OAAO,GAAGf,KAAK,CAACY,OAAO,EAAEI,MAAM,GACpC;QACC,GAAGd,IAAI;QACP,CAAEE,EAAE,GAAIU;MACT,CAAC,EACDd,KACD,CAAC;MAED,IAAKe,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,EAAGf,mBAAqB;IAC9BgB,uBAAuB;IACvBb,KAAK,EAAGA,KAAO;IACfc,IAAI,EAAGb,WAAa;IACpBc,OAAO,EAAGhB,QAAQ,CAAE;MAAEiB,IAAI,EAAEpB;IAAK,CAAE,CAAG;IACtCD,QAAQ,EAAGA,CAAA,KACVA,QAAQ,CAAE;MAAE,CAAEG,EAAE,GAAI,CAAEC,QAAQ,CAAE;QAAEiB,IAAI,EAAEpB;MAAK,CAAE;IAAE,CAAE;EACnD,CACD,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { link } from '@wordpress/icons';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import ValidatedText from './utils/validated-text';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
export default function Url({
|
|
13
|
+
data,
|
|
14
|
+
field,
|
|
15
|
+
onChange,
|
|
16
|
+
hideLabelFromVision
|
|
17
|
+
}) {
|
|
18
|
+
return /*#__PURE__*/_jsx(ValidatedText, {
|
|
19
|
+
data,
|
|
20
|
+
field,
|
|
21
|
+
onChange,
|
|
22
|
+
hideLabelFromVision,
|
|
23
|
+
type: 'url',
|
|
24
|
+
icon: link
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["link","ValidatedText","jsx","_jsx","Url","data","field","onChange","hideLabelFromVision","type","icon"],"sources":["@wordpress/dataviews/src/dataform-controls/url.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { link } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport type { DataFormControlProps } from '../types';\nimport ValidatedText from './utils/validated-text';\n\nexport default function Url< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n}: DataFormControlProps< Item > ) {\n\treturn (\n\t\t<ValidatedText\n\t\t\t{ ...{\n\t\t\t\tdata,\n\t\t\t\tfield,\n\t\t\t\tonChange,\n\t\t\t\thideLabelFromVision,\n\t\t\t\ttype: 'url',\n\t\t\t\ticon: link,\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAI,QAAQ,kBAAkB;;AAEvC;AACA;AACA;;AAEA,OAAOC,aAAa,MAAM,wBAAwB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEnD,eAAe,SAASC,GAAGA,CAAU;EACpCC,IAAI;EACJC,KAAK;EACLC,QAAQ;EACRC;AAC6B,CAAC,EAAG;EACjC,oBACCL,IAAA,CAACF,aAAa;IAEZI,IAAI;IACJC,KAAK;IACLC,QAAQ;IACRC,mBAAmB;IACnBC,IAAI,EAAE,KAAK;IACXC,IAAI,EAAEV;EAAI,CAEX,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { Icon, privateApis, __experimentalInputControlPrefixWrapper as InputControlPrefixWrapper } from '@wordpress/components';
|
|
5
|
+
import { useCallback, useState } from '@wordpress/element';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { unlock } from '../../lock-unlock';
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
const {
|
|
14
|
+
ValidatedInputControl
|
|
15
|
+
} = unlock(privateApis);
|
|
16
|
+
export default function ValidatedText({
|
|
17
|
+
data,
|
|
18
|
+
field,
|
|
19
|
+
onChange,
|
|
20
|
+
hideLabelFromVision,
|
|
21
|
+
type,
|
|
22
|
+
icon
|
|
23
|
+
}) {
|
|
24
|
+
const {
|
|
25
|
+
id,
|
|
26
|
+
label,
|
|
27
|
+
placeholder,
|
|
28
|
+
description
|
|
29
|
+
} = field;
|
|
30
|
+
const value = field.getValue({
|
|
31
|
+
item: data
|
|
32
|
+
});
|
|
33
|
+
const [customValidity, setCustomValidity] = useState(undefined);
|
|
34
|
+
const onChangeControl = useCallback(newValue => onChange({
|
|
35
|
+
[id]: newValue
|
|
36
|
+
}), [id, onChange]);
|
|
37
|
+
return /*#__PURE__*/_jsx(ValidatedInputControl, {
|
|
38
|
+
required: !!field.isValid?.required,
|
|
39
|
+
onValidate: newValue => {
|
|
40
|
+
const message = field.isValid?.custom?.({
|
|
41
|
+
...data,
|
|
42
|
+
[id]: newValue
|
|
43
|
+
}, field);
|
|
44
|
+
if (message) {
|
|
45
|
+
setCustomValidity({
|
|
46
|
+
type: 'invalid',
|
|
47
|
+
message
|
|
48
|
+
});
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
setCustomValidity(undefined);
|
|
52
|
+
},
|
|
53
|
+
customValidity: customValidity,
|
|
54
|
+
label: label,
|
|
55
|
+
placeholder: placeholder,
|
|
56
|
+
value: value !== null && value !== void 0 ? value : '',
|
|
57
|
+
help: description,
|
|
58
|
+
onChange: onChangeControl,
|
|
59
|
+
hideLabelFromVision: hideLabelFromVision,
|
|
60
|
+
type: type,
|
|
61
|
+
prefix: icon ? /*#__PURE__*/_jsx(InputControlPrefixWrapper, {
|
|
62
|
+
variant: "icon",
|
|
63
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
64
|
+
icon: icon
|
|
65
|
+
})
|
|
66
|
+
}) : undefined,
|
|
67
|
+
__next40pxDefaultSize: true
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=validated-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Icon","privateApis","__experimentalInputControlPrefixWrapper","InputControlPrefixWrapper","useCallback","useState","unlock","jsx","_jsx","ValidatedInputControl","ValidatedText","data","field","onChange","hideLabelFromVision","type","icon","id","label","placeholder","description","value","getValue","item","customValidity","setCustomValidity","undefined","onChangeControl","newValue","required","isValid","onValidate","message","custom","help","prefix","variant","children","__next40pxDefaultSize"],"sources":["@wordpress/dataviews/src/dataform-controls/utils/validated-text.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\tprivateApis,\n\t__experimentalInputControlPrefixWrapper as InputControlPrefixWrapper,\n} 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 { ValidatedInputControl } = unlock( privateApis );\n\nexport type DataFormValidatedTextControlProps< Item > =\n\tDataFormControlProps< Item > & {\n\t\t/**\n\t\t * The input type of the control.\n\t\t */\n\t\ttype?: 'text' | 'email' | 'tel' | 'url';\n\t\t/**\n\t\t * Optional icon to display as prefix.\n\t\t */\n\t\ticon?: React.ComponentType | React.ReactElement;\n\t};\n\nexport default function ValidatedText< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n\ttype,\n\ticon,\n}: DataFormValidatedTextControlProps< 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 ValidatedInputControl\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<ValidatedInputControl\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\thideLabelFromVision={ hideLabelFromVision }\n\t\t\ttype={ type }\n\t\t\tprefix={\n\t\t\t\ticon ? (\n\t\t\t\t\t<InputControlPrefixWrapper variant=\"icon\">\n\t\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t\t</InputControlPrefixWrapper>\n\t\t\t\t) : undefined\n\t\t\t}\n\t\t\t__next40pxDefaultSize\n\t\t/>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,IAAI,EACJC,WAAW,EACXC,uCAAuC,IAAIC,yBAAyB,QAC9D,uBAAuB;AAC9B,SAASC,WAAW,EAAEC,QAAQ,QAAQ,oBAAoB;;AAE1D;AACA;AACA;;AAEA,SAASC,MAAM,QAAQ,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE3C,MAAM;EAAEC;AAAsB,CAAC,GAAG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CC,IAAI,EAAGA,IAAM;IACboB,MAAM,EACLnB,IAAI,gBACHR,IAAA,CAACL,yBAAyB;MAACiC,OAAO,EAAC,MAAM;MAAAC,QAAA,eACxC7B,IAAA,CAACR,IAAI;QAACgB,IAAI,EAAGA;MAAM,CAAE;IAAC,CACI,CAAC,GACzBU,SACJ;IACDY,qBAAqB;EAAA,CACrB,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
1
|
/**
|
|
6
2
|
* WordPress dependencies
|
|
7
3
|
*/
|
|
@@ -86,13 +82,16 @@ export default function FormCardField({
|
|
|
86
82
|
/*#__PURE__*/
|
|
87
83
|
// If it doesn't have a header, keep it open.
|
|
88
84
|
// Otherwise, the card will not be visible.
|
|
89
|
-
|
|
85
|
+
_jsxs(CardBody, {
|
|
90
86
|
className: "dataforms-layouts-card__field-control",
|
|
91
|
-
children: /*#__PURE__*/_jsx(
|
|
87
|
+
children: [field.description && /*#__PURE__*/_jsx("div", {
|
|
88
|
+
className: "dataforms-layouts-card__field-description",
|
|
89
|
+
children: field.description
|
|
90
|
+
}), /*#__PURE__*/_jsx(DataFormLayout, {
|
|
92
91
|
data: data,
|
|
93
92
|
form: form,
|
|
94
93
|
onChange: onChange
|
|
95
|
-
})
|
|
94
|
+
})]
|
|
96
95
|
})]
|
|
97
96
|
});
|
|
98
97
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Button","Card","CardBody","CardHeader","useCallback","useContext","useMemo","useState","chevronDown","chevronUp","getFormFieldLayout","DataFormContext","DataFormLayout","isCombinedField","DEFAULT_LAYOUT","normalizeLayout","jsx","_jsx","jsxs","_jsxs","useCollapsibleCard","initialIsOpen","isOpen","setIsOpen","toggle","prev","CollapsibleCardHeader","children","props","onClick","style","cursor","width","display","justifyContent","alignItems","__next40pxDefaultSize","variant","icon","FormCardField","data","field","onChange","hideLabelFromVision","fields","layout","type","form","isOpened","withHeader","label","className","fieldDefinition","find","fieldDef","id","Edit","RegularLayout","component"],"sources":["@wordpress/dataviews/src/dataforms-layouts/card/index.tsx"],"sourcesContent":["/**\n *
|
|
1
|
+
{"version":3,"names":["Button","Card","CardBody","CardHeader","useCallback","useContext","useMemo","useState","chevronDown","chevronUp","getFormFieldLayout","DataFormContext","DataFormLayout","isCombinedField","DEFAULT_LAYOUT","normalizeLayout","jsx","_jsx","jsxs","_jsxs","useCollapsibleCard","initialIsOpen","isOpen","setIsOpen","toggle","prev","CollapsibleCardHeader","children","props","onClick","style","cursor","width","display","justifyContent","alignItems","__next40pxDefaultSize","variant","icon","FormCardField","data","field","onChange","hideLabelFromVision","fields","layout","type","form","isOpened","withHeader","label","className","description","fieldDefinition","find","fieldDef","id","Edit","RegularLayout","component"],"sources":["@wordpress/dataviews/src/dataforms-layouts/card/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, Card, CardBody, CardHeader } from '@wordpress/components';\nimport { useCallback, useContext, useMemo, useState } from '@wordpress/element';\nimport { chevronDown, chevronUp } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { getFormFieldLayout } from '..';\nimport DataFormContext from '../../components/dataform-context';\nimport type { NormalizedCardLayout, FieldLayoutProps, Form } from '../../types';\nimport { DataFormLayout } from '../data-form-layout';\nimport { isCombinedField } from '../is-combined-field';\nimport { DEFAULT_LAYOUT, normalizeLayout } from '../../normalize-form-fields';\n\nexport function useCollapsibleCard( initialIsOpen: boolean = true ) {\n\tconst [ isOpen, setIsOpen ] = useState( initialIsOpen );\n\n\tconst toggle = useCallback( () => {\n\t\tsetIsOpen( ( prev ) => ! prev );\n\t}, [] );\n\n\tconst CollapsibleCardHeader = useCallback(\n\t\t( {\n\t\t\tchildren,\n\t\t\t...props\n\t\t}: {\n\t\t\tchildren: React.ReactNode;\n\t\t\t[ key: string ]: any;\n\t\t} ) => (\n\t\t\t<CardHeader\n\t\t\t\t{ ...props }\n\t\t\t\tonClick={ toggle }\n\t\t\t\tstyle={ {\n\t\t\t\t\tcursor: 'pointer',\n\t\t\t\t\t...props.style,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\tjustifyContent: 'space-between',\n\t\t\t\t\t\talignItems: 'center',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</div>\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\ticon={ isOpen ? chevronUp : chevronDown }\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-label={ isOpen ? 'Collapse' : 'Expand' }\n\t\t\t\t/>\n\t\t\t</CardHeader>\n\t\t),\n\t\t[ toggle, isOpen ]\n\t);\n\n\treturn { isOpen, CollapsibleCardHeader };\n}\n\nexport default function FormCardField< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n}: FieldLayoutProps< Item > ) {\n\tconst { fields } = useContext( DataFormContext );\n\n\tconst layout: NormalizedCardLayout = normalizeLayout( {\n\t\t...field.layout,\n\t\ttype: 'card',\n\t} ) as NormalizedCardLayout;\n\n\tconst form: Form = useMemo(\n\t\t(): Form => ( {\n\t\t\tlayout: DEFAULT_LAYOUT,\n\t\t\tfields: isCombinedField( field ) ? field.children : [],\n\t\t} ),\n\t\t[ field ]\n\t);\n\n\tconst { isOpen, CollapsibleCardHeader } = useCollapsibleCard(\n\t\tlayout.isOpened\n\t);\n\tif ( isCombinedField( field ) ) {\n\t\tconst withHeader = !! field.label && layout.withHeader;\n\t\treturn (\n\t\t\t<Card className=\"dataforms-layouts-card__field\">\n\t\t\t\t{ withHeader && (\n\t\t\t\t\t<CollapsibleCardHeader className=\"dataforms-layouts-card__field-label\">\n\t\t\t\t\t\t{ field.label }\n\t\t\t\t\t</CollapsibleCardHeader>\n\t\t\t\t) }\n\t\t\t\t{ ( isOpen || ! withHeader ) && (\n\t\t\t\t\t// If it doesn't have a header, keep it open.\n\t\t\t\t\t// Otherwise, the card will not be visible.\n\t\t\t\t\t<CardBody className=\"dataforms-layouts-card__field-control\">\n\t\t\t\t\t\t{ field.description && (\n\t\t\t\t\t\t\t<div className=\"dataforms-layouts-card__field-description\">\n\t\t\t\t\t\t\t\t{ field.description }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<DataFormLayout\n\t\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\t\tform={ form }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</CardBody>\n\t\t\t\t) }\n\t\t\t</Card>\n\t\t);\n\t}\n\n\tconst fieldDefinition = fields.find(\n\t\t( fieldDef ) => fieldDef.id === field.id\n\t);\n\n\tif ( ! fieldDefinition || ! fieldDefinition.Edit ) {\n\t\treturn null;\n\t}\n\n\tconst RegularLayout = getFormFieldLayout( 'regular' )?.component;\n\tif ( ! RegularLayout ) {\n\t\treturn null;\n\t}\n\tconst withHeader = !! fieldDefinition.label && layout.withHeader;\n\treturn (\n\t\t<Card className=\"dataforms-layouts-card__field\">\n\t\t\t{ withHeader && (\n\t\t\t\t<CollapsibleCardHeader className=\"dataforms-layouts-card__field-label\">\n\t\t\t\t\t{ fieldDefinition.label }\n\t\t\t\t</CollapsibleCardHeader>\n\t\t\t) }\n\t\t\t{ ( isOpen || ! withHeader ) && (\n\t\t\t\t// If it doesn't have a header, keep it open.\n\t\t\t\t// Otherwise, the card will not be visible.\n\t\t\t\t<CardBody className=\"dataforms-layouts-card__field-control\">\n\t\t\t\t\t<RegularLayout\n\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\tfield={ field }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\thideLabelFromVision={\n\t\t\t\t\t\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A,KAAO;QACfC,QAAQ,EAAGA,QAAU;QACrBC,mBAAmB,EAClBA,mBAAmB,IAAIM;MACvB,CACD;IAAC,CACO,CACV;EAAA,CACI,CAAC;AAET","ignoreList":[]}
|
|
@@ -11,14 +11,22 @@ import { useContext, useMemo } from '@wordpress/element';
|
|
|
11
11
|
import { getFormFieldLayout } from './index';
|
|
12
12
|
import DataFormContext from '../components/dataform-context';
|
|
13
13
|
import { isCombinedField } from './is-combined-field';
|
|
14
|
-
import normalizeFormFields from '../normalize-form-fields';
|
|
14
|
+
import normalizeFormFields, { normalizeLayout } from '../normalize-form-fields';
|
|
15
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
const DEFAULT_WRAPPER = ({
|
|
17
|
+
children
|
|
18
|
+
}) => /*#__PURE__*/_jsx(VStack, {
|
|
19
|
+
spacing: 4,
|
|
20
|
+
children: children
|
|
21
|
+
});
|
|
16
22
|
export function DataFormLayout({
|
|
17
23
|
data,
|
|
18
24
|
form,
|
|
19
25
|
onChange,
|
|
20
|
-
children
|
|
26
|
+
children,
|
|
27
|
+
as
|
|
21
28
|
}) {
|
|
29
|
+
var _ref;
|
|
22
30
|
const {
|
|
23
31
|
fields: fieldDefinitions
|
|
24
32
|
} = useContext(DataFormContext);
|
|
@@ -27,8 +35,10 @@ export function DataFormLayout({
|
|
|
27
35
|
return fieldDefinitions.find(fieldDefinition => fieldDefinition.id === fieldId);
|
|
28
36
|
}
|
|
29
37
|
const normalizedFormFields = useMemo(() => normalizeFormFields(form), [form]);
|
|
30
|
-
|
|
31
|
-
|
|
38
|
+
const normalizedFormLayout = normalizeLayout(form.layout);
|
|
39
|
+
const Wrapper = (_ref = as !== null && as !== void 0 ? as : getFormFieldLayout(normalizedFormLayout.type)?.wrapper) !== null && _ref !== void 0 ? _ref : DEFAULT_WRAPPER;
|
|
40
|
+
return /*#__PURE__*/_jsx(Wrapper, {
|
|
41
|
+
layout: normalizedFormLayout,
|
|
32
42
|
children: normalizedFormFields.map(formField => {
|
|
33
43
|
const FieldLayout = getFormFieldLayout(formField.layout.type)?.component;
|
|
34
44
|
if (!FieldLayout) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__experimentalVStack","VStack","useContext","useMemo","getFormFieldLayout","DataFormContext","isCombinedField","normalizeFormFields","jsx","_jsx","DataFormLayout","data","form","onChange","
|
|
1
|
+
{"version":3,"names":["__experimentalVStack","VStack","useContext","useMemo","getFormFieldLayout","DataFormContext","isCombinedField","normalizeFormFields","normalizeLayout","jsx","_jsx","DEFAULT_WRAPPER","children","spacing","DataFormLayout","data","form","onChange","as","_ref","fields","fieldDefinitions","getFieldDefinition","field","fieldId","id","find","fieldDefinition","normalizedFormFields","normalizedFormLayout","layout","Wrapper","type","wrapper","map","formField","FieldLayout","component","undefined","isVisible"],"sources":["@wordpress/dataviews/src/dataforms-layouts/data-form-layout.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalVStack as VStack } from '@wordpress/components';\nimport { useContext, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { Form, FormField, SimpleFormField } from '../types';\nimport { getFormFieldLayout } from './index';\nimport DataFormContext from '../components/dataform-context';\nimport { isCombinedField } from './is-combined-field';\nimport normalizeFormFields, { normalizeLayout } from '../normalize-form-fields';\n\nconst DEFAULT_WRAPPER = ( { children }: { children: React.ReactNode } ) => (\n\t<VStack spacing={ 4 }>{ children }</VStack>\n);\n\nexport function DataFormLayout< Item >( {\n\tdata,\n\tform,\n\tonChange,\n\tchildren,\n\tas,\n}: {\n\tdata: Item;\n\tform: Form;\n\tonChange: ( value: any ) => void;\n\tchildren?: (\n\t\tFieldLayout: ( props: {\n\t\t\tdata: Item;\n\t\t\tfield: FormField;\n\t\t\tonChange: ( value: any ) => void;\n\t\t\thideLabelFromVision?: boolean;\n\t\t} ) => React.JSX.Element | null,\n\t\tfield: FormField\n\t) => React.JSX.Element;\n\tas?: React.ComponentType< { children: React.ReactNode } >;\n} ) {\n\tconst { fields: fieldDefinitions } = useContext( DataFormContext );\n\n\tfunction getFieldDefinition( field: SimpleFormField | string ) {\n\t\tconst fieldId = typeof field === 'string' ? field : field.id;\n\n\t\treturn fieldDefinitions.find(\n\t\t\t( fieldDefinition ) => fieldDefinition.id === fieldId\n\t\t);\n\t}\n\n\tconst normalizedFormFields = useMemo(\n\t\t() => normalizeFormFields( form ),\n\t\t[ form ]\n\t);\n\n\tconst normalizedFormLayout = normalizeLayout( form.layout );\n\tconst Wrapper =\n\t\tas ??\n\t\tgetFormFieldLayout( normalizedFormLayout.type )?.wrapper ??\n\t\tDEFAULT_WRAPPER;\n\n\treturn (\n\t\t<Wrapper layout={ normalizedFormLayout }>\n\t\t\t{ normalizedFormFields.map( ( formField ) => {\n\t\t\t\tconst FieldLayout = getFormFieldLayout( formField.layout.type )\n\t\t\t\t\t?.component;\n\n\t\t\t\tif ( ! FieldLayout ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst fieldDefinition = ! isCombinedField( formField )\n\t\t\t\t\t? getFieldDefinition( formField )\n\t\t\t\t\t: undefined;\n\n\t\t\t\tif (\n\t\t\t\t\tfieldDefinition &&\n\t\t\t\t\tfieldDefinition.isVisible &&\n\t\t\t\t\t! fieldDefinition.isVisible( data )\n\t\t\t\t) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tif ( children ) {\n\t\t\t\t\treturn children( FieldLayout, formField );\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\t<FieldLayout\n\t\t\t\t\t\tkey={ formField.id }\n\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\tfield={ formField }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Wrapper>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,oBAAoB,IAAIC,MAAM,QAAQ,uBAAuB;AACtE,SAASC,UAAU,EAAEC,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AA,EACrCgB,oBAAoB,CAACM,GAAG,CAAIC,SAAS,IAAM;MAC5C,MAAMC,WAAW,GAAGhC,kBAAkB,CAAE+B,SAAS,CAACL,MAAM,CAACE,IAAK,CAAC,EAC5DK,SAAS;MAEZ,IAAK,CAAED,WAAW,EAAG;QACpB,OAAO,IAAI;MACZ;MAEA,MAAMT,eAAe,GAAG,CAAErB,eAAe,CAAE6B,SAAU,CAAC,GACnDb,kBAAkB,CAAEa,SAAU,CAAC,GAC/BG,SAAS;MAEZ,IACCX,eAAe,IACfA,eAAe,CAACY,SAAS,IACzB,CAAEZ,eAAe,CAACY,SAAS,CAAExB,IAAK,CAAC,EAClC;QACD,OAAO,IAAI;MACZ;MAEA,IAAKH,QAAQ,EAAG;QACf,OAAOA,QAAQ,CAAEwB,WAAW,EAAED,SAAU,CAAC;MAC1C;MAEA,oBACCzB,IAAA,CAAC0B,WAAW;QAEXrB,IAAI,EAAGA,IAAM;QACbQ,KAAK,EAAGY,SAAW;QACnBlB,QAAQ,EAAGA;MAAU,GAHfkB,SAAS,CAACV,EAIhB,CAAC;IAEJ,CAAE;EAAC,CACK,CAAC;AAEZ","ignoreList":[]}
|
|
@@ -1,18 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __experimentalVStack as VStack, __experimentalHStack as HStack } from '@wordpress/components';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* Internal dependencies
|
|
3
8
|
*/
|
|
9
|
+
|
|
4
10
|
import FormRegularField from './regular';
|
|
5
11
|
import FormPanelField from './panel';
|
|
6
12
|
import FormCardField from './card';
|
|
13
|
+
import FormRowField from './row';
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
15
|
const FORM_FIELD_LAYOUTS = [{
|
|
8
16
|
type: 'regular',
|
|
9
17
|
component: FormRegularField
|
|
10
18
|
}, {
|
|
11
19
|
type: 'panel',
|
|
12
|
-
component: FormPanelField
|
|
20
|
+
component: FormPanelField,
|
|
21
|
+
wrapper: ({
|
|
22
|
+
children
|
|
23
|
+
}) => /*#__PURE__*/_jsx(VStack, {
|
|
24
|
+
spacing: 2,
|
|
25
|
+
children: children
|
|
26
|
+
})
|
|
13
27
|
}, {
|
|
14
28
|
type: 'card',
|
|
15
29
|
component: FormCardField
|
|
30
|
+
}, {
|
|
31
|
+
type: 'row',
|
|
32
|
+
component: FormRowField,
|
|
33
|
+
wrapper: ({
|
|
34
|
+
children,
|
|
35
|
+
layout
|
|
36
|
+
}) => /*#__PURE__*/_jsx(VStack, {
|
|
37
|
+
spacing: 4,
|
|
38
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
39
|
+
className: "dataforms-layouts-row__field",
|
|
40
|
+
children: /*#__PURE__*/_jsx(HStack, {
|
|
41
|
+
spacing: 4,
|
|
42
|
+
alignment: layout.alignment,
|
|
43
|
+
children: children
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
})
|
|
16
47
|
}];
|
|
17
48
|
export function getFormFieldLayout(type) {
|
|
18
49
|
return FORM_FIELD_LAYOUTS.find(layout => layout.type === type);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FormRegularField","FormPanelField","FormCardField","FORM_FIELD_LAYOUTS","type","component","
|
|
1
|
+
{"version":3,"names":["__experimentalVStack","VStack","__experimentalHStack","HStack","FormRegularField","FormPanelField","FormCardField","FormRowField","jsx","_jsx","FORM_FIELD_LAYOUTS","type","component","wrapper","children","spacing","layout","className","alignment","getFormFieldLayout","find"],"sources":["@wordpress/dataviews/src/dataforms-layouts/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport type { Layout, RowLayout } from '../types';\nimport FormRegularField from './regular';\nimport FormPanelField from './panel';\nimport FormCardField from './card';\nimport FormRowField from './row';\n\nconst FORM_FIELD_LAYOUTS = [\n\t{\n\t\ttype: 'regular',\n\t\tcomponent: FormRegularField,\n\t},\n\t{\n\t\ttype: 'panel',\n\t\tcomponent: FormPanelField,\n\t\twrapper: ( { children }: { children: React.ReactNode } ) => (\n\t\t\t<VStack spacing={ 2 }>{ children }</VStack>\n\t\t),\n\t},\n\t{\n\t\ttype: 'card',\n\t\tcomponent: FormCardField,\n\t},\n\t{\n\t\ttype: 'row',\n\t\tcomponent: FormRowField,\n\t\twrapper: ( {\n\t\t\tchildren,\n\t\t\tlayout,\n\t\t}: {\n\t\t\tchildren: React.ReactNode;\n\t\t\tlayout: Layout;\n\t\t} ) => (\n\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t<div className=\"dataforms-layouts-row__field\">\n\t\t\t\t\t<HStack\n\t\t\t\t\t\tspacing={ 4 }\n\t\t\t\t\t\talignment={ ( layout as RowLayout ).alignment }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</HStack>\n\t\t\t\t</div>\n\t\t\t</VStack>\n\t\t),\n\t},\n];\n\nexport function getFormFieldLayout( type: string ) {\n\treturn FORM_FIELD_LAYOUTS.find( ( layout ) => layout.type === type );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;;AAE9B;AACA;AACA;;AAEA,OAAOC,gBAAgB,MAAM,WAAW;AACxC,OAAOC,cAAc,MAAM,SAAS;AACpC,OAAOC,aAAa,MAAM,QAAQ;AAClC,OAAOC,YAAY,MAAM,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEjC,MAAMC,kBAAkB,GAAG,CAC1B;EACCC,IAAI,EAAE,SAAS;EACfC,SAAS,EAAER;AACZ,CAAC,EACD;EACCO,IAAI,EAAE,OAAO;EACbC,SAAS,EAAEP,cAAc;EACzBQ,OAAO,EAAEA,CAAE;IAAEC;EAAwC,CAAC,kBACrDL,IAAA,CAACR,MAAM;IAACc,OAAO,EAAG,CAAG;IAAAD,QAAA,EAAGA;EAAQ,CAAU;AAE5C,CAAC,EACD;EACCH,IAAI,EAAE,MAAM;EACZC,SAAS,EAAEN;AACZ,CAAC,EACD;EACCK,IAAI,EAAE,KAAK;EACXC,SAAS,EAAEL,YAAY;EACvBM,OAAO,EAAEA,CAAE;IACVC,QAAQ;IACRE;EAID,CAAC,kBACAP,IAAA,CAACR,MAAM;IAACc,OAAO,EAAG,CAAG;IAAAD,QAAA,eACpBL,IAAA;MAAKQ,SAAS,EAAC,8BAA8B;MAAAH,QAAA,eAC5CL,IAAA,CAACN,MAAM;QACNY,OAAO,EAAG,CAAG;QACbG,SAAS,EAAKF,MAAM,CAAgBE,SAAW;QAAAJ,QAAA,EAE7CA;MAAQ,CACH;IAAC,CACL;EAAC,CACC;AAEV,CAAC,CACD;AAED,OAAO,SAASK,kBAAkBA,CAAER,IAAY,EAAG;EAClD,OAAOD,kBAAkB,CAACU,IAAI,CAAIJ,MAAM,IAAMA,MAAM,CAACL,IAAI,KAAKA,IAAK,CAAC;AACrE","ignoreList":[]}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __experimentalHStack as HStack, __experimentalSpacer as Spacer, __experimentalVStack as VStack, __experimentalHeading as Heading } from '@wordpress/components';
|
|
5
|
+
import { useContext } from '@wordpress/element';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import DataFormContext from '../../components/dataform-context';
|
|
12
|
+
import { DataFormLayout } from '../data-form-layout';
|
|
13
|
+
import { isCombinedField } from '../is-combined-field';
|
|
14
|
+
import { normalizeLayout } from '../../normalize-form-fields';
|
|
15
|
+
import { getFormFieldLayout } from '..';
|
|
16
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
17
|
+
function Header({
|
|
18
|
+
title
|
|
19
|
+
}) {
|
|
20
|
+
return /*#__PURE__*/_jsx(VStack, {
|
|
21
|
+
className: "dataforms-layouts-row__header",
|
|
22
|
+
spacing: 4,
|
|
23
|
+
children: /*#__PURE__*/_jsxs(HStack, {
|
|
24
|
+
alignment: "center",
|
|
25
|
+
children: [/*#__PURE__*/_jsx(Heading, {
|
|
26
|
+
level: 2,
|
|
27
|
+
size: 13,
|
|
28
|
+
children: title
|
|
29
|
+
}), /*#__PURE__*/_jsx(Spacer, {})]
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const EMPTY_WRAPPER = ({
|
|
34
|
+
children
|
|
35
|
+
}) => /*#__PURE__*/_jsx(_Fragment, {
|
|
36
|
+
children: children
|
|
37
|
+
});
|
|
38
|
+
export default function FormRowField({
|
|
39
|
+
data,
|
|
40
|
+
field,
|
|
41
|
+
onChange,
|
|
42
|
+
hideLabelFromVision
|
|
43
|
+
}) {
|
|
44
|
+
const {
|
|
45
|
+
fields
|
|
46
|
+
} = useContext(DataFormContext);
|
|
47
|
+
const layout = normalizeLayout({
|
|
48
|
+
...field.layout,
|
|
49
|
+
type: 'row'
|
|
50
|
+
});
|
|
51
|
+
if (isCombinedField(field)) {
|
|
52
|
+
const form = {
|
|
53
|
+
fields: field.children.map(child => {
|
|
54
|
+
if (typeof child === 'string') {
|
|
55
|
+
return {
|
|
56
|
+
id: child
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return child;
|
|
60
|
+
})
|
|
61
|
+
};
|
|
62
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
63
|
+
className: "dataforms-layouts-row__field",
|
|
64
|
+
children: [!hideLabelFromVision && field.label && /*#__PURE__*/_jsx(Header, {
|
|
65
|
+
title: field.label
|
|
66
|
+
}), /*#__PURE__*/_jsx(HStack, {
|
|
67
|
+
alignment: layout.alignment,
|
|
68
|
+
spacing: 4,
|
|
69
|
+
children: /*#__PURE__*/_jsx(DataFormLayout, {
|
|
70
|
+
data: data,
|
|
71
|
+
form: form,
|
|
72
|
+
onChange: onChange,
|
|
73
|
+
as: EMPTY_WRAPPER,
|
|
74
|
+
children: (FieldLayout, nestedField) => /*#__PURE__*/_jsx("div", {
|
|
75
|
+
className: "dataforms-layouts-row__field-control",
|
|
76
|
+
children: /*#__PURE__*/_jsx(FieldLayout, {
|
|
77
|
+
data: data,
|
|
78
|
+
field: nestedField,
|
|
79
|
+
onChange: onChange,
|
|
80
|
+
hideLabelFromVision: hideLabelFromVision
|
|
81
|
+
})
|
|
82
|
+
}, nestedField.id)
|
|
83
|
+
})
|
|
84
|
+
})]
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const fieldDefinition = fields.find(f => f.id === field.id);
|
|
88
|
+
if (!fieldDefinition || !fieldDefinition.Edit) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const RegularLayout = getFormFieldLayout('regular')?.component;
|
|
92
|
+
if (!RegularLayout) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
96
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
97
|
+
className: "dataforms-layouts-row__field-control",
|
|
98
|
+
children: /*#__PURE__*/_jsx(RegularLayout, {
|
|
99
|
+
data: data,
|
|
100
|
+
field: fieldDefinition,
|
|
101
|
+
onChange: onChange
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=index.js.map
|