@wordpress/dataviews 7.0.1-next.0f6f9d12c.0 → 7.0.1-next.f34ab90e9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -1
- package/build/components/dataviews-item-actions/index.js +1 -10
- package/build/components/dataviews-item-actions/index.js.map +1 -1
- package/build/dataform-controls/boolean.js +15 -7
- package/build/dataform-controls/boolean.js.map +1 -1
- package/build/dataform-controls/email.js +14 -7
- package/build/dataform-controls/email.js.map +1 -1
- package/build/dataform-controls/integer.js +14 -7
- package/build/dataform-controls/integer.js.map +1 -1
- package/build/dataform-controls/text.js +14 -7
- package/build/dataform-controls/text.js.map +1 -1
- package/build/dataforms-layouts/panel/dropdown.js +124 -0
- package/build/dataforms-layouts/panel/dropdown.js.map +1 -0
- package/build/dataforms-layouts/panel/index.js +19 -127
- package/build/dataforms-layouts/panel/index.js.map +1 -1
- package/build/dataforms-layouts/panel/modal.js +125 -0
- package/build/dataforms-layouts/panel/modal.js.map +1 -0
- package/build/normalize-form-fields.js +3 -2
- package/build/normalize-form-fields.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build-module/components/dataviews-item-actions/index.js +1 -10
- package/build-module/components/dataviews-item-actions/index.js.map +1 -1
- package/build-module/dataform-controls/boolean.js +15 -7
- package/build-module/dataform-controls/boolean.js.map +1 -1
- package/build-module/dataform-controls/email.js +15 -8
- package/build-module/dataform-controls/email.js.map +1 -1
- package/build-module/dataform-controls/integer.js +15 -8
- package/build-module/dataform-controls/integer.js.map +1 -1
- package/build-module/dataform-controls/text.js +15 -8
- package/build-module/dataform-controls/text.js.map +1 -1
- package/build-module/dataforms-layouts/panel/dropdown.js +118 -0
- package/build-module/dataforms-layouts/panel/dropdown.js.map +1 -0
- package/build-module/dataforms-layouts/panel/index.js +23 -131
- package/build-module/dataforms-layouts/panel/index.js.map +1 -1
- package/build-module/dataforms-layouts/panel/modal.js +119 -0
- package/build-module/dataforms-layouts/panel/modal.js.map +1 -0
- package/build-module/normalize-form-fields.js +3 -2
- package/build-module/normalize-form-fields.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-style/style-rtl.css +4 -0
- package/build-style/style.css +4 -0
- package/build-types/components/dataform/stories/index.story.d.ts +58 -25
- package/build-types/components/dataform/stories/index.story.d.ts.map +1 -1
- package/build-types/components/dataviews-item-actions/index.d.ts.map +1 -1
- package/build-types/dataform-controls/boolean.d.ts.map +1 -1
- package/build-types/dataform-controls/email.d.ts.map +1 -1
- package/build-types/dataform-controls/integer.d.ts.map +1 -1
- package/build-types/dataform-controls/text.d.ts.map +1 -1
- package/build-types/dataforms-layouts/panel/dropdown.d.ts +14 -0
- package/build-types/dataforms-layouts/panel/dropdown.d.ts.map +1 -0
- package/build-types/dataforms-layouts/panel/index.d.ts.map +1 -1
- package/build-types/dataforms-layouts/panel/modal.d.ts +13 -0
- package/build-types/dataforms-layouts/panel/modal.d.ts.map +1 -0
- package/build-types/normalize-form-fields.d.ts.map +1 -1
- package/build-types/types.d.ts +2 -0
- package/build-types/types.d.ts.map +1 -1
- package/build-wp/index.js +394 -178
- package/package.json +15 -15
- package/src/components/dataform/stories/index.story.tsx +354 -219
- package/src/components/dataviews-item-actions/index.tsx +7 -16
- package/src/dataform-controls/boolean.tsx +24 -10
- package/src/dataform-controls/email.tsx +24 -11
- package/src/dataform-controls/integer.tsx +27 -13
- package/src/dataform-controls/text.tsx +24 -11
- package/src/dataforms-layouts/panel/dropdown.tsx +160 -0
- package/src/dataforms-layouts/panel/index.tsx +28 -172
- package/src/dataforms-layouts/panel/modal.tsx +165 -0
- package/src/dataforms-layouts/panel/style.scss +4 -0
- package/src/normalize-form-fields.ts +1 -0
- package/src/test/dataform.tsx +169 -0
- package/src/test/normalize-form-fields.ts +15 -3
- package/src/types.ts +2 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -7,13 +7,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = FormPanelField;
|
|
8
8
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
9
9
|
var _components = require("@wordpress/components");
|
|
10
|
-
var _i18n = require("@wordpress/i18n");
|
|
11
10
|
var _element = require("@wordpress/element");
|
|
12
|
-
var _icons = require("@wordpress/icons");
|
|
13
11
|
var _dataformContext = _interopRequireDefault(require("../../components/dataform-context"));
|
|
14
|
-
var _dataFormLayout = require("../data-form-layout");
|
|
15
12
|
var _isCombinedField = require("../is-combined-field");
|
|
16
13
|
var _normalizeFormFields = require("../../normalize-form-fields");
|
|
14
|
+
var _dropdown = _interopRequireDefault(require("./dropdown"));
|
|
15
|
+
var _modal = _interopRequireDefault(require("./modal"));
|
|
17
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
17
|
/**
|
|
19
18
|
* External dependencies
|
|
@@ -27,106 +26,6 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
27
26
|
* Internal dependencies
|
|
28
27
|
*/
|
|
29
28
|
|
|
30
|
-
function DropdownHeader({
|
|
31
|
-
title,
|
|
32
|
-
onClose
|
|
33
|
-
}) {
|
|
34
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalVStack, {
|
|
35
|
-
className: "dataforms-layouts-panel__dropdown-header",
|
|
36
|
-
spacing: 4,
|
|
37
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
38
|
-
alignment: "center",
|
|
39
|
-
children: [title && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalHeading, {
|
|
40
|
-
level: 2,
|
|
41
|
-
size: 13,
|
|
42
|
-
children: title
|
|
43
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalSpacer, {}), onClose && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
44
|
-
label: (0, _i18n.__)('Close'),
|
|
45
|
-
icon: _icons.closeSmall,
|
|
46
|
-
onClick: onClose,
|
|
47
|
-
size: "small"
|
|
48
|
-
})]
|
|
49
|
-
})
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
function PanelDropdown({
|
|
53
|
-
fieldDefinition,
|
|
54
|
-
popoverAnchor,
|
|
55
|
-
labelPosition = 'side',
|
|
56
|
-
data,
|
|
57
|
-
onChange,
|
|
58
|
-
field
|
|
59
|
-
}) {
|
|
60
|
-
const fieldLabel = (0, _isCombinedField.isCombinedField)(field) ? field.label : fieldDefinition?.label;
|
|
61
|
-
const form = (0, _element.useMemo)(() => ({
|
|
62
|
-
layout: _normalizeFormFields.DEFAULT_LAYOUT,
|
|
63
|
-
fields: (0, _isCombinedField.isCombinedField)(field) ? field.children :
|
|
64
|
-
// If not explicit children return the field id itself.
|
|
65
|
-
[{
|
|
66
|
-
id: field.id
|
|
67
|
-
}]
|
|
68
|
-
}), [field]);
|
|
69
|
-
|
|
70
|
-
// Memoize popoverProps to avoid returning a new object every time.
|
|
71
|
-
const popoverProps = (0, _element.useMemo)(() => ({
|
|
72
|
-
// Anchor the popover to the middle of the entire row so that it doesn't
|
|
73
|
-
// move around when the label changes.
|
|
74
|
-
anchor: popoverAnchor,
|
|
75
|
-
placement: 'left-start',
|
|
76
|
-
offset: 36,
|
|
77
|
-
shift: true
|
|
78
|
-
}), [popoverAnchor]);
|
|
79
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Dropdown, {
|
|
80
|
-
contentClassName: "dataforms-layouts-panel__field-dropdown",
|
|
81
|
-
popoverProps: popoverProps,
|
|
82
|
-
focusOnMount: true,
|
|
83
|
-
toggleProps: {
|
|
84
|
-
size: 'compact',
|
|
85
|
-
variant: 'tertiary',
|
|
86
|
-
tooltipPosition: 'middle left'
|
|
87
|
-
},
|
|
88
|
-
renderToggle: ({
|
|
89
|
-
isOpen,
|
|
90
|
-
onToggle
|
|
91
|
-
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
92
|
-
className: "dataforms-layouts-panel__field-control",
|
|
93
|
-
size: "compact",
|
|
94
|
-
variant: ['none', 'top'].includes(labelPosition) ? 'link' : 'tertiary',
|
|
95
|
-
"aria-expanded": isOpen,
|
|
96
|
-
"aria-label": (0, _i18n.sprintf)(
|
|
97
|
-
// translators: %s: Field name.
|
|
98
|
-
(0, _i18n._x)('Edit %s', 'field'), fieldLabel || ''),
|
|
99
|
-
onClick: onToggle,
|
|
100
|
-
disabled: fieldDefinition.readOnly === true,
|
|
101
|
-
accessibleWhenDisabled: true,
|
|
102
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(fieldDefinition.render, {
|
|
103
|
-
item: data,
|
|
104
|
-
field: fieldDefinition
|
|
105
|
-
})
|
|
106
|
-
}),
|
|
107
|
-
renderContent: ({
|
|
108
|
-
onClose
|
|
109
|
-
}) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
110
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(DropdownHeader, {
|
|
111
|
-
title: fieldLabel,
|
|
112
|
-
onClose: onClose
|
|
113
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_dataFormLayout.DataFormLayout, {
|
|
114
|
-
data: data,
|
|
115
|
-
form: form,
|
|
116
|
-
onChange: onChange,
|
|
117
|
-
children: (FieldLayout, nestedField) => {
|
|
118
|
-
var _form$fields;
|
|
119
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(FieldLayout, {
|
|
120
|
-
data: data,
|
|
121
|
-
field: nestedField,
|
|
122
|
-
onChange: onChange,
|
|
123
|
-
hideLabelFromVision: ((_form$fields = form?.fields) !== null && _form$fields !== void 0 ? _form$fields : []).length < 2
|
|
124
|
-
}, nestedField.id);
|
|
125
|
-
}
|
|
126
|
-
})]
|
|
127
|
-
})
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
29
|
function FormPanelField({
|
|
131
30
|
data,
|
|
132
31
|
field,
|
|
@@ -161,6 +60,20 @@ function FormPanelField({
|
|
|
161
60
|
const labelPosition = layout.labelPosition;
|
|
162
61
|
const labelClassName = (0, _clsx.default)('dataforms-layouts-panel__field-label', `dataforms-layouts-panel__field-label--label-position-${labelPosition}`);
|
|
163
62
|
const fieldLabel = (0, _isCombinedField.isCombinedField)(field) ? field.label : fieldDefinition?.label;
|
|
63
|
+
const renderedControl = layout.openAs === 'modal' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_modal.default, {
|
|
64
|
+
field: field,
|
|
65
|
+
fieldDefinition: fieldDefinition,
|
|
66
|
+
data: data,
|
|
67
|
+
onChange: onChange,
|
|
68
|
+
labelPosition: labelPosition
|
|
69
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_dropdown.default, {
|
|
70
|
+
field: field,
|
|
71
|
+
popoverAnchor: popoverAnchor,
|
|
72
|
+
fieldDefinition: fieldDefinition,
|
|
73
|
+
data: data,
|
|
74
|
+
onChange: onChange,
|
|
75
|
+
labelPosition: labelPosition
|
|
76
|
+
});
|
|
164
77
|
if (labelPosition === 'top') {
|
|
165
78
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
|
|
166
79
|
className: "dataforms-layouts-panel__field",
|
|
@@ -173,28 +86,14 @@ function FormPanelField({
|
|
|
173
86
|
children: fieldLabel
|
|
174
87
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
175
88
|
className: "dataforms-layouts-panel__field-control",
|
|
176
|
-
children:
|
|
177
|
-
field: field,
|
|
178
|
-
popoverAnchor: popoverAnchor,
|
|
179
|
-
fieldDefinition: fieldDefinition,
|
|
180
|
-
data: data,
|
|
181
|
-
onChange: onChange,
|
|
182
|
-
labelPosition: labelPosition
|
|
183
|
-
})
|
|
89
|
+
children: renderedControl
|
|
184
90
|
})]
|
|
185
91
|
});
|
|
186
92
|
}
|
|
187
93
|
if (labelPosition === 'none') {
|
|
188
94
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
189
95
|
className: "dataforms-layouts-panel__field",
|
|
190
|
-
children:
|
|
191
|
-
field: field,
|
|
192
|
-
popoverAnchor: popoverAnchor,
|
|
193
|
-
fieldDefinition: fieldDefinition,
|
|
194
|
-
data: data,
|
|
195
|
-
onChange: onChange,
|
|
196
|
-
labelPosition: labelPosition
|
|
197
|
-
})
|
|
96
|
+
children: renderedControl
|
|
198
97
|
});
|
|
199
98
|
}
|
|
200
99
|
|
|
@@ -207,14 +106,7 @@ function FormPanelField({
|
|
|
207
106
|
children: fieldLabel
|
|
208
107
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
209
108
|
className: "dataforms-layouts-panel__field-control",
|
|
210
|
-
children:
|
|
211
|
-
field: field,
|
|
212
|
-
popoverAnchor: popoverAnchor,
|
|
213
|
-
fieldDefinition: fieldDefinition,
|
|
214
|
-
data: data,
|
|
215
|
-
onChange: onChange,
|
|
216
|
-
labelPosition: labelPosition
|
|
217
|
-
})
|
|
109
|
+
children: renderedControl
|
|
218
110
|
})]
|
|
219
111
|
});
|
|
220
112
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_components","_i18n","_element","_icons","_dataformContext","_dataFormLayout","_isCombinedField","_normalizeFormFields","_jsxRuntime","DropdownHeader","title","onClose","jsx","__experimentalVStack","className","spacing","children","jsxs","__experimentalHStack","alignment","__experimentalHeading","level","size","__experimentalSpacer","Button","label","__","icon","closeSmall","onClick","PanelDropdown","fieldDefinition","popoverAnchor","labelPosition","data","onChange","field","fieldLabel","isCombinedField","form","useMemo","layout","DEFAULT_LAYOUT","fields","id","popoverProps","anchor","placement","offset","shift","Dropdown","contentClassName","focusOnMount","toggleProps","variant","tooltipPosition","renderToggle","isOpen","onToggle","includes","sprintf","_x","disabled","readOnly","accessibleWhenDisabled","render","item","renderContent","Fragment","DataFormLayout","FieldLayout","nestedField","_form$fields","hideLabelFromVision","length","FormPanelField","useContext","DataFormContext","find","_field","simpleChildren","filter","child","firstChildFieldId","setPopoverAnchor","useState","normalizeLayout","type","labelClassName","clsx","style","paddingBottom","ref"],"sources":["@wordpress/dataviews/src/dataforms-layouts/panel/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n\t__experimentalHeading as Heading,\n\t__experimentalSpacer as Spacer,\n\tDropdown,\n\tButton,\n} from '@wordpress/components';\nimport { sprintf, __, _x } from '@wordpress/i18n';\nimport { useState, useMemo, useContext } from '@wordpress/element';\nimport { closeSmall } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tForm,\n\tFormField,\n\tFieldLayoutProps,\n\tNormalizedPanelLayout,\n\tNormalizedField,\n\tSimpleFormField,\n} from '../../types';\nimport DataFormContext from '../../components/dataform-context';\nimport { DataFormLayout } from '../data-form-layout';\nimport { isCombinedField } from '../is-combined-field';\nimport { DEFAULT_LAYOUT, normalizeLayout } from '../../normalize-form-fields';\n\nfunction DropdownHeader( {\n\ttitle,\n\tonClose,\n}: {\n\ttitle?: string;\n\tonClose: () => void;\n} ) {\n\treturn (\n\t\t<VStack\n\t\t\tclassName=\"dataforms-layouts-panel__dropdown-header\"\n\t\t\tspacing={ 4 }\n\t\t>\n\t\t\t<HStack alignment=\"center\">\n\t\t\t\t{ title && (\n\t\t\t\t\t<Heading level={ 2 } size={ 13 }>\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</Heading>\n\t\t\t\t) }\n\t\t\t\t<Spacer />\n\t\t\t\t{ onClose && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tlabel={ __( 'Close' ) }\n\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t</VStack>\n\t);\n}\n\nfunction PanelDropdown< Item >( {\n\tfieldDefinition,\n\tpopoverAnchor,\n\tlabelPosition = 'side',\n\tdata,\n\tonChange,\n\tfield,\n}: {\n\tfieldDefinition: NormalizedField< Item >;\n\tpopoverAnchor: HTMLElement | null;\n\tlabelPosition: 'side' | 'top' | 'none';\n\tdata: Item;\n\tonChange: ( value: any ) => void;\n\tfield: FormField;\n} ) {\n\tconst fieldLabel = isCombinedField( field )\n\t\t? field.label\n\t\t: fieldDefinition?.label;\n\n\tconst form: Form = useMemo(\n\t\t(): Form => ( {\n\t\t\tlayout: DEFAULT_LAYOUT,\n\t\t\tfields: isCombinedField( field )\n\t\t\t\t? field.children\n\t\t\t\t: // If not explicit children return the field id itself.\n\t\t\t\t [ { id: field.id } ],\n\t\t} ),\n\t\t[ field ]\n\t);\n\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\n\treturn (\n\t\t<Dropdown\n\t\t\tcontentClassName=\"dataforms-layouts-panel__field-dropdown\"\n\t\t\tpopoverProps={ popoverProps }\n\t\t\tfocusOnMount\n\t\t\ttoggleProps={ {\n\t\t\t\tsize: 'compact',\n\t\t\t\tvariant: 'tertiary',\n\t\t\t\ttooltipPosition: 'middle left',\n\t\t\t} }\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"dataforms-layouts-panel__field-control\"\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\tvariant={\n\t\t\t\t\t\t[ 'none', 'top' ].includes( labelPosition )\n\t\t\t\t\t\t\t? 'link'\n\t\t\t\t\t\t\t: 'tertiary'\n\t\t\t\t\t}\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t// translators: %s: Field name.\n\t\t\t\t\t\t_x( 'Edit %s', 'field' ),\n\t\t\t\t\t\tfieldLabel || ''\n\t\t\t\t\t) }\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\tdisabled={ fieldDefinition.readOnly === true }\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t>\n\t\t\t\t\t<fieldDefinition.render\n\t\t\t\t\t\titem={ data }\n\t\t\t\t\t\tfield={ fieldDefinition }\n\t\t\t\t\t/>\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<DropdownHeader title={ fieldLabel } onClose={ onClose } />\n\t\t\t\t\t<DataFormLayout\n\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\tform={ form }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ( FieldLayout, nestedField ) => (\n\t\t\t\t\t\t\t<FieldLayout\n\t\t\t\t\t\t\t\tkey={ nestedField.id }\n\t\t\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\t\t\tfield={ nestedField }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\thideLabelFromVision={\n\t\t\t\t\t\t\t\t\t( form?.fields ?? [] ).length < 2\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</DataFormLayout>\n\t\t\t\t</>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default function FormPanelField< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n}: FieldLayoutProps< Item > ) {\n\tconst { fields } = useContext( DataFormContext );\n\tconst fieldDefinition = fields.find( ( _field ) => {\n\t\t// Default to the first simple child if it is a combined field.\n\t\tif ( isCombinedField( field ) ) {\n\t\t\tconst simpleChildren = field.children.filter(\n\t\t\t\t( child ): child is string | SimpleFormField =>\n\t\t\t\t\ttypeof child === 'string' || ! isCombinedField( child )\n\t\t\t);\n\n\t\t\tif ( simpleChildren.length === 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst firstChildFieldId =\n\t\t\t\ttypeof simpleChildren[ 0 ] === 'string'\n\t\t\t\t\t? simpleChildren[ 0 ]\n\t\t\t\t\t: simpleChildren[ 0 ].id;\n\t\t\treturn _field.id === firstChildFieldId;\n\t\t}\n\n\t\treturn _field.id === field.id;\n\t} );\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState< HTMLElement | null >(\n\t\tnull\n\t);\n\n\tif ( ! fieldDefinition ) {\n\t\treturn null;\n\t}\n\n\tconst layout: NormalizedPanelLayout = normalizeLayout( {\n\t\t...field.layout,\n\t\ttype: 'panel',\n\t} ) as NormalizedPanelLayout;\n\n\tconst labelPosition = layout.labelPosition;\n\tconst labelClassName = clsx(\n\t\t'dataforms-layouts-panel__field-label',\n\t\t`dataforms-layouts-panel__field-label--label-position-${ labelPosition }`\n\t);\n\tconst fieldLabel = isCombinedField( field )\n\t\t? field.label\n\t\t: fieldDefinition?.label;\n\n\tif ( labelPosition === 'top' ) {\n\t\treturn (\n\t\t\t<VStack className=\"dataforms-layouts-panel__field\" spacing={ 0 }>\n\t\t\t\t<div\n\t\t\t\t\tclassName={ labelClassName }\n\t\t\t\t\tstyle={ { paddingBottom: 0 } }\n\t\t\t\t>\n\t\t\t\t\t{ fieldLabel }\n\t\t\t\t</div>\n\t\t\t\t<div className=\"dataforms-layouts-panel__field-control\">\n\t\t\t\t\t<PanelDropdown\n\t\t\t\t\t\tfield={ field }\n\t\t\t\t\t\tpopoverAnchor={ popoverAnchor }\n\t\t\t\t\t\tfieldDefinition={ fieldDefinition }\n\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tlabelPosition={ labelPosition }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</VStack>\n\t\t);\n\t}\n\n\tif ( labelPosition === 'none' ) {\n\t\treturn (\n\t\t\t<div className=\"dataforms-layouts-panel__field\">\n\t\t\t\t<PanelDropdown\n\t\t\t\t\tfield={ field }\n\t\t\t\t\tpopoverAnchor={ popoverAnchor }\n\t\t\t\t\tfieldDefinition={ fieldDefinition }\n\t\t\t\t\tdata={ data }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tlabelPosition={ labelPosition }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Defaults to label position side.\n\treturn (\n\t\t<HStack\n\t\t\tref={ setPopoverAnchor }\n\t\t\tclassName=\"dataforms-layouts-panel__field\"\n\t\t>\n\t\t\t<div className={ labelClassName }>{ fieldLabel }</div>\n\t\t\t<div className=\"dataforms-layouts-panel__field-control\">\n\t\t\t\t<PanelDropdown\n\t\t\t\t\tfield={ field }\n\t\t\t\t\tpopoverAnchor={ popoverAnchor }\n\t\t\t\t\tfieldDefinition={ fieldDefinition }\n\t\t\t\t\tdata={ data }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tlabelPosition={ labelPosition }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</HStack>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AAQA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAaA,IAAAK,gBAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,eAAA,GAAAN,OAAA;AACA,IAAAO,gBAAA,GAAAP,OAAA;AACA,IAAAQ,oBAAA,GAAAR,OAAA;AAA8E,IAAAS,WAAA,GAAAT,OAAA;AAlC9E;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;;AAcA,SAASU,cAAcA,CAAE;EACxBC,KAAK;EACLC;AAID,CAAC,EAAG;EACH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AGA,aAAe;UAC/BD,eAAe,EAAGA,eAAiB;UACnCG,IAAI,EAAGA,IAAM;UACbC,QAAQ,EAAGA,QAAU;UACrBF,aAAa,EAAGA;QAAe,CAC/B;MAAC,CACE,CAAC;IAAA,CACC,CAAC;EAEX;EAEA,IAAKA,aAAa,KAAK,MAAM,EAAG;IAC/B,oBACC,IAAAzB,WAAA,CAAAI,GAAA;MAAKE,SAAS,EAAC,gCAAgC;MAAAE,QAAA,eAC9C,IAAAR,WAAA,CAAAI,GAAA,EAACkB,aAAa;QACbM,KAAK,EAAGA,KAAO;QACfJ,aAAa,EAAGA,aAAe;QAC/BD,eAAe,EAAGA,eAAiB;QACnCG,IAAI,EAAGA,IAAM;QACbC,QAAQ,EAAGA,QAAU;QACrBF,aAAa,EAAGA;MAAe,CAC/B;IAAC,CACE,CAAC;EAER;;EAEA;EACA,oBACC,IAAAzB,WAAA,CAAAS,IAAA,EAACjB,WAAA,CAAAkB,oBAAM;IACN0E,GAAG,EAAGR,gBAAkB;IACxBtE,SAAS,EAAC,gCAAgC;IAAAE,QAAA,gBAE1C,IAAAR,WAAA,CAAAI,GAAA;MAAKE,SAAS,EAAG0E,cAAgB;MAAAxE,QAAA,EAAGqB;IAAU,CAAO,CAAC,eACtD,IAAA7B,WAAA,CAAAI,GAAA;MAAKE,SAAS,EAAC,wCAAwC;MAAAE,QAAA,eACtD,IAAAR,WAAA,CAAAI,GAAA,EAACkB,aAAa;QACbM,KAAK,EAAGA,KAAO;QACfJ,aAAa,EAAGA,aAAe;QAC/BD,eAAe,EAAGA,eAAiB;QACnCG,IAAI,EAAGA,IAAM;QACbC,QAAQ,EAAGA,QAAU;QACrBF,aAAa,EAAGA;MAAe,CAC/B;IAAC,CACE,CAAC;EAAA,CACC,CAAC;AAEX","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_components","_element","_dataformContext","_isCombinedField","_normalizeFormFields","_dropdown","_modal","_jsxRuntime","FormPanelField","data","field","onChange","fields","useContext","DataFormContext","fieldDefinition","find","_field","isCombinedField","simpleChildren","children","filter","child","length","firstChildFieldId","id","popoverAnchor","setPopoverAnchor","useState","layout","normalizeLayout","type","labelPosition","labelClassName","clsx","fieldLabel","label","renderedControl","openAs","jsx","default","jsxs","__experimentalVStack","className","spacing","style","paddingBottom","__experimentalHStack","ref"],"sources":["@wordpress/dataviews/src/dataforms-layouts/panel/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { useState, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tFieldLayoutProps,\n\tNormalizedPanelLayout,\n\tSimpleFormField,\n} from '../../types';\nimport DataFormContext from '../../components/dataform-context';\nimport { isCombinedField } from '../is-combined-field';\nimport { normalizeLayout } from '../../normalize-form-fields';\nimport PanelDropdown from './dropdown';\nimport PanelModal from './modal';\n\nexport default function FormPanelField< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n}: FieldLayoutProps< Item > ) {\n\tconst { fields } = useContext( DataFormContext );\n\tconst fieldDefinition = fields.find( ( _field ) => {\n\t\t// Default to the first simple child if it is a combined field.\n\t\tif ( isCombinedField( field ) ) {\n\t\t\tconst simpleChildren = field.children.filter(\n\t\t\t\t( child ): child is string | SimpleFormField =>\n\t\t\t\t\ttypeof child === 'string' || ! isCombinedField( child )\n\t\t\t);\n\n\t\t\tif ( simpleChildren.length === 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst firstChildFieldId =\n\t\t\t\ttypeof simpleChildren[ 0 ] === 'string'\n\t\t\t\t\t? simpleChildren[ 0 ]\n\t\t\t\t\t: simpleChildren[ 0 ].id;\n\n\t\t\treturn _field.id === firstChildFieldId;\n\t\t}\n\n\t\treturn _field.id === field.id;\n\t} );\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState< HTMLElement | null >(\n\t\tnull\n\t);\n\n\tif ( ! fieldDefinition ) {\n\t\treturn null;\n\t}\n\n\tconst layout: NormalizedPanelLayout = normalizeLayout( {\n\t\t...field.layout,\n\t\ttype: 'panel',\n\t} ) as NormalizedPanelLayout;\n\n\tconst labelPosition = layout.labelPosition;\n\tconst labelClassName = clsx(\n\t\t'dataforms-layouts-panel__field-label',\n\t\t`dataforms-layouts-panel__field-label--label-position-${ labelPosition }`\n\t);\n\tconst fieldLabel = isCombinedField( field )\n\t\t? field.label\n\t\t: fieldDefinition?.label;\n\n\tconst renderedControl =\n\t\tlayout.openAs === 'modal' ? (\n\t\t\t<PanelModal\n\t\t\t\tfield={ field }\n\t\t\t\tfieldDefinition={ fieldDefinition }\n\t\t\t\tdata={ data }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tlabelPosition={ labelPosition }\n\t\t\t/>\n\t\t) : (\n\t\t\t<PanelDropdown\n\t\t\t\tfield={ field }\n\t\t\t\tpopoverAnchor={ popoverAnchor }\n\t\t\t\tfieldDefinition={ fieldDefinition }\n\t\t\t\tdata={ data }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tlabelPosition={ labelPosition }\n\t\t\t/>\n\t\t);\n\n\tif ( labelPosition === 'top' ) {\n\t\treturn (\n\t\t\t<VStack className=\"dataforms-layouts-panel__field\" spacing={ 0 }>\n\t\t\t\t<div\n\t\t\t\t\tclassName={ labelClassName }\n\t\t\t\t\tstyle={ { paddingBottom: 0 } }\n\t\t\t\t>\n\t\t\t\t\t{ fieldLabel }\n\t\t\t\t</div>\n\t\t\t\t<div className=\"dataforms-layouts-panel__field-control\">\n\t\t\t\t\t{ renderedControl }\n\t\t\t\t</div>\n\t\t\t</VStack>\n\t\t);\n\t}\n\n\tif ( labelPosition === 'none' ) {\n\t\treturn (\n\t\t\t<div className=\"dataforms-layouts-panel__field\">\n\t\t\t\t{ renderedControl }\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Defaults to label position side.\n\treturn (\n\t\t<HStack\n\t\t\tref={ setPopoverAnchor }\n\t\t\tclassName=\"dataforms-layouts-panel__field\"\n\t\t>\n\t\t\t<div className={ labelClassName }>{ fieldLabel }</div>\n\t\t\t<div className=\"dataforms-layouts-panel__field-control\">\n\t\t\t\t{ renderedControl }\n\t\t\t</div>\n\t\t</HStack>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AAIA,IAAAE,QAAA,GAAAF,OAAA;AAUA,IAAAG,gBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,MAAA,GAAAR,sBAAA,CAAAC,OAAA;AAAiC,IAAAQ,WAAA,GAAAR,OAAA;AA1BjC;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;;AAYe,SAASS,cAAcA,CAAU;EAC/CC,IAAI;EACJC,KAAK;EACLC;AACyB,CAAC,EAAG;EAC7B,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,mBAAU,EAAEC,wBAAgB,CAAC;EAChD,MAAMC,eAAe,GAAGH,MAAM,CAACI,IAAI,CAAIC,MAAM,IAAM;IAClD;IACA,IAAK,IAAAC,gCAAe,EAAER,KAAM,CAAC,EAAG;MAC/B,MAAMS,cAAc,GAAGT,KAAK,CAACU,QAAQ,CAACC,MAAM,CACzCC,KAAK,IACN,OAAOA,KAAK,KAAK,QAAQ,IAAI,CAAE,IAAAJ,gCAAe,EAAEI,KAAM,CACxD,CAAC;MAED,IAAKH,cAAc,CAACI,MAAM,KAAK,CAAC,EAAG;QAClC,OAAO,KAAK;MACb;MAEA,MAAMC,iBAAiB,GACtB,OAAOL,cAAc,CAAE,C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A;EAAe,CAC/B,CACD;EAEF,IAAKA,aAAa,KAAK,KAAK,EAAG;IAC9B,oBACC,IAAAzB,WAAA,CAAAkC,IAAA,EAACzC,WAAA,CAAA0C,oBAAM;MAACC,SAAS,EAAC,gCAAgC;MAACC,OAAO,EAAG,CAAG;MAAAxB,QAAA,gBAC/D,IAAAb,WAAA,CAAAgC,GAAA;QACCI,SAAS,EAAGV,cAAgB;QAC5BY,KAAK,EAAG;UAAEC,aAAa,EAAE;QAAE,CAAG;QAAA1B,QAAA,EAE5Be;MAAU,CACR,CAAC,eACN,IAAA5B,WAAA,CAAAgC,GAAA;QAAKI,SAAS,EAAC,wCAAwC;QAAAvB,QAAA,EACpDiB;MAAe,CACb,CAAC;IAAA,CACC,CAAC;EAEX;EAEA,IAAKL,aAAa,KAAK,MAAM,EAAG;IAC/B,oBACC,IAAAzB,WAAA,CAAAgC,GAAA;MAAKI,SAAS,EAAC,gCAAgC;MAAAvB,QAAA,EAC5CiB;IAAe,CACb,CAAC;EAER;;EAEA;EACA,oBACC,IAAA9B,WAAA,CAAAkC,IAAA,EAACzC,WAAA,CAAA+C,oBAAM;IACNC,GAAG,EAAGrB,gBAAkB;IACxBgB,SAAS,EAAC,gCAAgC;IAAAvB,QAAA,gBAE1C,IAAAb,WAAA,CAAAgC,GAAA;MAAKI,SAAS,EAAGV,cAAgB;MAAAb,QAAA,EAAGe;IAAU,CAAO,CAAC,eACtD,IAAA5B,WAAA,CAAAgC,GAAA;MAAKI,SAAS,EAAC,wCAAwC;MAAAvB,QAAA,EACpDiB;IAAe,CACb,CAAC;EAAA,CACC,CAAC;AAEX","ignoreList":[]}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _components = require("@wordpress/components");
|
|
8
|
+
var _i18n = require("@wordpress/i18n");
|
|
9
|
+
var _element = require("@wordpress/element");
|
|
10
|
+
var _dataFormLayout = require("../data-form-layout");
|
|
11
|
+
var _isCombinedField = require("../is-combined-field");
|
|
12
|
+
var _normalizeFormFields = require("../../normalize-form-fields");
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
/**
|
|
15
|
+
* WordPress dependencies
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Internal dependencies
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
function ModalContent({
|
|
23
|
+
data,
|
|
24
|
+
form,
|
|
25
|
+
fieldLabel,
|
|
26
|
+
onChange,
|
|
27
|
+
onClose
|
|
28
|
+
}) {
|
|
29
|
+
const [changes, setChanges] = (0, _element.useState)({});
|
|
30
|
+
const onApply = () => {
|
|
31
|
+
onChange(changes);
|
|
32
|
+
onClose();
|
|
33
|
+
};
|
|
34
|
+
const handleOnChange = value => {
|
|
35
|
+
setChanges(prev => ({
|
|
36
|
+
...prev,
|
|
37
|
+
...value
|
|
38
|
+
}));
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// Merge original data with local changes for display
|
|
42
|
+
const displayData = {
|
|
43
|
+
...data,
|
|
44
|
+
...changes
|
|
45
|
+
};
|
|
46
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.Modal, {
|
|
47
|
+
className: "dataforms-layouts-panel__modal",
|
|
48
|
+
onRequestClose: onClose,
|
|
49
|
+
isFullScreen: false,
|
|
50
|
+
title: fieldLabel,
|
|
51
|
+
size: "medium",
|
|
52
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_dataFormLayout.DataFormLayout, {
|
|
53
|
+
data: displayData,
|
|
54
|
+
form: form,
|
|
55
|
+
onChange: handleOnChange,
|
|
56
|
+
children: (FieldLayout, nestedField) => {
|
|
57
|
+
var _form$fields;
|
|
58
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(FieldLayout, {
|
|
59
|
+
data: displayData,
|
|
60
|
+
field: nestedField,
|
|
61
|
+
onChange: handleOnChange,
|
|
62
|
+
hideLabelFromVision: ((_form$fields = form?.fields) !== null && _form$fields !== void 0 ? _form$fields : []).length < 2
|
|
63
|
+
}, nestedField.id);
|
|
64
|
+
}
|
|
65
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
66
|
+
className: "dataforms-layouts-panel__modal-footer",
|
|
67
|
+
spacing: 3,
|
|
68
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalSpacer, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
69
|
+
variant: "tertiary",
|
|
70
|
+
onClick: onClose,
|
|
71
|
+
__next40pxDefaultSize: true,
|
|
72
|
+
children: (0, _i18n.__)('Cancel')
|
|
73
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
74
|
+
variant: "primary",
|
|
75
|
+
onClick: onApply,
|
|
76
|
+
__next40pxDefaultSize: true,
|
|
77
|
+
children: (0, _i18n.__)('Apply')
|
|
78
|
+
})]
|
|
79
|
+
})]
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function PanelModal({
|
|
83
|
+
fieldDefinition,
|
|
84
|
+
labelPosition,
|
|
85
|
+
data,
|
|
86
|
+
onChange,
|
|
87
|
+
field
|
|
88
|
+
}) {
|
|
89
|
+
const [isOpen, setIsOpen] = (0, _element.useState)(false);
|
|
90
|
+
const fieldLabel = (0, _isCombinedField.isCombinedField)(field) ? field.label : fieldDefinition?.label;
|
|
91
|
+
const form = (0, _element.useMemo)(() => ({
|
|
92
|
+
layout: _normalizeFormFields.DEFAULT_LAYOUT,
|
|
93
|
+
fields: (0, _isCombinedField.isCombinedField)(field) ? field.children :
|
|
94
|
+
// If not explicit children return the field id itself.
|
|
95
|
+
[{
|
|
96
|
+
id: field.id
|
|
97
|
+
}]
|
|
98
|
+
}), [field]);
|
|
99
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
100
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
101
|
+
className: "dataforms-layouts-modal__field-control",
|
|
102
|
+
size: "compact",
|
|
103
|
+
variant: ['none', 'top'].includes(labelPosition) ? 'link' : 'tertiary',
|
|
104
|
+
"aria-expanded": isOpen,
|
|
105
|
+
"aria-label": (0, _i18n.sprintf)(
|
|
106
|
+
// translators: %s: Field name.
|
|
107
|
+
(0, _i18n._x)('Edit %s', 'field'), fieldLabel || ''),
|
|
108
|
+
onClick: () => setIsOpen(true),
|
|
109
|
+
disabled: fieldDefinition.readOnly === true,
|
|
110
|
+
accessibleWhenDisabled: true,
|
|
111
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(fieldDefinition.render, {
|
|
112
|
+
item: data,
|
|
113
|
+
field: fieldDefinition
|
|
114
|
+
})
|
|
115
|
+
}), isOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(ModalContent, {
|
|
116
|
+
data: data,
|
|
117
|
+
form: form,
|
|
118
|
+
fieldLabel: fieldLabel !== null && fieldLabel !== void 0 ? fieldLabel : '',
|
|
119
|
+
onChange: onChange,
|
|
120
|
+
onClose: () => setIsOpen(false)
|
|
121
|
+
})]
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
var _default = exports.default = PanelModal;
|
|
125
|
+
//# sourceMappingURL=modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_components","require","_i18n","_element","_dataFormLayout","_isCombinedField","_normalizeFormFields","_jsxRuntime","ModalContent","data","form","fieldLabel","onChange","onClose","changes","setChanges","useState","onApply","handleOnChange","value","prev","displayData","jsxs","Modal","className","onRequestClose","isFullScreen","title","size","children","jsx","DataFormLayout","FieldLayout","nestedField","_form$fields","field","hideLabelFromVision","fields","length","id","__experimentalHStack","spacing","__experimentalSpacer","Button","variant","onClick","__next40pxDefaultSize","__","PanelModal","fieldDefinition","labelPosition","isOpen","setIsOpen","isCombinedField","label","useMemo","layout","DEFAULT_LAYOUT","Fragment","includes","sprintf","_x","disabled","readOnly","accessibleWhenDisabled","render","item","_default","exports","default"],"sources":["@wordpress/dataviews/src/dataforms-layouts/panel/modal.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalSpacer as Spacer,\n\tButton,\n\tModal,\n} from '@wordpress/components';\nimport { __, sprintf, _x } from '@wordpress/i18n';\nimport { useState, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { Form, FormField, NormalizedField } from '../../types';\nimport { DataFormLayout } from '../data-form-layout';\nimport { isCombinedField } from '../is-combined-field';\nimport { DEFAULT_LAYOUT } from '../../normalize-form-fields';\n\nfunction ModalContent< Item >( {\n\tdata,\n\tform,\n\tfieldLabel,\n\tonChange,\n\tonClose,\n}: {\n\tdata: Item;\n\tform: Form;\n\tfieldLabel: string;\n\tonChange: ( data: Partial< Item > ) => void;\n\tonClose: () => void;\n} ) {\n\tconst [ changes, setChanges ] = useState< Partial< Item > >( {} );\n\n\tconst onApply = () => {\n\t\tonChange( changes );\n\t\tonClose();\n\t};\n\n\tconst handleOnChange = ( value: Partial< Item > ) => {\n\t\tsetChanges( ( prev ) => ( { ...prev, ...value } ) );\n\t};\n\n\t// Merge original data with local changes for display\n\tconst displayData = { ...data, ...changes };\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"dataforms-layouts-panel__modal\"\n\t\t\tonRequestClose={ onClose }\n\t\t\tisFullScreen={ false }\n\t\t\ttitle={ fieldLabel }\n\t\t\tsize=\"medium\"\n\t\t>\n\t\t\t<DataFormLayout\n\t\t\t\tdata={ displayData }\n\t\t\t\tform={ form }\n\t\t\t\tonChange={ handleOnChange }\n\t\t\t>\n\t\t\t\t{ ( FieldLayout, nestedField ) => (\n\t\t\t\t\t<FieldLayout\n\t\t\t\t\t\tkey={ nestedField.id }\n\t\t\t\t\t\tdata={ displayData }\n\t\t\t\t\t\tfield={ nestedField }\n\t\t\t\t\t\tonChange={ handleOnChange }\n\t\t\t\t\t\thideLabelFromVision={\n\t\t\t\t\t\t\t( form?.fields ?? [] ).length < 2\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</DataFormLayout>\n\t\t\t<HStack\n\t\t\t\tclassName=\"dataforms-layouts-panel__modal-footer\"\n\t\t\t\tspacing={ 3 }\n\t\t\t>\n\t\t\t\t<Spacer />\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t</Button>\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tonClick={ onApply }\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Apply' ) }\n\t\t\t\t</Button>\n\t\t\t</HStack>\n\t\t</Modal>\n\t);\n}\n\nfunction PanelModal< Item >( {\n\tfieldDefinition,\n\tlabelPosition,\n\tdata,\n\tonChange,\n\tfield,\n}: {\n\tfieldDefinition: NormalizedField< Item >;\n\tlabelPosition: 'side' | 'top' | 'none';\n\tdata: Item;\n\tonChange: ( value: any ) => void;\n\tfield: FormField;\n} ) {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\n\tconst fieldLabel = isCombinedField( field )\n\t\t? field.label\n\t\t: fieldDefinition?.label;\n\n\tconst form: Form = useMemo(\n\t\t(): Form => ( {\n\t\t\tlayout: DEFAULT_LAYOUT,\n\t\t\tfields: isCombinedField( field )\n\t\t\t\t? field.children\n\t\t\t\t: // If not explicit children return the field id itself.\n\t\t\t\t [ { id: field.id } ],\n\t\t} ),\n\t\t[ field ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tclassName=\"dataforms-layouts-modal__field-control\"\n\t\t\t\tsize=\"compact\"\n\t\t\t\tvariant={\n\t\t\t\t\t[ 'none', 'top' ].includes( labelPosition )\n\t\t\t\t\t\t? 'link'\n\t\t\t\t\t\t: 'tertiary'\n\t\t\t\t}\n\t\t\t\taria-expanded={ isOpen }\n\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t// translators: %s: Field name.\n\t\t\t\t\t_x( 'Edit %s', 'field' ),\n\t\t\t\t\tfieldLabel || ''\n\t\t\t\t) }\n\t\t\t\tonClick={ () => setIsOpen( true ) }\n\t\t\t\tdisabled={ fieldDefinition.readOnly === true }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t>\n\t\t\t\t<fieldDefinition.render\n\t\t\t\t\titem={ data }\n\t\t\t\t\tfield={ fieldDefinition }\n\t\t\t\t/>\n\t\t\t</Button>\n\t\t\t{ isOpen && (\n\t\t\t\t<ModalContent\n\t\t\t\t\tdata={ data }\n\t\t\t\t\tform={ form as Form }\n\t\t\t\t\tfieldLabel={ fieldLabel ?? '' }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tonClose={ () => setIsOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default PanelModal;\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAMA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAMA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAL,OAAA;AAA6D,IAAAM,WAAA,GAAAN,OAAA;AAlB7D;AACA;AACA;;AAUA;AACA;AACA;;AAMA,SAASO,YAAYA,CAAU;EAC9BC,IAAI;EACJC,IAAI;EACJC,UAAU;EACVC,QAAQ;EACRC;AAOD,CAAC,EAAG;EACH,MAAM,CAAEC,OAAO,EAAEC,UAAU,CAAE,GAAG,IAAAC,iBAAQ,EAAqB,CAAC,CAAE,CAAC;EAEj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;MAClDI,IAAI,EAAC,SAAS;MACdgB,OAAO,EACN,CAAE,MAAM,EAAE,KAAK,CAAE,CAACe,QAAQ,CAAET,aAAc,CAAC,GACxC,MAAM,GACN,UACH;MACD,iBAAgBC,MAAQ;MACxB,cAAa,IAAAS,aAAO;MACnB;MACA,IAAAC,QAAE,EAAE,SAAS,EAAE,OAAQ,CAAC,EACxBlD,UAAU,IAAI,EACf,CAAG;MACHkC,OAAO,EAAGA,CAAA,KAAMO,SAAS,CAAE,IAAK,CAAG;MACnCU,QAAQ,EAAGb,eAAe,CAACc,QAAQ,KAAK,IAAM;MAC9CC,sBAAsB;MAAAnC,QAAA,eAEtB,IAAAtB,WAAA,CAAAuB,GAAA,EAACmB,eAAe,CAACgB,MAAM;QACtBC,IAAI,EAAGzD,IAAM;QACb0B,KAAK,EAAGc;MAAiB,CACzB;IAAC,CACK,CAAC,EACPE,MAAM,iBACP,IAAA5C,WAAA,CAAAuB,GAAA,EAACtB,YAAY;MACZC,IAAI,EAAGA,IAAM;MACbC,IAAI,EAAGA,IAAc;MACrBC,UAAU,EAAGA,UAAU,aAAVA,UAAU,cAAVA,UAAU,GAAI,EAAI;MAC/BC,QAAQ,EAAGA,QAAU;MACrBC,OAAO,EAAGA,CAAA,KAAMuC,SAAS,CAAE,KAAM;IAAG,CACpC,CACD;EAAA,CACA,CAAC;AAEL;AAAC,IAAAe,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcrB,UAAU","ignoreList":[]}
|
|
@@ -30,10 +30,11 @@ function normalizeLayout(layout) {
|
|
|
30
30
|
labelPosition: (_layout$labelPosition = layout?.labelPosition) !== null && _layout$labelPosition !== void 0 ? _layout$labelPosition : 'top'
|
|
31
31
|
};
|
|
32
32
|
} else if (layout?.type === 'panel') {
|
|
33
|
-
var _layout$labelPosition2;
|
|
33
|
+
var _layout$labelPosition2, _layout$openAs;
|
|
34
34
|
normalizedLayout = {
|
|
35
35
|
type: 'panel',
|
|
36
|
-
labelPosition: (_layout$labelPosition2 = layout?.labelPosition) !== null && _layout$labelPosition2 !== void 0 ? _layout$labelPosition2 : 'side'
|
|
36
|
+
labelPosition: (_layout$labelPosition2 = layout?.labelPosition) !== null && _layout$labelPosition2 !== void 0 ? _layout$labelPosition2 : 'side',
|
|
37
|
+
openAs: (_layout$openAs = layout?.openAs) !== null && _layout$openAs !== void 0 ? _layout$openAs : 'dropdown'
|
|
37
38
|
};
|
|
38
39
|
} else if (layout?.type === 'card') {
|
|
39
40
|
if (layout.withHeader === false) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DEFAULT_LAYOUT","exports","type","labelPosition","normalizeLayout","layout","normalizedLayout","_layout$labelPosition","_layout$labelPosition2","withHeader","isOpened","normalizeFormFields","form","_form$fields","formLayout","fields","map","field","id","fieldLayout"],"sources":["@wordpress/dataviews/src/normalize-form-fields.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type {\n\tForm,\n\tLayout,\n\tNormalizedLayout,\n\tNormalizedRegularLayout,\n\tNormalizedPanelLayout,\n\tNormalizedCardLayout,\n} from './types';\n\ninterface NormalizedFormField {\n\tid: string;\n\tlayout: Layout;\n}\n\nexport const DEFAULT_LAYOUT: NormalizedLayout = {\n\ttype: 'regular',\n\tlabelPosition: 'top',\n};\n\n/**\n * Normalizes a layout configuration based on its type.\n *\n * @param layout The layout object to normalize.\n * @return The normalized layout object.\n */\nexport function normalizeLayout( layout?: Layout ): NormalizedLayout {\n\tlet normalizedLayout = DEFAULT_LAYOUT;\n\n\tif ( layout?.type === 'regular' ) {\n\t\tnormalizedLayout = {\n\t\t\ttype: 'regular',\n\t\t\tlabelPosition: layout?.labelPosition ?? 'top',\n\t\t} satisfies NormalizedRegularLayout;\n\t} else if ( layout?.type === 'panel' ) {\n\t\tnormalizedLayout = {\n\t\t\ttype: 'panel',\n\t\t\tlabelPosition: layout?.labelPosition ?? 'side',\n\t\t} satisfies NormalizedPanelLayout;\n\t} else if ( layout?.type === 'card' ) {\n\t\tif ( layout.withHeader === false ) {\n\t\t\t// Don't let isOpened be false if withHeader is false.\n\t\t\t// Otherwise, the card will not be visible.\n\t\t\tnormalizedLayout = {\n\t\t\t\ttype: 'card',\n\t\t\t\twithHeader: false,\n\t\t\t\tisOpened: true,\n\t\t\t} satisfies NormalizedCardLayout;\n\t\t} else {\n\t\t\tnormalizedLayout = {\n\t\t\t\ttype: 'card',\n\t\t\t\twithHeader: true,\n\t\t\t\tisOpened:\n\t\t\t\t\ttypeof layout.isOpened === 'boolean'\n\t\t\t\t\t\t? layout.isOpened\n\t\t\t\t\t\t: true,\n\t\t\t} satisfies NormalizedCardLayout;\n\t\t}\n\t}\n\n\treturn normalizedLayout;\n}\n\nexport default function normalizeFormFields(\n\tform: Form\n): NormalizedFormField[] {\n\tconst formLayout = normalizeLayout( form?.layout );\n\n\treturn ( form.fields ?? [] ).map( ( field ) => {\n\t\tif ( typeof field === 'string' ) {\n\t\t\treturn {\n\t\t\t\tid: field,\n\t\t\t\tlayout: formLayout,\n\t\t\t};\n\t\t}\n\n\t\tconst fieldLayout = field.layout\n\t\t\t? normalizeLayout( field.layout )\n\t\t\t: formLayout;\n\t\treturn {\n\t\t\t...field,\n\t\t\tlayout: fieldLayout,\n\t\t};\n\t} );\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;;AAeO,MAAMA,cAAgC,GAAAC,OAAA,CAAAD,cAAA,GAAG;EAC/CE,IAAI,EAAE,SAAS;EACfC,aAAa,EAAE;AAChB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAAEC,MAAe,EAAqB;EACpE,IAAIC,gBAAgB,GAAGN,cAAc;EAErC,IAAKK,MAAM,EAAEH,IAAI,KAAK,SAAS,EAAG;IAAA,IAAAK,qBAAA;IACjCD,gBAAgB,GAAG;MAClBJ,IAAI,EAAE,SAAS;MACfC,aAAa,GAAAI,qBAAA,GAAEF,MAAM,EAAEF,aAAa,cAAAI,qBAAA,cAAAA,qBAAA,GAAI;IACzC,CAAmC;EACpC,CAAC,MAAM,IAAKF,MAAM,EAAEH,IAAI,KAAK,OAAO,EAAG;IAAA,IAAAM,sBAAA;
|
|
1
|
+
{"version":3,"names":["DEFAULT_LAYOUT","exports","type","labelPosition","normalizeLayout","layout","normalizedLayout","_layout$labelPosition","_layout$labelPosition2","_layout$openAs","openAs","withHeader","isOpened","normalizeFormFields","form","_form$fields","formLayout","fields","map","field","id","fieldLayout"],"sources":["@wordpress/dataviews/src/normalize-form-fields.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type {\n\tForm,\n\tLayout,\n\tNormalizedLayout,\n\tNormalizedRegularLayout,\n\tNormalizedPanelLayout,\n\tNormalizedCardLayout,\n} from './types';\n\ninterface NormalizedFormField {\n\tid: string;\n\tlayout: Layout;\n}\n\nexport const DEFAULT_LAYOUT: NormalizedLayout = {\n\ttype: 'regular',\n\tlabelPosition: 'top',\n};\n\n/**\n * Normalizes a layout configuration based on its type.\n *\n * @param layout The layout object to normalize.\n * @return The normalized layout object.\n */\nexport function normalizeLayout( layout?: Layout ): NormalizedLayout {\n\tlet normalizedLayout = DEFAULT_LAYOUT;\n\n\tif ( layout?.type === 'regular' ) {\n\t\tnormalizedLayout = {\n\t\t\ttype: 'regular',\n\t\t\tlabelPosition: layout?.labelPosition ?? 'top',\n\t\t} satisfies NormalizedRegularLayout;\n\t} else if ( layout?.type === 'panel' ) {\n\t\tnormalizedLayout = {\n\t\t\ttype: 'panel',\n\t\t\tlabelPosition: layout?.labelPosition ?? 'side',\n\t\t\topenAs: layout?.openAs ?? 'dropdown',\n\t\t} satisfies NormalizedPanelLayout;\n\t} else if ( layout?.type === 'card' ) {\n\t\tif ( layout.withHeader === false ) {\n\t\t\t// Don't let isOpened be false if withHeader is false.\n\t\t\t// Otherwise, the card will not be visible.\n\t\t\tnormalizedLayout = {\n\t\t\t\ttype: 'card',\n\t\t\t\twithHeader: false,\n\t\t\t\tisOpened: true,\n\t\t\t} satisfies NormalizedCardLayout;\n\t\t} else {\n\t\t\tnormalizedLayout = {\n\t\t\t\ttype: 'card',\n\t\t\t\twithHeader: true,\n\t\t\t\tisOpened:\n\t\t\t\t\ttypeof layout.isOpened === 'boolean'\n\t\t\t\t\t\t? layout.isOpened\n\t\t\t\t\t\t: true,\n\t\t\t} satisfies NormalizedCardLayout;\n\t\t}\n\t}\n\n\treturn normalizedLayout;\n}\n\nexport default function normalizeFormFields(\n\tform: Form\n): NormalizedFormField[] {\n\tconst formLayout = normalizeLayout( form?.layout );\n\n\treturn ( form.fields ?? [] ).map( ( field ) => {\n\t\tif ( typeof field === 'string' ) {\n\t\t\treturn {\n\t\t\t\tid: field,\n\t\t\t\tlayout: formLayout,\n\t\t\t};\n\t\t}\n\n\t\tconst fieldLayout = field.layout\n\t\t\t? normalizeLayout( field.layout )\n\t\t\t: formLayout;\n\t\treturn {\n\t\t\t...field,\n\t\t\tlayout: fieldLayout,\n\t\t};\n\t} );\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;;AAeO,MAAMA,cAAgC,GAAAC,OAAA,CAAAD,cAAA,GAAG;EAC/CE,IAAI,EAAE,SAAS;EACfC,aAAa,EAAE;AAChB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAAEC,MAAe,EAAqB;EACpE,IAAIC,gBAAgB,GAAGN,cAAc;EAErC,IAAKK,MAAM,EAAEH,IAAI,KAAK,SAAS,EAAG;IAAA,IAAAK,qBAAA;IACjCD,gBAAgB,GAAG;MAClBJ,IAAI,EAAE,SAAS;MACfC,aAAa,GAAAI,qBAAA,GAAEF,MAAM,EAAEF,aAAa,cAAAI,qBAAA,cAAAA,qBAAA,GAAI;IACzC,CAAmC;EACpC,CAAC,MAAM,IAAKF,MAAM,EAAEH,IAAI,KAAK,OAAO,EAAG;IAAA,IAAAM,sBAAA,EAAAC,cAAA;IACtCH,gBAAgB,GAAG;MAClBJ,IAAI,EAAE,OAAO;MACbC,aAAa,GAAAK,sBAAA,GAAEH,MA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version":3,"names":[],"sources":["@wordpress/dataviews/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type {\n\tReactElement,\n\tReactNode,\n\tComponentType,\n\tComponentProps,\n} from 'react';\n\n/**\n * Internal dependencies\n */\nimport type { SetSelection } from './private-types';\n\n/**\n * WordPress dependencies\n */\nimport type { useFocusOnMount } from '@wordpress/compose';\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\nexport interface 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 interface NormalizedFilterByConfig {\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\ninterface FilterConfigForType {\n\t/**\n\t * What operators are used by default.\n\t */\n\tdefaultOperators: Operator[];\n\n\t/**\n\t * What operators are supported by the field.\n\t */\n\tvalidOperators: Operator[];\n}\n\nexport type Operator =\n\t| 'is'\n\t| 'isNot'\n\t| 'isAny'\n\t| 'isNone'\n\t| 'isAll'\n\t| 'isNotAll'\n\t| 'lessThan'\n\t| 'greaterThan'\n\t| 'lessThanOrEqual'\n\t| 'greaterThanOrEqual'\n\t| 'before'\n\t| 'after'\n\t| 'beforeInc'\n\t| 'afterInc'\n\t| 'contains'\n\t| 'notContains'\n\t| 'startsWith'\n\t| 'between'\n\t| 'on'\n\t| 'notOn'\n\t| 'inThePast'\n\t| 'over';\n\nexport type FieldType =\n\t| 'text'\n\t| 'integer'\n\t| 'datetime'\n\t| 'date'\n\t| 'media'\n\t| 'boolean'\n\t| 'email'\n\t| 'array';\n\n/**\n * An abstract interface for Field based on the field type.\n */\nexport type FieldTypeDefinition< Item > = {\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: Rules< Item >;\n\n\t/**\n\t * Callback used to render an edit control for the field or control name.\n\t */\n\tEdit: ComponentType< DataFormControlProps< Item > > | string | null;\n\n\t/**\n\t * Callback used to render the field.\n\t */\n\trender: ComponentType< DataViewRenderFieldProps< Item > >;\n\n\t/**\n\t * The filter config for the field.\n\t */\n\tfilterBy: FilterConfigForType | false;\n\n\t/**\n\t * Whether the field is readOnly.\n\t * If `true`, the value will be rendered using the `render` callback.\n\t */\n\treadOnly?: boolean;\n\n\t/**\n\t * Whether the field is sortable.\n\t */\n\tenableSorting: boolean;\n};\n\nexport type Rules< Item > = {\n\trequired?: boolean;\n\tcustom?: ( item: Item, field: NormalizedField< Item > ) => null | string;\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 * The header of the field. Defaults to the label.\n\t * It allows the usage of a React Element to render the field labels.\n\t */\n\theader?: string | ReactElement;\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< DataViewRenderFieldProps< Item > >;\n\n\t/**\n\t * Callback used to render an edit control for the field.\n\t */\n\tEdit?: ComponentType< DataFormControlProps< Item > > | string;\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?: Rules< Item >;\n\n\t/**\n\t * Callback used to decide if a field should be displayed.\n\t */\n\tisVisible?: ( item: Item ) => 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 | false;\n\n\t/**\n\t * Whether the field is readOnly.\n\t * If `true`, the value will be rendered using the `render` callback.\n\t */\n\treadOnly?: boolean;\n\n\t/**\n\t * Callback used to retrieve the value of the field from the item.\n\t * Defaults to `item[ field.id ]`.\n\t */\n\tgetValue?: ( args: { item: Item } ) => any;\n};\n\nexport type NormalizedField< Item > = Omit< Field< Item >, 'Edit' > & {\n\tlabel: string;\n\theader: string | ReactElement;\n\tgetValue: ( args: { item: Item } ) => any;\n\trender: ComponentType< DataViewRenderFieldProps< Item > >;\n\tEdit: ComponentType< DataFormControlProps< Item > > | null;\n\tsort: ( a: Item, b: Item, direction: SortDirection ) => number;\n\tisValid: Rules< Item >;\n\tenableHiding: boolean;\n\tenableSorting: boolean;\n\tfilterBy: NormalizedFilterByConfig | false;\n\treadOnly: 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\nexport type DataFormControlProps< Item > = {\n\tdata: Item;\n\tfield: NormalizedField< Item >;\n\tonChange: ( value: Record< string, any > ) => void;\n\thideLabelFromVision?: boolean;\n\t/**\n\t * The currently selected filter operator for this field.\n\t *\n\t * Used by DataViews filters to determine which control to render based on the operator type.\n\t */\n\toperator?: Operator;\n};\n\nexport type DataViewRenderFieldProps< Item > = {\n\titem: Item;\n\tfield: NormalizedField< Item >;\n\tconfig?: {\n\t\tsizes: string;\n\t};\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\t/**\n\t * Whether the filter can be edited by the user.\n\t */\n\tisLocked?: boolean;\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\t/**\n\t * Whether the filter can be edited by the user.\n\t */\n\tisLocked: 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\t/**\n\t * Title field\n\t */\n\ttitleField?: string;\n\n\t/**\n\t * Media field\n\t */\n\tmediaField?: string;\n\n\t/**\n\t * Description field\n\t */\n\tdescriptionField?: string;\n\n\t/**\n\t * Whether to show the title\n\t */\n\tshowTitle?: boolean;\n\n\t/**\n\t * Whether to show the media\n\t */\n\tshowMedia?: boolean;\n\n\t/**\n\t * Whether to show the description\n\t */\n\tshowDescription?: boolean;\n\n\t/**\n\t * Whether to show the hierarchical levels.\n\t */\n\tshowLevels?: boolean;\n\n\t/**\n\t * The field to group by.\n\t */\n\tgroupByField?: string;\n\n\t/**\n\t * Whether infinite scroll is enabled.\n\t */\n\tinfiniteScrollEnabled?: boolean;\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\t/**\n\t * The alignment of the field column, defaults to left.\n\t */\n\talign?: 'start' | 'center' | 'end';\n}\n\nexport type Density = 'compact' | 'balanced' | 'comfortable';\n\nexport interface ViewTable extends ViewBase {\n\ttype: 'table';\n\n\tlayout?: {\n\t\t/**\n\t\t * The styles for the columns.\n\t\t */\n\t\tstyles?: Record< string, ColumnStyle >;\n\n\t\t/**\n\t\t * The density of the view.\n\t\t */\n\t\tdensity?: Density;\n\n\t\t/**\n\t\t * Whether the view allows column moving.\n\t\t */\n\t\tenableMoving?: boolean;\n\t};\n}\n\nexport interface ViewList extends ViewBase {\n\ttype: 'list';\n}\n\nexport interface ViewGrid extends ViewBase {\n\ttype: 'grid';\n\n\tlayout?: {\n\t\t/**\n\t\t * The fields to use as badge fields.\n\t\t */\n\t\tbadgeFields?: string[];\n\n\t\t/**\n\t\t * The preview size of the grid.\n\t\t */\n\t\tpreviewSize?: number;\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\t/**\n\t * The context in which the action is visible.\n\t * This is only a \"meta\" information for now.\n\t */\n\tcontext?: 'list' | 'single';\n}\n\nexport interface RenderModalProps< Item > {\n\titems: Item[];\n\tcloseModal?: () => void;\n\tonActionPerformed?: ( items: Item[] ) => void;\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}: RenderModalProps< Item > ) => 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\t/**\n\t * The size of the modal.\n\t *\n\t * @default 'medium'\n\t */\n\tmodalSize?: 'small' | 'medium' | 'large' | 'fill';\n\n\t/**\n\t * The focus on mount property of the modal.\n\t */\n\tmodalFocusOnMount?:\n\t\t| Parameters< typeof useFocusOnMount >[ 0 ]\n\t\t| 'firstContentElement';\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\tclassName?: string;\n\tactions: Action< Item >[];\n\tdata: Item[];\n\tfields: NormalizedField< Item >[];\n\tgetItemId: ( item: Item ) => string;\n\tgetItemLevel?: ( item: Item ) => number;\n\tisLoading?: boolean;\n\tonChangeView: ( view: View ) => void;\n\tonChangeSelection: SetSelection;\n\tselection: string[];\n\tsetOpenedFilter: ( fieldId: string ) => void;\n\tonClickItem?: ( item: Item ) => void;\n\trenderItemLink?: (\n\t\tprops: {\n\t\t\titem: Item;\n\t\t} & ComponentProps< 'a' >\n\t) => ReactElement;\n\tisItemClickable: ( item: Item ) => boolean;\n\tview: View;\n\tempty: ReactNode;\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\n/**\n * DataForm layouts.\n */\nexport type LayoutType = 'regular' | 'panel' | 'card';\nexport type LabelPosition = 'top' | 'side' | 'none';\n\nexport type RegularLayout = {\n\ttype: 'regular';\n\tlabelPosition?: LabelPosition;\n};\nexport type NormalizedRegularLayout = {\n\ttype: 'regular';\n\tlabelPosition: LabelPosition;\n};\n\nexport type PanelLayout = {\n\ttype: 'panel';\n\tlabelPosition?: LabelPosition;\n};\nexport type NormalizedPanelLayout = {\n\ttype: 'panel';\n\tlabelPosition: LabelPosition;\n};\n\nexport type CardLayout =\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader: false;\n\t\t\t// isOpened cannot be false if withHeader is false as well.\n\t\t\t// Otherwise, the card would not be visible.\n\t\t\tisOpened?: true;\n\t }\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader?: true | undefined;\n\t\t\tisOpened?: boolean;\n\t };\nexport type NormalizedCardLayout =\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader: false;\n\t\t\t// isOpened cannot be false if withHeader is false as well.\n\t\t\t// Otherwise, the card would not be visible.\n\t\t\tisOpened: true;\n\t }\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader: true;\n\t\t\tisOpened: boolean;\n\t };\n\nexport type Layout = RegularLayout | PanelLayout | CardLayout;\nexport type NormalizedLayout =\n\t| NormalizedRegularLayout\n\t| NormalizedPanelLayout\n\t| NormalizedCardLayout;\n\nexport type SimpleFormField = {\n\tid: string;\n\tlayout?: Layout;\n};\n\nexport type CombinedFormField = {\n\tid: string;\n\tlabel?: string;\n\tlayout?: Layout;\n\tchildren: Array< FormField | string >;\n};\n\nexport type FormField = SimpleFormField | CombinedFormField;\n\n/**\n * The form configuration.\n */\nexport type Form = {\n\tlayout?: Layout;\n\tfields?: Array< FormField | string >;\n};\n\nexport interface DataFormProps< Item > {\n\tdata: Item;\n\tfields: Field< Item >[];\n\tform: Form;\n\tonChange: ( value: Record< string, any > ) => void;\n}\n\nexport interface FieldLayoutProps< Item > {\n\tdata: Item;\n\tfield: FormField;\n\tonChange: ( value: any ) => void;\n\thideLabelFromVision?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/dataviews/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type {\n\tReactElement,\n\tReactNode,\n\tComponentType,\n\tComponentProps,\n} from 'react';\n\n/**\n * Internal dependencies\n */\nimport type { SetSelection } from './private-types';\n\n/**\n * WordPress dependencies\n */\nimport type { useFocusOnMount } from '@wordpress/compose';\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\nexport interface 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 interface NormalizedFilterByConfig {\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\ninterface FilterConfigForType {\n\t/**\n\t * What operators are used by default.\n\t */\n\tdefaultOperators: Operator[];\n\n\t/**\n\t * What operators are supported by the field.\n\t */\n\tvalidOperators: Operator[];\n}\n\nexport type Operator =\n\t| 'is'\n\t| 'isNot'\n\t| 'isAny'\n\t| 'isNone'\n\t| 'isAll'\n\t| 'isNotAll'\n\t| 'lessThan'\n\t| 'greaterThan'\n\t| 'lessThanOrEqual'\n\t| 'greaterThanOrEqual'\n\t| 'before'\n\t| 'after'\n\t| 'beforeInc'\n\t| 'afterInc'\n\t| 'contains'\n\t| 'notContains'\n\t| 'startsWith'\n\t| 'between'\n\t| 'on'\n\t| 'notOn'\n\t| 'inThePast'\n\t| 'over';\n\nexport type FieldType =\n\t| 'text'\n\t| 'integer'\n\t| 'datetime'\n\t| 'date'\n\t| 'media'\n\t| 'boolean'\n\t| 'email'\n\t| 'array';\n\n/**\n * An abstract interface for Field based on the field type.\n */\nexport type FieldTypeDefinition< Item > = {\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: Rules< Item >;\n\n\t/**\n\t * Callback used to render an edit control for the field or control name.\n\t */\n\tEdit: ComponentType< DataFormControlProps< Item > > | string | null;\n\n\t/**\n\t * Callback used to render the field.\n\t */\n\trender: ComponentType< DataViewRenderFieldProps< Item > >;\n\n\t/**\n\t * The filter config for the field.\n\t */\n\tfilterBy: FilterConfigForType | false;\n\n\t/**\n\t * Whether the field is readOnly.\n\t * If `true`, the value will be rendered using the `render` callback.\n\t */\n\treadOnly?: boolean;\n\n\t/**\n\t * Whether the field is sortable.\n\t */\n\tenableSorting: boolean;\n};\n\nexport type Rules< Item > = {\n\trequired?: boolean;\n\tcustom?: ( item: Item, field: NormalizedField< Item > ) => null | string;\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 * The header of the field. Defaults to the label.\n\t * It allows the usage of a React Element to render the field labels.\n\t */\n\theader?: string | ReactElement;\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< DataViewRenderFieldProps< Item > >;\n\n\t/**\n\t * Callback used to render an edit control for the field.\n\t */\n\tEdit?: ComponentType< DataFormControlProps< Item > > | string;\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?: Rules< Item >;\n\n\t/**\n\t * Callback used to decide if a field should be displayed.\n\t */\n\tisVisible?: ( item: Item ) => 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 | false;\n\n\t/**\n\t * Whether the field is readOnly.\n\t * If `true`, the value will be rendered using the `render` callback.\n\t */\n\treadOnly?: boolean;\n\n\t/**\n\t * Callback used to retrieve the value of the field from the item.\n\t * Defaults to `item[ field.id ]`.\n\t */\n\tgetValue?: ( args: { item: Item } ) => any;\n};\n\nexport type NormalizedField< Item > = Omit< Field< Item >, 'Edit' > & {\n\tlabel: string;\n\theader: string | ReactElement;\n\tgetValue: ( args: { item: Item } ) => any;\n\trender: ComponentType< DataViewRenderFieldProps< Item > >;\n\tEdit: ComponentType< DataFormControlProps< Item > > | null;\n\tsort: ( a: Item, b: Item, direction: SortDirection ) => number;\n\tisValid: Rules< Item >;\n\tenableHiding: boolean;\n\tenableSorting: boolean;\n\tfilterBy: NormalizedFilterByConfig | false;\n\treadOnly: 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\nexport type DataFormControlProps< Item > = {\n\tdata: Item;\n\tfield: NormalizedField< Item >;\n\tonChange: ( value: Record< string, any > ) => void;\n\thideLabelFromVision?: boolean;\n\t/**\n\t * The currently selected filter operator for this field.\n\t *\n\t * Used by DataViews filters to determine which control to render based on the operator type.\n\t */\n\toperator?: Operator;\n};\n\nexport type DataViewRenderFieldProps< Item > = {\n\titem: Item;\n\tfield: NormalizedField< Item >;\n\tconfig?: {\n\t\tsizes: string;\n\t};\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\t/**\n\t * Whether the filter can be edited by the user.\n\t */\n\tisLocked?: boolean;\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\t/**\n\t * Whether the filter can be edited by the user.\n\t */\n\tisLocked: 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\t/**\n\t * Title field\n\t */\n\ttitleField?: string;\n\n\t/**\n\t * Media field\n\t */\n\tmediaField?: string;\n\n\t/**\n\t * Description field\n\t */\n\tdescriptionField?: string;\n\n\t/**\n\t * Whether to show the title\n\t */\n\tshowTitle?: boolean;\n\n\t/**\n\t * Whether to show the media\n\t */\n\tshowMedia?: boolean;\n\n\t/**\n\t * Whether to show the description\n\t */\n\tshowDescription?: boolean;\n\n\t/**\n\t * Whether to show the hierarchical levels.\n\t */\n\tshowLevels?: boolean;\n\n\t/**\n\t * The field to group by.\n\t */\n\tgroupByField?: string;\n\n\t/**\n\t * Whether infinite scroll is enabled.\n\t */\n\tinfiniteScrollEnabled?: boolean;\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\t/**\n\t * The alignment of the field column, defaults to left.\n\t */\n\talign?: 'start' | 'center' | 'end';\n}\n\nexport type Density = 'compact' | 'balanced' | 'comfortable';\n\nexport interface ViewTable extends ViewBase {\n\ttype: 'table';\n\n\tlayout?: {\n\t\t/**\n\t\t * The styles for the columns.\n\t\t */\n\t\tstyles?: Record< string, ColumnStyle >;\n\n\t\t/**\n\t\t * The density of the view.\n\t\t */\n\t\tdensity?: Density;\n\n\t\t/**\n\t\t * Whether the view allows column moving.\n\t\t */\n\t\tenableMoving?: boolean;\n\t};\n}\n\nexport interface ViewList extends ViewBase {\n\ttype: 'list';\n}\n\nexport interface ViewGrid extends ViewBase {\n\ttype: 'grid';\n\n\tlayout?: {\n\t\t/**\n\t\t * The fields to use as badge fields.\n\t\t */\n\t\tbadgeFields?: string[];\n\n\t\t/**\n\t\t * The preview size of the grid.\n\t\t */\n\t\tpreviewSize?: number;\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\t/**\n\t * The context in which the action is visible.\n\t * This is only a \"meta\" information for now.\n\t */\n\tcontext?: 'list' | 'single';\n}\n\nexport interface RenderModalProps< Item > {\n\titems: Item[];\n\tcloseModal?: () => void;\n\tonActionPerformed?: ( items: Item[] ) => void;\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}: RenderModalProps< Item > ) => 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\t/**\n\t * The size of the modal.\n\t *\n\t * @default 'medium'\n\t */\n\tmodalSize?: 'small' | 'medium' | 'large' | 'fill';\n\n\t/**\n\t * The focus on mount property of the modal.\n\t */\n\tmodalFocusOnMount?:\n\t\t| Parameters< typeof useFocusOnMount >[ 0 ]\n\t\t| 'firstContentElement';\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\tclassName?: string;\n\tactions: Action< Item >[];\n\tdata: Item[];\n\tfields: NormalizedField< Item >[];\n\tgetItemId: ( item: Item ) => string;\n\tgetItemLevel?: ( item: Item ) => number;\n\tisLoading?: boolean;\n\tonChangeView: ( view: View ) => void;\n\tonChangeSelection: SetSelection;\n\tselection: string[];\n\tsetOpenedFilter: ( fieldId: string ) => void;\n\tonClickItem?: ( item: Item ) => void;\n\trenderItemLink?: (\n\t\tprops: {\n\t\t\titem: Item;\n\t\t} & ComponentProps< 'a' >\n\t) => ReactElement;\n\tisItemClickable: ( item: Item ) => boolean;\n\tview: View;\n\tempty: ReactNode;\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\n/**\n * DataForm layouts.\n */\nexport type LayoutType = 'regular' | 'panel' | 'card';\nexport type LabelPosition = 'top' | 'side' | 'none';\n\nexport type RegularLayout = {\n\ttype: 'regular';\n\tlabelPosition?: LabelPosition;\n};\nexport type NormalizedRegularLayout = {\n\ttype: 'regular';\n\tlabelPosition: LabelPosition;\n};\n\nexport type PanelLayout = {\n\ttype: 'panel';\n\tlabelPosition?: LabelPosition;\n\topenAs?: 'dropdown' | 'modal';\n};\nexport type NormalizedPanelLayout = {\n\ttype: 'panel';\n\tlabelPosition: LabelPosition;\n\topenAs: 'dropdown' | 'modal';\n};\n\nexport type CardLayout =\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader: false;\n\t\t\t// isOpened cannot be false if withHeader is false as well.\n\t\t\t// Otherwise, the card would not be visible.\n\t\t\tisOpened?: true;\n\t }\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader?: true | undefined;\n\t\t\tisOpened?: boolean;\n\t };\nexport type NormalizedCardLayout =\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader: false;\n\t\t\t// isOpened cannot be false if withHeader is false as well.\n\t\t\t// Otherwise, the card would not be visible.\n\t\t\tisOpened: true;\n\t }\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader: true;\n\t\t\tisOpened: boolean;\n\t };\n\nexport type Layout = RegularLayout | PanelLayout | CardLayout;\nexport type NormalizedLayout =\n\t| NormalizedRegularLayout\n\t| NormalizedPanelLayout\n\t| NormalizedCardLayout;\n\nexport type SimpleFormField = {\n\tid: string;\n\tlayout?: Layout;\n};\n\nexport type CombinedFormField = {\n\tid: string;\n\tlabel?: string;\n\tlayout?: Layout;\n\tchildren: Array< FormField | string >;\n};\n\nexport type FormField = SimpleFormField | CombinedFormField;\n\n/**\n * The form configuration.\n */\nexport type Form = {\n\tlayout?: Layout;\n\tfields?: Array< FormField | string >;\n};\n\nexport interface DataFormProps< Item > {\n\tdata: Item;\n\tfields: Field< Item >[];\n\tform: Form;\n\tonChange: ( value: Record< string, any > ) => void;\n}\n\nexport interface FieldLayoutProps< Item > {\n\tdata: Item;\n\tfield: FormField;\n\tonChange: ( value: any ) => void;\n\thideLabelFromVision?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -119,15 +119,6 @@ export default function ItemActions({
|
|
|
119
119
|
registry: registry
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
|
-
|
|
123
|
-
// If all actions are primary, there is no need to render the dropdown.
|
|
124
|
-
if (primaryActions.length === eligibleActions.length) {
|
|
125
|
-
return /*#__PURE__*/_jsx(PrimaryActions, {
|
|
126
|
-
item: item,
|
|
127
|
-
actions: primaryActions,
|
|
128
|
-
registry: registry
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
122
|
return /*#__PURE__*/_jsxs(HStack, {
|
|
132
123
|
spacing: 1,
|
|
133
124
|
justify: "flex-end",
|
|
@@ -140,7 +131,7 @@ export default function ItemActions({
|
|
|
140
131
|
item: item,
|
|
141
132
|
actions: primaryActions,
|
|
142
133
|
registry: registry
|
|
143
|
-
}), /*#__PURE__*/_jsx(CompactItemActions, {
|
|
134
|
+
}), primaryActions.length < eligibleActions.length && /*#__PURE__*/_jsx(CompactItemActions, {
|
|
144
135
|
item: item,
|
|
145
136
|
actions: eligibleActions,
|
|
146
137
|
registry: registry
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Button","Modal","__experimentalHStack","HStack","privateApis","componentsPrivateApis","__","useMemo","useState","moreVertical","useRegistry","unlock","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","Menu","kebabCase","ButtonTrigger","action","onClick","items","label","icon","disabled","accessibleWhenDisabled","isDestructive","size","MenuItemTrigger","Item","children","ItemLabel","ActionModal","closeModal","_action$modalFocusOnM","title","modalHeader","__experimentalHideHeader","hideModalHeader","onRequestClose","focusOnMount","modalFocusOnMount","modalSize","overlayClassName","id","RenderModal","ActionsMenuGroup","actions","item","registry","setActiveModalAction","Group","map","callback","ItemActions","isCompact","primaryActions","eligibleActions","_eligibleActions","filter","isEligible","_primaryActions","isPrimary","CompactItemActions","isSmall","length","PrimaryActions","spacing","justify","className","style","flexShrink","width","activeModalAction","placement","TriggerButton","render","Popover","Array","isArray"],"sources":["@wordpress/dataviews/src/components/dataviews-item-actions/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { MouseEventHandler } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\t__experimentalHStack as HStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport { moreVertical } from '@wordpress/icons';\nimport { useRegistry } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport type { Action, ActionModal as ActionModalType } from '../../types';\n\nconst { Menu, kebabCase } = unlock( componentsPrivateApis );\n\nexport interface ActionTriggerProps< Item > {\n\taction: Action< Item >;\n\tonClick: MouseEventHandler;\n\tisBusy?: boolean;\n\titems: Item[];\n}\n\nexport interface ActionModalProps< Item > {\n\taction: ActionModalType< Item >;\n\titems: Item[];\n\tcloseModal: () => void;\n}\n\ninterface ActionsMenuGroupProps< Item > {\n\tactions: Action< Item >[];\n\titem: Item;\n\tregistry: ReturnType< typeof useRegistry >;\n\tsetActiveModalAction: ( action: ActionModalType< Item > | null ) => void;\n}\n\ninterface ItemActionsProps< Item > {\n\titem: Item;\n\tactions: Action< Item >[];\n\tisCompact?: boolean;\n}\n\ninterface CompactItemActionsProps< Item > {\n\titem: Item;\n\tactions: Action< Item >[];\n\tisSmall?: boolean;\n\tregistry: ReturnType< typeof useRegistry >;\n}\n\ninterface PrimaryActionsProps< Item > {\n\titem: Item;\n\tactions: Action< Item >[];\n\tregistry: ReturnType< typeof useRegistry >;\n}\n\nfunction ButtonTrigger< Item >( {\n\taction,\n\tonClick,\n\titems,\n}: ActionTriggerProps< Item > ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Button\n\t\t\tlabel={ label }\n\t\t\ticon={ action.icon }\n\t\t\tdisabled={ !! action.disabled }\n\t\t\taccessibleWhenDisabled\n\t\t\tisDestructive={ action.isDestructive }\n\t\t\tsize=\"compact\"\n\t\t\tonClick={ onClick }\n\t\t/>\n\t);\n}\n\nfunction MenuItemTrigger< Item >( {\n\taction,\n\tonClick,\n\titems,\n}: ActionTriggerProps< Item > ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Menu.Item disabled={ action.disabled } onClick={ onClick }>\n\t\t\t<Menu.ItemLabel>{ label }</Menu.ItemLabel>\n\t\t</Menu.Item>\n\t);\n}\n\nexport function ActionModal< Item >( {\n\taction,\n\titems,\n\tcloseModal,\n}: ActionModalProps< Item > ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ action.modalHeader || label }\n\t\t\t__experimentalHideHeader={ !! action.hideModalHeader }\n\t\t\tonRequestClose={ closeModal }\n\t\t\tfocusOnMount={ action.modalFocusOnMount ?? true }\n\t\t\tsize={ action.modalSize || 'medium' }\n\t\t\toverlayClassName={ `dataviews-action-modal dataviews-action-modal__${ kebabCase(\n\t\t\t\taction.id\n\t\t\t) }` }\n\t\t>\n\t\t\t<action.RenderModal items={ items } closeModal={ closeModal } />\n\t\t</Modal>\n\t);\n}\n\nexport function ActionsMenuGroup< Item >( {\n\tactions,\n\titem,\n\tregistry,\n\tsetActiveModalAction,\n}: ActionsMenuGroupProps< Item > ) {\n\treturn (\n\t\t<Menu.Group>\n\t\t\t{ actions.map( ( action ) => (\n\t\t\t\t<MenuItemTrigger\n\t\t\t\t\tkey={ action.id }\n\t\t\t\t\taction={ action }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tif ( 'RenderModal' in action ) {\n\t\t\t\t\t\t\tsetActiveModalAction( action );\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\taction.callback( [ item ], { registry } );\n\t\t\t\t\t} }\n\t\t\t\t\titems={ [ item ] }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</Menu.Group>\n\t);\n}\n\nexport default function ItemActions< Item >( {\n\titem,\n\tactions,\n\tisCompact,\n}: ItemActionsProps< Item > ) {\n\tconst registry = useRegistry();\n\tconst { primaryActions, eligibleActions } = useMemo( () => {\n\t\t// If an action is eligible for all items, doesn't need\n\t\t// to provide the `isEligible` function.\n\t\tconst _eligibleActions = actions.filter(\n\t\t\t( action ) => ! action.isEligible || action.isEligible( item )\n\t\t);\n\t\tconst _primaryActions = _eligibleActions.filter(\n\t\t\t( action ) => action.isPrimary && !! action.icon\n\t\t);\n\t\treturn {\n\t\t\tprimaryActions: _primaryActions,\n\t\t\teligibleActions: _eligibleActions,\n\t\t};\n\t}, [ actions, item ] );\n\n\tif ( isCompact ) {\n\t\treturn (\n\t\t\t<CompactItemActions\n\t\t\t\titem={ item }\n\t\t\t\tactions={ eligibleActions }\n\t\t\t\tisSmall\n\t\t\t\tregistry={ registry }\n\t\t\t/>\n\t\t);\n\t}\n\n\t// If all actions are primary, there is no need to render the dropdown.\n\tif ( primaryActions.length === eligibleActions.length ) {\n\t\treturn (\n\t\t\t<PrimaryActions\n\t\t\t\titem={ item }\n\t\t\t\tactions={ primaryActions }\n\t\t\t\tregistry={ registry }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<HStack\n\t\t\tspacing={ 1 }\n\t\t\tjustify=\"flex-end\"\n\t\t\tclassName=\"dataviews-item-actions\"\n\t\t\tstyle={ {\n\t\t\t\tflexShrink: 0,\n\t\t\t\twidth: 'auto',\n\t\t\t} }\n\t\t>\n\t\t\t<PrimaryActions\n\t\t\t\titem={ item }\n\t\t\t\tactions={ primaryActions }\n\t\t\t\tregistry={ registry }\n\t\t\t/>\n\t\t\t<CompactItemActions\n\t\t\t\titem={ item }\n\t\t\t\tactions={ eligibleActions }\n\t\t\t\tregistry={ registry }\n\t\t\t/>\n\t\t</HStack>\n\t);\n}\n\nfunction CompactItemActions< Item >( {\n\titem,\n\tactions,\n\tisSmall,\n\tregistry,\n}: CompactItemActionsProps< Item > ) {\n\tconst [ activeModalAction, setActiveModalAction ] = useState(\n\t\tnull as ActionModalType< Item > | null\n\t);\n\treturn (\n\t\t<>\n\t\t\t<Menu placement=\"bottom-end\">\n\t\t\t\t<Menu.TriggerButton\n\t\t\t\t\trender={\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsize={ isSmall ? 'small' : 'compact' }\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\tlabel={ __( 'Actions' ) }\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\tdisabled={ ! actions.length }\n\t\t\t\t\t\t\tclassName=\"dataviews-all-actions-button\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<Menu.Popover>\n\t\t\t\t\t<ActionsMenuGroup\n\t\t\t\t\t\tactions={ actions }\n\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\tregistry={ registry }\n\t\t\t\t\t\tsetActiveModalAction={ setActiveModalAction }\n\t\t\t\t\t/>\n\t\t\t\t</Menu.Popover>\n\t\t\t</Menu>\n\t\t\t{ !! activeModalAction && (\n\t\t\t\t<ActionModal\n\t\t\t\t\taction={ activeModalAction }\n\t\t\t\t\titems={ [ item ] }\n\t\t\t\t\tcloseModal={ () => setActiveModalAction( null ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction PrimaryActions< Item >( {\n\titem,\n\tactions,\n\tregistry,\n}: PrimaryActionsProps< Item > ) {\n\tconst [ activeModalAction, setActiveModalAction ] = useState( null as any );\n\tif ( ! Array.isArray( actions ) || actions.length === 0 ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t{ actions.map( ( action ) => (\n\t\t\t\t<ButtonTrigger\n\t\t\t\t\tkey={ action.id }\n\t\t\t\t\taction={ action }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tif ( 'RenderModal' in action ) {\n\t\t\t\t\t\t\tsetActiveModalAction( action );\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\taction.callback( [ item ], { registry } );\n\t\t\t\t\t} }\n\t\t\t\t\titems={ [ item ] }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ !! activeModalAction && (\n\t\t\t\t<ActionModal\n\t\t\t\t\taction={ activeModalAction }\n\t\t\t\t\titems={ [ item ] }\n\t\t\t\t\tcloseModal={ () => setActiveModalAction( null ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SACCA,MAAM,EACNC,KAAK,EACLC,oBAAoB,IAAIC,MAAM,EAC9BC,WAAW,IAAIC,qBAAqB,QAC9B,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;A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B;MAC5BpD,KAAK,EAAG,CAAE2B,IAAI,CAAI;MAClBf,UAAU,EAAGA,CAAA,KAAMiB,oBAAoB,CAAE,IAAK;IAAG,CACjD,CACD;EAAA,CACA,CAAC;AAEL;AAEA,SAASgB,cAAcA,CAAU;EAChClB,IAAI;EACJD,OAAO;EACPE;AAC4B,CAAC,EAAG;EAChC,MAAM,CAAEwB,iBAAiB,EAAEvB,oBAAoB,CAAE,GAAG5C,QAAQ,CAAE,IAAY,CAAC;EAC3E,IAAK,CAAEwE,KAAK,CAACC,OAAO,CAAEhC,OAAQ,CAAC,IAAIA,OAAO,CAACkB,MAAM,KAAK,CAAC,EAAG;IACzD,OAAO,IAAI;EACZ;EACA,oBACCpD,KAAA,CAAAE,SAAA;IAAAe,QAAA,GACGiB,OAAO,CAACK,GAAG,CAAIjC,MAAM,iBACtBR,IAAA,CAACO,aAAa;MAEbC,MAAM,EAAGA,MAAQ;MACjBC,OAAO,EAAGA,CAAA,KAAM;QACf,IAAK,aAAa,IAAID,MAAM,EAAG;UAC9B+B,oBAAoB,CAAE/B,MAAO,CAAC;UAC9B;QACD;QACAA,MAAM,CAACkC,QAAQ,CAAE,CAAEL,IAAI,CAAE,EAAE;UAAEC;QAAS,CAAE,CAAC;MAC1C,CAAG;MACH5B,KAAK,EAAG,CAAE2B,IAAI;IAAI,GATZ7B,MAAM,CAACyB,EAUb,CACA,CAAC,EACD,CAAC,CAAE6B,iBAAiB,iBACrB9D,IAAA,CAACqB,WAAW;MACXb,MAAM,EAAGsD,iBAAmB;MAC5BpD,KAAK,EAAG,CAAE2B,IAAI,CAAI;MAClBf,UAAU,EAAGA,CAAA,KAAMiB,oBAAoB,CAAE,IAAK;IAAG,CACjD,CACD;EAAA,CACA,CAAC;AAEL","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Button","Modal","__experimentalHStack","HStack","privateApis","componentsPrivateApis","__","useMemo","useState","moreVertical","useRegistry","unlock","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","Menu","kebabCase","ButtonTrigger","action","onClick","items","label","icon","disabled","accessibleWhenDisabled","isDestructive","size","MenuItemTrigger","Item","children","ItemLabel","ActionModal","closeModal","_action$modalFocusOnM","title","modalHeader","__experimentalHideHeader","hideModalHeader","onRequestClose","focusOnMount","modalFocusOnMount","modalSize","overlayClassName","id","RenderModal","ActionsMenuGroup","actions","item","registry","setActiveModalAction","Group","map","callback","ItemActions","isCompact","primaryActions","eligibleActions","_eligibleActions","filter","isEligible","_primaryActions","isPrimary","CompactItemActions","isSmall","spacing","justify","className","style","flexShrink","width","PrimaryActions","length","activeModalAction","placement","TriggerButton","render","Popover","Array","isArray"],"sources":["@wordpress/dataviews/src/components/dataviews-item-actions/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { MouseEventHandler } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\t__experimentalHStack as HStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport { moreVertical } from '@wordpress/icons';\nimport { useRegistry } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport type { Action, ActionModal as ActionModalType } from '../../types';\n\nconst { Menu, kebabCase } = unlock( componentsPrivateApis );\n\nexport interface ActionTriggerProps< Item > {\n\taction: Action< Item >;\n\tonClick: MouseEventHandler;\n\tisBusy?: boolean;\n\titems: Item[];\n}\n\nexport interface ActionModalProps< Item > {\n\taction: ActionModalType< Item >;\n\titems: Item[];\n\tcloseModal: () => void;\n}\n\ninterface ActionsMenuGroupProps< Item > {\n\tactions: Action< Item >[];\n\titem: Item;\n\tregistry: ReturnType< typeof useRegistry >;\n\tsetActiveModalAction: ( action: ActionModalType< Item > | null ) => void;\n}\n\ninterface ItemActionsProps< Item > {\n\titem: Item;\n\tactions: Action< Item >[];\n\tisCompact?: boolean;\n}\n\ninterface CompactItemActionsProps< Item > {\n\titem: Item;\n\tactions: Action< Item >[];\n\tisSmall?: boolean;\n\tregistry: ReturnType< typeof useRegistry >;\n}\n\ninterface PrimaryActionsProps< Item > {\n\titem: Item;\n\tactions: Action< Item >[];\n\tregistry: ReturnType< typeof useRegistry >;\n}\n\nfunction ButtonTrigger< Item >( {\n\taction,\n\tonClick,\n\titems,\n}: ActionTriggerProps< Item > ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Button\n\t\t\tlabel={ label }\n\t\t\ticon={ action.icon }\n\t\t\tdisabled={ !! action.disabled }\n\t\t\taccessibleWhenDisabled\n\t\t\tisDestructive={ action.isDestructive }\n\t\t\tsize=\"compact\"\n\t\t\tonClick={ onClick }\n\t\t/>\n\t);\n}\n\nfunction MenuItemTrigger< Item >( {\n\taction,\n\tonClick,\n\titems,\n}: ActionTriggerProps< Item > ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Menu.Item disabled={ action.disabled } onClick={ onClick }>\n\t\t\t<Menu.ItemLabel>{ label }</Menu.ItemLabel>\n\t\t</Menu.Item>\n\t);\n}\n\nexport function ActionModal< Item >( {\n\taction,\n\titems,\n\tcloseModal,\n}: ActionModalProps< Item > ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ action.modalHeader || label }\n\t\t\t__experimentalHideHeader={ !! action.hideModalHeader }\n\t\t\tonRequestClose={ closeModal }\n\t\t\tfocusOnMount={ action.modalFocusOnMount ?? true }\n\t\t\tsize={ action.modalSize || 'medium' }\n\t\t\toverlayClassName={ `dataviews-action-modal dataviews-action-modal__${ kebabCase(\n\t\t\t\taction.id\n\t\t\t) }` }\n\t\t>\n\t\t\t<action.RenderModal items={ items } closeModal={ closeModal } />\n\t\t</Modal>\n\t);\n}\n\nexport function ActionsMenuGroup< Item >( {\n\tactions,\n\titem,\n\tregistry,\n\tsetActiveModalAction,\n}: ActionsMenuGroupProps< Item > ) {\n\treturn (\n\t\t<Menu.Group>\n\t\t\t{ actions.map( ( action ) => (\n\t\t\t\t<MenuItemTrigger\n\t\t\t\t\tkey={ action.id }\n\t\t\t\t\taction={ action }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tif ( 'RenderModal' in action ) {\n\t\t\t\t\t\t\tsetActiveModalAction( action );\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\taction.callback( [ item ], { registry } );\n\t\t\t\t\t} }\n\t\t\t\t\titems={ [ item ] }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</Menu.Group>\n\t);\n}\n\nexport default function ItemActions< Item >( {\n\titem,\n\tactions,\n\tisCompact,\n}: ItemActionsProps< Item > ) {\n\tconst registry = useRegistry();\n\tconst { primaryActions, eligibleActions } = useMemo( () => {\n\t\t// If an action is eligible for all items, doesn't need\n\t\t// to provide the `isEligible` function.\n\t\tconst _eligibleActions = actions.filter(\n\t\t\t( action ) => ! action.isEligible || action.isEligible( item )\n\t\t);\n\t\tconst _primaryActions = _eligibleActions.filter(\n\t\t\t( action ) => action.isPrimary && !! action.icon\n\t\t);\n\t\treturn {\n\t\t\tprimaryActions: _primaryActions,\n\t\t\teligibleActions: _eligibleActions,\n\t\t};\n\t}, [ actions, item ] );\n\n\tif ( isCompact ) {\n\t\treturn (\n\t\t\t<CompactItemActions\n\t\t\t\titem={ item }\n\t\t\t\tactions={ eligibleActions }\n\t\t\t\tisSmall\n\t\t\t\tregistry={ registry }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<HStack\n\t\t\tspacing={ 1 }\n\t\t\tjustify=\"flex-end\"\n\t\t\tclassName=\"dataviews-item-actions\"\n\t\t\tstyle={ {\n\t\t\t\tflexShrink: 0,\n\t\t\t\twidth: 'auto',\n\t\t\t} }\n\t\t>\n\t\t\t<PrimaryActions\n\t\t\t\titem={ item }\n\t\t\t\tactions={ primaryActions }\n\t\t\t\tregistry={ registry }\n\t\t\t/>\n\t\t\t{ primaryActions.length < eligibleActions.length && (\n\t\t\t\t<CompactItemActions\n\t\t\t\t\titem={ item }\n\t\t\t\t\tactions={ eligibleActions }\n\t\t\t\t\tregistry={ registry }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</HStack>\n\t);\n}\n\nfunction CompactItemActions< Item >( {\n\titem,\n\tactions,\n\tisSmall,\n\tregistry,\n}: CompactItemActionsProps< Item > ) {\n\tconst [ activeModalAction, setActiveModalAction ] = useState(\n\t\tnull as ActionModalType< Item > | null\n\t);\n\treturn (\n\t\t<>\n\t\t\t<Menu placement=\"bottom-end\">\n\t\t\t\t<Menu.TriggerButton\n\t\t\t\t\trender={\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsize={ isSmall ? 'small' : 'compact' }\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\tlabel={ __( 'Actions' ) }\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\tdisabled={ ! actions.length }\n\t\t\t\t\t\t\tclassName=\"dataviews-all-actions-button\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<Menu.Popover>\n\t\t\t\t\t<ActionsMenuGroup\n\t\t\t\t\t\tactions={ actions }\n\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\tregistry={ registry }\n\t\t\t\t\t\tsetActiveModalAction={ setActiveModalAction }\n\t\t\t\t\t/>\n\t\t\t\t</Menu.Popover>\n\t\t\t</Menu>\n\t\t\t{ !! activeModalAction && (\n\t\t\t\t<ActionModal\n\t\t\t\t\taction={ activeModalAction }\n\t\t\t\t\titems={ [ item ] }\n\t\t\t\t\tcloseModal={ () => setActiveModalAction( null ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction PrimaryActions< Item >( {\n\titem,\n\tactions,\n\tregistry,\n}: PrimaryActionsProps< Item > ) {\n\tconst [ activeModalAction, setActiveModalAction ] = useState( null as any );\n\tif ( ! Array.isArray( actions ) || actions.length === 0 ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t{ actions.map( ( action ) => (\n\t\t\t\t<ButtonTrigger\n\t\t\t\t\tkey={ action.id }\n\t\t\t\t\taction={ action }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tif ( 'RenderModal' in action ) {\n\t\t\t\t\t\t\tsetActiveModalAction( action );\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\taction.callback( [ item ], { registry } );\n\t\t\t\t\t} }\n\t\t\t\t\titems={ [ item ] }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ !! activeModalAction && (\n\t\t\t\t<ActionModal\n\t\t\t\t\taction={ activeModalAction }\n\t\t\t\t\titems={ [ item ] }\n\t\t\t\t\tcloseModal={ () => setActiveModalAction( null ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SACCA,MAAM,EACNC,KAAK,EACLC,oBAAoB,IAAIC,MAAM,EAC9BC,WAAW,IAAIC,qBAAqB,QAC9B,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,WAAW,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,SAASC,MAAM,QAAQ,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA,EAAAC,QAAA,IAAAC,SAAA;AAG3C,MAAM;EAAEC,IAAI;EAAEC;AAAU,CAAC,GAAGR,MAAM,CAAEN,qBAAsB,CAAC;AAyC3D,SAASe,aAAaA,CAAU;EAC/BC,MAAM;EACNC,OAAO;EACPC;AAC2B,CAAC,EAAG;EAC/B,MAAMC,KA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