@wordpress/dataviews 4.0.0 → 4.1.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 +16 -5
- package/build/components/dataform/index.js +10 -61
- package/build/components/dataform/index.js.map +1 -1
- package/build/components/dataviews/index.js +16 -5
- package/build/components/dataviews/index.js.map +1 -1
- package/build/components/dataviews-bulk-actions/index.js +3 -0
- package/build/components/dataviews-bulk-actions/index.js.map +1 -1
- package/build/components/dataviews-filters/add-filter.js +34 -17
- package/build/components/dataviews-filters/add-filter.js.map +1 -1
- package/build/components/dataviews-filters/index.js +106 -43
- package/build/components/dataviews-filters/index.js.map +1 -1
- package/build/components/dataviews-layout/index.js +2 -2
- package/build/components/dataviews-layout/index.js.map +1 -1
- package/build/components/dataviews-search/index.js +8 -5
- package/build/components/dataviews-search/index.js.map +1 -1
- package/build/components/dataviews-view-config/index.js +225 -190
- package/build/components/dataviews-view-config/index.js.map +1 -1
- package/build/constants.js +6 -1
- package/build/constants.js.map +1 -1
- package/build/dataforms-layouts/index.js +24 -0
- package/build/dataforms-layouts/index.js.map +1 -0
- package/build/dataforms-layouts/panel/index.js +129 -0
- package/build/dataforms-layouts/panel/index.js.map +1 -0
- package/build/dataforms-layouts/regular/index.js +39 -0
- package/build/dataforms-layouts/regular/index.js.map +1 -0
- package/build/{layouts → dataviews-layouts}/grid/density-picker.js +1 -1
- package/build/dataviews-layouts/grid/density-picker.js.map +1 -0
- package/build/{layouts → dataviews-layouts}/grid/index.js +8 -8
- package/build/dataviews-layouts/grid/index.js.map +1 -0
- package/build/dataviews-layouts/index.js.map +1 -0
- package/build/dataviews-layouts/list/index.js.map +1 -0
- package/build/{layouts → dataviews-layouts}/table/column-header-menu.js +1 -1
- package/build/dataviews-layouts/table/column-header-menu.js.map +1 -0
- package/build/dataviews-layouts/table/index.js.map +1 -0
- package/build/field-types/index.js +46 -0
- package/build/field-types/index.js.map +1 -0
- package/build/field-types/integer.js +94 -0
- package/build/field-types/integer.js.map +1 -0
- package/build/field-types/text.js +87 -0
- package/build/field-types/text.js.map +1 -0
- package/build/filter-and-sort-data-view.js +2 -11
- package/build/filter-and-sort-data-view.js.map +1 -1
- package/build/index.js +9 -2
- package/build/index.js.map +1 -1
- package/build/normalize-fields.js +35 -1
- package/build/normalize-fields.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build/validation.js +22 -0
- package/build/validation.js.map +1 -0
- package/build-module/components/dataform/index.js +10 -61
- package/build-module/components/dataform/index.js.map +1 -1
- package/build-module/components/dataviews/index.js +14 -5
- package/build-module/components/dataviews/index.js.map +1 -1
- package/build-module/components/dataviews-bulk-actions/index.js +3 -0
- package/build-module/components/dataviews-bulk-actions/index.js.map +1 -1
- package/build-module/components/dataviews-filters/add-filter.js +33 -17
- package/build-module/components/dataviews-filters/add-filter.js.map +1 -1
- package/build-module/components/dataviews-filters/index.js +105 -45
- package/build-module/components/dataviews-filters/index.js.map +1 -1
- package/build-module/components/dataviews-layout/index.js +1 -1
- package/build-module/components/dataviews-layout/index.js.map +1 -1
- package/build-module/components/dataviews-search/index.js +8 -5
- package/build-module/components/dataviews-search/index.js.map +1 -1
- package/build-module/components/dataviews-view-config/index.js +228 -193
- package/build-module/components/dataviews-view-config/index.js.map +1 -1
- package/build-module/constants.js +5 -0
- package/build-module/constants.js.map +1 -1
- package/build-module/dataforms-layouts/index.js +16 -0
- package/build-module/dataforms-layouts/index.js.map +1 -0
- package/build-module/dataforms-layouts/panel/index.js +124 -0
- package/build-module/dataforms-layouts/panel/index.js.map +1 -0
- package/build-module/dataforms-layouts/regular/index.js +32 -0
- package/build-module/dataforms-layouts/regular/index.js.map +1 -0
- package/build-module/{layouts → dataviews-layouts}/grid/density-picker.js +2 -2
- package/build-module/dataviews-layouts/grid/density-picker.js.map +1 -0
- package/build-module/{layouts → dataviews-layouts}/grid/index.js +8 -8
- package/build-module/dataviews-layouts/grid/index.js.map +1 -0
- package/build-module/dataviews-layouts/index.js.map +1 -0
- package/build-module/dataviews-layouts/list/index.js.map +1 -0
- package/build-module/{layouts → dataviews-layouts}/table/column-header-menu.js +1 -1
- package/build-module/dataviews-layouts/table/column-header-menu.js.map +1 -0
- package/build-module/dataviews-layouts/table/index.js.map +1 -0
- package/build-module/field-types/index.js +40 -0
- package/build-module/field-types/index.js.map +1 -0
- package/build-module/field-types/integer.js +87 -0
- package/build-module/field-types/integer.js.map +1 -0
- package/build-module/field-types/text.js +80 -0
- package/build-module/field-types/text.js.map +1 -0
- package/build-module/filter-and-sort-data-view.js +2 -11
- package/build-module/filter-and-sort-data-view.js.map +1 -1
- package/build-module/index.js +2 -1
- package/build-module/index.js.map +1 -1
- package/build-module/normalize-fields.js +34 -2
- package/build-module/normalize-fields.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-module/validation.js +15 -0
- package/build-module/validation.js.map +1 -0
- package/build-style/style-rtl.css +175 -6
- package/build-style/style.css +175 -6
- package/build-types/components/dataform/index.d.ts +2 -13
- package/build-types/components/dataform/index.d.ts.map +1 -1
- package/build-types/components/dataform/stories/index.story.d.ts +12 -1
- package/build-types/components/dataform/stories/index.story.d.ts.map +1 -1
- package/build-types/components/dataviews/index.d.ts.map +1 -1
- package/build-types/components/dataviews/stories/fixtures.d.ts +6 -0
- package/build-types/components/dataviews/stories/fixtures.d.ts.map +1 -1
- package/build-types/components/dataviews-bulk-actions/index.d.ts.map +1 -1
- package/build-types/components/dataviews-filters/add-filter.d.ts +3 -0
- package/build-types/components/dataviews-filters/add-filter.d.ts.map +1 -1
- package/build-types/components/dataviews-filters/index.d.ts +11 -1
- package/build-types/components/dataviews-filters/index.d.ts.map +1 -1
- package/build-types/components/dataviews-search/index.d.ts.map +1 -1
- package/build-types/components/dataviews-view-config/index.d.ts +1 -1
- package/build-types/components/dataviews-view-config/index.d.ts.map +1 -1
- package/build-types/constants.d.ts +4 -0
- package/build-types/constants.d.ts.map +1 -1
- package/build-types/dataforms-layouts/index.d.ts +9 -0
- package/build-types/dataforms-layouts/index.d.ts.map +1 -0
- package/build-types/dataforms-layouts/panel/index.d.ts +3 -0
- package/build-types/dataforms-layouts/panel/index.d.ts.map +1 -0
- package/build-types/dataforms-layouts/regular/index.d.ts +3 -0
- package/build-types/dataforms-layouts/regular/index.d.ts.map +1 -0
- package/build-types/dataviews-layouts/grid/density-picker.d.ts.map +1 -0
- package/build-types/dataviews-layouts/grid/index.d.ts.map +1 -0
- package/build-types/dataviews-layouts/index.d.ts.map +1 -0
- package/build-types/dataviews-layouts/list/index.d.ts.map +1 -0
- package/build-types/dataviews-layouts/table/column-header-menu.d.ts.map +1 -0
- package/build-types/dataviews-layouts/table/index.d.ts.map +1 -0
- package/build-types/field-types/index.d.ts +20 -0
- package/build-types/field-types/index.d.ts.map +1 -0
- package/build-types/field-types/integer.d.ts +14 -0
- package/build-types/field-types/integer.d.ts.map +1 -0
- package/build-types/field-types/text.d.ts +14 -0
- package/build-types/field-types/text.d.ts.map +1 -0
- package/build-types/filter-and-sort-data-view.d.ts.map +1 -1
- package/build-types/index.d.ts +2 -1
- package/build-types/index.d.ts.map +1 -1
- package/build-types/normalize-fields.d.ts +0 -3
- package/build-types/normalize-fields.d.ts.map +1 -1
- package/build-types/types.d.ts +38 -3
- package/build-types/types.d.ts.map +1 -1
- package/build-types/validation.d.ts +3 -0
- package/build-types/validation.d.ts.map +1 -0
- package/package.json +12 -11
- package/src/components/dataform/index.tsx +8 -97
- package/src/components/dataform/stories/index.story.tsx +40 -3
- package/src/components/dataviews/index.tsx +20 -8
- package/src/components/dataviews/stories/fixtures.js +1 -0
- package/src/components/dataviews/style.scss +5 -2
- package/src/components/dataviews-bulk-actions/index.tsx +5 -0
- package/src/components/dataviews-filters/add-filter.tsx +37 -21
- package/src/components/dataviews-filters/index.tsx +149 -61
- package/src/components/dataviews-filters/style.scss +30 -0
- package/src/components/dataviews-layout/index.tsx +1 -1
- package/src/components/dataviews-search/index.tsx +8 -5
- package/src/components/dataviews-view-config/index.tsx +272 -258
- package/src/components/dataviews-view-config/style.scss +44 -0
- package/src/constants.ts +5 -0
- package/src/dataforms-layouts/index.tsx +20 -0
- package/src/dataforms-layouts/panel/index.tsx +164 -0
- package/src/dataforms-layouts/panel/style.scss +59 -0
- package/src/dataforms-layouts/regular/index.tsx +41 -0
- package/src/{layouts → dataviews-layouts}/grid/density-picker.tsx +2 -2
- package/src/{layouts → dataviews-layouts}/grid/index.tsx +8 -8
- package/src/{layouts → dataviews-layouts}/grid/style.scss +29 -0
- package/src/{layouts → dataviews-layouts}/list/style.scss +4 -1
- package/src/{layouts → dataviews-layouts}/table/column-header-menu.tsx +1 -1
- package/src/field-types/index.tsx +45 -0
- package/src/field-types/integer.tsx +103 -0
- package/src/field-types/text.tsx +95 -0
- package/src/filter-and-sort-data-view.ts +1 -15
- package/src/index.ts +2 -1
- package/src/normalize-fields.ts +44 -3
- package/src/style.scss +6 -3
- package/src/test/filter-and-sort-data-view.js +46 -3
- package/src/test/validation.ts +131 -0
- package/src/types.ts +50 -3
- package/src/validation.ts +18 -0
- package/tsconfig.json +2 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/layouts/grid/density-picker.js.map +0 -1
- package/build/layouts/grid/index.js.map +0 -1
- package/build/layouts/index.js.map +0 -1
- package/build/layouts/list/index.js.map +0 -1
- package/build/layouts/table/column-header-menu.js.map +0 -1
- package/build/layouts/table/index.js.map +0 -1
- package/build-module/layouts/grid/density-picker.js.map +0 -1
- package/build-module/layouts/grid/index.js.map +0 -1
- package/build-module/layouts/index.js.map +0 -1
- package/build-module/layouts/list/index.js.map +0 -1
- package/build-module/layouts/table/column-header-menu.js.map +0 -1
- package/build-module/layouts/table/index.js.map +0 -1
- package/build-types/layouts/grid/density-picker.d.ts.map +0 -1
- package/build-types/layouts/grid/index.d.ts.map +0 -1
- package/build-types/layouts/index.d.ts.map +0 -1
- package/build-types/layouts/list/index.d.ts.map +0 -1
- package/build-types/layouts/table/column-header-menu.d.ts.map +0 -1
- package/build-types/layouts/table/index.d.ts.map +0 -1
- /package/build/{layouts → dataviews-layouts}/index.js +0 -0
- /package/build/{layouts → dataviews-layouts}/list/index.js +0 -0
- /package/build/{layouts → dataviews-layouts}/table/index.js +0 -0
- /package/build-module/{layouts → dataviews-layouts}/index.js +0 -0
- /package/build-module/{layouts → dataviews-layouts}/list/index.js +0 -0
- /package/build-module/{layouts → dataviews-layouts}/table/index.js +0 -0
- /package/build-types/{layouts → dataviews-layouts}/grid/density-picker.d.ts +0 -0
- /package/build-types/{layouts → dataviews-layouts}/grid/index.d.ts +0 -0
- /package/build-types/{layouts → dataviews-layouts}/index.d.ts +0 -0
- /package/build-types/{layouts → dataviews-layouts}/list/index.d.ts +0 -0
- /package/build-types/{layouts → dataviews-layouts}/table/column-header-menu.d.ts +0 -0
- /package/build-types/{layouts → dataviews-layouts}/table/index.d.ts +0 -0
- /package/src/{layouts → dataviews-layouts}/index.ts +0 -0
- /package/src/{layouts → dataviews-layouts}/list/index.tsx +0 -0
- /package/src/{layouts → dataviews-layouts}/table/index.tsx +0 -0
- /package/src/{layouts → dataviews-layouts}/table/style.scss +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__experimentalNumberControl","NumberControl","SelectControl","useCallback","__","jsx","_jsx","sort","a","b","direction","isValid","value","context","Number","isInteger","elements","validValues","map","f","includes","Edit","data","field","onChange","hideLabelFromVision","_field$getValue","id","label","description","getValue","item","onChangeControl","newValue","prevItem","options","__next40pxDefaultSize","__nextHasNoMarginBottom","help"],"sources":["@wordpress/dataviews/src/field-types/integer.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalNumberControl as NumberControl,\n\tSelectControl,\n} from '@wordpress/components';\nimport { useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tSortDirection,\n\tValidationContext,\n\tDataFormControlProps,\n} from '../types';\n\nfunction sort( a: any, b: any, direction: SortDirection ) {\n\treturn direction === 'asc' ? a - b : b - a;\n}\n\nfunction isValid( value: any, context?: ValidationContext ) {\n\t// TODO: this implicitely means the value is required.\n\tif ( value === '' ) {\n\t\treturn false;\n\t}\n\n\tif ( ! Number.isInteger( Number( value ) ) ) {\n\t\treturn false;\n\t}\n\n\tif ( context?.elements ) {\n\t\tconst validValues = context?.elements.map( ( f ) => f.value );\n\t\tif ( ! validValues.includes( Number( value ) ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\nfunction Edit< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n}: DataFormControlProps< Item > ) {\n\tconst { id, label, description } = field;\n\tconst value = field.getValue( { item: data } ) ?? '';\n\tconst onChangeControl = useCallback(\n\t\t( newValue: string | undefined ) =>\n\t\t\tonChange( ( prevItem: Item ) => ( {\n\t\t\t\t...prevItem,\n\t\t\t\t[ id ]: newValue,\n\t\t\t} ) ),\n\t\t[ id, onChange ]\n\t);\n\n\tif ( field.elements ) {\n\t\tconst elements = [\n\t\t\t/*\n\t\t\t * Value can be undefined when:\n\t\t\t *\n\t\t\t * - the field is not required\n\t\t\t * - in bulk editing\n\t\t\t *\n\t\t\t */\n\t\t\t{ label: __( 'Select item' ), value: '' },\n\t\t\t...field.elements,\n\t\t];\n\n\t\treturn (\n\t\t\t<SelectControl\n\t\t\t\tlabel={ label }\n\t\t\t\tvalue={ value }\n\t\t\t\toptions={ elements }\n\t\t\t\tonChange={ onChangeControl }\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<NumberControl\n\t\t\tlabel={ label }\n\t\t\thelp={ description }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChangeControl }\n\t\t\t__next40pxDefaultSize\n\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t/>\n\t);\n}\n\nexport default {\n\tsort,\n\tisValid,\n\tE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C8B,QAA4B,IAC7BT,QAAQ,CAAIU,QAAc,KAAQ;IACjC,GAAGA,QAAQ;IACX,CAAEP,EAAE,GAAIM;EACT,CAAC,CAAG,CAAC,EACN,CAAEN,EAAE,EAAEH,QAAQ,CACf,CAAC;EAED,IAAKD,KAAK,CAACP,QAAQ,EAAG;IACrB,MAAMA,QAAQ,GAAG;IAChB;AACH;AACA;AACA;AACA;AACA;AACA;IACG;MAAEY,KAAK,EAAExB,EAAE,CAAE,aAAc,CAAC;MAAEQ,KAAK,EAAE;IAAG,CAAC,EACzC,GAAGW,KAAK,CAACP,QAAQ,CACjB;IAED,oBACCV,IAAA,CAACJ,aAAa;MACb0B,KAAK,EAAGA,KAAO;MACfhB,KAAK,EAAGA,KAAO;MACfuB,OAAO,EAAGnB,QAAU;MACpBQ,QAAQ,EAAGQ,eAAiB;MAC5BI,qBAAqB;MACrBC,uBAAuB;MACvBZ,mBAAmB,EAAGA;IAAqB,CAC3C,CAAC;EAEJ;EAEA,oBACCnB,IAAA,CAACL,aAAa;IACb2B,KAAK,EAAGA,KAAO;IACfU,IAAI,EAAGT,WAAa;IACpBjB,KAAK,EAAGA,KAAO;IACfY,QAAQ,EAAGQ,eAAiB;IAC5BI,qBAAqB;IACrBX,mBAAmB,EAAGA;EAAqB,CAC3C,CAAC;AAEJ;AAEA,eAAe;EACdlB,IAAI;EACJI,OAAO;EACPU;AACD,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { SelectControl, TextControl } from '@wordpress/components';
|
|
5
|
+
import { useCallback } from '@wordpress/element';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
function sort(valueA, valueB, direction) {
|
|
13
|
+
return direction === 'asc' ? valueA.localeCompare(valueB) : valueB.localeCompare(valueA);
|
|
14
|
+
}
|
|
15
|
+
function isValid(value, context) {
|
|
16
|
+
if (context?.elements) {
|
|
17
|
+
const validValues = context?.elements?.map(f => f.value);
|
|
18
|
+
if (!validValues.includes(value)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
function Edit({
|
|
25
|
+
data,
|
|
26
|
+
field,
|
|
27
|
+
onChange,
|
|
28
|
+
hideLabelFromVision
|
|
29
|
+
}) {
|
|
30
|
+
const {
|
|
31
|
+
id,
|
|
32
|
+
label,
|
|
33
|
+
placeholder
|
|
34
|
+
} = field;
|
|
35
|
+
const value = field.getValue({
|
|
36
|
+
item: data
|
|
37
|
+
});
|
|
38
|
+
const onChangeControl = useCallback(newValue => onChange(prevItem => ({
|
|
39
|
+
...prevItem,
|
|
40
|
+
[id]: newValue
|
|
41
|
+
})), [id, onChange]);
|
|
42
|
+
if (field.elements) {
|
|
43
|
+
const elements = [
|
|
44
|
+
/*
|
|
45
|
+
* Value can be undefined when:
|
|
46
|
+
*
|
|
47
|
+
* - the field is not required
|
|
48
|
+
* - in bulk editing
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
{
|
|
52
|
+
label: __('Select item'),
|
|
53
|
+
value: ''
|
|
54
|
+
}, ...field.elements];
|
|
55
|
+
return /*#__PURE__*/_jsx(SelectControl, {
|
|
56
|
+
label: label,
|
|
57
|
+
value: value,
|
|
58
|
+
options: elements,
|
|
59
|
+
onChange: onChangeControl,
|
|
60
|
+
__next40pxDefaultSize: true,
|
|
61
|
+
__nextHasNoMarginBottom: true,
|
|
62
|
+
hideLabelFromVision: hideLabelFromVision
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return /*#__PURE__*/_jsx(TextControl, {
|
|
66
|
+
label: label,
|
|
67
|
+
placeholder: placeholder,
|
|
68
|
+
value: value !== null && value !== void 0 ? value : '',
|
|
69
|
+
onChange: onChangeControl,
|
|
70
|
+
__next40pxDefaultSize: true,
|
|
71
|
+
__nextHasNoMarginBottom: true,
|
|
72
|
+
hideLabelFromVision: hideLabelFromVision
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export default {
|
|
76
|
+
sort,
|
|
77
|
+
isValid,
|
|
78
|
+
Edit
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SelectControl","TextControl","useCallback","__","jsx","_jsx","sort","valueA","valueB","direction","localeCompare","isValid","value","context","elements","validValues","map","f","includes","Edit","data","field","onChange","hideLabelFromVision","id","label","placeholder","getValue","item","onChangeControl","newValue","prevItem","options","__next40pxDefaultSize","__nextHasNoMarginBottom"],"sources":["@wordpress/dataviews/src/field-types/text.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SelectControl, TextControl } from '@wordpress/components';\nimport { useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tSortDirection,\n\tValidationContext,\n\tDataFormControlProps,\n} from '../types';\n\nfunction sort( valueA: any, valueB: any, direction: SortDirection ) {\n\treturn direction === 'asc'\n\t\t? valueA.localeCompare( valueB )\n\t\t: valueB.localeCompare( valueA );\n}\n\nfunction isValid( value: any, context?: ValidationContext ) {\n\tif ( context?.elements ) {\n\t\tconst validValues = context?.elements?.map( ( f ) => f.value );\n\t\tif ( ! validValues.includes( value ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\nfunction Edit< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n}: DataFormControlProps< Item > ) {\n\tconst { id, label, placeholder } = field;\n\tconst value = field.getValue( { item: data } );\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue: string ) =>\n\t\t\tonChange( ( prevItem: Item ) => ( {\n\t\t\t\t...prevItem,\n\t\t\t\t[ id ]: newValue,\n\t\t\t} ) ),\n\t\t[ id, onChange ]\n\t);\n\n\tif ( field.elements ) {\n\t\tconst elements = [\n\t\t\t/*\n\t\t\t * Value can be undefined when:\n\t\t\t *\n\t\t\t * - the field is not required\n\t\t\t * - in bulk editing\n\t\t\t *\n\t\t\t */\n\t\t\t{ label: __( 'Select item' ), value: '' },\n\t\t\t...field.elements,\n\t\t];\n\n\t\treturn (\n\t\t\t<SelectControl\n\t\t\t\tlabel={ label }\n\t\t\t\tvalue={ value }\n\t\t\t\toptions={ elements }\n\t\t\t\tonChange={ onChangeControl }\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<TextControl\n\t\t\tlabel={ label }\n\t\t\tplaceholder={ placeholder }\n\t\t\tvalue={ value ?? '' }\n\t\t\tonChange={ onChangeControl }\n\t\t\t__next40pxDefaultSize\n\t\t\t__nextHasNoMarginBottom\n\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t/>\n\t);\n}\n\nexport default {\n\tsort,\n\tisValid,\n\tEdit,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,WAAW,QAAQ,uBAAuB;AAClE,SAASC,WAAW,QAAQ,oBAAoB;AAChD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AASA,SAASC,IAAIA,CAAEC,MAAW,EAAEC,MAAW,EAAEC,SAAwB,EAAG;EACnE,OAAOA,SAAS,KAAK,KAAK,GACvBF,MAAM,CAACG,aAAa,CAAEF,MAAO,CAAC,GAC9BA,MAAM,CAACE,aAAa,CAAEH,MAAO,CAAC;AAClC;AAEA,SAASI,OAAOA,CAAEC,KAAU,EAAEC,OAA2B,EAAG;EAC3D,IAAKA,OAAO,EAAEC,QAAQ,EAAG;IACxB,MAAMC,WA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AI,EAAI;IACrBU,QAAQ,EAAGO,eAAiB;IAC5BI,qBAAqB;IACrBC,uBAAuB;IACvBX,mBAAmB,EAAGA;EAAqB,CAC3C,CAAC;AAEJ;AAEA,eAAe;EACdjB,IAAI;EACJK,OAAO;EACPQ;AACD,CAAC","ignoreList":[]}
|
|
@@ -114,17 +114,8 @@ export function filterSortAndPaginate(data, view, fields) {
|
|
|
114
114
|
});
|
|
115
115
|
if (fieldToSort) {
|
|
116
116
|
filteredData.sort((a, b) => {
|
|
117
|
-
var
|
|
118
|
-
|
|
119
|
-
item: a
|
|
120
|
-
})) !== null && _fieldToSort$getValue !== void 0 ? _fieldToSort$getValue : '';
|
|
121
|
-
const valueB = (_fieldToSort$getValue2 = fieldToSort.getValue({
|
|
122
|
-
item: b
|
|
123
|
-
})) !== null && _fieldToSort$getValue2 !== void 0 ? _fieldToSort$getValue2 : '';
|
|
124
|
-
if (typeof valueA === 'number' && typeof valueB === 'number') {
|
|
125
|
-
return view.sort?.direction === 'asc' ? valueA - valueB : valueB - valueA;
|
|
126
|
-
}
|
|
127
|
-
return view.sort?.direction === 'asc' ? valueA.localeCompare(valueB) : valueB.localeCompare(valueA);
|
|
117
|
+
var _view$sort$direction;
|
|
118
|
+
return fieldToSort.sort(a, b, (_view$sort$direction = view.sort?.direction) !== null && _view$sort$direction !== void 0 ? _view$sort$direction : 'desc');
|
|
128
119
|
});
|
|
129
120
|
}
|
|
130
121
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["removeAccents","OPERATOR_IS","OPERATOR_IS_NOT","OPERATOR_IS_NONE","OPERATOR_IS_ANY","OPERATOR_IS_ALL","OPERATOR_IS_NOT_ALL","normalizeFields","normalizeSearchInput","input","trim","toLowerCase","EMPTY_ARRAY","filterSortAndPaginate","data","view","fields","paginationInfo","totalItems","totalPages","_fields","filteredData","search","normalizedSearch","filter","item","field","enableGlobalSearch","map","getValue","some","includes","filters","length","forEach","find","_field","id","operator","value","fieldValue","Array","isArray","filterValue","every","sort","fieldId","fieldToSort","a","b","_fieldToSort$getValue","_fieldToSort$getValue2","valueA","valueB","direction","localeCompare","page","undefined","perPage","start","Math","ceil","slice"],"sources":["@wordpress/dataviews/src/filter-and-sort-data-view.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * Internal dependencies\n */\nimport {\n\tOPERATOR_IS,\n\tOPERATOR_IS_NOT,\n\tOPERATOR_IS_NONE,\n\tOPERATOR_IS_ANY,\n\tOPERATOR_IS_ALL,\n\tOPERATOR_IS_NOT_ALL,\n} from './constants';\nimport { normalizeFields } from './normalize-fields';\nimport type { Field, View } from './types';\n\nfunction normalizeSearchInput( input = '' ) {\n\treturn removeAccents( input.trim().toLowerCase() );\n}\n\nconst EMPTY_ARRAY: [] = [];\n\n/**\n * Applies the filtering, sorting and pagination to the raw data based on the view configuration.\n *\n * @param data Raw data.\n * @param view View config.\n * @param fields Fields config.\n *\n * @return Filtered, sorted and paginated data.\n */\nexport function filterSortAndPaginate< Item >(\n\tdata: Item[],\n\tview: View,\n\tfields: Field< Item >[]\n): {\n\tdata: Item[];\n\tpaginationInfo: { totalItems: number; totalPages: number };\n} {\n\tif ( ! data ) {\n\t\treturn {\n\t\t\tdata: EMPTY_ARRAY,\n\t\t\tpaginationInfo: { totalItems: 0, totalPages: 0 },\n\t\t};\n\t}\n\tconst _fields = normalizeFields( fields );\n\tlet filteredData = [ ...data ];\n\t// Handle global search.\n\tif ( view.search ) {\n\t\tconst normalizedSearch = normalizeSearchInput( view.search );\n\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\treturn _fields\n\t\t\t\t.filter( ( field ) => field.enableGlobalSearch )\n\t\t\t\t.map( ( field ) => {\n\t\t\t\t\treturn normalizeSearchInput( field.getValue( { item } ) );\n\t\t\t\t} )\n\t\t\t\t.some( ( field ) => field.includes( normalizedSearch ) );\n\t\t} );\n\t}\n\n\tif ( view.filters && view.filters?.length > 0 ) {\n\t\tview.filters.forEach( ( filter ) => {\n\t\t\tconst field = _fields.find(\n\t\t\t\t( _field ) => _field.id === filter.field\n\t\t\t);\n\t\t\tif ( field ) {\n\t\t\t\tif (\n\t\t\t\t\tfilter.operator === OPERATOR_IS_ANY &&\n\t\t\t\t\tfilter?.value?.length > 0\n\t\t\t\t) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\tconst fieldValue = field.getValue( { item } );\n\t\t\t\t\t\tif ( Array.isArray( fieldValue ) ) {\n\t\t\t\t\t\t\treturn filter.value.some( ( filterValue: any ) =>\n\t\t\t\t\t\t\t\tfieldValue.includes( filterValue )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else if ( typeof fieldValue === 'string' ) {\n\t\t\t\t\t\t\treturn filter.value.includes( fieldValue );\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t} );\n\t\t\t\t} else if (\n\t\t\t\t\tfilter.operator === OPERATOR_IS_NONE &&\n\t\t\t\t\tfilter?.value?.length > 0\n\t\t\t\t) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\tconst fieldValue = field.getValue( { item } );\n\t\t\t\t\t\tif ( Array.isArray( fieldValue ) ) {\n\t\t\t\t\t\t\treturn ! filter.value.some( ( filterValue: any ) =>\n\t\t\t\t\t\t\t\tfieldValue.includes( filterValue )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else if ( typeof fieldValue === 'string' ) {\n\t\t\t\t\t\t\treturn ! filter.value.includes( fieldValue );\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t} );\n\t\t\t\t} else if (\n\t\t\t\t\tfilter.operator === OPERATOR_IS_ALL &&\n\t\t\t\t\tfilter?.value?.length > 0\n\t\t\t\t) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\treturn filter.value.every( ( value: any ) => {\n\t\t\t\t\t\t\treturn field\n\t\t\t\t\t\t\t\t.getValue( { item } )\n\t\t\t\t\t\t\t\t?.includes( value );\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t} else if (\n\t\t\t\t\tfilter.operator === OPERATOR_IS_NOT_ALL &&\n\t\t\t\t\tfilter?.value?.length > 0\n\t\t\t\t) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\treturn filter.value.every( ( value: any ) => {\n\t\t\t\t\t\t\treturn ! field\n\t\t\t\t\t\t\t\t.getValue( { item } )\n\t\t\t\t\t\t\t\t?.includes( value );\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t} else if ( filter.operator === OPERATOR_IS ) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\treturn filter.value === field.getValue( { item } );\n\t\t\t\t\t} );\n\t\t\t\t} else if ( filter.operator === OPERATOR_IS_NOT ) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\treturn filter.value !== field.getValue( { item } );\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}\n\n\t// Handle sorting.\n\tif ( view.sort ) {\n\t\tconst fieldId = view.sort.field;\n\t\tconst fieldToSort = _fields.find( ( field ) => {\n\t\t\treturn field.id === fieldId;\n\t\t} );\n\t\tif ( fieldToSort ) {\n\t\t\tfilteredData.sort( ( a, b ) => {\n\t\t\t\tconst valueA = fieldToSort.getValue( { item: a } ) ?? '';\n\t\t\t\tconst valueB = fieldToSort.getValue( { item: b } ) ?? '';\n\n\t\t\t\tif (\n\t\t\t\t\ttypeof valueA === 'number' &&\n\t\t\t\t\ttypeof valueB === 'number'\n\t\t\t\t) {\n\t\t\t\t\treturn view.sort?.direction === 'asc'\n\t\t\t\t\t\t? valueA - valueB\n\t\t\t\t\t\t: valueB - valueA;\n\t\t\t\t}\n\n\t\t\t\treturn view.sort?.direction === 'asc'\n\t\t\t\t\t? valueA.localeCompare( valueB )\n\t\t\t\t\t: valueB.localeCompare( valueA );\n\t\t\t} );\n\t\t}\n\t}\n\n\t// Handle pagination.\n\tlet totalItems = filteredData.length;\n\tlet totalPages = 1;\n\tif ( view.page !== undefined && view.perPage !== undefined ) {\n\t\tconst start = ( view.page - 1 ) * view.perPage;\n\t\ttotalItems = filteredData?.length || 0;\n\t\ttotalPages = Math.ceil( totalItems / view.perPage );\n\t\tfilteredData = filteredData?.slice( start, start + view.perPage );\n\t}\n\n\treturn {\n\t\tdata: filteredData,\n\t\tpaginationInfo: {\n\t\t\ttotalItems,\n\t\t\ttotalPages,\n\t\t},\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,gBAAgB;;AAE1C;AACA;AACA;AACA,SACCC,WAAW,EACXC,eAAe,EACfC,gBAAgB,EAChBC,eAAe,EACfC,eAAe,EACfC,mBAAmB,QACb,aAAa;AACpB,SAASC,eAAe,QAAQ,oBAAoB;AAGpD,SAASC,oBAAoBA,CAAEC,KAAK,GAAG,EAAE,EAAG;EAC3C,OAAOT,aAAa,CAAES,KAAK,CAACC,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAE,CAAC;AACnD;AAEA,MAAMC,WAAe,GAAG,EAAE;;AAE1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CACpCC,IAAY,EACZC,IAAU,EACVC,MAAuB,EAItB;EACD,IAAK,CAAEF,IAAI,EAAG;IACb,OAAO;MACNA,IAAI,EAAEF,WAAW;MACjBK,cAAc,EAAE;QAAEC,UAAU,EAAE,CAAC;QAAEC,UAAU,EAAE;MAAE;IAChD,CAAC;EACF;EACA,MAAMC,OAAO,GAAGb,eAAe,CAAES,MAAO,CAAC;EACzC,IAAIK,YAAY,GAAG,CAAE,GAAGP,IAAI,CAAE;EAC9B;EACA,IAAKC,IAAI,CAACO,MAAM,EAAG;IAClB,MAAMC,gBAAgB,GAAGf,oBAAoB,CAA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R_IS_NOT_ALL","normalizeFields","normalizeSearchInput","input","trim","toLowerCase","EMPTY_ARRAY","filterSortAndPaginate","data","view","fields","paginationInfo","totalItems","totalPages","_fields","filteredData","search","normalizedSearch","filter","item","field","enableGlobalSearch","map","getValue","some","includes","filters","length","forEach","find","_field","id","operator","value","fieldValue","Array","isArray","filterValue","every","sort","fieldId","fieldToSort","a","b","_view$sort$direction","direction","page","undefined","perPage","start","Math","ceil","slice"],"sources":["@wordpress/dataviews/src/filter-and-sort-data-view.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * Internal dependencies\n */\nimport {\n\tOPERATOR_IS,\n\tOPERATOR_IS_NOT,\n\tOPERATOR_IS_NONE,\n\tOPERATOR_IS_ANY,\n\tOPERATOR_IS_ALL,\n\tOPERATOR_IS_NOT_ALL,\n} from './constants';\nimport { normalizeFields } from './normalize-fields';\nimport type { Field, View } from './types';\n\nfunction normalizeSearchInput( input = '' ) {\n\treturn removeAccents( input.trim().toLowerCase() );\n}\n\nconst EMPTY_ARRAY: [] = [];\n\n/**\n * Applies the filtering, sorting and pagination to the raw data based on the view configuration.\n *\n * @param data Raw data.\n * @param view View config.\n * @param fields Fields config.\n *\n * @return Filtered, sorted and paginated data.\n */\nexport function filterSortAndPaginate< Item >(\n\tdata: Item[],\n\tview: View,\n\tfields: Field< Item >[]\n): {\n\tdata: Item[];\n\tpaginationInfo: { totalItems: number; totalPages: number };\n} {\n\tif ( ! data ) {\n\t\treturn {\n\t\t\tdata: EMPTY_ARRAY,\n\t\t\tpaginationInfo: { totalItems: 0, totalPages: 0 },\n\t\t};\n\t}\n\tconst _fields = normalizeFields( fields );\n\tlet filteredData = [ ...data ];\n\t// Handle global search.\n\tif ( view.search ) {\n\t\tconst normalizedSearch = normalizeSearchInput( view.search );\n\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\treturn _fields\n\t\t\t\t.filter( ( field ) => field.enableGlobalSearch )\n\t\t\t\t.map( ( field ) => {\n\t\t\t\t\treturn normalizeSearchInput( field.getValue( { item } ) );\n\t\t\t\t} )\n\t\t\t\t.some( ( field ) => field.includes( normalizedSearch ) );\n\t\t} );\n\t}\n\n\tif ( view.filters && view.filters?.length > 0 ) {\n\t\tview.filters.forEach( ( filter ) => {\n\t\t\tconst field = _fields.find(\n\t\t\t\t( _field ) => _field.id === filter.field\n\t\t\t);\n\t\t\tif ( field ) {\n\t\t\t\tif (\n\t\t\t\t\tfilter.operator === OPERATOR_IS_ANY &&\n\t\t\t\t\tfilter?.value?.length > 0\n\t\t\t\t) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\tconst fieldValue = field.getValue( { item } );\n\t\t\t\t\t\tif ( Array.isArray( fieldValue ) ) {\n\t\t\t\t\t\t\treturn filter.value.some( ( filterValue: any ) =>\n\t\t\t\t\t\t\t\tfieldValue.includes( filterValue )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else if ( typeof fieldValue === 'string' ) {\n\t\t\t\t\t\t\treturn filter.value.includes( fieldValue );\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t} );\n\t\t\t\t} else if (\n\t\t\t\t\tfilter.operator === OPERATOR_IS_NONE &&\n\t\t\t\t\tfilter?.value?.length > 0\n\t\t\t\t) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\tconst fieldValue = field.getValue( { item } );\n\t\t\t\t\t\tif ( Array.isArray( fieldValue ) ) {\n\t\t\t\t\t\t\treturn ! filter.value.some( ( filterValue: any ) =>\n\t\t\t\t\t\t\t\tfieldValue.includes( filterValue )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else if ( typeof fieldValue === 'string' ) {\n\t\t\t\t\t\t\treturn ! filter.value.includes( fieldValue );\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t} );\n\t\t\t\t} else if (\n\t\t\t\t\tfilter.operator === OPERATOR_IS_ALL &&\n\t\t\t\t\tfilter?.value?.length > 0\n\t\t\t\t) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\treturn filter.value.every( ( value: any ) => {\n\t\t\t\t\t\t\treturn field\n\t\t\t\t\t\t\t\t.getValue( { item } )\n\t\t\t\t\t\t\t\t?.includes( value );\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t} else if (\n\t\t\t\t\tfilter.operator === OPERATOR_IS_NOT_ALL &&\n\t\t\t\t\tfilter?.value?.length > 0\n\t\t\t\t) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\treturn filter.value.every( ( value: any ) => {\n\t\t\t\t\t\t\treturn ! field\n\t\t\t\t\t\t\t\t.getValue( { item } )\n\t\t\t\t\t\t\t\t?.includes( value );\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t} else if ( filter.operator === OPERATOR_IS ) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\treturn filter.value === field.getValue( { item } );\n\t\t\t\t\t} );\n\t\t\t\t} else if ( filter.operator === OPERATOR_IS_NOT ) {\n\t\t\t\t\tfilteredData = filteredData.filter( ( item ) => {\n\t\t\t\t\t\treturn filter.value !== field.getValue( { item } );\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}\n\n\t// Handle sorting.\n\tif ( view.sort ) {\n\t\tconst fieldId = view.sort.field;\n\t\tconst fieldToSort = _fields.find( ( field ) => {\n\t\t\treturn field.id === fieldId;\n\t\t} );\n\t\tif ( fieldToSort ) {\n\t\t\tfilteredData.sort( ( a, b ) => {\n\t\t\t\treturn fieldToSort.sort( a, b, view.sort?.direction ?? 'desc' );\n\t\t\t} );\n\t\t}\n\t}\n\n\t// Handle pagination.\n\tlet totalItems = filteredData.length;\n\tlet totalPages = 1;\n\tif ( view.page !== undefined && view.perPage !== undefined ) {\n\t\tconst start = ( view.page - 1 ) * view.perPage;\n\t\ttotalItems = filteredData?.length || 0;\n\t\ttotalPages = Math.ceil( totalItems / view.perPage );\n\t\tfilteredData = filteredData?.slice( start, start + view.perPage );\n\t}\n\n\treturn {\n\t\tdata: filteredData,\n\t\tpaginationInfo: {\n\t\t\ttotalItems,\n\t\t\ttotalPages,\n\t\t},\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,gBAAgB;;AAE1C;AACA;AACA;AACA,SACCC,WAAW,EACXC,eAAe,EACfC,gBAAgB,EAChBC,eAAe,EACfC,eAAe,EACfC,mBAAmB,QACb,aAAa;AACpB,SAASC,eAAe,QAAQ,oBAAoB;AAGpD,SAASC,oBAAoBA,CAAEC,KAAK,GAAG,EAAE,EAAG;EAC3C,OAAOT,aAAa,CAAES,KAAK,CAACC,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAE,CAAC;AACnD;AAEA,MAAMC,WAAe,GAAG,EAAE;;AAE1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CACpCC,IAAY,EACZC,IAAU,EACVC,MAAuB,EAItB;EACD,IAAK,CAAEF,IAAI,EAAG;IACb,OAAO;MACNA,IAAI,EAAEF,WAAW;MACjBK,cAAc,EAAE;QAAEC,UAAU,EAAE,CAAC;QAAEC,UAAU,EAAE;MAAE;IAChD,CAAC;EACF;EACA,MAAMC,OAAO,GAAGb,eAAe,CAAES,MAAO,CAAC;EACzC,IAAIK,YAAY,GAAG,CAAE,GAAGP,IAAI,CAAE;EAC9B;EACA,IAAKC,IAAI,CAACO,MAAM,EAAG;IAClB,MAAMC,gBAAgB,GAAGf,oBAAoB,CAAEO,IAAI,CAACO,MAAO,CAAC;IAC5DD,YAAY,GAAGA,YAAY,CAACG,MAAM,CAAIC,IAAI,IAAM;MAC/C,OAAOL,OAAO,CACZI,MAAM,CAAIE,KAAK,IAAMA,KAAK,CAACC,kBAAmB,CAAC,C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,MAAME,KAAK,GAAG,CAAExC,IAAI,CAACqC,IAAI,GAAG,CAAC,IAAKrC,IAAI,CAACuC,OAAO;IAC9CpC,UAAU,GAAGG,YAAY,EAAEY,MAAM,IAAI,CAAC;IACtCd,UAAU,GAAGqC,IAAI,CAACC,IAAI,CAAEvC,UAAU,GAAGH,IAAI,CAACuC,OAAQ,CAAC;IACnDjC,YAAY,GAAGA,YAAY,EAAEqC,KAAK,CAAEH,KAAK,EAAEA,KAAK,GAAGxC,IAAI,CAACuC,OAAQ,CAAC;EAClE;EAEA,OAAO;IACNxC,IAAI,EAAEO,YAAY;IAClBJ,cAAc,EAAE;MACfC,UAAU;MACVC;IACD;EACD,CAAC;AACF","ignoreList":[]}
|
package/build-module/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { default as DataViews } from './components/dataviews';
|
|
2
2
|
export { default as DataForm } from './components/dataform';
|
|
3
|
-
export { VIEW_LAYOUTS } from './layouts';
|
|
3
|
+
export { VIEW_LAYOUTS } from './dataviews-layouts';
|
|
4
4
|
export { filterSortAndPaginate } from './filter-and-sort-data-view';
|
|
5
|
+
export { isItemValid } from './validation';
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default","DataViews","DataForm","VIEW_LAYOUTS","filterSortAndPaginate"],"sources":["@wordpress/dataviews/src/index.ts"],"sourcesContent":["export { default as DataViews } from './components/dataviews';\nexport { default as DataForm } from './components/dataform';\nexport { VIEW_LAYOUTS } from './layouts';\nexport { filterSortAndPaginate } from './filter-and-sort-data-view';\nexport type * from './types';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,SAAS,QAAQ,wBAAwB;AAC7D,SAASD,OAAO,IAAIE,QAAQ,QAAQ,uBAAuB;AAC3D,SAASC,YAAY,QAAQ,
|
|
1
|
+
{"version":3,"names":["default","DataViews","DataForm","VIEW_LAYOUTS","filterSortAndPaginate","isItemValid"],"sources":["@wordpress/dataviews/src/index.ts"],"sourcesContent":["export { default as DataViews } from './components/dataviews';\nexport { default as DataForm } from './components/dataform';\nexport { VIEW_LAYOUTS } from './dataviews-layouts';\nexport { filterSortAndPaginate } from './filter-and-sort-data-view';\nexport type * from './types';\nexport { isItemValid } from './validation';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,SAAS,QAAQ,wBAAwB;AAC7D,SAASD,OAAO,IAAIE,QAAQ,QAAQ,uBAAuB;AAC3D,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,qBAAqB,QAAQ,6BAA6B;AAEnE,SAASC,WAAW,QAAQ,cAAc","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
import getFieldTypeDefinition from './field-types';
|
|
5
5
|
/**
|
|
6
6
|
* Apply default values and normalize the fields config.
|
|
7
7
|
*
|
|
@@ -10,14 +10,46 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export function normalizeFields(fields) {
|
|
12
12
|
return fields.map(field => {
|
|
13
|
+
var _field$sort, _field$isValid;
|
|
14
|
+
const fieldTypeDefinition = getFieldTypeDefinition(field.type);
|
|
13
15
|
const getValue = field.getValue || (({
|
|
14
16
|
item
|
|
15
17
|
}) => item[field.id]);
|
|
18
|
+
const sort = (_field$sort = field.sort) !== null && _field$sort !== void 0 ? _field$sort : function sort(a, b, direction) {
|
|
19
|
+
return fieldTypeDefinition.sort(getValue({
|
|
20
|
+
item: a
|
|
21
|
+
}), getValue({
|
|
22
|
+
item: b
|
|
23
|
+
}), direction);
|
|
24
|
+
};
|
|
25
|
+
const isValid = (_field$isValid = field.isValid) !== null && _field$isValid !== void 0 ? _field$isValid : function isValid(item, context) {
|
|
26
|
+
return fieldTypeDefinition.isValid(getValue({
|
|
27
|
+
item
|
|
28
|
+
}), context);
|
|
29
|
+
};
|
|
30
|
+
const Edit = field.Edit || fieldTypeDefinition.Edit;
|
|
31
|
+
const renderFromElements = ({
|
|
32
|
+
item
|
|
33
|
+
}) => {
|
|
34
|
+
const value = getValue({
|
|
35
|
+
item
|
|
36
|
+
});
|
|
37
|
+
const label = field?.elements?.find(element => {
|
|
38
|
+
// Intentionally using == here to allow for type coercion.
|
|
39
|
+
// eslint-disable-next-line eqeqeq
|
|
40
|
+
return element.value == value;
|
|
41
|
+
})?.label;
|
|
42
|
+
return label || value;
|
|
43
|
+
};
|
|
44
|
+
const render = field.render || (field.elements ? renderFromElements : getValue);
|
|
16
45
|
return {
|
|
17
46
|
...field,
|
|
18
47
|
label: field.label || field.id,
|
|
19
48
|
getValue,
|
|
20
|
-
render
|
|
49
|
+
render,
|
|
50
|
+
sort,
|
|
51
|
+
isValid,
|
|
52
|
+
Edit
|
|
21
53
|
};
|
|
22
54
|
});
|
|
23
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["normalizeFields","fields","map","field","getValue","item","id","label","render"],"sources":["@wordpress/dataviews/src/normalize-fields.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Field, NormalizedField
|
|
1
|
+
{"version":3,"names":["getFieldTypeDefinition","normalizeFields","fields","map","field","_field$sort","_field$isValid","fieldTypeDefinition","type","getValue","item","id","sort","a","b","direction","isValid","context","Edit","renderFromElements","value","label","elements","find","element","render"],"sources":["@wordpress/dataviews/src/normalize-fields.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport getFieldTypeDefinition from './field-types';\nimport type { Field, NormalizedField } from './types';\n\n/**\n * Apply default values and normalize the fields config.\n *\n * @param fields Fields config.\n * @return Normalized fields config.\n */\nexport function normalizeFields< Item >(\n\tfields: Field< Item >[]\n): NormalizedField< Item >[] {\n\treturn fields.map( ( field ) => {\n\t\tconst fieldTypeDefinition = getFieldTypeDefinition( field.type );\n\n\t\tconst getValue =\n\t\t\tfield.getValue ||\n\t\t\t( ( { item }: { item: Item } ) => item[ field.id as keyof Item ] );\n\n\t\tconst sort =\n\t\t\tfield.sort ??\n\t\t\tfunction sort( a, b, direction ) {\n\t\t\t\treturn fieldTypeDefinition.sort(\n\t\t\t\t\tgetValue( { item: a } ),\n\t\t\t\t\tgetValue( { item: b } ),\n\t\t\t\t\tdirection\n\t\t\t\t);\n\t\t\t};\n\n\t\tconst isValid =\n\t\t\tfield.isValid ??\n\t\t\tfunction isValid( item, context ) {\n\t\t\t\treturn fieldTypeDefinition.isValid(\n\t\t\t\t\tgetValue( { item } ),\n\t\t\t\t\tcontext\n\t\t\t\t);\n\t\t\t};\n\n\t\tconst Edit = field.Edit || fieldTypeDefinition.Edit;\n\n\t\tconst renderFromElements = ( { item }: { item: Item } ) => {\n\t\t\tconst value = getValue( { item } );\n\t\t\tconst label = field?.elements?.find( ( element ) => {\n\t\t\t\t// Intentionally using == here to allow for type coercion.\n\t\t\t\t// eslint-disable-next-line eqeqeq\n\t\t\t\treturn element.value == value;\n\t\t\t} )?.label;\n\n\t\t\treturn label || value;\n\t\t};\n\n\t\tconst render =\n\t\t\tfield.render || ( field.elements ? renderFromElements : getValue );\n\n\t\treturn {\n\t\t\t...field,\n\t\t\tlabel: field.label || field.id,\n\t\t\tgetValue,\n\t\t\trender,\n\t\t\tsort,\n\t\t\tisValid,\n\t\t\tEdit,\n\t\t};\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,sBAAsB,MAAM,eAAe;AAGlD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC9BC,MAAuB,EACK;EAC5B,OAAOA,MAAM,CAACC,GAAG,CAAIC,KAAK,IAAM;IAAA,IAAAC,WAAA,EAAAC,cAAA;IAC/B,MAAMC,mBAAmB,GAAGP,sBAAsB,CAAEI,KAAK,CAACI,IAAK,CAAC;IAEhE,MAAMC,QAAQ,GACbL,KAAK,CAACK,QAAQ,KACZ,CAAE;MAAEC;IAAqB,CAAC,KAAMA,IAAI,CAAEN,KAAK,CAACO,EAAE,CAAgB,CAAE;IAEnE,MAA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AAO;MACPE;IACD,CAAC;EACF,CAAE,CAAC;AACJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["@wordpress/dataviews/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactElement, ComponentType } from 'react';\n\n/**\n * Internal dependencies\n */\nimport type { SetSelection } from './private-types';\n\nexport type SortDirection = 'asc' | 'desc';\n\n/**\n * Generic option type.\n */\nexport interface Option< Value extends any = any > {\n\tvalue: Value;\n\tlabel: string;\n\tdescription?: string;\n}\n\ninterface FilterByConfig {\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators?: Operator[];\n\n\t/**\n\t * Whether it is a primary filter.\n\t *\n\t * A primary filter is always visible and is not listed in the \"Add filter\" component,\n\t * except for the list layout where it behaves like a secondary filter.\n\t */\n\tisPrimary?: boolean;\n}\n\nexport type Operator =\n\t| 'is'\n\t| 'isNot'\n\t| 'isAny'\n\t| 'isNone'\n\t| 'isAll'\n\t| 'isNotAll';\n\nexport type ItemRecord = Record< string, unknown >;\n\nexport type FieldType = 'text';\n\n/**\n * A dataview field for a specific property of a data type.\n */\nexport type Field< Item > = {\n\t/**\n\t * Type of the fields.\n\t */\n\ttype?: FieldType;\n\n\t/**\n\t * The unique identifier of the field.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the field. Defaults to the id.\n\t */\n\tlabel?: string;\n\n\t/**\n\t * Placeholder for the field.\n\t */\n\tplaceholder?: string;\n\n\t/**\n\t * Callback used to render the field. Defaults to `field.getValue`.\n\t */\n\trender?: ComponentType< { item: Item } >;\n\n\t/**\n\t * Whether the field is sortable.\n\t */\n\tenableSorting?: boolean;\n\n\t/**\n\t * Whether the field is searchable.\n\t */\n\tenableGlobalSearch?: boolean;\n\n\t/**\n\t * Whether the field is filterable.\n\t */\n\tenableHiding?: boolean;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements?: Option[];\n\n\t/**\n\t * Filter config for the field.\n\t */\n\tfilterBy?: FilterByConfig | undefined;\n} & ( Item extends ItemRecord\n\t? {\n\t\t\t/**\n\t\t\t * Callback used to retrieve the value of the field from the item.\n\t\t\t * Defaults to `item[ field.id ]`.\n\t\t\t */\n\t\t\tgetValue?: ( args: { item: Item } ) => any;\n\t }\n\t: {\n\t\t\t/**\n\t\t\t * Callback used to retrieve the value of the field from the item.\n\t\t\t * Defaults to `item[ field.id ]`.\n\t\t\t */\n\t\t\tgetValue: ( args: { item: Item } ) => any;\n\t } );\n\nexport type NormalizedField< Item > = Field< Item > & {\n\tlabel: string;\n\tgetValue: ( args: { item: Item } ) => any;\n\trender: ComponentType< { item: Item } >;\n};\n\n/**\n * A collection of dataview fields for a data type.\n */\nexport type Fields< Item > = Field< Item >[];\n\nexport type Data< Item > = Item[];\n\n/**\n * The form configuration.\n */\nexport type Form = {\n\tvisibleFields?: string[];\n};\n\n/**\n * The filters applied to the dataset.\n */\nexport interface Filter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The operator to use.\n\t */\n\toperator: Operator;\n\n\t/**\n\t * The value to filter by.\n\t */\n\tvalue: any;\n}\n\nexport interface NormalizedFilter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The field name.\n\t */\n\tname: string;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements: Option[];\n\n\t/**\n\t * Is a single selection filter.\n\t */\n\tsingleSelection: boolean;\n\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators: Operator[];\n\n\t/**\n\t * Whether the filter is visible.\n\t */\n\tisVisible: boolean;\n\n\t/**\n\t * Whether it is a primary filter.\n\t */\n\tisPrimary: boolean;\n}\n\ninterface ViewBase {\n\t/**\n\t * The layout of the view.\n\t */\n\ttype: string;\n\n\t/**\n\t * The global search term.\n\t */\n\tsearch?: string;\n\n\t/**\n\t * The filters to apply.\n\t */\n\tfilters?: Filter[];\n\n\t/**\n\t * The sorting configuration.\n\t */\n\tsort?: {\n\t\t/**\n\t\t * The field to sort by.\n\t\t */\n\t\tfield: string;\n\n\t\t/**\n\t\t * The direction to sort by.\n\t\t */\n\t\tdirection: SortDirection;\n\t};\n\n\t/**\n\t * The active page\n\t */\n\tpage?: number;\n\n\t/**\n\t * The number of items per page\n\t */\n\tperPage?: number;\n\n\t/**\n\t * The fields to render\n\t */\n\tfields?: string[];\n}\n\nexport interface CombinedField {\n\tid: string;\n\n\tlabel: string;\n\n\t/**\n\t * The fields to use as columns.\n\t */\n\tchildren: string[];\n\n\t/**\n\t * The direction of the stack.\n\t */\n\tdirection: 'horizontal' | 'vertical';\n}\n\nexport interface ColumnStyle {\n\t/**\n\t * The width of the field column.\n\t */\n\twidth?: string | number;\n\n\t/**\n\t * The minimum width of the field column.\n\t */\n\tmaxWidth?: string | number;\n\n\t/**\n\t * The maximum width of the field column.\n\t */\n\tminWidth?: string | number;\n}\n\nexport interface ViewTable extends ViewBase {\n\ttype: 'table';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The fields to use as columns.\n\t\t */\n\t\tcombinedFields?: CombinedField[];\n\n\t\t/**\n\t\t * The styles for the columns.\n\t\t */\n\t\tstyles?: Record< string, ColumnStyle >;\n\t};\n}\n\nexport interface ViewList extends ViewBase {\n\ttype: 'list';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField?: string;\n\t};\n}\n\nexport interface ViewGrid extends ViewBase {\n\ttype: 'grid';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField?: string;\n\n\t\t/**\n\t\t * The fields to use as columns.\n\t\t */\n\t\tcolumnFields?: string[];\n\n\t\t/**\n\t\t * The fields to use as badge fields.\n\t\t */\n\t\tbadgeFields?: string[];\n\t};\n}\n\nexport type View = ViewList | ViewGrid | ViewTable;\n\ninterface ActionBase< Item > {\n\t/**\n\t * The unique identifier of the action.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the action.\n\t * In case we want to adjust the label based on the selected items,\n\t * a function can be provided.\n\t */\n\tlabel: string | ( ( items: Item[] ) => string );\n\n\t/**\n\t * The icon of the action. (Either a string or an SVG element)\n\t * This should be IconType from the components package\n\t * but that import is breaking typescript build for the moment.\n\t */\n\ticon?: any;\n\n\t/**\n\t * Whether the action is disabled.\n\t */\n\tdisabled?: boolean;\n\n\t/**\n\t * Whether the action is destructive.\n\t */\n\tisDestructive?: boolean;\n\n\t/**\n\t * Whether the action is a primary action.\n\t */\n\tisPrimary?: boolean;\n\n\t/**\n\t * Whether the item passed as an argument supports the current action.\n\t */\n\tisEligible?: ( item: Item ) => boolean;\n\n\t/**\n\t * Whether the action can be used as a bulk action.\n\t */\n\tsupportsBulk?: boolean;\n}\n\nexport interface ActionModal< Item > extends ActionBase< Item > {\n\t/**\n\t * Modal to render when the action is triggered.\n\t */\n\tRenderModal: ( {\n\t\titems,\n\t\tcloseModal,\n\t\tonActionPerformed,\n\t}: {\n\t\titems: Item[];\n\t\tcloseModal?: () => void;\n\t\tonActionPerformed?: ( items: Item[] ) => void;\n\t} ) => ReactElement;\n\n\t/**\n\t * Whether to hide the modal header.\n\t */\n\thideModalHeader?: boolean;\n\n\t/**\n\t * The header of the modal.\n\t */\n\tmodalHeader?: string;\n}\n\nexport interface ActionButton< Item > extends ActionBase< Item > {\n\t/**\n\t * The callback to execute when the action is triggered.\n\t */\n\tcallback: (\n\t\titems: Item[],\n\t\tcontext: {\n\t\t\tregistry: any;\n\t\t\tonActionPerformed?: ( items: Item[] ) => void;\n\t\t}\n\t) => void;\n}\n\nexport type Action< Item > = ActionModal< Item > | ActionButton< Item >;\n\nexport interface ViewBaseProps< Item > {\n\tactions: Action< Item >[];\n\tdata: Item[];\n\tfields: NormalizedField< Item >[];\n\tgetItemId: ( item: Item ) => string;\n\tisLoading?: boolean;\n\tonChangeView: ( view: View ) => void;\n\tonChangeSelection: SetSelection;\n\tselection: string[];\n\tsetOpenedFilter: ( fieldId: string ) => void;\n\tview: View;\n\tdensity: number;\n}\n\nexport interface ViewTableProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewTable;\n}\n\nexport interface ViewListProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewList;\n}\n\nexport interface ViewGridProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewGrid;\n}\n\nexport type ViewProps< Item > =\n\t| ViewTableProps< Item >\n\t| ViewGridProps< Item >\n\t| ViewListProps< Item >;\n\nexport interface SupportedLayouts {\n\tlist?: Omit< ViewList, 'type' >;\n\tgrid?: Omit< ViewGrid, 'type' >;\n\ttable?: Omit< ViewTable, 'type' >;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/dataviews/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type {\n\tReactElement,\n\tComponentType,\n\tDispatch,\n\tSetStateAction,\n} from 'react';\n\n/**\n * Internal dependencies\n */\nimport type { SetSelection } from './private-types';\n\nexport type SortDirection = 'asc' | 'desc';\n\n/**\n * Generic option type.\n */\nexport interface Option< Value extends any = any > {\n\tvalue: Value;\n\tlabel: string;\n\tdescription?: string;\n}\n\ninterface FilterByConfig {\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators?: Operator[];\n\n\t/**\n\t * Whether it is a primary filter.\n\t *\n\t * A primary filter is always visible and is not listed in the \"Add filter\" component,\n\t * except for the list layout where it behaves like a secondary filter.\n\t */\n\tisPrimary?: boolean;\n}\n\nexport type Operator =\n\t| 'is'\n\t| 'isNot'\n\t| 'isAny'\n\t| 'isNone'\n\t| 'isAll'\n\t| 'isNotAll';\n\nexport type ItemRecord = Record< string, unknown >;\n\nexport type FieldType = 'text' | 'integer';\n\nexport type ValidationContext = {\n\telements?: Option[];\n};\n\n/**\n * A dataview field for a specific property of a data type.\n */\nexport type Field< Item > = {\n\t/**\n\t * Type of the fields.\n\t */\n\ttype?: FieldType;\n\n\t/**\n\t * The unique identifier of the field.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the field. Defaults to the id.\n\t */\n\tlabel?: string;\n\n\t/**\n\t * A description of the field.\n\t */\n\tdescription?: string;\n\n\t/**\n\t * Placeholder for the field.\n\t */\n\tplaceholder?: string;\n\n\t/**\n\t * Callback used to render the field. Defaults to `field.getValue`.\n\t */\n\trender?: ComponentType< { item: Item } >;\n\n\t/**\n\t * Callback used to render an edit control for the field.\n\t */\n\tEdit?: ComponentType< DataFormControlProps< Item > >;\n\n\t/**\n\t * Callback used to sort the field.\n\t */\n\tsort?: ( a: Item, b: Item, direction: SortDirection ) => number;\n\n\t/**\n\t * Callback used to validate the field.\n\t */\n\tisValid?: ( item: Item, context?: ValidationContext ) => boolean;\n\n\t/**\n\t * Whether the field is sortable.\n\t */\n\tenableSorting?: boolean;\n\n\t/**\n\t * Whether the field is searchable.\n\t */\n\tenableGlobalSearch?: boolean;\n\n\t/**\n\t * Whether the field is filterable.\n\t */\n\tenableHiding?: boolean;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements?: Option[];\n\n\t/**\n\t * Filter config for the field.\n\t */\n\tfilterBy?: FilterByConfig | undefined;\n} & ( Item extends ItemRecord\n\t? {\n\t\t\t/**\n\t\t\t * Callback used to retrieve the value of the field from the item.\n\t\t\t * Defaults to `item[ field.id ]`.\n\t\t\t */\n\t\t\tgetValue?: ( args: { item: Item } ) => any;\n\t }\n\t: {\n\t\t\t/**\n\t\t\t * Callback used to retrieve the value of the field from the item.\n\t\t\t * Defaults to `item[ field.id ]`.\n\t\t\t */\n\t\t\tgetValue: ( args: { item: Item } ) => any;\n\t } );\n\nexport type NormalizedField< Item > = Field< Item > & {\n\tlabel: string;\n\tgetValue: ( args: { item: Item } ) => any;\n\trender: ComponentType< { item: Item } >;\n\tEdit: ComponentType< DataFormControlProps< Item > >;\n\tsort: ( a: Item, b: Item, direction: SortDirection ) => number;\n\tisValid: ( item: Item, context?: ValidationContext ) => boolean;\n};\n\n/**\n * A collection of dataview fields for a data type.\n */\nexport type Fields< Item > = Field< Item >[];\n\nexport type Data< Item > = Item[];\n\n/**\n * The form configuration.\n */\nexport type Form = {\n\ttype?: 'regular' | 'panel';\n\tfields?: string[];\n};\n\nexport type DataFormControlProps< Item > = {\n\tdata: Item;\n\tfield: NormalizedField< Item >;\n\tonChange: Dispatch< SetStateAction< Item > >;\n\thideLabelFromVision?: boolean;\n};\n\n/**\n * The filters applied to the dataset.\n */\nexport interface Filter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The operator to use.\n\t */\n\toperator: Operator;\n\n\t/**\n\t * The value to filter by.\n\t */\n\tvalue: any;\n}\n\nexport interface NormalizedFilter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The field name.\n\t */\n\tname: string;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements: Option[];\n\n\t/**\n\t * Is a single selection filter.\n\t */\n\tsingleSelection: boolean;\n\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators: Operator[];\n\n\t/**\n\t * Whether the filter is visible.\n\t */\n\tisVisible: boolean;\n\n\t/**\n\t * Whether it is a primary filter.\n\t */\n\tisPrimary: boolean;\n}\n\ninterface ViewBase {\n\t/**\n\t * The layout of the view.\n\t */\n\ttype: string;\n\n\t/**\n\t * The global search term.\n\t */\n\tsearch?: string;\n\n\t/**\n\t * The filters to apply.\n\t */\n\tfilters?: Filter[];\n\n\t/**\n\t * The sorting configuration.\n\t */\n\tsort?: {\n\t\t/**\n\t\t * The field to sort by.\n\t\t */\n\t\tfield: string;\n\n\t\t/**\n\t\t * The direction to sort by.\n\t\t */\n\t\tdirection: SortDirection;\n\t};\n\n\t/**\n\t * The active page\n\t */\n\tpage?: number;\n\n\t/**\n\t * The number of items per page\n\t */\n\tperPage?: number;\n\n\t/**\n\t * The fields to render\n\t */\n\tfields?: string[];\n}\n\nexport interface CombinedField {\n\tid: string;\n\n\tlabel: string;\n\n\t/**\n\t * The fields to use as columns.\n\t */\n\tchildren: string[];\n\n\t/**\n\t * The direction of the stack.\n\t */\n\tdirection: 'horizontal' | 'vertical';\n}\n\nexport interface ColumnStyle {\n\t/**\n\t * The width of the field column.\n\t */\n\twidth?: string | number;\n\n\t/**\n\t * The minimum width of the field column.\n\t */\n\tmaxWidth?: string | number;\n\n\t/**\n\t * The maximum width of the field column.\n\t */\n\tminWidth?: string | number;\n}\n\nexport interface ViewTable extends ViewBase {\n\ttype: 'table';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The fields to use as columns.\n\t\t */\n\t\tcombinedFields?: CombinedField[];\n\n\t\t/**\n\t\t * The styles for the columns.\n\t\t */\n\t\tstyles?: Record< string, ColumnStyle >;\n\t};\n}\n\nexport interface ViewList extends ViewBase {\n\ttype: 'list';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField?: string;\n\t};\n}\n\nexport interface ViewGrid extends ViewBase {\n\ttype: 'grid';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField?: string;\n\n\t\t/**\n\t\t * The fields to use as columns.\n\t\t */\n\t\tcolumnFields?: string[];\n\n\t\t/**\n\t\t * The fields to use as badge fields.\n\t\t */\n\t\tbadgeFields?: string[];\n\t};\n}\n\nexport type View = ViewList | ViewGrid | ViewTable;\n\ninterface ActionBase< Item > {\n\t/**\n\t * The unique identifier of the action.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the action.\n\t * In case we want to adjust the label based on the selected items,\n\t * a function can be provided.\n\t */\n\tlabel: string | ( ( items: Item[] ) => string );\n\n\t/**\n\t * The icon of the action. (Either a string or an SVG element)\n\t * This should be IconType from the components package\n\t * but that import is breaking typescript build for the moment.\n\t */\n\ticon?: any;\n\n\t/**\n\t * Whether the action is disabled.\n\t */\n\tdisabled?: boolean;\n\n\t/**\n\t * Whether the action is destructive.\n\t */\n\tisDestructive?: boolean;\n\n\t/**\n\t * Whether the action is a primary action.\n\t */\n\tisPrimary?: boolean;\n\n\t/**\n\t * Whether the item passed as an argument supports the current action.\n\t */\n\tisEligible?: ( item: Item ) => boolean;\n\n\t/**\n\t * Whether the action can be used as a bulk action.\n\t */\n\tsupportsBulk?: boolean;\n}\n\nexport interface ActionModal< Item > extends ActionBase< Item > {\n\t/**\n\t * Modal to render when the action is triggered.\n\t */\n\tRenderModal: ( {\n\t\titems,\n\t\tcloseModal,\n\t\tonActionPerformed,\n\t}: {\n\t\titems: Item[];\n\t\tcloseModal?: () => void;\n\t\tonActionPerformed?: ( items: Item[] ) => void;\n\t} ) => ReactElement;\n\n\t/**\n\t * Whether to hide the modal header.\n\t */\n\thideModalHeader?: boolean;\n\n\t/**\n\t * The header of the modal.\n\t */\n\tmodalHeader?: string;\n}\n\nexport interface ActionButton< Item > extends ActionBase< Item > {\n\t/**\n\t * The callback to execute when the action is triggered.\n\t */\n\tcallback: (\n\t\titems: Item[],\n\t\tcontext: {\n\t\t\tregistry: any;\n\t\t\tonActionPerformed?: ( items: Item[] ) => void;\n\t\t}\n\t) => void;\n}\n\nexport type Action< Item > = ActionModal< Item > | ActionButton< Item >;\n\nexport interface ViewBaseProps< Item > {\n\tactions: Action< Item >[];\n\tdata: Item[];\n\tfields: NormalizedField< Item >[];\n\tgetItemId: ( item: Item ) => string;\n\tisLoading?: boolean;\n\tonChangeView: ( view: View ) => void;\n\tonChangeSelection: SetSelection;\n\tselection: string[];\n\tsetOpenedFilter: ( fieldId: string ) => void;\n\tview: View;\n\tdensity: number;\n}\n\nexport interface ViewTableProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewTable;\n}\n\nexport interface ViewListProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewList;\n}\n\nexport interface ViewGridProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewGrid;\n}\n\nexport type ViewProps< Item > =\n\t| ViewTableProps< Item >\n\t| ViewGridProps< Item >\n\t| ViewListProps< Item >;\n\nexport interface SupportedLayouts {\n\tlist?: Omit< ViewList, 'type' >;\n\tgrid?: Omit< ViewGrid, 'type' >;\n\ttable?: Omit< ViewTable, 'type' >;\n}\n\nexport interface DataFormProps< Item > {\n\tdata: Item;\n\tfields: Field< Item >[];\n\tform: Form;\n\tonChange: Dispatch< SetStateAction< Item > >;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { normalizeFields } from './normalize-fields';
|
|
5
|
+
export function isItemValid(item, fields, form) {
|
|
6
|
+
const _fields = normalizeFields(fields.filter(({
|
|
7
|
+
id
|
|
8
|
+
}) => !!form.fields?.includes(id)));
|
|
9
|
+
return _fields.every(field => {
|
|
10
|
+
return field.isValid(item, {
|
|
11
|
+
elements: field.elements
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["normalizeFields","isItemValid","item","fields","form","_fields","filter","id","includes","every","field","isValid","elements"],"sources":["@wordpress/dataviews/src/validation.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { normalizeFields } from './normalize-fields';\nimport type { Field, Form } from './types';\n\nexport function isItemValid< Item >(\n\titem: Item,\n\tfields: Field< Item >[],\n\tform: Form\n): boolean {\n\tconst _fields = normalizeFields(\n\t\tfields.filter( ( { id } ) => !! form.fields?.includes( id ) )\n\t);\n\treturn _fields.every( ( field ) => {\n\t\treturn field.isValid( item, { elements: field.elements } );\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAe,QAAQ,oBAAoB;AAGpD,OAAO,SAASC,WAAWA,CAC1BC,IAAU,EACVC,MAAuB,EACvBC,IAAU,EACA;EACV,MAAMC,OAAO,GAAGL,eAAe,CAC9BG,MAAM,CAACG,MAAM,CAAE,CAAE;IAAEC;EAAG,CAAC,KAAM,CAAC,CAAEH,IAAI,CAACD,MAAM,EAAEK,QAAQ,CAAED,EAAG,CAAE,CAC7D,CAAC;EACD,OAAOF,OAAO,CAACI,KAAK,CAAIC,KAAK,IAAM;IAClC,OAAOA,KAAK,CAACC,OAAO,CAAET,IAAI,EAAE;MAAEU,QAAQ,EAAEF,KAAK,CAACE;IAAS,CAAE,CAAC;EAC3D,CAAE,CAAC;AACJ","ignoreList":[]}
|
|
@@ -33,6 +33,9 @@
|
|
|
33
33
|
* Grid System.
|
|
34
34
|
* https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
|
|
35
35
|
*/
|
|
36
|
+
/**
|
|
37
|
+
* Radius scale.
|
|
38
|
+
*/
|
|
36
39
|
/**
|
|
37
40
|
* Dimensions.
|
|
38
41
|
*/
|
|
@@ -115,7 +118,8 @@
|
|
|
115
118
|
flex-direction: column;
|
|
116
119
|
}
|
|
117
120
|
|
|
118
|
-
.dataviews__view-actions
|
|
121
|
+
.dataviews__view-actions,
|
|
122
|
+
.dataviews-filters__container {
|
|
119
123
|
box-sizing: border-box;
|
|
120
124
|
padding: 16px 48px;
|
|
121
125
|
flex-shrink: 0;
|
|
@@ -124,12 +128,14 @@
|
|
|
124
128
|
transition: padding ease-out 0.1s;
|
|
125
129
|
}
|
|
126
130
|
@media (prefers-reduced-motion: reduce) {
|
|
127
|
-
.dataviews__view-actions
|
|
131
|
+
.dataviews__view-actions,
|
|
132
|
+
.dataviews-filters__container {
|
|
128
133
|
transition-duration: 0s;
|
|
129
134
|
transition-delay: 0s;
|
|
130
135
|
}
|
|
131
136
|
}
|
|
132
|
-
.dataviews__view-actions .components-search-control .components-base-control__field
|
|
137
|
+
.dataviews__view-actions .components-search-control .components-base-control__field,
|
|
138
|
+
.dataviews-filters__container .components-search-control .components-base-control__field {
|
|
133
139
|
max-width: 240px;
|
|
134
140
|
}
|
|
135
141
|
|
|
@@ -203,10 +209,12 @@
|
|
|
203
209
|
|
|
204
210
|
/* stylelint-disable-next-line scss/at-rule-no-unknown -- '@container' not globally permitted */
|
|
205
211
|
@container (max-width: 430px) {
|
|
206
|
-
.dataviews__view-actions
|
|
212
|
+
.dataviews__view-actions,
|
|
213
|
+
.dataviews-filters__container {
|
|
207
214
|
padding: 12px 24px;
|
|
208
215
|
}
|
|
209
|
-
.dataviews__view-actions .components-search-control .components-base-control__field
|
|
216
|
+
.dataviews__view-actions .components-search-control .components-base-control__field,
|
|
217
|
+
.dataviews-filters__container .components-search-control .components-base-control__field {
|
|
210
218
|
max-width: 112px;
|
|
211
219
|
}
|
|
212
220
|
|
|
@@ -270,6 +278,10 @@
|
|
|
270
278
|
position: relative;
|
|
271
279
|
}
|
|
272
280
|
|
|
281
|
+
.dataviews-filters__container {
|
|
282
|
+
padding-top: 0;
|
|
283
|
+
}
|
|
284
|
+
|
|
273
285
|
.dataviews-filters__reset-button.dataviews-filters__reset-button[aria-disabled=true], .dataviews-filters__reset-button.dataviews-filters__reset-button[aria-disabled=true]:hover {
|
|
274
286
|
opacity: 0;
|
|
275
287
|
}
|
|
@@ -503,6 +515,33 @@
|
|
|
503
515
|
width: 24px;
|
|
504
516
|
}
|
|
505
517
|
|
|
518
|
+
.dataviews-filters__container-visibility-toggle {
|
|
519
|
+
position: relative;
|
|
520
|
+
flex-shrink: 0;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
.dataviews-filters-toggle__count {
|
|
524
|
+
position: absolute;
|
|
525
|
+
top: 0;
|
|
526
|
+
left: 0;
|
|
527
|
+
transform: translate(-50%, -50%);
|
|
528
|
+
background: var(--wp-admin-theme-color, #3858e9);
|
|
529
|
+
height: 16px;
|
|
530
|
+
min-width: 16px;
|
|
531
|
+
line-height: 16px;
|
|
532
|
+
padding: 0 4px;
|
|
533
|
+
text-align: center;
|
|
534
|
+
border-radius: 8px;
|
|
535
|
+
font-size: 11px;
|
|
536
|
+
outline: var(--wp-admin-border-width-focus) solid #fff;
|
|
537
|
+
color: #fff;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
.dataviews-search {
|
|
541
|
+
width: -moz-fit-content;
|
|
542
|
+
width: fit-content;
|
|
543
|
+
}
|
|
544
|
+
|
|
506
545
|
.dataviews-pagination {
|
|
507
546
|
position: sticky;
|
|
508
547
|
bottom: 0;
|
|
@@ -552,6 +591,50 @@
|
|
|
552
591
|
margin: 0;
|
|
553
592
|
}
|
|
554
593
|
|
|
594
|
+
.dataviews-view-config {
|
|
595
|
+
width: 320px;
|
|
596
|
+
/* stylelint-disable-next-line property-no-unknown -- the linter needs to be updated to accepted the container-type property */
|
|
597
|
+
container-type: inline-size;
|
|
598
|
+
padding: 16px;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
.dataviews-view-config__sort-direction .components-toggle-group-control-option-base {
|
|
602
|
+
text-transform: uppercase;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
.dataviews-settings-section__title.dataviews-settings-section__title {
|
|
606
|
+
line-height: 24px;
|
|
607
|
+
font-size: 15px;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
.dataviews-settings-section__sidebar {
|
|
611
|
+
grid-column: span 4;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
.dataviews-settings-section__content,
|
|
615
|
+
.dataviews-settings-section__content > * {
|
|
616
|
+
grid-column: span 8;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
.dataviews-settings-section__content .is-divided-in-two {
|
|
620
|
+
display: contents;
|
|
621
|
+
}
|
|
622
|
+
.dataviews-settings-section__content .is-divided-in-two > * {
|
|
623
|
+
grid-column: span 4;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
/* stylelint-disable-next-line scss/at-rule-no-unknown -- '@container' not globally permitted */
|
|
627
|
+
@container (max-width: 500px) {
|
|
628
|
+
.dataviews-settings-section.dataviews-settings-section {
|
|
629
|
+
grid-template-columns: repeat(2, 1fr);
|
|
630
|
+
}
|
|
631
|
+
.dataviews-settings-section.dataviews-settings-section .dataviews-settings-section__sidebar {
|
|
632
|
+
grid-column: span 2;
|
|
633
|
+
}
|
|
634
|
+
.dataviews-settings-section.dataviews-settings-section .dataviews-settings-section__content {
|
|
635
|
+
grid-column: span 2;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
555
638
|
.dataviews-view-grid {
|
|
556
639
|
margin-bottom: auto;
|
|
557
640
|
grid-template-rows: max-content;
|
|
@@ -567,6 +650,7 @@
|
|
|
567
650
|
.dataviews-view-grid .dataviews-view-grid__card {
|
|
568
651
|
height: 100%;
|
|
569
652
|
justify-content: flex-start;
|
|
653
|
+
position: relative;
|
|
570
654
|
}
|
|
571
655
|
.dataviews-view-grid .dataviews-view-grid__card .dataviews-view-grid__title-actions {
|
|
572
656
|
padding: 8px 0 4px;
|
|
@@ -577,6 +661,10 @@
|
|
|
577
661
|
.dataviews-view-grid .dataviews-view-grid__card.is-selected .dataviews-view-grid__fields .dataviews-view-grid__field .dataviews-view-grid__field-value {
|
|
578
662
|
color: #1e1e1e;
|
|
579
663
|
}
|
|
664
|
+
.dataviews-view-grid .dataviews-view-grid__card.is-selected .dataviews-view-grid__media::after {
|
|
665
|
+
background-color: rgba(var(--wp-admin-theme-color--rgb), 0.08);
|
|
666
|
+
box-shadow: inset 0 0 0 1px var(--wp-admin-theme-color);
|
|
667
|
+
}
|
|
580
668
|
.dataviews-view-grid .dataviews-view-grid__media {
|
|
581
669
|
width: 100%;
|
|
582
670
|
min-height: 200px;
|
|
@@ -609,10 +697,18 @@
|
|
|
609
697
|
.dataviews-view-grid .dataviews-view-grid__fields:not(:empty) {
|
|
610
698
|
padding: 0 0 12px;
|
|
611
699
|
}
|
|
700
|
+
.dataviews-view-grid .dataviews-view-grid__fields .dataviews-view-grid__field-value:not(:empty) {
|
|
701
|
+
min-height: 24px;
|
|
702
|
+
line-height: 20px;
|
|
703
|
+
padding-top: 2px;
|
|
704
|
+
}
|
|
612
705
|
.dataviews-view-grid .dataviews-view-grid__fields .dataviews-view-grid__field {
|
|
613
706
|
align-items: flex-start;
|
|
614
707
|
min-height: 24px;
|
|
615
708
|
}
|
|
709
|
+
.dataviews-view-grid .dataviews-view-grid__fields .dataviews-view-grid__field:not(:has(.dataviews-view-grid__field-value:not(:empty))) {
|
|
710
|
+
display: none;
|
|
711
|
+
}
|
|
616
712
|
.dataviews-view-grid .dataviews-view-grid__fields .dataviews-view-grid__field:not(.is-column) {
|
|
617
713
|
align-items: center;
|
|
618
714
|
}
|
|
@@ -679,6 +775,19 @@
|
|
|
679
775
|
display: none;
|
|
680
776
|
}
|
|
681
777
|
|
|
778
|
+
.dataviews-view-grid__card .dataviews-selection-checkbox {
|
|
779
|
+
position: absolute;
|
|
780
|
+
top: -9999em;
|
|
781
|
+
right: 8px;
|
|
782
|
+
z-index: 1;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
.dataviews-view-grid__card:hover .dataviews-selection-checkbox,
|
|
786
|
+
.dataviews-view-grid__card:focus-within .dataviews-selection-checkbox,
|
|
787
|
+
.dataviews-view-grid__card.is-selected .dataviews-selection-checkbox {
|
|
788
|
+
top: 8px;
|
|
789
|
+
}
|
|
790
|
+
|
|
682
791
|
.dataviews-view-list {
|
|
683
792
|
margin: 0 0 auto;
|
|
684
793
|
}
|
|
@@ -819,7 +928,10 @@
|
|
|
819
928
|
display: none;
|
|
820
929
|
}
|
|
821
930
|
.dataviews-view-list .dataviews-view-list__fields .dataviews-view-list__field-value {
|
|
822
|
-
|
|
931
|
+
min-height: 24px;
|
|
932
|
+
line-height: 20px;
|
|
933
|
+
display: flex;
|
|
934
|
+
align-items: center;
|
|
823
935
|
}
|
|
824
936
|
.dataviews-view-list + .dataviews-pagination {
|
|
825
937
|
justify-content: space-between;
|
|
@@ -994,4 +1106,61 @@
|
|
|
994
1106
|
.dataviews-view-table-selection-checkbox {
|
|
995
1107
|
--checkbox-input-size: 16px;
|
|
996
1108
|
}
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
.dataforms-layouts-panel__field {
|
|
1112
|
+
width: 100%;
|
|
1113
|
+
min-height: 32px;
|
|
1114
|
+
justify-content: flex-start !important;
|
|
1115
|
+
align-items: flex-start !important;
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
.dataforms-layouts-panel__field-label {
|
|
1119
|
+
width: 38%;
|
|
1120
|
+
flex-shrink: 0;
|
|
1121
|
+
min-height: 32px;
|
|
1122
|
+
display: flex;
|
|
1123
|
+
align-items: center;
|
|
1124
|
+
padding: 6px 0;
|
|
1125
|
+
line-height: 20px;
|
|
1126
|
+
-webkit-hyphens: auto;
|
|
1127
|
+
hyphens: auto;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
.dataforms-layouts-panel__field-control {
|
|
1131
|
+
flex-grow: 1;
|
|
1132
|
+
min-height: 32px;
|
|
1133
|
+
display: flex;
|
|
1134
|
+
align-items: center;
|
|
1135
|
+
}
|
|
1136
|
+
.dataforms-layouts-panel__field-control .components-button {
|
|
1137
|
+
max-width: 100%;
|
|
1138
|
+
text-align: right;
|
|
1139
|
+
white-space: normal;
|
|
1140
|
+
text-wrap: balance;
|
|
1141
|
+
text-wrap: pretty;
|
|
1142
|
+
min-height: 32px;
|
|
1143
|
+
}
|
|
1144
|
+
.dataforms-layouts-panel__field-control .components-dropdown {
|
|
1145
|
+
max-width: 100%;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
.dataforms-layouts-panel__field-dropdown .components-popover__content {
|
|
1149
|
+
min-width: 320px;
|
|
1150
|
+
padding: 16px;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
.dataforms-layouts-panel__dropdown-header {
|
|
1154
|
+
margin-bottom: 16px;
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
[class].dataforms-layouts-panel__dropdown-header-action {
|
|
1158
|
+
height: 24px;
|
|
1159
|
+
}
|
|
1160
|
+
[class].dataforms-layouts-panel__dropdown-header-action.has-icon {
|
|
1161
|
+
min-width: 24px;
|
|
1162
|
+
padding: 0;
|
|
1163
|
+
}
|
|
1164
|
+
[class].dataforms-layouts-panel__dropdown-header-action:not(.has-icon) {
|
|
1165
|
+
text-decoration: underline;
|
|
997
1166
|
}
|