@wordpress/dataviews 4.4.3 → 4.5.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 +2 -0
- package/README.md +4 -0
- package/build/components/dataform-combined-edit/index.js +67 -0
- package/build/components/dataform-combined-edit/index.js.map +1 -0
- package/build/components/dataviews-view-config/index.js +49 -38
- package/build/components/dataviews-view-config/index.js.map +1 -1
- package/build/dataforms-layouts/get-visible-fields.js +21 -0
- package/build/dataforms-layouts/get-visible-fields.js.map +1 -0
- package/build/dataforms-layouts/panel/index.js +5 -12
- package/build/dataforms-layouts/panel/index.js.map +1 -1
- package/build/dataforms-layouts/regular/index.js +2 -6
- package/build/dataforms-layouts/regular/index.js.map +1 -1
- package/build/normalize-fields.js +21 -0
- package/build/normalize-fields.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build/validation.js.map +1 -1
- package/build-module/components/dataform-combined-edit/index.js +62 -0
- package/build-module/components/dataform-combined-edit/index.js.map +1 -0
- package/build-module/components/dataviews-view-config/index.js +50 -39
- package/build-module/components/dataviews-view-config/index.js.map +1 -1
- package/build-module/dataforms-layouts/get-visible-fields.js +14 -0
- package/build-module/dataforms-layouts/get-visible-fields.js.map +1 -0
- package/build-module/dataforms-layouts/panel/index.js +5 -12
- package/build-module/dataforms-layouts/panel/index.js.map +1 -1
- package/build-module/dataforms-layouts/regular/index.js +2 -6
- package/build-module/dataforms-layouts/regular/index.js.map +1 -1
- package/build-module/normalize-fields.js +20 -0
- package/build-module/normalize-fields.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-module/validation.js.map +1 -1
- package/build-style/style-rtl.css +20 -15
- package/build-style/style.css +20 -15
- package/build-types/components/dataform/stories/index.story.d.ts +23 -0
- package/build-types/components/dataform/stories/index.story.d.ts.map +1 -1
- package/build-types/components/dataform-combined-edit/index.d.ts +7 -0
- package/build-types/components/dataform-combined-edit/index.d.ts.map +1 -0
- package/build-types/components/dataviews-view-config/index.d.ts.map +1 -1
- package/build-types/dataforms-layouts/get-visible-fields.d.ts +3 -0
- package/build-types/dataforms-layouts/get-visible-fields.d.ts.map +1 -0
- package/build-types/dataforms-layouts/panel/index.d.ts.map +1 -1
- package/build-types/dataforms-layouts/regular/index.d.ts.map +1 -1
- package/build-types/normalize-fields.d.ts +9 -1
- package/build-types/normalize-fields.d.ts.map +1 -1
- package/build-types/types.d.ts +27 -8
- package/build-types/types.d.ts.map +1 -1
- package/build-types/validation.d.ts +1 -1
- package/build-types/validation.d.ts.map +1 -1
- package/package.json +11 -11
- package/src/components/dataform/stories/index.story.tsx +65 -0
- package/src/components/dataform-combined-edit/index.tsx +66 -0
- package/src/components/dataform-combined-edit/style.scss +12 -0
- package/src/components/dataviews-filters/style.scss +0 -1
- package/src/components/dataviews-view-config/index.tsx +52 -40
- package/src/components/dataviews-view-config/style.scss +5 -8
- package/src/dataforms-layouts/get-visible-fields.ts +29 -0
- package/src/dataforms-layouts/panel/index.tsx +9 -10
- package/src/dataforms-layouts/panel/style.scss +0 -13
- package/src/dataforms-layouts/regular/index.tsx +8 -7
- package/src/normalize-fields.ts +33 -1
- package/src/style.scss +1 -0
- package/src/types.ts +29 -9
- package/src/validation.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import getFieldTypeDefinition from './field-types';
|
|
5
5
|
import { getControl } from './dataform-controls';
|
|
6
|
+
import DataFormCombinedEdit from './components/dataform-combined-edit';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Apply default values and normalize the fields config.
|
|
@@ -55,4 +56,23 @@ export function normalizeFields(fields) {
|
|
|
55
56
|
};
|
|
56
57
|
});
|
|
57
58
|
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Apply default values and normalize the fields config.
|
|
62
|
+
*
|
|
63
|
+
* @param combinedFields combined field list.
|
|
64
|
+
* @param fields Fields config.
|
|
65
|
+
* @return Normalized fields config.
|
|
66
|
+
*/
|
|
67
|
+
export function normalizeCombinedFields(combinedFields, fields) {
|
|
68
|
+
return combinedFields.map(combinedField => {
|
|
69
|
+
return {
|
|
70
|
+
...combinedField,
|
|
71
|
+
Edit: DataFormCombinedEdit,
|
|
72
|
+
fields: normalizeFields(combinedField.children.map(fieldId => fields.find(({
|
|
73
|
+
id
|
|
74
|
+
}) => id === fieldId)).filter(field => !!field))
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
}
|
|
58
78
|
//# sourceMappingURL=normalize-fields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getFieldTypeDefinition","getControl","normalizeFields","fields","map","field","_field$sort","_field$isValid","_field$enableHiding","_field$enableSorting","fieldTypeDefinition","type","getValue","item","id","sort","a","b","direction","isValid","context","Edit","renderFromElements","value","elements","find","element","label","render","header","enableHiding","enableSorting"],"sources":["@wordpress/dataviews/src/normalize-fields.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport getFieldTypeDefinition from './field-types';\nimport type {
|
|
1
|
+
{"version":3,"names":["getFieldTypeDefinition","getControl","DataFormCombinedEdit","normalizeFields","fields","map","field","_field$sort","_field$isValid","_field$enableHiding","_field$enableSorting","fieldTypeDefinition","type","getValue","item","id","sort","a","b","direction","isValid","context","Edit","renderFromElements","value","elements","find","element","label","render","header","enableHiding","enableSorting","normalizeCombinedFields","combinedFields","combinedField","children","fieldId","filter"],"sources":["@wordpress/dataviews/src/normalize-fields.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport getFieldTypeDefinition from './field-types';\nimport type {\n\tCombinedFormField,\n\tField,\n\tNormalizedField,\n\tNormalizedCombinedFormField,\n} from './types';\nimport { getControl } from './dataform-controls';\nimport DataFormCombinedEdit from './components/dataform-combined-edit';\n\n/**\n * Apply default values and normalize the fields config.\n *\n * @param fields Fields config.\n * @return Normalized fields config.\n */\nexport function normalizeFields< Item >(\n\tfields: Field< Item >[]\n): NormalizedField< Item >[] {\n\treturn fields.map( ( field ) => {\n\t\tconst fieldTypeDefinition = getFieldTypeDefinition( field.type );\n\n\t\tconst getValue =\n\t\t\tfield.getValue || ( ( { item } ) => ( item as any )[ field.id ] );\n\n\t\tconst sort =\n\t\t\tfield.sort ??\n\t\t\tfunction sort( a, b, direction ) {\n\t\t\t\treturn fieldTypeDefinition.sort(\n\t\t\t\t\tgetValue( { item: a } ),\n\t\t\t\t\tgetValue( { item: b } ),\n\t\t\t\t\tdirection\n\t\t\t\t);\n\t\t\t};\n\n\t\tconst isValid =\n\t\t\tfield.isValid ??\n\t\t\tfunction isValid( item, context ) {\n\t\t\t\treturn fieldTypeDefinition.isValid(\n\t\t\t\t\tgetValue( { item } ),\n\t\t\t\t\tcontext\n\t\t\t\t);\n\t\t\t};\n\n\t\tconst Edit = getControl( field, fieldTypeDefinition );\n\n\t\tconst renderFromElements = ( { item }: { item: Item } ) => {\n\t\t\tconst value = getValue( { item } );\n\t\t\treturn (\n\t\t\t\tfield?.elements?.find( ( element ) => element.value === value )\n\t\t\t\t\t?.label || getValue( { item } )\n\t\t\t);\n\t\t};\n\n\t\tconst render =\n\t\t\tfield.render || ( field.elements ? renderFromElements : getValue );\n\n\t\treturn {\n\t\t\t...field,\n\t\t\tlabel: field.label || field.id,\n\t\t\theader: field.header || field.label || field.id,\n\t\t\tgetValue,\n\t\t\trender,\n\t\t\tsort,\n\t\t\tisValid,\n\t\t\tEdit,\n\t\t\tenableHiding: field.enableHiding ?? true,\n\t\t\tenableSorting: field.enableSorting ?? true,\n\t\t};\n\t} );\n}\n\n/**\n * Apply default values and normalize the fields config.\n *\n * @param combinedFields combined field list.\n * @param fields Fields config.\n * @return Normalized fields config.\n */\nexport function normalizeCombinedFields< Item >(\n\tcombinedFields: CombinedFormField< Item >[],\n\tfields: Field< Item >[]\n): NormalizedCombinedFormField< Item >[] {\n\treturn combinedFields.map( ( combinedField ) => {\n\t\treturn {\n\t\t\t...combinedField,\n\t\t\tEdit: DataFormCombinedEdit,\n\t\t\tfields: normalizeFields(\n\t\t\t\tcombinedField.children\n\t\t\t\t\t.map( ( fieldId ) =>\n\t\t\t\t\t\tfields.find( ( { id } ) => id === fieldId )\n\t\t\t\t\t)\n\t\t\t\t\t.filter( ( field ): field is Field< Item > => !! field )\n\t\t\t),\n\t\t};\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,sBAAsB,MAAM,eAAe;AAOlD,SAASC,UAAU,QAAQ,qBAAqB;AAChD,OAAOC,oBAAoB,MAAM,qCAAqC;;AAEtE;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC9BC,MAAuB,EACK;EAC5B,OAAOA,MAAM,CAACC,GAAG,CAAIC,KAAK,IAAM;IAAA,IAAAC,WAAA,EAAAC,cAAA,EAAAC,mBAAA,EAAAC,oBAAA;IAC/B,MAAMC,mBAAmB,GAAGX,sBAAsB,CAAEM,KAAK,CAACM,IAAK,CAAC;IAEhE,MAAMC,QAAQ,GACbP,KAAK,CAACO,QAAQ,KAAM,CAAE;MAAEC;IAAK,CAAC,KAAQA,IAAI,CAAWR,KAAK,CAACS,EAAE,CAAE,CAAE;IAElE,MAAMC,IAAI,IAAAT,WAAA,GACTD,KAAK,CAACU,IAAI,cAAAT,WAAA,cAAAA,WAAA,GACV,SAASS,IAAIA,CAAEC,CAAC,EAAEC,CAAC,EAAEC,SAAS,EAAG;MAChC,OAAOR,mBAAmB,CAACK,IAAI,CAC9BH,QAAQ,CAAE;QAAEC,IAAI,EAAEG;MAAE,CAAE,CAAC,EACvBJ,QAAQ,CAAE;QAAEC,IAAI,EAAEI;MAAE,CAAE,CAAC,EACvBC,SACD,CAAC;IACF,CAAC;IAEF,MAAMC,OAAO,IAAAZ,cAAA,GACZF,KAAK,CAACc,OAAO,cAAAZ,cAAA,cAAAA,cAAA,GACb,SAASY,OAAOA,CAAEN,IAAI,EAAEO,OAAO,EAAG;MACjC,OAAOV,mBAAmB,CAACS,OAAO,CACjCP,QA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AEpB,oBAAoB;MAC1BE,MAAM,EAAED,eAAe,CACtBgC,aAAa,CAACC,QAAQ,CACpB/B,GAAG,CAAIgC,OAAO,IACdjC,MAAM,CAACsB,IAAI,CAAE,CAAE;QAAEX;MAAG,CAAC,KAAMA,EAAE,KAAKsB,OAAQ,CAC3C,CAAC,CACAC,MAAM,CAAIhC,KAAK,IAA8B,CAAC,CAAEA,KAAM,CACzD;IACD,CAAC;EACF,CAAE,CAAC;AACJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["@wordpress/dataviews/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactElement, ComponentType } from 'react';\n\n/**\n * Internal dependencies\n */\nimport type { SetSelection } from './private-types';\n\nexport type SortDirection = 'asc' | 'desc';\n\n/**\n * Generic option type.\n */\nexport interface Option< Value extends any = any > {\n\tvalue: Value;\n\tlabel: string;\n\tdescription?: string;\n}\n\ninterface FilterByConfig {\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators?: Operator[];\n\n\t/**\n\t * Whether it is a primary filter.\n\t *\n\t * A primary filter is always visible and is not listed in the \"Add filter\" component,\n\t * except for the list layout where it behaves like a secondary filter.\n\t */\n\tisPrimary?: boolean;\n}\n\nexport type Operator =\n\t| 'is'\n\t| 'isNot'\n\t| 'isAny'\n\t| 'isNone'\n\t| 'isAll'\n\t| 'isNotAll';\n\nexport type FieldType = 'text' | 'integer' | 'datetime';\n\nexport type ValidationContext = {\n\telements?: Option[];\n};\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: ( item: Item, context?: ValidationContext ) => boolean;\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;\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< { item: 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?: ( item: Item, context?: ValidationContext ) => boolean;\n\n\t/**\n\t * Whether the field is sortable.\n\t */\n\tenableSorting?: boolean;\n\n\t/**\n\t * Whether the field is searchable.\n\t */\n\tenableGlobalSearch?: boolean;\n\n\t/**\n\t * Whether the field is filterable.\n\t */\n\tenableHiding?: boolean;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements?: Option[];\n\n\t/**\n\t * Filter config for the field.\n\t */\n\tfilterBy?: FilterByConfig | undefined;\n\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 > = Field< Item > & {\n\tlabel: string;\n\theader: string | ReactElement;\n\tgetValue: ( args: { item: Item } ) => any;\n\trender: ComponentType< { item: Item } >;\n\tEdit: ComponentType< DataFormControlProps< Item > >;\n\tsort: ( a: Item, b: Item, direction: SortDirection ) => number;\n\tisValid: ( item: Item, context?: ValidationContext ) => boolean;\n\tenableHiding: boolean;\n\tenableSorting: boolean;\n};\n\n/**\n * A collection of dataview fields for a data type.\n */\nexport type Fields< Item > = Field< Item >[];\n\nexport type Data< Item > = Item[];\n\n/**\n * The form configuration.\n */\nexport type Form = {\n\ttype?: 'regular' | 'panel';\n\tfields?: string[];\n};\n\nexport type DataFormControlProps< Item > = {\n\tdata: Item;\n\tfield: NormalizedField< Item >;\n\tonChange: ( value: Record< string, any > ) => void;\n\thideLabelFromVision?: boolean;\n};\n\n/**\n * The filters applied to the dataset.\n */\nexport interface Filter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The operator to use.\n\t */\n\toperator: Operator;\n\n\t/**\n\t * The value to filter by.\n\t */\n\tvalue: any;\n}\n\nexport interface NormalizedFilter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The field name.\n\t */\n\tname: string;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements: Option[];\n\n\t/**\n\t * Is a single selection filter.\n\t */\n\tsingleSelection: boolean;\n\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators: Operator[];\n\n\t/**\n\t * Whether the filter is visible.\n\t */\n\tisVisible: boolean;\n\n\t/**\n\t * Whether it is a primary filter.\n\t */\n\tisPrimary: boolean;\n}\n\ninterface ViewBase {\n\t/**\n\t * The layout of the view.\n\t */\n\ttype: string;\n\n\t/**\n\t * The global search term.\n\t */\n\tsearch?: string;\n\n\t/**\n\t * The filters to apply.\n\t */\n\tfilters?: Filter[];\n\n\t/**\n\t * The sorting configuration.\n\t */\n\tsort?: {\n\t\t/**\n\t\t * The field to sort by.\n\t\t */\n\t\tfield: string;\n\n\t\t/**\n\t\t * The direction to sort by.\n\t\t */\n\t\tdirection: SortDirection;\n\t};\n\n\t/**\n\t * The active page\n\t */\n\tpage?: number;\n\n\t/**\n\t * The number of items per page\n\t */\n\tperPage?: number;\n\n\t/**\n\t * The fields to render\n\t */\n\tfields?: string[];\n}\n\nexport interface CombinedField {\n\tid: string;\n\n\tlabel: string;\n\n\theader?: string | ReactElement;\n\n\t/**\n\t * The fields to use as columns.\n\t */\n\tchildren: string[];\n\n\t/**\n\t * The direction of the stack.\n\t */\n\tdirection: 'horizontal' | 'vertical';\n}\n\nexport interface ColumnStyle {\n\t/**\n\t * The width of the field column.\n\t */\n\twidth?: string | number;\n\n\t/**\n\t * The minimum width of the field column.\n\t */\n\tmaxWidth?: string | number;\n\n\t/**\n\t * The maximum width of the field column.\n\t */\n\tminWidth?: string | number;\n}\n\nexport interface ViewTable extends ViewBase {\n\ttype: 'table';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The fields to use as columns.\n\t\t */\n\t\tcombinedFields?: CombinedField[];\n\n\t\t/**\n\t\t * The styles for the columns.\n\t\t */\n\t\tstyles?: Record< string, ColumnStyle >;\n\t};\n}\n\nexport interface ViewList extends ViewBase {\n\ttype: 'list';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField?: string;\n\t};\n}\n\nexport interface ViewGrid extends ViewBase {\n\ttype: 'grid';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField?: string;\n\n\t\t/**\n\t\t * The fields to use as columns.\n\t\t */\n\t\tcolumnFields?: string[];\n\n\t\t/**\n\t\t * The fields to use as badge fields.\n\t\t */\n\t\tbadgeFields?: string[];\n\t};\n}\n\nexport type View = ViewList | ViewGrid | ViewTable;\n\ninterface ActionBase< Item > {\n\t/**\n\t * The unique identifier of the action.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the action.\n\t * In case we want to adjust the label based on the selected items,\n\t * a function can be provided.\n\t */\n\tlabel: string | ( ( items: Item[] ) => string );\n\n\t/**\n\t * The icon of the action. (Either a string or an SVG element)\n\t * This should be IconType from the components package\n\t * but that import is breaking typescript build for the moment.\n\t */\n\ticon?: any;\n\n\t/**\n\t * Whether the action is disabled.\n\t */\n\tdisabled?: boolean;\n\n\t/**\n\t * Whether the action is destructive.\n\t */\n\tisDestructive?: boolean;\n\n\t/**\n\t * Whether the action is a primary action.\n\t */\n\tisPrimary?: boolean;\n\n\t/**\n\t * Whether the item passed as an argument supports the current action.\n\t */\n\tisEligible?: ( item: Item ) => boolean;\n\n\t/**\n\t * Whether the action can be used as a bulk action.\n\t */\n\tsupportsBulk?: boolean;\n\n\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\nexport interface ActionButton< Item > extends ActionBase< Item > {\n\t/**\n\t * The callback to execute when the action is triggered.\n\t */\n\tcallback: (\n\t\titems: Item[],\n\t\tcontext: {\n\t\t\tregistry: any;\n\t\t\tonActionPerformed?: ( items: Item[] ) => void;\n\t\t}\n\t) => void;\n}\n\nexport type Action< Item > = ActionModal< Item > | ActionButton< Item >;\n\nexport interface ViewBaseProps< Item > {\n\tactions: Action< Item >[];\n\tdata: Item[];\n\tfields: NormalizedField< Item >[];\n\tgetItemId: ( item: Item ) => string;\n\tisLoading?: boolean;\n\tonChangeView: ( view: View ) => void;\n\tonChangeSelection: SetSelection;\n\tselection: string[];\n\tsetOpenedFilter: ( fieldId: string ) => void;\n\tview: View;\n\tdensity: number;\n}\n\nexport interface ViewTableProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewTable;\n}\n\nexport interface ViewListProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewList;\n}\n\nexport interface ViewGridProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewGrid;\n}\n\nexport type ViewProps< Item > =\n\t| ViewTableProps< Item >\n\t| ViewGridProps< Item >\n\t| ViewListProps< Item >;\n\nexport interface SupportedLayouts {\n\tlist?: Omit< ViewList, 'type' >;\n\tgrid?: Omit< ViewGrid, 'type' >;\n\ttable?: Omit< ViewTable, 'type' >;\n}\n\nexport interface DataFormProps< Item > {\n\tdata: Item;\n\tfields: Field< Item >[];\n\tform: Form;\n\tonChange: ( value: Record< string, any > ) => void;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/dataviews/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactElement, ComponentType } from 'react';\n\n/**\n * Internal dependencies\n */\nimport type { SetSelection } from './private-types';\n\nexport type SortDirection = 'asc' | 'desc';\n\n/**\n * Generic option type.\n */\nexport interface Option< Value extends any = any > {\n\tvalue: Value;\n\tlabel: string;\n\tdescription?: string;\n}\n\ninterface FilterByConfig {\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators?: Operator[];\n\n\t/**\n\t * Whether it is a primary filter.\n\t *\n\t * A primary filter is always visible and is not listed in the \"Add filter\" component,\n\t * except for the list layout where it behaves like a secondary filter.\n\t */\n\tisPrimary?: boolean;\n}\n\nexport type Operator =\n\t| 'is'\n\t| 'isNot'\n\t| 'isAny'\n\t| 'isNone'\n\t| 'isAll'\n\t| 'isNotAll';\n\nexport type FieldType = 'text' | 'integer' | 'datetime';\n\nexport type ValidationContext = {\n\telements?: Option[];\n};\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: ( item: Item, context?: ValidationContext ) => boolean;\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;\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< { item: 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?: ( item: Item, context?: ValidationContext ) => boolean;\n\n\t/**\n\t * Whether the field is sortable.\n\t */\n\tenableSorting?: boolean;\n\n\t/**\n\t * Whether the field is searchable.\n\t */\n\tenableGlobalSearch?: boolean;\n\n\t/**\n\t * Whether the field is filterable.\n\t */\n\tenableHiding?: boolean;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements?: Option[];\n\n\t/**\n\t * Filter config for the field.\n\t */\n\tfilterBy?: FilterByConfig | undefined;\n\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 > = Field< Item > & {\n\tlabel: string;\n\theader: string | ReactElement;\n\tgetValue: ( args: { item: Item } ) => any;\n\trender: ComponentType< { item: Item } >;\n\tEdit: ComponentType< DataFormControlProps< Item > >;\n\tsort: ( a: Item, b: Item, direction: SortDirection ) => number;\n\tisValid: ( item: Item, context?: ValidationContext ) => boolean;\n\tenableHiding: boolean;\n\tenableSorting: 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};\n\n/**\n * The filters applied to the dataset.\n */\nexport interface Filter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The operator to use.\n\t */\n\toperator: Operator;\n\n\t/**\n\t * The value to filter by.\n\t */\n\tvalue: any;\n}\n\nexport interface NormalizedFilter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The field name.\n\t */\n\tname: string;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements: Option[];\n\n\t/**\n\t * Is a single selection filter.\n\t */\n\tsingleSelection: boolean;\n\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators: Operator[];\n\n\t/**\n\t * Whether the filter is visible.\n\t */\n\tisVisible: boolean;\n\n\t/**\n\t * Whether it is a primary filter.\n\t */\n\tisPrimary: boolean;\n}\n\ninterface ViewBase {\n\t/**\n\t * The layout of the view.\n\t */\n\ttype: string;\n\n\t/**\n\t * The global search term.\n\t */\n\tsearch?: string;\n\n\t/**\n\t * The filters to apply.\n\t */\n\tfilters?: Filter[];\n\n\t/**\n\t * The sorting configuration.\n\t */\n\tsort?: {\n\t\t/**\n\t\t * The field to sort by.\n\t\t */\n\t\tfield: string;\n\n\t\t/**\n\t\t * The direction to sort by.\n\t\t */\n\t\tdirection: SortDirection;\n\t};\n\n\t/**\n\t * The active page\n\t */\n\tpage?: number;\n\n\t/**\n\t * The number of items per page\n\t */\n\tperPage?: number;\n\n\t/**\n\t * The fields to render\n\t */\n\tfields?: string[];\n}\n\nexport interface CombinedField {\n\tid: string;\n\n\tlabel: string;\n\n\theader?: string | ReactElement;\n\n\t/**\n\t * The fields to use as columns.\n\t */\n\tchildren: string[];\n\n\t/**\n\t * The direction of the stack.\n\t */\n\tdirection: 'horizontal' | 'vertical';\n}\n\nexport interface ColumnStyle {\n\t/**\n\t * The width of the field column.\n\t */\n\twidth?: string | number;\n\n\t/**\n\t * The minimum width of the field column.\n\t */\n\tmaxWidth?: string | number;\n\n\t/**\n\t * The maximum width of the field column.\n\t */\n\tminWidth?: string | number;\n}\n\nexport interface ViewTable extends ViewBase {\n\ttype: 'table';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The fields to use as columns.\n\t\t */\n\t\tcombinedFields?: CombinedField[];\n\n\t\t/**\n\t\t * The styles for the columns.\n\t\t */\n\t\tstyles?: Record< string, ColumnStyle >;\n\t};\n}\n\nexport interface ViewList extends ViewBase {\n\ttype: 'list';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField?: string;\n\t};\n}\n\nexport interface ViewGrid extends ViewBase {\n\ttype: 'grid';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField?: string;\n\n\t\t/**\n\t\t * The fields to use as columns.\n\t\t */\n\t\tcolumnFields?: string[];\n\n\t\t/**\n\t\t * The fields to use as badge fields.\n\t\t */\n\t\tbadgeFields?: string[];\n\t};\n}\n\nexport type View = ViewList | ViewGrid | ViewTable;\n\ninterface ActionBase< Item > {\n\t/**\n\t * The unique identifier of the action.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the action.\n\t * In case we want to adjust the label based on the selected items,\n\t * a function can be provided.\n\t */\n\tlabel: string | ( ( items: Item[] ) => string );\n\n\t/**\n\t * The icon of the action. (Either a string or an SVG element)\n\t * This should be IconType from the components package\n\t * but that import is breaking typescript build for the moment.\n\t */\n\ticon?: any;\n\n\t/**\n\t * Whether the action is disabled.\n\t */\n\tdisabled?: boolean;\n\n\t/**\n\t * Whether the action is destructive.\n\t */\n\tisDestructive?: boolean;\n\n\t/**\n\t * Whether the action is a primary action.\n\t */\n\tisPrimary?: boolean;\n\n\t/**\n\t * Whether the item passed as an argument supports the current action.\n\t */\n\tisEligible?: ( item: Item ) => boolean;\n\n\t/**\n\t * Whether the action can be used as a bulk action.\n\t */\n\tsupportsBulk?: boolean;\n\n\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\nexport interface ActionButton< Item > extends ActionBase< Item > {\n\t/**\n\t * The callback to execute when the action is triggered.\n\t */\n\tcallback: (\n\t\titems: Item[],\n\t\tcontext: {\n\t\t\tregistry: any;\n\t\t\tonActionPerformed?: ( items: Item[] ) => void;\n\t\t}\n\t) => void;\n}\n\nexport type Action< Item > = ActionModal< Item > | ActionButton< Item >;\n\nexport interface ViewBaseProps< Item > {\n\tactions: Action< Item >[];\n\tdata: Item[];\n\tfields: NormalizedField< Item >[];\n\tgetItemId: ( item: Item ) => string;\n\tisLoading?: boolean;\n\tonChangeView: ( view: View ) => void;\n\tonChangeSelection: SetSelection;\n\tselection: string[];\n\tsetOpenedFilter: ( fieldId: string ) => void;\n\tview: View;\n\tdensity: number;\n}\n\nexport interface ViewTableProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewTable;\n}\n\nexport interface ViewListProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewList;\n}\n\nexport interface ViewGridProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewGrid;\n}\n\nexport type ViewProps< Item > =\n\t| ViewTableProps< Item >\n\t| ViewGridProps< Item >\n\t| ViewListProps< Item >;\n\nexport interface SupportedLayouts {\n\tlist?: Omit< ViewList, 'type' >;\n\tgrid?: Omit< ViewGrid, 'type' >;\n\ttable?: Omit< ViewTable, 'type' >;\n}\n\nexport interface CombinedFormField< Item > extends CombinedField {\n\trender?: ComponentType< { item: Item } >;\n}\n\nexport interface DataFormCombinedEditProps< Item > {\n\tfield: NormalizedCombinedFormField< Item >;\n\tdata: Item;\n\tonChange: ( value: Record< string, any > ) => void;\n\thideLabelFromVision?: boolean;\n}\n\nexport type NormalizedCombinedFormField< Item > = CombinedFormField< Item > & {\n\tfields: NormalizedField< Item >[];\n\tEdit?: ComponentType< DataFormCombinedEditProps< Item > >;\n};\n\n/**\n * The form configuration.\n */\nexport type Form< Item > = {\n\ttype?: 'regular' | 'panel';\n\tfields?: string[];\n\t/**\n\t * The fields to combine.\n\t */\n\tcombinedFields?: CombinedFormField< Item >[];\n};\n\nexport interface DataFormProps< Item > {\n\tdata: Item;\n\tfields: Field< Item >[];\n\tform: Form< Item >;\n\tonChange: ( value: Record< string, any > ) => void;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["normalizeFields","isItemValid","item","fields","form","_fields","filter","id","includes","every","field","isValid","elements"],"sources":["@wordpress/dataviews/src/validation.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { normalizeFields } from './normalize-fields';\nimport type { Field, Form } from './types';\n\nexport function isItemValid< Item >(\n\titem: Item,\n\tfields: Field< Item >[],\n\tform: Form
|
|
1
|
+
{"version":3,"names":["normalizeFields","isItemValid","item","fields","form","_fields","filter","id","includes","every","field","isValid","elements"],"sources":["@wordpress/dataviews/src/validation.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { normalizeFields } from './normalize-fields';\nimport type { Field, Form } from './types';\n\nexport function isItemValid< Item >(\n\titem: Item,\n\tfields: Field< Item >[],\n\tform: Form< Item >\n): boolean {\n\tconst _fields = normalizeFields(\n\t\tfields.filter( ( { id } ) => !! form.fields?.includes( id ) )\n\t);\n\treturn _fields.every( ( field ) => {\n\t\treturn field.isValid( item, { elements: field.elements } );\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAe,QAAQ,oBAAoB;AAGpD,OAAO,SAASC,WAAWA,CAC1BC,IAAU,EACVC,MAAuB,EACvBC,IAAkB,EACR;EACV,MAAMC,OAAO,GAAGL,eAAe,CAC9BG,MAAM,CAACG,MAAM,CAAE,CAAE;IAAEC;EAAG,CAAC,KAAM,CAAC,CAAEH,IAAI,CAACD,MAAM,EAAEK,QAAQ,CAAED,EAAG,CAAE,CAC7D,CAAC;EACD,OAAOF,OAAO,CAACI,KAAK,CAAIC,KAAK,IAAM;IAClC,OAAOA,KAAK,CAACC,OAAO,CAAET,IAAI,EAAE;MAAEU,QAAQ,EAAEF,KAAK,CAACE;IAAS,CAAE,CAAC;EAC3D,CAAE,CAAC;AACJ","ignoreList":[]}
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
/**
|
|
30
30
|
* Fonts & basic variables.
|
|
31
31
|
*/
|
|
32
|
+
/**
|
|
33
|
+
* Typography
|
|
34
|
+
*/
|
|
32
35
|
/**
|
|
33
36
|
* Grid System.
|
|
34
37
|
* https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
|
|
@@ -43,7 +46,10 @@
|
|
|
43
46
|
* Dimensions.
|
|
44
47
|
*/
|
|
45
48
|
/**
|
|
46
|
-
*
|
|
49
|
+
* Mobile specific styles
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* Editor styles.
|
|
47
53
|
*/
|
|
48
54
|
/**
|
|
49
55
|
* Block & Editor UI.
|
|
@@ -67,6 +73,9 @@
|
|
|
67
73
|
* Creates a fading overlay to signify that the content is longer
|
|
68
74
|
* than the space allows.
|
|
69
75
|
*/
|
|
76
|
+
/**
|
|
77
|
+
* Typography
|
|
78
|
+
*/
|
|
70
79
|
/**
|
|
71
80
|
* Breakpoint mixins
|
|
72
81
|
*/
|
|
@@ -356,7 +365,6 @@
|
|
|
356
365
|
}
|
|
357
366
|
|
|
358
367
|
.dataviews-filters__search-widget-listbox {
|
|
359
|
-
max-height: 184px;
|
|
360
368
|
padding: 4px;
|
|
361
369
|
overflow: auto;
|
|
362
370
|
}
|
|
@@ -576,11 +584,10 @@
|
|
|
576
584
|
margin: 0;
|
|
577
585
|
}
|
|
578
586
|
|
|
579
|
-
.dataviews-view-config
|
|
587
|
+
.dataviews-view-config {
|
|
580
588
|
width: 320px;
|
|
581
589
|
/* stylelint-disable-next-line property-no-unknown -- the linter needs to be updated to accepted the container-type property */
|
|
582
590
|
container-type: inline-size;
|
|
583
|
-
padding: 16px;
|
|
584
591
|
font-size: 13px;
|
|
585
592
|
line-height: 1.4;
|
|
586
593
|
}
|
|
@@ -645,6 +652,15 @@
|
|
|
645
652
|
top: unset;
|
|
646
653
|
}
|
|
647
654
|
|
|
655
|
+
.dataforms-layouts-panel__field-dropdown .dataforms-combined-edit {
|
|
656
|
+
border: none;
|
|
657
|
+
padding: 0;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
.dataforms-combined-edit__field {
|
|
661
|
+
flex: 1 1 auto;
|
|
662
|
+
}
|
|
663
|
+
|
|
648
664
|
.dataviews-view-grid {
|
|
649
665
|
margin-bottom: auto;
|
|
650
666
|
grid-template-rows: max-content;
|
|
@@ -1167,15 +1183,4 @@ ul.dataviews-view-list {
|
|
|
1167
1183
|
|
|
1168
1184
|
.dataforms-layouts-panel__dropdown-header {
|
|
1169
1185
|
margin-bottom: 16px;
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
[class].dataforms-layouts-panel__dropdown-header-action {
|
|
1173
|
-
height: 24px;
|
|
1174
|
-
}
|
|
1175
|
-
[class].dataforms-layouts-panel__dropdown-header-action.has-icon {
|
|
1176
|
-
min-width: 24px;
|
|
1177
|
-
padding: 0;
|
|
1178
|
-
}
|
|
1179
|
-
[class].dataforms-layouts-panel__dropdown-header-action:not(.has-icon) {
|
|
1180
|
-
text-decoration: underline;
|
|
1181
1186
|
}
|
package/build-style/style.css
CHANGED
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
/**
|
|
30
30
|
* Fonts & basic variables.
|
|
31
31
|
*/
|
|
32
|
+
/**
|
|
33
|
+
* Typography
|
|
34
|
+
*/
|
|
32
35
|
/**
|
|
33
36
|
* Grid System.
|
|
34
37
|
* https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
|
|
@@ -43,7 +46,10 @@
|
|
|
43
46
|
* Dimensions.
|
|
44
47
|
*/
|
|
45
48
|
/**
|
|
46
|
-
*
|
|
49
|
+
* Mobile specific styles
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* Editor styles.
|
|
47
53
|
*/
|
|
48
54
|
/**
|
|
49
55
|
* Block & Editor UI.
|
|
@@ -67,6 +73,9 @@
|
|
|
67
73
|
* Creates a fading overlay to signify that the content is longer
|
|
68
74
|
* than the space allows.
|
|
69
75
|
*/
|
|
76
|
+
/**
|
|
77
|
+
* Typography
|
|
78
|
+
*/
|
|
70
79
|
/**
|
|
71
80
|
* Breakpoint mixins
|
|
72
81
|
*/
|
|
@@ -356,7 +365,6 @@
|
|
|
356
365
|
}
|
|
357
366
|
|
|
358
367
|
.dataviews-filters__search-widget-listbox {
|
|
359
|
-
max-height: 184px;
|
|
360
368
|
padding: 4px;
|
|
361
369
|
overflow: auto;
|
|
362
370
|
}
|
|
@@ -576,11 +584,10 @@
|
|
|
576
584
|
margin: 0;
|
|
577
585
|
}
|
|
578
586
|
|
|
579
|
-
.dataviews-view-config
|
|
587
|
+
.dataviews-view-config {
|
|
580
588
|
width: 320px;
|
|
581
589
|
/* stylelint-disable-next-line property-no-unknown -- the linter needs to be updated to accepted the container-type property */
|
|
582
590
|
container-type: inline-size;
|
|
583
|
-
padding: 16px;
|
|
584
591
|
font-size: 13px;
|
|
585
592
|
line-height: 1.4;
|
|
586
593
|
}
|
|
@@ -645,6 +652,15 @@
|
|
|
645
652
|
top: unset;
|
|
646
653
|
}
|
|
647
654
|
|
|
655
|
+
.dataforms-layouts-panel__field-dropdown .dataforms-combined-edit {
|
|
656
|
+
border: none;
|
|
657
|
+
padding: 0;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
.dataforms-combined-edit__field {
|
|
661
|
+
flex: 1 1 auto;
|
|
662
|
+
}
|
|
663
|
+
|
|
648
664
|
.dataviews-view-grid {
|
|
649
665
|
margin-bottom: auto;
|
|
650
666
|
grid-template-rows: max-content;
|
|
@@ -1167,15 +1183,4 @@ ul.dataviews-view-list {
|
|
|
1167
1183
|
|
|
1168
1184
|
.dataforms-layouts-panel__dropdown-header {
|
|
1169
1185
|
margin-bottom: 16px;
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
[class].dataforms-layouts-panel__dropdown-header-action {
|
|
1173
|
-
height: 24px;
|
|
1174
|
-
}
|
|
1175
|
-
[class].dataforms-layouts-panel__dropdown-header-action.has-icon {
|
|
1176
|
-
min-width: 24px;
|
|
1177
|
-
padding: 0;
|
|
1178
|
-
}
|
|
1179
|
-
[class].dataforms-layouts-panel__dropdown-header-action:not(.has-icon) {
|
|
1180
|
-
text-decoration: underline;
|
|
1181
1186
|
}
|
|
@@ -19,4 +19,27 @@ export default meta;
|
|
|
19
19
|
export declare const Default: ({ type }: {
|
|
20
20
|
type: "panel" | "regular";
|
|
21
21
|
}) => import("react").JSX.Element;
|
|
22
|
+
export declare const CombinedFields: {
|
|
23
|
+
title: string;
|
|
24
|
+
render: ({ type, combinedFieldDirection, }: {
|
|
25
|
+
type: "panel" | "regular";
|
|
26
|
+
combinedFieldDirection: "vertical" | "horizontal";
|
|
27
|
+
}) => import("react").JSX.Element;
|
|
28
|
+
argTypes: {
|
|
29
|
+
combinedFieldDirection: {
|
|
30
|
+
control: {
|
|
31
|
+
type: string;
|
|
32
|
+
};
|
|
33
|
+
description: string;
|
|
34
|
+
options: string[];
|
|
35
|
+
};
|
|
36
|
+
type: {
|
|
37
|
+
control: {
|
|
38
|
+
type: string;
|
|
39
|
+
};
|
|
40
|
+
description: string;
|
|
41
|
+
options: string[];
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
22
45
|
//# sourceMappingURL=index.story.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../../src/components/dataform/stories/index.story.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,QAAQ,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../../src/components/dataform/stories/index.story.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,QAAQ,MAAM,UAAU,CAAC;AAGhC,QAAA,MAAM,IAAI;;;;;;;;;;;;CAWT,CAAC;AACF,eAAe,IAAI,CAAC;AA+DpB,eAAO,MAAM,OAAO,aAAe;IAAE,IAAI,EAAE,OAAO,GAAG,SAAS,CAAA;CAAE,gCAuC/D,CAAC;AA+CF,eAAO,MAAM,cAAc;;gDA1CxB;QACF,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;QAC1B,sBAAsB,EAAE,UAAU,GAAG,YAAY,CAAC;KAClD;;;;;;;;;;;;;;;;;CAmDA,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { DataFormCombinedEditProps } from '../../types';
|
|
5
|
+
declare function DataFormCombinedEdit<Item>({ field, data, onChange, hideLabelFromVision, }: DataFormCombinedEditProps<Item>): import("react").JSX.Element;
|
|
6
|
+
export default DataFormCombinedEdit;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/dataform-combined-edit/index.tsx"],"names":[],"mappings":"AAUA;;GAEG;AACH,OAAO,KAAK,EAAE,yBAAyB,EAAmB,MAAM,aAAa,CAAC;AAe9E,iBAAS,oBAAoB,CAAE,IAAI,EAAI,EACtC,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,mBAAmB,GACnB,EAAE,yBAAyB,CAAE,IAAI,CAAE,+BA8BnC;AAED,eAAe,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/dataviews-view-config/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/dataviews-view-config/index.tsx"],"names":[],"mappings":"AAgDA,OAAO,KAAK,EAAE,gBAAgB,EAAe,MAAM,aAAa,CAAC;AA6gBjE,iBAAS,oBAAoB,CAAE,EAC9B,OAAO,EACP,UAAU,EACV,cAAkD,GAClD,EAAE;IACF,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAE,KAAK,CAAC,cAAc,CAAE,MAAM,CAAE,CAAE,CAAC;IAC7D,cAAc,CAAC,EAAE,gBAAgB,CAAC;CAClC,+BAUA;AAED,QAAA,MAAM,mBAAmB,kEAA+B,CAAC;AAEzD,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-visible-fields.d.ts","sourceRoot":"","sources":["../../src/dataforms-layouts/get-visible-fields.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACX,KAAK,EACL,iBAAiB,EAEjB,MAAM,UAAU,CAAC;AAElB,wBAAgB,gBAAgB,CAAE,IAAI,EACrC,MAAM,EAAE,KAAK,CAAE,IAAI,CAAE,EAAE,EACvB,UAAU,GAAE,MAAM,EAAO,EACzB,cAAc,CAAC,EAAE,iBAAiB,CAAE,IAAI,CAAE,EAAE,GAC1C,KAAK,CAAE,IAAI,CAAE,EAAE,CAcjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dataforms-layouts/panel/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dataforms-layouts/panel/index.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,aAAa,EAAmB,MAAM,aAAa,CAAC;AAoHlE,MAAM,CAAC,OAAO,UAAU,SAAS,CAAE,IAAI,EAAI,EAC1C,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,QAAQ,GACR,EAAE,aAAa,CAAE,IAAI,CAAE,+BA2BvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dataforms-layouts/regular/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dataforms-layouts/regular/index.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAE,IAAI,EAAI,EAC5C,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,QAAQ,GACR,EAAE,aAAa,CAAE,IAAI,CAAE,+BA2BvB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Field, NormalizedField } from './types';
|
|
1
|
+
import type { CombinedFormField, Field, NormalizedField, NormalizedCombinedFormField } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Apply default values and normalize the fields config.
|
|
4
4
|
*
|
|
@@ -6,4 +6,12 @@ import type { Field, NormalizedField } from './types';
|
|
|
6
6
|
* @return Normalized fields config.
|
|
7
7
|
*/
|
|
8
8
|
export declare function normalizeFields<Item>(fields: Field<Item>[]): NormalizedField<Item>[];
|
|
9
|
+
/**
|
|
10
|
+
* Apply default values and normalize the fields config.
|
|
11
|
+
*
|
|
12
|
+
* @param combinedFields combined field list.
|
|
13
|
+
* @param fields Fields config.
|
|
14
|
+
* @return Normalized fields config.
|
|
15
|
+
*/
|
|
16
|
+
export declare function normalizeCombinedFields<Item>(combinedFields: CombinedFormField<Item>[], fields: Field<Item>[]): NormalizedCombinedFormField<Item>[];
|
|
9
17
|
//# sourceMappingURL=normalize-fields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-fields.d.ts","sourceRoot":"","sources":["../src/normalize-fields.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"normalize-fields.d.ts","sourceRoot":"","sources":["../src/normalize-fields.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACX,iBAAiB,EACjB,KAAK,EACL,eAAe,EACf,2BAA2B,EAC3B,MAAM,SAAS,CAAC;AAIjB;;;;;GAKG;AACH,wBAAgB,eAAe,CAAE,IAAI,EACpC,MAAM,EAAE,KAAK,CAAE,IAAI,CAAE,EAAE,GACrB,eAAe,CAAE,IAAI,CAAE,EAAE,CAoD3B;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAE,IAAI,EAC5C,cAAc,EAAE,iBAAiB,CAAE,IAAI,CAAE,EAAE,EAC3C,MAAM,EAAE,KAAK,CAAE,IAAI,CAAE,EAAE,GACrB,2BAA2B,CAAE,IAAI,CAAE,EAAE,CAcvC"}
|
package/build-types/types.d.ts
CHANGED
|
@@ -145,13 +145,6 @@ export type NormalizedField<Item> = Field<Item> & {
|
|
|
145
145
|
*/
|
|
146
146
|
export type Fields<Item> = Field<Item>[];
|
|
147
147
|
export type Data<Item> = Item[];
|
|
148
|
-
/**
|
|
149
|
-
* The form configuration.
|
|
150
|
-
*/
|
|
151
|
-
export type Form = {
|
|
152
|
-
type?: 'regular' | 'panel';
|
|
153
|
-
fields?: string[];
|
|
154
|
-
};
|
|
155
148
|
export type DataFormControlProps<Item> = {
|
|
156
149
|
data: Item;
|
|
157
150
|
field: NormalizedField<Item>;
|
|
@@ -423,10 +416,36 @@ export interface SupportedLayouts {
|
|
|
423
416
|
grid?: Omit<ViewGrid, 'type'>;
|
|
424
417
|
table?: Omit<ViewTable, 'type'>;
|
|
425
418
|
}
|
|
419
|
+
export interface CombinedFormField<Item> extends CombinedField {
|
|
420
|
+
render?: ComponentType<{
|
|
421
|
+
item: Item;
|
|
422
|
+
}>;
|
|
423
|
+
}
|
|
424
|
+
export interface DataFormCombinedEditProps<Item> {
|
|
425
|
+
field: NormalizedCombinedFormField<Item>;
|
|
426
|
+
data: Item;
|
|
427
|
+
onChange: (value: Record<string, any>) => void;
|
|
428
|
+
hideLabelFromVision?: boolean;
|
|
429
|
+
}
|
|
430
|
+
export type NormalizedCombinedFormField<Item> = CombinedFormField<Item> & {
|
|
431
|
+
fields: NormalizedField<Item>[];
|
|
432
|
+
Edit?: ComponentType<DataFormCombinedEditProps<Item>>;
|
|
433
|
+
};
|
|
434
|
+
/**
|
|
435
|
+
* The form configuration.
|
|
436
|
+
*/
|
|
437
|
+
export type Form<Item> = {
|
|
438
|
+
type?: 'regular' | 'panel';
|
|
439
|
+
fields?: string[];
|
|
440
|
+
/**
|
|
441
|
+
* The fields to combine.
|
|
442
|
+
*/
|
|
443
|
+
combinedFields?: CombinedFormField<Item>[];
|
|
444
|
+
};
|
|
426
445
|
export interface DataFormProps<Item> {
|
|
427
446
|
data: Item;
|
|
428
447
|
fields: Field<Item>[];
|
|
429
|
-
form: Form
|
|
448
|
+
form: Form<Item>;
|
|
430
449
|
onChange: (value: Record<string, any>) => void;
|
|
431
450
|
}
|
|
432
451
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEzD;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,MAAM,CAAE,KAAK,SAAS,GAAG,GAAG,GAAG;IAC/C,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,cAAc;IACvB;;OAEG;IACH,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IAEvB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,MAAM,QAAQ,GACjB,IAAI,GACJ,OAAO,GACP,OAAO,GACP,QAAQ,GACR,OAAO,GACP,UAAU,CAAC;AAEd,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;AAExD,MAAM,MAAM,iBAAiB,GAAG;IAC/B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mBAAmB,CAAE,IAAI,IAAK;IACzC;;OAEG;IACH,IAAI,E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AM,CAAE,MAAM,EAAE,GAAG,CAAE,KAAM,IAAI,CAAC;IACnD,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,MAAM,2BAA2B,CAAE,IAAI,IAAK,iBAAiB,CAAE,IAAI,CAAE,GAAG;IAC7E,MAAM,EAAE,eAAe,CAAE,IAAI,CAAE,EAAE,CAAC;IAClC,IAAI,CAAC,EAAE,aAAa,CAAE,yBAAyB,CAAE,IAAI,CAAE,CAAE,CAAC;CAC1D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,IAAI,CAAE,IAAI,IAAK;IAC1B,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;OAEG;IACH,cAAc,CAAC,EAAE,iBAAiB,CAAE,IAAI,CAAE,EAAE,CAAC;CAC7C,CAAC;AAEF,MAAM,WAAW,aAAa,CAAE,IAAI;IACnC,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,KAAK,CAAE,IAAI,CAAE,EAAE,CAAC;IACxB,IAAI,EAAE,IAAI,CAAE,IAAI,CAAE,CAAC;IACnB,QAAQ,EAAE,CAAE,KAAK,EAAE,MAAM,CAAE,MAAM,EAAE,GAAG,CAAE,KAAM,IAAI,CAAC;CACnD"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Field, Form } from './types';
|
|
2
|
-
export declare function isItemValid<Item>(item: Item, fields: Field<Item>[], form: Form): boolean;
|
|
2
|
+
export declare function isItemValid<Item>(item: Item, fields: Field<Item>[], form: Form<Item>): boolean;
|
|
3
3
|
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE3C,wBAAgB,WAAW,CAAE,IAAI,EAChC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,KAAK,CAAE,IAAI,CAAE,EAAE,EACvB,IAAI,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE3C,wBAAgB,WAAW,CAAE,IAAI,EAChC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,KAAK,CAAE,IAAI,CAAE,EAAE,EACvB,IAAI,EAAE,IAAI,CAAE,IAAI,CAAE,GAChB,OAAO,CAOT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/dataviews",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "DataViews is a component that provides an API to render datasets using different types of layouts (table, grid, list, etc.).",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@ariakit/react": "^0.4.10",
|
|
32
32
|
"@babel/runtime": "^7.16.0",
|
|
33
|
-
"@wordpress/components": "^28.
|
|
34
|
-
"@wordpress/compose": "^7.
|
|
35
|
-
"@wordpress/data": "^10.
|
|
36
|
-
"@wordpress/element": "^6.
|
|
37
|
-
"@wordpress/i18n": "^5.
|
|
38
|
-
"@wordpress/icons": "^10.
|
|
39
|
-
"@wordpress/primitives": "^4.
|
|
40
|
-
"@wordpress/private-apis": "^1.
|
|
41
|
-
"@wordpress/warning": "^3.
|
|
33
|
+
"@wordpress/components": "^28.9.0",
|
|
34
|
+
"@wordpress/compose": "^7.9.0",
|
|
35
|
+
"@wordpress/data": "^10.9.0",
|
|
36
|
+
"@wordpress/element": "^6.9.0",
|
|
37
|
+
"@wordpress/i18n": "^5.9.0",
|
|
38
|
+
"@wordpress/icons": "^10.9.0",
|
|
39
|
+
"@wordpress/primitives": "^4.9.0",
|
|
40
|
+
"@wordpress/private-apis": "^1.9.0",
|
|
41
|
+
"@wordpress/warning": "^3.9.0",
|
|
42
42
|
"clsx": "^2.1.1",
|
|
43
43
|
"remove-accents": "^0.5.0"
|
|
44
44
|
},
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "2e5495c635910cb34bfaca3c6258d2e989f66214"
|
|
52
52
|
}
|
|
@@ -7,6 +7,7 @@ import { useState } from '@wordpress/element';
|
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
9
|
import DataForm from '../index';
|
|
10
|
+
import type { CombinedFormField } from '../../../types';
|
|
10
11
|
|
|
11
12
|
const meta = {
|
|
12
13
|
title: 'DataViews/DataForm',
|
|
@@ -76,6 +77,11 @@ const fields = [
|
|
|
76
77
|
{ value: 'published', label: 'Published' },
|
|
77
78
|
],
|
|
78
79
|
},
|
|
80
|
+
{
|
|
81
|
+
id: 'password',
|
|
82
|
+
label: 'Password',
|
|
83
|
+
type: 'text' as const,
|
|
84
|
+
},
|
|
79
85
|
];
|
|
80
86
|
|
|
81
87
|
export const Default = ( { type }: { type: 'panel' | 'regular' } ) => {
|
|
@@ -118,3 +124,62 @@ export const Default = ( { type }: { type: 'panel' | 'regular' } ) => {
|
|
|
118
124
|
/>
|
|
119
125
|
);
|
|
120
126
|
};
|
|
127
|
+
|
|
128
|
+
const CombinedFieldsComponent = ( {
|
|
129
|
+
type = 'regular',
|
|
130
|
+
combinedFieldDirection = 'vertical',
|
|
131
|
+
}: {
|
|
132
|
+
type: 'panel' | 'regular';
|
|
133
|
+
combinedFieldDirection: 'vertical' | 'horizontal';
|
|
134
|
+
} ) => {
|
|
135
|
+
const [ post, setPost ] = useState( {
|
|
136
|
+
title: 'Hello, World!',
|
|
137
|
+
order: 2,
|
|
138
|
+
author: 1,
|
|
139
|
+
status: 'draft',
|
|
140
|
+
} );
|
|
141
|
+
|
|
142
|
+
const form = {
|
|
143
|
+
fields: [ 'title', 'status_and_visibility', 'order', 'author' ],
|
|
144
|
+
combinedFields: [
|
|
145
|
+
{
|
|
146
|
+
id: 'status_and_visibility',
|
|
147
|
+
label: 'Status & Visibility',
|
|
148
|
+
children: [ 'status', 'password' ],
|
|
149
|
+
direction: combinedFieldDirection,
|
|
150
|
+
render: ( { item } ) => item.status,
|
|
151
|
+
},
|
|
152
|
+
] as CombinedFormField< any >[],
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
return (
|
|
156
|
+
<DataForm
|
|
157
|
+
data={ post }
|
|
158
|
+
fields={ fields }
|
|
159
|
+
form={ {
|
|
160
|
+
...form,
|
|
161
|
+
type,
|
|
162
|
+
} }
|
|
163
|
+
onChange={ ( edits ) =>
|
|
164
|
+
setPost( ( prev ) => ( {
|
|
165
|
+
...prev,
|
|
166
|
+
...edits,
|
|
167
|
+
} ) )
|
|
168
|
+
}
|
|
169
|
+
/>
|
|
170
|
+
);
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export const CombinedFields = {
|
|
174
|
+
title: 'DataViews/CombinedFields',
|
|
175
|
+
render: CombinedFieldsComponent,
|
|
176
|
+
argTypes: {
|
|
177
|
+
...meta.argTypes,
|
|
178
|
+
combinedFieldDirection: {
|
|
179
|
+
control: { type: 'select' },
|
|
180
|
+
description:
|
|
181
|
+
'Chooses the direction of the combined field. "vertical" is the default layout.',
|
|
182
|
+
options: [ 'vertical', 'horizontal' ],
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
};
|