@wordpress/dataviews 9.0.1-next.6f42e1382.0 → 9.0.1-next.a730c9c8c.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 +7 -1
- package/README.md +106 -11
- package/build/components/dataviews-filters/input-widget.js +48 -4
- package/build/components/dataviews-filters/input-widget.js.map +1 -1
- package/build/dataform-controls/array.js +9 -7
- package/build/dataform-controls/array.js.map +1 -1
- package/build/dataform-controls/checkbox.js +31 -20
- package/build/dataform-controls/checkbox.js.map +1 -1
- package/build/dataform-controls/color.js +29 -24
- package/build/dataform-controls/color.js.map +1 -1
- package/build/dataform-controls/date.js +32 -24
- package/build/dataform-controls/date.js.map +1 -1
- package/build/dataform-controls/datetime.js +133 -19
- package/build/dataform-controls/datetime.js.map +1 -1
- package/build/dataform-controls/email.js +7 -1
- package/build/dataform-controls/email.js.map +1 -1
- package/build/dataform-controls/index.js +23 -0
- package/build/dataform-controls/index.js.map +1 -1
- package/build/dataform-controls/integer.js +47 -34
- package/build/dataform-controls/integer.js.map +1 -1
- package/build/dataform-controls/radio.js +42 -9
- package/build/dataform-controls/radio.js.map +1 -1
- package/build/dataform-controls/relative-date-control.js +6 -10
- package/build/dataform-controls/relative-date-control.js.map +1 -1
- package/build/dataform-controls/select.js +41 -10
- package/build/dataform-controls/select.js.map +1 -1
- package/build/dataform-controls/telephone.js +7 -1
- package/build/dataform-controls/telephone.js.map +1 -1
- package/build/dataform-controls/text.js +14 -2
- package/build/dataform-controls/text.js.map +1 -1
- package/build/dataform-controls/textarea.js +33 -20
- package/build/dataform-controls/textarea.js.map +1 -1
- package/build/dataform-controls/toggle-group.js +36 -6
- package/build/dataform-controls/toggle-group.js.map +1 -1
- package/build/dataform-controls/toggle.js +33 -22
- package/build/dataform-controls/toggle.js.map +1 -1
- package/build/dataform-controls/url.js +7 -1
- package/build/dataform-controls/url.js.map +1 -1
- package/build/dataform-controls/utils/validated-input.js +34 -32
- package/build/dataform-controls/utils/validated-input.js.map +1 -1
- package/build/dataforms-layouts/panel/dropdown.js +10 -14
- package/build/dataforms-layouts/panel/dropdown.js.map +1 -1
- package/build/dataforms-layouts/panel/index.js +24 -11
- package/build/dataforms-layouts/panel/index.js.map +1 -1
- package/build/dataforms-layouts/panel/modal.js +22 -27
- package/build/dataforms-layouts/panel/modal.js.map +1 -1
- package/build/dataforms-layouts/panel/summary-button.js +67 -0
- package/build/dataforms-layouts/panel/summary-button.js.map +1 -0
- package/build/normalize-fields.js +17 -0
- package/build/normalize-fields.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build-module/components/dataviews-filters/input-widget.js +48 -4
- package/build-module/components/dataviews-filters/input-widget.js.map +1 -1
- package/build-module/dataform-controls/array.js +9 -7
- package/build-module/dataform-controls/array.js.map +1 -1
- package/build-module/dataform-controls/checkbox.js +31 -21
- package/build-module/dataform-controls/checkbox.js.map +1 -1
- package/build-module/dataform-controls/color.js +28 -24
- package/build-module/dataform-controls/color.js.map +1 -1
- package/build-module/dataform-controls/date.js +32 -24
- package/build-module/dataform-controls/date.js.map +1 -1
- package/build-module/dataform-controls/datetime.js +135 -21
- package/build-module/dataform-controls/datetime.js.map +1 -1
- package/build-module/dataform-controls/email.js +7 -1
- package/build-module/dataform-controls/email.js.map +1 -1
- package/build-module/dataform-controls/index.js +23 -0
- package/build-module/dataform-controls/index.js.map +1 -1
- package/build-module/dataform-controls/integer.js +46 -34
- package/build-module/dataform-controls/integer.js.map +1 -1
- package/build-module/dataform-controls/radio.js +44 -11
- package/build-module/dataform-controls/radio.js.map +1 -1
- package/build-module/dataform-controls/relative-date-control.js +6 -10
- package/build-module/dataform-controls/relative-date-control.js.map +1 -1
- package/build-module/dataform-controls/select.js +43 -12
- package/build-module/dataform-controls/select.js.map +1 -1
- package/build-module/dataform-controls/telephone.js +7 -1
- package/build-module/dataform-controls/telephone.js.map +1 -1
- package/build-module/dataform-controls/text.js +14 -2
- package/build-module/dataform-controls/text.js.map +1 -1
- package/build-module/dataform-controls/textarea.js +32 -20
- package/build-module/dataform-controls/textarea.js.map +1 -1
- package/build-module/dataform-controls/toggle-group.js +38 -8
- package/build-module/dataform-controls/toggle-group.js.map +1 -1
- package/build-module/dataform-controls/toggle.js +33 -23
- package/build-module/dataform-controls/toggle.js.map +1 -1
- package/build-module/dataform-controls/url.js +7 -1
- package/build-module/dataform-controls/url.js.map +1 -1
- package/build-module/dataform-controls/utils/validated-input.js +34 -33
- package/build-module/dataform-controls/utils/validated-input.js.map +1 -1
- package/build-module/dataforms-layouts/panel/dropdown.js +10 -15
- package/build-module/dataforms-layouts/panel/dropdown.js.map +1 -1
- package/build-module/dataforms-layouts/panel/index.js +24 -11
- package/build-module/dataforms-layouts/panel/index.js.map +1 -1
- package/build-module/dataforms-layouts/panel/modal.js +22 -28
- package/build-module/dataforms-layouts/panel/modal.js.map +1 -1
- package/build-module/dataforms-layouts/panel/summary-button.js +60 -0
- package/build-module/dataforms-layouts/panel/summary-button.js.map +1 -0
- package/build-module/normalize-fields.js +15 -0
- package/build-module/normalize-fields.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-types/components/dataform/stories/index.story.d.ts +3 -0
- package/build-types/components/dataform/stories/index.story.d.ts.map +1 -1
- package/build-types/components/dataviews/stories/fixtures.d.ts +4 -2
- package/build-types/components/dataviews/stories/fixtures.d.ts.map +1 -1
- package/build-types/components/dataviews-filters/input-widget.d.ts.map +1 -1
- package/build-types/dataform-controls/array.d.ts.map +1 -1
- package/build-types/dataform-controls/checkbox.d.ts.map +1 -1
- package/build-types/dataform-controls/color.d.ts.map +1 -1
- package/build-types/dataform-controls/date.d.ts.map +1 -1
- package/build-types/dataform-controls/datetime.d.ts.map +1 -1
- package/build-types/dataform-controls/email.d.ts.map +1 -1
- package/build-types/dataform-controls/index.d.ts +1 -1
- package/build-types/dataform-controls/index.d.ts.map +1 -1
- package/build-types/dataform-controls/integer.d.ts.map +1 -1
- package/build-types/dataform-controls/radio.d.ts.map +1 -1
- package/build-types/dataform-controls/relative-date-control.d.ts +6 -5
- package/build-types/dataform-controls/relative-date-control.d.ts.map +1 -1
- package/build-types/dataform-controls/select.d.ts.map +1 -1
- package/build-types/dataform-controls/telephone.d.ts.map +1 -1
- package/build-types/dataform-controls/text.d.ts +1 -1
- package/build-types/dataform-controls/text.d.ts.map +1 -1
- package/build-types/dataform-controls/textarea.d.ts +1 -1
- package/build-types/dataform-controls/textarea.d.ts.map +1 -1
- package/build-types/dataform-controls/toggle-group.d.ts.map +1 -1
- package/build-types/dataform-controls/toggle.d.ts.map +1 -1
- package/build-types/dataform-controls/url.d.ts.map +1 -1
- package/build-types/dataform-controls/utils/validated-input.d.ts +4 -4
- package/build-types/dataform-controls/utils/validated-input.d.ts.map +1 -1
- package/build-types/dataforms-layouts/panel/dropdown.d.ts +2 -1
- package/build-types/dataforms-layouts/panel/dropdown.d.ts.map +1 -1
- package/build-types/dataforms-layouts/panel/index.d.ts.map +1 -1
- package/build-types/dataforms-layouts/panel/modal.d.ts +2 -1
- package/build-types/dataforms-layouts/panel/modal.d.ts.map +1 -1
- package/build-types/dataforms-layouts/panel/summary-button.d.ts +15 -0
- package/build-types/dataforms-layouts/panel/summary-button.d.ts.map +1 -0
- package/build-types/field-types/stories/index.story.d.ts.map +1 -1
- package/build-types/normalize-fields.d.ts +3 -0
- package/build-types/normalize-fields.d.ts.map +1 -1
- package/build-types/types.d.ts +66 -3
- package/build-types/types.d.ts.map +1 -1
- package/build-wp/index.js +1468 -1422
- package/package.json +16 -15
- package/src/components/dataform/stories/index.story.tsx +436 -7
- package/src/components/dataviews/stories/fixtures.tsx +99 -41
- package/src/components/dataviews/stories/index.story.tsx +1 -1
- package/src/components/dataviews-filters/input-widget.tsx +44 -5
- package/src/components/dataviews-picker/stories/index.story.tsx +1 -1
- package/src/dataform-controls/array.tsx +4 -6
- package/src/dataform-controls/checkbox.tsx +41 -24
- package/src/dataform-controls/color.tsx +33 -24
- package/src/dataform-controls/date.tsx +47 -21
- package/src/dataform-controls/datetime.tsx +171 -23
- package/src/dataform-controls/email.tsx +9 -1
- package/src/dataform-controls/index.tsx +26 -0
- package/src/dataform-controls/integer.tsx +82 -49
- package/src/dataform-controls/radio.tsx +53 -11
- package/src/dataform-controls/relative-date-control.tsx +11 -10
- package/src/dataform-controls/select.tsx +53 -10
- package/src/dataform-controls/telephone.tsx +9 -1
- package/src/dataform-controls/text.tsx +18 -1
- package/src/dataform-controls/textarea.tsx +38 -24
- package/src/dataform-controls/toggle-group.tsx +50 -10
- package/src/dataform-controls/toggle.tsx +41 -24
- package/src/dataform-controls/url.tsx +9 -1
- package/src/dataform-controls/utils/validated-input.tsx +50 -50
- package/src/dataforms-layouts/panel/dropdown.tsx +12 -23
- package/src/dataforms-layouts/panel/index.tsx +39 -16
- package/src/dataforms-layouts/panel/modal.tsx +24 -30
- package/src/dataforms-layouts/panel/summary-button.tsx +92 -0
- package/src/field-types/stories/index.story.tsx +89 -1
- package/src/normalize-fields.ts +18 -0
- package/src/test/filter-and-sort-data-view.js +148 -138
- package/src/test/normalize-fields.ts +114 -0
- package/src/types.ts +73 -3
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","BaseControl","SelectControl","__experimentalNumberControl","NumberControl","__experimentalHStack","HStack","useCallback","__","OPERATOR_IN_THE_PAST","OPERATOR_OVER","jsx","_jsx","jsxs","_jsxs","TIME_UNITS_OPTIONS","value","label","RelativeDateControl","id","onChange","hideLabelFromVision","options","className","relValue","unit","onChangeValue","newValue","Number","onChangeUnit","newUnit","__nextHasNoMarginBottom","children","spacing","__next40pxDefaultSize","spinControls","min","step"],"sources":["@wordpress/dataviews/src/dataform-controls/relative-date-control.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBaseControl,\n\tSelectControl,\n\t__experimentalNumberControl as NumberControl,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { OPERATOR_IN_THE_PAST, OPERATOR_OVER } from '../constants';\n\
|
|
1
|
+
{"version":3,"names":["clsx","BaseControl","SelectControl","__experimentalNumberControl","NumberControl","__experimentalHStack","HStack","useCallback","__","OPERATOR_IN_THE_PAST","OPERATOR_OVER","jsx","_jsx","jsxs","_jsxs","TIME_UNITS_OPTIONS","value","label","RelativeDateControl","id","onChange","hideLabelFromVision","options","className","relValue","unit","onChangeValue","newValue","Number","onChangeUnit","newUnit","__nextHasNoMarginBottom","children","spacing","__next40pxDefaultSize","spinControls","min","step"],"sources":["@wordpress/dataviews/src/dataform-controls/relative-date-control.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBaseControl,\n\tSelectControl,\n\t__experimentalNumberControl as NumberControl,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { OPERATOR_IN_THE_PAST, OPERATOR_OVER } from '../constants';\n\nexport type DateRelative = {\n\tvalue?: string | number;\n\tunit?: string;\n};\n\ninterface RelativeDateControlProps {\n\tid: string;\n\tvalue: DateRelative;\n\tonChange: ( args: DateRelative ) => void;\n\tlabel: string;\n\thideLabelFromVision?: boolean;\n\toptions: { value: string; label: string }[];\n\tclassName?: string;\n}\n\nexport const TIME_UNITS_OPTIONS = {\n\t[ OPERATOR_IN_THE_PAST ]: [\n\t\t{ value: 'days', label: __( 'Days' ) },\n\t\t{ value: 'weeks', label: __( 'Weeks' ) },\n\t\t{ value: 'months', label: __( 'Months' ) },\n\t\t{ value: 'years', label: __( 'Years' ) },\n\t],\n\t[ OPERATOR_OVER ]: [\n\t\t{ value: 'days', label: __( 'Days ago' ) },\n\t\t{ value: 'weeks', label: __( 'Weeks ago' ) },\n\t\t{ value: 'months', label: __( 'Months ago' ) },\n\t\t{ value: 'years', label: __( 'Years ago' ) },\n\t],\n};\n\nexport default function RelativeDateControl( {\n\tid,\n\tvalue,\n\tonChange,\n\tlabel,\n\thideLabelFromVision,\n\toptions,\n\tclassName,\n}: RelativeDateControlProps ) {\n\tconst { value: relValue = '', unit = options[ 0 ].value } = value;\n\n\tconst onChangeValue = useCallback(\n\t\t( newValue: string | undefined ) =>\n\t\t\tonChange( { value: Number( newValue ), unit } ),\n\t\t[ onChange, unit ]\n\t);\n\n\tconst onChangeUnit = useCallback(\n\t\t( newUnit: string | undefined ) =>\n\t\t\tonChange( { value: relValue, unit: newUnit } ),\n\t\t[ onChange, relValue ]\n\t);\n\n\treturn (\n\t\t<BaseControl\n\t\t\tid={ id }\n\t\t\t__nextHasNoMarginBottom\n\t\t\tclassName={ clsx( className, 'dataviews-controls__relative-date' ) }\n\t\t\tlabel={ label }\n\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t>\n\t\t\t<HStack spacing={ 2.5 }>\n\t\t\t\t<NumberControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tclassName=\"dataviews-controls__relative-date-number\"\n\t\t\t\t\tspinControls=\"none\"\n\t\t\t\t\tmin={ 1 }\n\t\t\t\t\tstep={ 1 }\n\t\t\t\t\tvalue={ relValue }\n\t\t\t\t\tonChange={ onChangeValue }\n\t\t\t\t/>\n\t\t\t\t<SelectControl\n\t\t\t\t\tclassName=\"dataviews-controls__relative-date-unit\"\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Unit' ) }\n\t\t\t\t\tvalue={ unit }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tonChange={ onChangeUnit }\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t/>\n\t\t\t</HStack>\n\t\t</BaseControl>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MA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ACK;EAAC,CACG,CAAC;AAEhB","ignoreList":[]}
|
|
@@ -1,33 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import deepMerge from 'deepmerge';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import { useCallback } from '@wordpress/element';
|
|
9
|
+
import { privateApis } from '@wordpress/components';
|
|
10
|
+
import { useCallback, useState } from '@wordpress/element';
|
|
6
11
|
import { __ } from '@wordpress/i18n';
|
|
7
12
|
|
|
8
13
|
/**
|
|
9
14
|
* Internal dependencies
|
|
10
15
|
*/
|
|
16
|
+
|
|
17
|
+
import { unlock } from '../lock-unlock';
|
|
11
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
+
const {
|
|
20
|
+
ValidatedSelectControl
|
|
21
|
+
} = unlock(privateApis);
|
|
12
22
|
export default function Select({
|
|
13
23
|
data,
|
|
14
24
|
field,
|
|
15
25
|
onChange,
|
|
16
26
|
hideLabelFromVision
|
|
17
27
|
}) {
|
|
18
|
-
var
|
|
28
|
+
var _getValue, _field$elements;
|
|
19
29
|
const {
|
|
20
|
-
|
|
30
|
+
type,
|
|
21
31
|
label,
|
|
22
|
-
|
|
32
|
+
description,
|
|
33
|
+
getValue,
|
|
34
|
+
setValue
|
|
23
35
|
} = field;
|
|
36
|
+
const [customValidity, setCustomValidity] = useState(undefined);
|
|
24
37
|
const isMultiple = type === 'array';
|
|
25
|
-
const value = (
|
|
38
|
+
const value = (_getValue = getValue({
|
|
26
39
|
item: data
|
|
27
|
-
})) !== null &&
|
|
28
|
-
const onChangeControl = useCallback(newValue => onChange({
|
|
29
|
-
|
|
30
|
-
|
|
40
|
+
})) !== null && _getValue !== void 0 ? _getValue : isMultiple ? [] : '';
|
|
41
|
+
const onChangeControl = useCallback(newValue => onChange(setValue({
|
|
42
|
+
item: data,
|
|
43
|
+
value: newValue
|
|
44
|
+
})), [data, onChange, setValue]);
|
|
45
|
+
const onValidateControl = useCallback(newValue => {
|
|
46
|
+
const message = field.isValid?.custom?.(deepMerge(data, setValue({
|
|
47
|
+
item: data,
|
|
48
|
+
value: newValue
|
|
49
|
+
})), field);
|
|
50
|
+
if (message) {
|
|
51
|
+
setCustomValidity({
|
|
52
|
+
type: 'invalid',
|
|
53
|
+
message
|
|
54
|
+
});
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
setCustomValidity(undefined);
|
|
58
|
+
}, [data, field, setValue]);
|
|
31
59
|
const fieldElements = (_field$elements = field?.elements) !== null && _field$elements !== void 0 ? _field$elements : [];
|
|
32
60
|
const hasEmptyValue = fieldElements.some(({
|
|
33
61
|
value: elementValue
|
|
@@ -44,10 +72,13 @@ export default function Select({
|
|
|
44
72
|
label: __('Select item'),
|
|
45
73
|
value: ''
|
|
46
74
|
}, ...fieldElements];
|
|
47
|
-
return /*#__PURE__*/_jsx(
|
|
75
|
+
return /*#__PURE__*/_jsx(ValidatedSelectControl, {
|
|
76
|
+
required: !!field.isValid?.required,
|
|
77
|
+
onValidate: onValidateControl,
|
|
78
|
+
customValidity: customValidity,
|
|
48
79
|
label: label,
|
|
49
80
|
value: value,
|
|
50
|
-
help:
|
|
81
|
+
help: description,
|
|
51
82
|
options: elements,
|
|
52
83
|
onChange: onChangeControl,
|
|
53
84
|
__next40pxDefaultSize: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["deepMerge","privateApis","useCallback","useState","__","unlock","jsx","_jsx","ValidatedSelectControl","Select","data","field","onChange","hideLabelFromVision","_getValue","_field$elements","type","label","description","getValue","setValue","customValidity","setCustomValidity","undefined","isMultiple","value","item","onChangeControl","newValue","onValidateControl","message","isValid","custom","fieldElements","elements","hasEmptyValue","some","elementValue","required","onValidate","help","options","__next40pxDefaultSize","__nextHasNoMarginBottom","multiple"],"sources":["@wordpress/dataviews/src/dataform-controls/select.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport deepMerge from 'deepmerge';\n\n/**\n * WordPress dependencies\n */\nimport { privateApis } from '@wordpress/components';\nimport { useCallback, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { DataFormControlProps } from '../types';\nimport { unlock } from '../lock-unlock';\n\nconst { ValidatedSelectControl } = unlock( privateApis );\n\nexport default function Select< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n}: DataFormControlProps< Item > ) {\n\tconst { type, label, description, getValue, setValue } = field;\n\tconst [ customValidity, setCustomValidity ] =\n\t\tuseState<\n\t\t\tReact.ComponentProps<\n\t\t\t\ttypeof ValidatedSelectControl\n\t\t\t>[ 'customValidity' ]\n\t\t>( undefined );\n\n\tconst isMultiple = type === 'array';\n\tconst value = getValue( { item: data } ) ?? ( isMultiple ? [] : '' );\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue: any ) =>\n\t\t\tonChange( setValue( { item: data, value: newValue } ) ),\n\t\t[ data, onChange, setValue ]\n\t);\n\n\tconst onValidateControl = useCallback(\n\t\t( newValue: any ) => {\n\t\t\tconst message = field.isValid?.custom?.(\n\t\t\t\tdeepMerge(\n\t\t\t\t\tdata,\n\t\t\t\t\tsetValue( {\n\t\t\t\t\t\titem: data,\n\t\t\t\t\t\tvalue: newValue,\n\t\t\t\t\t} ) as Partial< Item >\n\t\t\t\t),\n\t\t\t\tfield\n\t\t\t);\n\n\t\t\tif ( message ) {\n\t\t\t\tsetCustomValidity( {\n\t\t\t\t\ttype: 'invalid',\n\t\t\t\t\tmessage,\n\t\t\t\t} );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetCustomValidity( undefined );\n\t\t},\n\t\t[ data, field, setValue ]\n\t);\n\n\tconst fieldElements = field?.elements ?? [];\n\tconst hasEmptyValue = fieldElements.some(\n\t\t( { value: elementValue } ) => elementValue === ''\n\t);\n\n\tconst elements =\n\t\thasEmptyValue || isMultiple\n\t\t\t? fieldElements\n\t\t\t: [\n\t\t\t\t\t/*\n\t\t\t\t\t * Value can be undefined when:\n\t\t\t\t\t *\n\t\t\t\t\t * - the field is not required\n\t\t\t\t\t * - in bulk editing\n\t\t\t\t\t *\n\t\t\t\t\t */\n\t\t\t\t\t{ label: __( 'Select item' ), value: '' },\n\t\t\t\t\t...fieldElements,\n\t\t\t ];\n\n\treturn (\n\t\t<ValidatedSelectControl\n\t\t\trequired={ !! field.isValid?.required }\n\t\t\tonValidate={ onValidateControl }\n\t\t\tcustomValidity={ customValidity }\n\t\t\tlabel={ label }\n\t\t\tvalue={ value }\n\t\t\thelp={ description }\n\t\t\toptions={ elements }\n\t\t\tonChange={ onChangeControl }\n\t\t\t__next40pxDefaultSize\n\t\t\t__nextHasNoMarginBottom\n\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\tmultiple={ isMultiple }\n\t\t/>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,WAAW;;AAEjC;AACA;AACA;AACA,SAASC,WAAW,QAAQ,uBAAuB;AACnD,SAASC,WAAW,EAAEC,QAAQ,QAAQ,oBAAoB;AAC1D,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAEA,SAASC,MAAM,QAAQ,gBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAExC,MAAM;EAAEC;AAAuB,CAAC,GAAGH,MAAM,CAAEJ,WAAY,CAAC;AAExD,eAAe,SAASQ,MAAMA,CAAU;EACvCC,IAAI;EACJC,KAAK;EACLC,QAAQ;EACRC;AAC6B,CAAC,EAAG;EAAA,IAAAC,SAAA,EAAAC,eAAA;EACjC,MAAM;IAAEC,IAAI;IAAEC,KAAK;IAAEC,WAAW;IAAEC,QAAQ;IAAEC;EAAS,CAAC,GAAGT,KAAK;EAC9D,MAAM,CAAEU,cAAc,EAAEC,iBAAiB,CAAE,GAC1CnB,QAAQ,CAILoB,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,EAAE,CAAE,aAAc,CAAC;IAAEqB,KAAK,EAAE;EAAG,CAAC,EACzC,GAAGQ,aAAa,CACf;EAEL,oBACC1B,IAAA,CAACC,sBAAsB;IACtB8B,QAAQ,EAAG,CAAC,CAAE3B,KAAK,CAACoB,OAAO,EAAEO,QAAU;IACvCC,UAAU,EAAGV,iBAAmB;IAChCR,cAAc,EAAGA,cAAgB;IACjCJ,KAAK,EAAGA,KAAO;IACfQ,KAAK,EAAGA,KAAO;IACfe,IAAI,EAAGtB,WAAa;IACpBuB,OAAO,EAAGP,QAAU;IACpBtB,QAAQ,EAAGe,eAAiB;IAC5Be,qBAAqB;IACrBC,uBAAuB;IACvB9B,mBAAmB,EAAGA,mBAAqB;IAC3C+B,QAAQ,EAAGpB;EAAY,CACvB,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
+
import { Icon, __experimentalInputControlPrefixWrapper as InputControlPrefixWrapper } from '@wordpress/components';
|
|
4
5
|
import { mobile } from '@wordpress/icons';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -21,7 +22,12 @@ export default function Telephone({
|
|
|
21
22
|
onChange,
|
|
22
23
|
hideLabelFromVision,
|
|
23
24
|
type: 'tel',
|
|
24
|
-
|
|
25
|
+
prefix: /*#__PURE__*/_jsx(InputControlPrefixWrapper, {
|
|
26
|
+
variant: "icon",
|
|
27
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
28
|
+
icon: mobile
|
|
29
|
+
})
|
|
30
|
+
})
|
|
25
31
|
});
|
|
26
32
|
}
|
|
27
33
|
//# sourceMappingURL=telephone.js.map
|
|
@@ -1 +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-input';\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\
|
|
1
|
+
{"version":3,"names":["Icon","__experimentalInputControlPrefixWrapper","InputControlPrefixWrapper","mobile","ValidatedText","jsx","_jsx","Telephone","data","field","onChange","hideLabelFromVision","type","prefix","variant","children","icon"],"sources":["@wordpress/dataviews/src/dataform-controls/telephone.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\t__experimentalInputControlPrefixWrapper as InputControlPrefixWrapper,\n} from '@wordpress/components';\nimport { mobile } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport type { DataFormControlProps } from '../types';\nimport ValidatedText from './utils/validated-input';\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\tprefix: (\n\t\t\t\t\t<InputControlPrefixWrapper variant=\"icon\">\n\t\t\t\t\t\t<Icon icon={ mobile } />\n\t\t\t\t\t</InputControlPrefixWrapper>\n\t\t\t\t),\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,IAAI,EACJC,uCAAuC,IAAIC,yBAAyB,QAC9D,uBAAuB;AAC9B,SAASC,MAAM,QAAQ,kBAAkB;;AAEzC;AACA;AACA;;AAEA,OAAOC,aAAa,MAAM,yBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEpD,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,MAAM,eACLP,IAAA,CAACJ,yBAAyB;MAACY,OAAO,EAAC,MAAM;MAAAC,QAAA,eACxCT,IAAA,CAACN,IAAI;QAACgB,IAAI,EAAGb;MAAQ,CAAE;IAAC,CACE;EAC3B,CAEF,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { createElement } from '@wordpress/element';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* Internal dependencies
|
|
3
8
|
*/
|
|
@@ -8,13 +13,20 @@ export default function Text({
|
|
|
8
13
|
data,
|
|
9
14
|
field,
|
|
10
15
|
onChange,
|
|
11
|
-
hideLabelFromVision
|
|
16
|
+
hideLabelFromVision,
|
|
17
|
+
config
|
|
12
18
|
}) {
|
|
19
|
+
const {
|
|
20
|
+
prefix,
|
|
21
|
+
suffix
|
|
22
|
+
} = config || {};
|
|
13
23
|
return /*#__PURE__*/_jsx(ValidatedText, {
|
|
14
24
|
data,
|
|
15
25
|
field,
|
|
16
26
|
onChange,
|
|
17
|
-
hideLabelFromVision
|
|
27
|
+
hideLabelFromVision,
|
|
28
|
+
prefix: prefix ? createElement(prefix) : undefined,
|
|
29
|
+
suffix: suffix ? createElement(suffix) : undefined
|
|
18
30
|
});
|
|
19
31
|
}
|
|
20
32
|
//# sourceMappingURL=text.js.map
|
|
@@ -1 +1 @@
|
|
|
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-input';\n\nexport default function Text< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n}: DataFormControlProps< Item > ) {\n\treturn (\n\t\t<ValidatedText
|
|
1
|
+
{"version":3,"names":["createElement","ValidatedText","jsx","_jsx","Text","data","field","onChange","hideLabelFromVision","config","prefix","suffix","undefined"],"sources":["@wordpress/dataviews/src/dataform-controls/text.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createElement } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { DataFormControlProps } from '../types';\nimport ValidatedText from './utils/validated-input';\n\nexport default function Text< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n\tconfig,\n}: DataFormControlProps< Item > ) {\n\tconst { prefix, suffix } = config || {};\n\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\tprefix: prefix ? createElement( prefix ) : undefined,\n\t\t\t\tsuffix: suffix ? createElement( suffix ) : undefined,\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,oBAAoB;;AAElD;AACA;AACA;;AAEA,OAAOC,aAAa,MAAM,yBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEpD,eAAe,SAASC,IAAIA,CAAU;EACrCC,IAAI;EACJC,KAAK;EACLC,QAAQ;EACRC,mBAAmB;EACnBC;AAC6B,CAAC,EAAG;EACjC,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGF,MAAM,IAAI,CAAC,CAAC;EAEvC,oBACCN,IAAA,CAACF,aAAa;IAEZI,IAAI;IACJC,KAAK;IACLC,QAAQ;IACRC,mBAAmB;IACnBE,MAAM,EAAEA,MAAM,GAAGV,aAAa,CAAEU,MAAO,CAAC,GAAGE,SAAS;IACpDD,MAAM,EAAEA,MAAM,GAAGX,aAAa,CAAEW,MAAO,CAAC,GAAGC;EAAS,CAErD,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import deepMerge from 'deepmerge';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
@@ -17,43 +22,50 @@ export default function Textarea({
|
|
|
17
22
|
data,
|
|
18
23
|
field,
|
|
19
24
|
onChange,
|
|
20
|
-
hideLabelFromVision
|
|
25
|
+
hideLabelFromVision,
|
|
26
|
+
config
|
|
21
27
|
}) {
|
|
22
28
|
const {
|
|
23
|
-
|
|
29
|
+
rows = 4
|
|
30
|
+
} = config || {};
|
|
31
|
+
const {
|
|
24
32
|
label,
|
|
25
33
|
placeholder,
|
|
26
|
-
description
|
|
34
|
+
description,
|
|
35
|
+
setValue
|
|
27
36
|
} = field;
|
|
28
37
|
const value = field.getValue({
|
|
29
38
|
item: data
|
|
30
39
|
});
|
|
31
40
|
const [customValidity, setCustomValidity] = useState(undefined);
|
|
32
|
-
const onChangeControl = useCallback(newValue => onChange({
|
|
33
|
-
|
|
34
|
-
|
|
41
|
+
const onChangeControl = useCallback(newValue => onChange(setValue({
|
|
42
|
+
item: data,
|
|
43
|
+
value: newValue
|
|
44
|
+
})), [data, onChange, setValue]);
|
|
45
|
+
const onValidateControl = useCallback(newValue => {
|
|
46
|
+
const message = field.isValid?.custom?.(deepMerge(data, setValue({
|
|
47
|
+
item: data,
|
|
48
|
+
value: newValue
|
|
49
|
+
})), field);
|
|
50
|
+
if (message) {
|
|
51
|
+
setCustomValidity({
|
|
52
|
+
type: 'invalid',
|
|
53
|
+
message
|
|
54
|
+
});
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
setCustomValidity(undefined);
|
|
58
|
+
}, [data, field, setValue]);
|
|
35
59
|
return /*#__PURE__*/_jsx(ValidatedTextareaControl, {
|
|
36
60
|
required: !!field.isValid?.required,
|
|
37
|
-
onValidate:
|
|
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
|
-
},
|
|
61
|
+
onValidate: onValidateControl,
|
|
51
62
|
customValidity: customValidity,
|
|
52
63
|
label: label,
|
|
53
64
|
placeholder: placeholder,
|
|
54
65
|
value: value !== null && value !== void 0 ? value : '',
|
|
55
66
|
help: description,
|
|
56
67
|
onChange: onChangeControl,
|
|
68
|
+
rows: rows,
|
|
57
69
|
__next40pxDefaultSize: true,
|
|
58
70
|
__nextHasNoMarginBottom: true,
|
|
59
71
|
hideLabelFromVision: hideLabelFromVision
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["privateApis","useCallback","useState","unlock","jsx","_jsx","ValidatedTextareaControl","Textarea","data","field","onChange","hideLabelFromVision","
|
|
1
|
+
{"version":3,"names":["deepMerge","privateApis","useCallback","useState","unlock","jsx","_jsx","ValidatedTextareaControl","Textarea","data","field","onChange","hideLabelFromVision","config","rows","label","placeholder","description","setValue","value","getValue","item","customValidity","setCustomValidity","undefined","onChangeControl","newValue","onValidateControl","message","isValid","custom","type","required","onValidate","help","__next40pxDefaultSize","__nextHasNoMarginBottom"],"sources":["@wordpress/dataviews/src/dataform-controls/textarea.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport deepMerge from 'deepmerge';\n\n/**\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 { ValidatedTextareaControl } = unlock( privateApis );\n\nexport default function Textarea< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n\tconfig,\n}: DataFormControlProps< Item > ) {\n\tconst { rows = 4 } = config || {};\n\tconst { label, placeholder, description, setValue } = 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 ValidatedTextareaControl\n\t\t\t>[ 'customValidity' ]\n\t\t>( undefined );\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue: string ) =>\n\t\t\tonChange( setValue( { item: data, value: newValue } ) ),\n\t\t[ data, onChange, setValue ]\n\t);\n\n\tconst onValidateControl = useCallback(\n\t\t( newValue: any ) => {\n\t\t\tconst message = field.isValid?.custom?.(\n\t\t\t\tdeepMerge(\n\t\t\t\t\tdata,\n\t\t\t\t\tsetValue( {\n\t\t\t\t\t\titem: data,\n\t\t\t\t\t\tvalue: newValue,\n\t\t\t\t\t} ) as Partial< Item >\n\t\t\t\t),\n\t\t\t\tfield\n\t\t\t);\n\n\t\t\tif ( message ) {\n\t\t\t\tsetCustomValidity( {\n\t\t\t\t\ttype: 'invalid',\n\t\t\t\t\tmessage,\n\t\t\t\t} );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetCustomValidity( undefined );\n\t\t},\n\t\t[ data, field, setValue ]\n\t);\n\n\treturn (\n\t\t<ValidatedTextareaControl\n\t\t\trequired={ !! field.isValid?.required }\n\t\t\tonValidate={ onValidateControl }\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\trows={ rows }\n\t\t\t__next40pxDefaultSize\n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AI;MACVU,KAAK,EAAEO;IACR,CAAE,CACH,CAAC,EACDhB,KACD,CAAC;IAED,IAAKkB,OAAO,EAAG;MACdL,iBAAiB,CAAE;QAClBQ,IAAI,EAAE,SAAS;QACfH;MACD,CAAE,CAAC;MACH;IACD;IAEAL,iBAAiB,CAAEC,SAAU,CAAC;EAC/B,CAAC,EACD,CAAEf,IAAI,EAAEC,KAAK,EAAEQ,QAAQ,CACxB,CAAC;EAED,oBACCZ,IAAA,CAACC,wBAAwB;IACxByB,QAAQ,EAAG,CAAC,CAAEtB,KAAK,CAACmB,OAAO,EAAEG,QAAU;IACvCC,UAAU,EAAGN,iBAAmB;IAChCL,cAAc,EAAGA,cAAgB;IACjCP,KAAK,EAAGA,KAAO;IACfC,WAAW,EAAGA,WAAa;IAC3BG,KAAK,EAAGA,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAI;IACrBe,IAAI,EAAGjB,WAAa;IACpBN,QAAQ,EAAGc,eAAiB;IAC5BX,IAAI,EAAGA,IAAM;IACbqB,qBAAqB;IACrBC,uBAAuB;IACvBxB,mBAAmB,EAAGA;EAAqB,CAC3C,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -1,13 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import deepMerge from 'deepmerge';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import { useCallback } from '@wordpress/element';
|
|
9
|
+
import { privateApis, __experimentalToggleGroupControlOption as ToggleGroupControlOption } from '@wordpress/components';
|
|
10
|
+
import { useCallback, useState } from '@wordpress/element';
|
|
6
11
|
|
|
7
12
|
/**
|
|
8
13
|
* Internal dependencies
|
|
9
14
|
*/
|
|
15
|
+
|
|
16
|
+
import { unlock } from '../lock-unlock';
|
|
10
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
+
const {
|
|
19
|
+
ValidatedToggleGroupControl
|
|
20
|
+
} = unlock(privateApis);
|
|
11
21
|
export default function ToggleGroup({
|
|
12
22
|
data,
|
|
13
23
|
field,
|
|
@@ -15,17 +25,37 @@ export default function ToggleGroup({
|
|
|
15
25
|
hideLabelFromVision
|
|
16
26
|
}) {
|
|
17
27
|
const {
|
|
18
|
-
|
|
28
|
+
getValue,
|
|
29
|
+
setValue
|
|
19
30
|
} = field;
|
|
20
|
-
const
|
|
31
|
+
const [customValidity, setCustomValidity] = useState(undefined);
|
|
32
|
+
const value = getValue({
|
|
21
33
|
item: data
|
|
22
34
|
});
|
|
23
|
-
const onChangeControl = useCallback(newValue => onChange({
|
|
24
|
-
|
|
25
|
-
|
|
35
|
+
const onChangeControl = useCallback(newValue => onChange(setValue({
|
|
36
|
+
item: data,
|
|
37
|
+
value: newValue
|
|
38
|
+
})), [data, onChange, setValue]);
|
|
39
|
+
const onValidateControl = useCallback(newValue => {
|
|
40
|
+
const message = field.isValid?.custom?.(deepMerge(data, setValue({
|
|
41
|
+
item: data,
|
|
42
|
+
value: newValue
|
|
43
|
+
})), field);
|
|
44
|
+
if (message) {
|
|
45
|
+
setCustomValidity({
|
|
46
|
+
type: 'invalid',
|
|
47
|
+
message
|
|
48
|
+
});
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
setCustomValidity(undefined);
|
|
52
|
+
}, [data, field, setValue]);
|
|
26
53
|
if (field.elements) {
|
|
27
54
|
const selectedOption = field.elements.find(el => el.value === value);
|
|
28
|
-
return /*#__PURE__*/_jsx(
|
|
55
|
+
return /*#__PURE__*/_jsx(ValidatedToggleGroupControl, {
|
|
56
|
+
required: !!field.isValid?.required,
|
|
57
|
+
onValidate: onValidateControl,
|
|
58
|
+
customValidity: customValidity,
|
|
29
59
|
__next40pxDefaultSize: true,
|
|
30
60
|
__nextHasNoMarginBottom: true,
|
|
31
61
|
isBlock: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["deepMerge","privateApis","__experimentalToggleGroupControlOption","ToggleGroupControlOption","useCallback","useState","unlock","jsx","_jsx","ValidatedToggleGroupControl","ToggleGroup","data","field","onChange","hideLabelFromVision","getValue","setValue","customValidity","setCustomValidity","undefined","value","item","onChangeControl","newValue","onValidateControl","message","isValid","custom","type","elements","selectedOption","find","el","required","onValidate","__next40pxDefaultSize","__nextHasNoMarginBottom","isBlock","label","help","description","children","map"],"sources":["@wordpress/dataviews/src/dataform-controls/toggle-group.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport deepMerge from 'deepmerge';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\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 { ValidatedToggleGroupControl } = unlock( privateApis );\n\nexport default function ToggleGroup< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n}: DataFormControlProps< Item > ) {\n\tconst { getValue, setValue } = field;\n\tconst [ customValidity, setCustomValidity ] =\n\t\tuseState<\n\t\t\tReact.ComponentProps<\n\t\t\t\ttypeof ValidatedToggleGroupControl\n\t\t\t>[ 'customValidity' ]\n\t\t>( undefined );\n\tconst value = getValue( { item: data } );\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue: string | number | undefined ) =>\n\t\t\tonChange( setValue( { item: data, value: newValue } ) ),\n\t\t[ data, onChange, setValue ]\n\t);\n\tconst onValidateControl = useCallback(\n\t\t( newValue: any ) => {\n\t\t\tconst message = field.isValid?.custom?.(\n\t\t\t\tdeepMerge(\n\t\t\t\t\tdata,\n\t\t\t\t\tsetValue( {\n\t\t\t\t\t\titem: data,\n\t\t\t\t\t\tvalue: newValue,\n\t\t\t\t\t} ) as Partial< Item >\n\t\t\t\t),\n\t\t\t\tfield\n\t\t\t);\n\n\t\t\tif ( message ) {\n\t\t\t\tsetCustomValidity( {\n\t\t\t\t\ttype: 'invalid',\n\t\t\t\t\tmessage,\n\t\t\t\t} );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetCustomValidity( undefined );\n\t\t},\n\t\t[ data, field, setValue ]\n\t);\n\n\tif ( field.elements ) {\n\t\tconst selectedOption = field.elements.find(\n\t\t\t( el ) => el.value === value\n\t\t);\n\t\treturn (\n\t\t\t<ValidatedToggleGroupControl\n\t\t\t\trequired={ !! field.isValid?.required }\n\t\t\t\tonValidate={ onValidateControl }\n\t\t\t\tcustomValidity={ customValidity }\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tisBlock\n\t\t\t\tlabel={ field.label }\n\t\t\t\thelp={ selectedOption?.description || field.description }\n\t\t\t\tonChange={ onChangeControl }\n\t\t\t\tvalue={ value }\n\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t>\n\t\t\t\t{ field.elements.map( ( el ) => (\n\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\tkey={ el.value }\n\t\t\t\t\t\tlabel={ el.label }\n\t\t\t\t\t\tvalue={ el.value }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t</ValidatedToggleGroupControl>\n\t\t);\n\t}\n\n\treturn null;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,WAAW;;AAEjC;AACA;AACA;AACA,SACCC,WAAW,EACXC,sCAAsC,IAAIC,wBAAwB,QAC5D,uBAAuB;AAC9B,SAASC,WAAW,EAAEC,QAAQ,QAAQ,oBAAoB;;AAE1D;AACA;AACA;;AAEA,SAASC,MAAM,QAAQ,gBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAExC,MAAM;EAAEC;AAA4B,CAAC,GAAGH,MAAM,CAAEL,WAAY,CAAC;AAE7D,eAAe,SAASS,WAAWA,CAAU;EAC5CC,IAAI;EACJC,K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AGA,cAAgB;MACjCkB,qBAAqB;MACrBC,uBAAuB;MACvBC,OAAO;MACPC,KAAK,EAAG1B,KAAK,CAAC0B,KAAO;MACrBC,IAAI,EAAGT,cAAc,EAAEU,WAAW,IAAI5B,KAAK,CAAC4B,WAAa;MACzD3B,QAAQ,EAAGS,eAAiB;MAC5BF,KAAK,EAAGA,KAAO;MACfN,mBAAmB,EAAGA,mBAAqB;MAAA2B,QAAA,EAEzC7B,KAAK,CAACiB,QAAQ,CAACa,GAAG,CAAIV,EAAE,iBACzBxB,IAAA,CAACL,wBAAwB;QAExBmC,KAAK,EAAGN,EAAE,CAACM,KAAO;QAClBlB,KAAK,EAAGY,EAAE,CAACZ;MAAO,GAFZY,EAAE,CAACZ,KAGT,CACA;IAAC,CACyB,CAAC;EAEhC;EAEA,OAAO,IAAI;AACZ","ignoreList":[]}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import deepMerge from 'deepmerge';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
4
9
|
import { privateApis } from '@wordpress/components';
|
|
5
|
-
import { useState } from '@wordpress/element';
|
|
10
|
+
import { useCallback, useState } from '@wordpress/element';
|
|
6
11
|
|
|
7
12
|
/**
|
|
8
13
|
* Internal dependencies
|
|
@@ -20,28 +25,37 @@ export default function Toggle({
|
|
|
20
25
|
hideLabelFromVision
|
|
21
26
|
}) {
|
|
22
27
|
const {
|
|
23
|
-
id,
|
|
24
|
-
getValue,
|
|
25
28
|
label,
|
|
26
|
-
description
|
|
29
|
+
description,
|
|
30
|
+
getValue,
|
|
31
|
+
setValue
|
|
27
32
|
} = field;
|
|
28
33
|
const [customValidity, setCustomValidity] = useState(undefined);
|
|
34
|
+
const onChangeControl = useCallback(() => {
|
|
35
|
+
onChange(setValue({
|
|
36
|
+
item: data,
|
|
37
|
+
value: !getValue({
|
|
38
|
+
item: data
|
|
39
|
+
})
|
|
40
|
+
}));
|
|
41
|
+
}, [onChange, setValue, data, getValue]);
|
|
42
|
+
const onValidateControl = useCallback(newValue => {
|
|
43
|
+
const message = field.isValid?.custom?.(deepMerge(data, setValue({
|
|
44
|
+
item: data,
|
|
45
|
+
value: newValue
|
|
46
|
+
})), field);
|
|
47
|
+
if (message) {
|
|
48
|
+
setCustomValidity({
|
|
49
|
+
type: 'invalid',
|
|
50
|
+
message
|
|
51
|
+
});
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
setCustomValidity(undefined);
|
|
55
|
+
}, [data, field, setValue]);
|
|
29
56
|
return /*#__PURE__*/_jsx(ValidatedToggleControl, {
|
|
30
57
|
required: !!field.isValid.required,
|
|
31
|
-
onValidate:
|
|
32
|
-
const message = field.isValid?.custom?.({
|
|
33
|
-
...data,
|
|
34
|
-
[id]: newValue
|
|
35
|
-
}, field);
|
|
36
|
-
if (message) {
|
|
37
|
-
setCustomValidity({
|
|
38
|
-
type: 'invalid',
|
|
39
|
-
message
|
|
40
|
-
});
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
setCustomValidity(undefined);
|
|
44
|
-
},
|
|
58
|
+
onValidate: onValidateControl,
|
|
45
59
|
customValidity: customValidity,
|
|
46
60
|
hidden: hideLabelFromVision,
|
|
47
61
|
__nextHasNoMarginBottom: true,
|
|
@@ -50,11 +64,7 @@ export default function Toggle({
|
|
|
50
64
|
checked: getValue({
|
|
51
65
|
item: data
|
|
52
66
|
}),
|
|
53
|
-
onChange:
|
|
54
|
-
[id]: !getValue({
|
|
55
|
-
item: data
|
|
56
|
-
})
|
|
57
|
-
})
|
|
67
|
+
onChange: onChangeControl
|
|
58
68
|
});
|
|
59
69
|
}
|
|
60
70
|
//# sourceMappingURL=toggle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["privateApis","useState","unlock","jsx","_jsx","ValidatedToggleControl","Toggle","field","onChange","data","hideLabelFromVision","
|
|
1
|
+
{"version":3,"names":["deepMerge","privateApis","useCallback","useState","unlock","jsx","_jsx","ValidatedToggleControl","Toggle","field","onChange","data","hideLabelFromVision","label","description","getValue","setValue","customValidity","setCustomValidity","undefined","onChangeControl","item","value","onValidateControl","newValue","message","isValid","custom","type","required","onValidate","hidden","__nextHasNoMarginBottom","help","checked"],"sources":["@wordpress/dataviews/src/dataform-controls/toggle.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport deepMerge from 'deepmerge';\n\n/**\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 { ValidatedToggleControl } = unlock( privateApis );\n\nexport default function Toggle< Item >( {\n\tfield,\n\tonChange,\n\tdata,\n\thideLabelFromVision,\n}: DataFormControlProps< Item > ) {\n\tconst { label, description, getValue, setValue } = 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\tconst onChangeControl = useCallback( () => {\n\t\tonChange(\n\t\t\tsetValue( { item: data, value: ! getValue( { item: data } ) } )\n\t\t);\n\t}, [ onChange, setValue, data, getValue ] );\n\n\tconst onValidateControl = useCallback(\n\t\t( newValue: any ) => {\n\t\t\tconst message = field.isValid?.custom?.(\n\t\t\t\tdeepMerge(\n\t\t\t\t\tdata,\n\t\t\t\t\tsetValue( {\n\t\t\t\t\t\titem: data,\n\t\t\t\t\t\tvalue: newValue,\n\t\t\t\t\t} ) as Partial< Item >\n\t\t\t\t),\n\t\t\t\tfield\n\t\t\t);\n\n\t\t\tif ( message ) {\n\t\t\t\tsetCustomValidity( {\n\t\t\t\t\ttype: 'invalid',\n\t\t\t\t\tmessage,\n\t\t\t\t} );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetCustomValidity( undefined );\n\t\t},\n\t\t[ data, field, setValue ]\n\t);\n\n\treturn (\n\t\t<ValidatedToggleControl\n\t\t\trequired={ !! field.isValid.required }\n\t\t\tonValidate={ onValidateControl }\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={ onChangeControl }\n\t\t/>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,WAAW;;AAEjC;AACA;AACA;AACA,SAASC,WAAW,QAAQ,uBAAuB;AACnD,SAASC,WAAW,EAAEC,QAAQ,QAAQ,oBAAoB;;AAE1D;AACA;AACA;;AAEA,SAASC,MAAM,QAAQ,gBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAExC,MAAM;EAAEC;AAAuB,CAAC,GAAGH,MAAM,CAAEH,WAAY,CAAC;AAExD,eAAe,SAASO,MAAMA,CAAU;EACvCC,KAAK;EACLC,QAAQ;EACRC,IAAI;EACJC;AAC6B,CAAC,EAAG;EACjC,MAAM;IAAEC,KAAK;IAAEC,WAAW;IAAEC,QAAQ;IAAEC;EAAS,CAAC,GAAGP,KAAK;EACxD,MAAM,CAAEQ,cAAc,EAAEC,iBAAiB,CAAE,GAC1Cf,QAAQ,CAILgB,SAAU,CAAC;EAEf,MAAMC,eAAe,GAAGlB,WAAW,CAAE,MAAM;IAC1CQ,QAAQ,CACPM,QAAQ,CAAE;MAAEK,IAAI,EAAEV,IAAI;MAAEW,KAAK,EAAE,CAAEP,QAAQ,CAAE;QAAEM,IAAI,EAAEV;MAAK,CAAE;IAAE,CAAE,CAC/D,CAAC;EACF,CAAC,EAAE,CAAED,QAAQ,EAAEM,QAAQ,EAAEL,IAAI,EAAEI,QAAQ,CAAG,CAAC;EAE3C,MAAMQ,iBAAiB,GAAGrB,WAAW,CAClCsB,QAAa,IAAM;IACpB,MAAMC,OAAO,GAAGhB,KAAK,CAACiB,OAAO,EAAEC,MAAM,GACpC3B,SAAS,CACRW,IAAI,EACJK,QAAQ,CAAE;MACTK,IAAI,EAAEV,IAAI;MACVW,KAAK,EAAEE;IACR,CAAE,CACH,CAAC,EACDf,KACD,CAAC;IAED,IAAKgB,OAAO,EAAG;MACdP,iBAAiB,CAAE;QAClBU,IAAI,EAAE,SAAS;QACfH;MACD,CAAE,CAAC;MACH;IACD;IAEAP,iBAAiB,CAAEC,SAAU,CAAC;EAC/B,CAAC,EACD,CAAER,IAAI,EAAEF,KAAK,EAAEO,QAAQ,CACxB,CAAC;EAED,oBACCV,IAAA,CAACC,sBAAsB;IACtBsB,QAAQ,EAAG,CAAC,CAAEpB,KAAK,CAACiB,OAAO,CAACG,QAAU;IACtCC,UAAU,EAAGP,iBAAmB;IAChCN,cAAc,EAAGA,cAAgB;IACjCc,MAAM,EAAGnB,mBAAqB;IAC9BoB,uBAAuB;IACvBnB,KAAK,EAAGA,KAAO;IACfoB,IAAI,EAAGnB,WAAa;IACpBoB,OAAO,EAAGnB,QAAQ,CAAE;MAAEM,IAAI,EAAEV;IAAK,CAAE,CAAG;IACtCD,QAAQ,EAAGU;EAAiB,CAC5B,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
+
import { Icon, __experimentalInputControlPrefixWrapper as InputControlPrefixWrapper } from '@wordpress/components';
|
|
4
5
|
import { link } from '@wordpress/icons';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -21,7 +22,12 @@ export default function Url({
|
|
|
21
22
|
onChange,
|
|
22
23
|
hideLabelFromVision,
|
|
23
24
|
type: 'url',
|
|
24
|
-
|
|
25
|
+
prefix: /*#__PURE__*/_jsx(InputControlPrefixWrapper, {
|
|
26
|
+
variant: "icon",
|
|
27
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
28
|
+
icon: link
|
|
29
|
+
})
|
|
30
|
+
})
|
|
25
31
|
});
|
|
26
32
|
}
|
|
27
33
|
//# sourceMappingURL=url.js.map
|
|
@@ -1 +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-input';\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\
|
|
1
|
+
{"version":3,"names":["Icon","__experimentalInputControlPrefixWrapper","InputControlPrefixWrapper","link","ValidatedText","jsx","_jsx","Url","data","field","onChange","hideLabelFromVision","type","prefix","variant","children","icon"],"sources":["@wordpress/dataviews/src/dataform-controls/url.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\t__experimentalInputControlPrefixWrapper as InputControlPrefixWrapper,\n} from '@wordpress/components';\nimport { link } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport type { DataFormControlProps } from '../types';\nimport ValidatedText from './utils/validated-input';\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\tprefix: (\n\t\t\t\t\t<InputControlPrefixWrapper variant=\"icon\">\n\t\t\t\t\t\t<Icon icon={ link } />\n\t\t\t\t\t</InputControlPrefixWrapper>\n\t\t\t\t),\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,IAAI,EACJC,uCAAuC,IAAIC,yBAAyB,QAC9D,uBAAuB;AAC9B,SAASC,IAAI,QAAQ,kBAAkB;;AAEvC;AACA;AACA;;AAEA,OAAOC,aAAa,MAAM,yBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEpD,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,MAAM,eACLP,IAAA,CAACJ,yBAAyB;MAACY,OAAO,EAAC,MAAM;MAAAC,QAAA,eACxCT,IAAA,CAACN,IAAI;QAACgB,IAAI,EAAGb;MAAM,CAAE;IAAC,CACI;EAC3B,CAEF,CAAC;AAEJ","ignoreList":[]}
|