@wordpress/dataviews 9.0.1-next.6f42e1382.0 → 9.0.1-next.a730c9c8c.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -1
- package/README.md +106 -11
- package/build/components/dataviews-filters/input-widget.js +48 -4
- package/build/components/dataviews-filters/input-widget.js.map +1 -1
- package/build/dataform-controls/array.js +9 -7
- package/build/dataform-controls/array.js.map +1 -1
- package/build/dataform-controls/checkbox.js +31 -20
- package/build/dataform-controls/checkbox.js.map +1 -1
- package/build/dataform-controls/color.js +29 -24
- package/build/dataform-controls/color.js.map +1 -1
- package/build/dataform-controls/date.js +32 -24
- package/build/dataform-controls/date.js.map +1 -1
- package/build/dataform-controls/datetime.js +133 -19
- package/build/dataform-controls/datetime.js.map +1 -1
- package/build/dataform-controls/email.js +7 -1
- package/build/dataform-controls/email.js.map +1 -1
- package/build/dataform-controls/index.js +23 -0
- package/build/dataform-controls/index.js.map +1 -1
- package/build/dataform-controls/integer.js +47 -34
- package/build/dataform-controls/integer.js.map +1 -1
- package/build/dataform-controls/radio.js +42 -9
- package/build/dataform-controls/radio.js.map +1 -1
- package/build/dataform-controls/relative-date-control.js +6 -10
- package/build/dataform-controls/relative-date-control.js.map +1 -1
- package/build/dataform-controls/select.js +41 -10
- package/build/dataform-controls/select.js.map +1 -1
- package/build/dataform-controls/telephone.js +7 -1
- package/build/dataform-controls/telephone.js.map +1 -1
- package/build/dataform-controls/text.js +14 -2
- package/build/dataform-controls/text.js.map +1 -1
- package/build/dataform-controls/textarea.js +33 -20
- package/build/dataform-controls/textarea.js.map +1 -1
- package/build/dataform-controls/toggle-group.js +36 -6
- package/build/dataform-controls/toggle-group.js.map +1 -1
- package/build/dataform-controls/toggle.js +33 -22
- package/build/dataform-controls/toggle.js.map +1 -1
- package/build/dataform-controls/url.js +7 -1
- package/build/dataform-controls/url.js.map +1 -1
- package/build/dataform-controls/utils/validated-input.js +34 -32
- package/build/dataform-controls/utils/validated-input.js.map +1 -1
- package/build/dataforms-layouts/panel/dropdown.js +10 -14
- package/build/dataforms-layouts/panel/dropdown.js.map +1 -1
- package/build/dataforms-layouts/panel/index.js +24 -11
- package/build/dataforms-layouts/panel/index.js.map +1 -1
- package/build/dataforms-layouts/panel/modal.js +22 -27
- package/build/dataforms-layouts/panel/modal.js.map +1 -1
- package/build/dataforms-layouts/panel/summary-button.js +67 -0
- package/build/dataforms-layouts/panel/summary-button.js.map +1 -0
- package/build/normalize-fields.js +17 -0
- package/build/normalize-fields.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build-module/components/dataviews-filters/input-widget.js +48 -4
- package/build-module/components/dataviews-filters/input-widget.js.map +1 -1
- package/build-module/dataform-controls/array.js +9 -7
- package/build-module/dataform-controls/array.js.map +1 -1
- package/build-module/dataform-controls/checkbox.js +31 -21
- package/build-module/dataform-controls/checkbox.js.map +1 -1
- package/build-module/dataform-controls/color.js +28 -24
- package/build-module/dataform-controls/color.js.map +1 -1
- package/build-module/dataform-controls/date.js +32 -24
- package/build-module/dataform-controls/date.js.map +1 -1
- package/build-module/dataform-controls/datetime.js +135 -21
- package/build-module/dataform-controls/datetime.js.map +1 -1
- package/build-module/dataform-controls/email.js +7 -1
- package/build-module/dataform-controls/email.js.map +1 -1
- package/build-module/dataform-controls/index.js +23 -0
- package/build-module/dataform-controls/index.js.map +1 -1
- package/build-module/dataform-controls/integer.js +46 -34
- package/build-module/dataform-controls/integer.js.map +1 -1
- package/build-module/dataform-controls/radio.js +44 -11
- package/build-module/dataform-controls/radio.js.map +1 -1
- package/build-module/dataform-controls/relative-date-control.js +6 -10
- package/build-module/dataform-controls/relative-date-control.js.map +1 -1
- package/build-module/dataform-controls/select.js +43 -12
- package/build-module/dataform-controls/select.js.map +1 -1
- package/build-module/dataform-controls/telephone.js +7 -1
- package/build-module/dataform-controls/telephone.js.map +1 -1
- package/build-module/dataform-controls/text.js +14 -2
- package/build-module/dataform-controls/text.js.map +1 -1
- package/build-module/dataform-controls/textarea.js +32 -20
- package/build-module/dataform-controls/textarea.js.map +1 -1
- package/build-module/dataform-controls/toggle-group.js +38 -8
- package/build-module/dataform-controls/toggle-group.js.map +1 -1
- package/build-module/dataform-controls/toggle.js +33 -23
- package/build-module/dataform-controls/toggle.js.map +1 -1
- package/build-module/dataform-controls/url.js +7 -1
- package/build-module/dataform-controls/url.js.map +1 -1
- package/build-module/dataform-controls/utils/validated-input.js +34 -33
- package/build-module/dataform-controls/utils/validated-input.js.map +1 -1
- package/build-module/dataforms-layouts/panel/dropdown.js +10 -15
- package/build-module/dataforms-layouts/panel/dropdown.js.map +1 -1
- package/build-module/dataforms-layouts/panel/index.js +24 -11
- package/build-module/dataforms-layouts/panel/index.js.map +1 -1
- package/build-module/dataforms-layouts/panel/modal.js +22 -28
- package/build-module/dataforms-layouts/panel/modal.js.map +1 -1
- package/build-module/dataforms-layouts/panel/summary-button.js +60 -0
- package/build-module/dataforms-layouts/panel/summary-button.js.map +1 -0
- package/build-module/normalize-fields.js +15 -0
- package/build-module/normalize-fields.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-types/components/dataform/stories/index.story.d.ts +3 -0
- package/build-types/components/dataform/stories/index.story.d.ts.map +1 -1
- package/build-types/components/dataviews/stories/fixtures.d.ts +4 -2
- package/build-types/components/dataviews/stories/fixtures.d.ts.map +1 -1
- package/build-types/components/dataviews-filters/input-widget.d.ts.map +1 -1
- package/build-types/dataform-controls/array.d.ts.map +1 -1
- package/build-types/dataform-controls/checkbox.d.ts.map +1 -1
- package/build-types/dataform-controls/color.d.ts.map +1 -1
- package/build-types/dataform-controls/date.d.ts.map +1 -1
- package/build-types/dataform-controls/datetime.d.ts.map +1 -1
- package/build-types/dataform-controls/email.d.ts.map +1 -1
- package/build-types/dataform-controls/index.d.ts +1 -1
- package/build-types/dataform-controls/index.d.ts.map +1 -1
- package/build-types/dataform-controls/integer.d.ts.map +1 -1
- package/build-types/dataform-controls/radio.d.ts.map +1 -1
- package/build-types/dataform-controls/relative-date-control.d.ts +6 -5
- package/build-types/dataform-controls/relative-date-control.d.ts.map +1 -1
- package/build-types/dataform-controls/select.d.ts.map +1 -1
- package/build-types/dataform-controls/telephone.d.ts.map +1 -1
- package/build-types/dataform-controls/text.d.ts +1 -1
- package/build-types/dataform-controls/text.d.ts.map +1 -1
- package/build-types/dataform-controls/textarea.d.ts +1 -1
- package/build-types/dataform-controls/textarea.d.ts.map +1 -1
- package/build-types/dataform-controls/toggle-group.d.ts.map +1 -1
- package/build-types/dataform-controls/toggle.d.ts.map +1 -1
- package/build-types/dataform-controls/url.d.ts.map +1 -1
- package/build-types/dataform-controls/utils/validated-input.d.ts +4 -4
- package/build-types/dataform-controls/utils/validated-input.d.ts.map +1 -1
- package/build-types/dataforms-layouts/panel/dropdown.d.ts +2 -1
- package/build-types/dataforms-layouts/panel/dropdown.d.ts.map +1 -1
- package/build-types/dataforms-layouts/panel/index.d.ts.map +1 -1
- package/build-types/dataforms-layouts/panel/modal.d.ts +2 -1
- package/build-types/dataforms-layouts/panel/modal.d.ts.map +1 -1
- package/build-types/dataforms-layouts/panel/summary-button.d.ts +15 -0
- package/build-types/dataforms-layouts/panel/summary-button.d.ts.map +1 -0
- package/build-types/field-types/stories/index.story.d.ts.map +1 -1
- package/build-types/normalize-fields.d.ts +3 -0
- package/build-types/normalize-fields.d.ts.map +1 -1
- package/build-types/types.d.ts +66 -3
- package/build-types/types.d.ts.map +1 -1
- package/build-wp/index.js +1468 -1422
- package/package.json +16 -15
- package/src/components/dataform/stories/index.story.tsx +436 -7
- package/src/components/dataviews/stories/fixtures.tsx +99 -41
- package/src/components/dataviews/stories/index.story.tsx +1 -1
- package/src/components/dataviews-filters/input-widget.tsx +44 -5
- package/src/components/dataviews-picker/stories/index.story.tsx +1 -1
- package/src/dataform-controls/array.tsx +4 -6
- package/src/dataform-controls/checkbox.tsx +41 -24
- package/src/dataform-controls/color.tsx +33 -24
- package/src/dataform-controls/date.tsx +47 -21
- package/src/dataform-controls/datetime.tsx +171 -23
- package/src/dataform-controls/email.tsx +9 -1
- package/src/dataform-controls/index.tsx +26 -0
- package/src/dataform-controls/integer.tsx +82 -49
- package/src/dataform-controls/radio.tsx +53 -11
- package/src/dataform-controls/relative-date-control.tsx +11 -10
- package/src/dataform-controls/select.tsx +53 -10
- package/src/dataform-controls/telephone.tsx +9 -1
- package/src/dataform-controls/text.tsx +18 -1
- package/src/dataform-controls/textarea.tsx +38 -24
- package/src/dataform-controls/toggle-group.tsx +50 -10
- package/src/dataform-controls/toggle.tsx +41 -24
- package/src/dataform-controls/url.tsx +9 -1
- package/src/dataform-controls/utils/validated-input.tsx +50 -50
- package/src/dataforms-layouts/panel/dropdown.tsx +12 -23
- package/src/dataforms-layouts/panel/index.tsx +39 -16
- package/src/dataforms-layouts/panel/modal.tsx +24 -30
- package/src/dataforms-layouts/panel/summary-button.tsx +92 -0
- package/src/field-types/stories/index.story.tsx +89 -1
- package/src/normalize-fields.ts +18 -0
- package/src/test/filter-and-sort-data-view.js +148 -138
- package/src/test/normalize-fields.ts +114 -0
- package/src/types.ts +73 -3
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getFieldTypeDefinition","getControl","ALL_OPERATORS","OPERATOR_BETWEEN","SINGLE_SELECTION_OPERATORS","getValueFromId","id","item","path","split","value","segment","hasOwnProperty","undefined","getFilterBy","field","fieldTypeDefinition","filterBy","operators","Array","isArray","defaultOperators","validOperators","filter","operator","includes","elements","hasSingleSelectionOperator","some","length","isPrimary","normalizeFields","fields","map","_field$sort","_field$render","_field$enableHiding","_ref","_field$enableSorting","_ref2","_field$readOnly","type","getValue","sort","a","b","direction","isValid","Edit","render","renderedField","label","header","enableHiding","enableSorting","readOnly"],"sources":["@wordpress/dataviews/src/normalize-fields.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { FunctionComponent } from 'react';\n\n/**\n * Internal dependencies\n */\nimport getFieldTypeDefinition from './field-types';\nimport type {\n\tDataViewRenderFieldProps,\n\tField,\n\tFieldTypeDefinition,\n\tNormalizedFilterByConfig,\n\tNormalizedField,\n} from './types';\nimport { getControl } from './dataform-controls';\nimport {\n\tALL_OPERATORS,\n\tOPERATOR_BETWEEN,\n\tSINGLE_SELECTION_OPERATORS,\n} from './constants';\n\nconst getValueFromId =\n\t( id: string ) =>\n\t( { item }: { item: any } ) => {\n\t\tconst path = id.split( '.' );\n\t\tlet value = item;\n\t\tfor ( const segment of path ) {\n\t\t\tif ( value.hasOwnProperty( segment ) ) {\n\t\t\t\tvalue = value[ segment ];\n\t\t\t} else {\n\t\t\t\tvalue = undefined;\n\t\t\t}\n\t\t}\n\n\t\treturn value;\n\t};\n\nfunction getFilterBy< Item >(\n\tfield: Field< Item >,\n\tfieldTypeDefinition: FieldTypeDefinition< Item >\n): NormalizedFilterByConfig | false {\n\tif ( field.filterBy === false ) {\n\t\treturn false;\n\t}\n\n\tif ( typeof field.filterBy === 'object' ) {\n\t\tlet operators = field.filterBy.operators;\n\n\t\t// Assign default values if no operator was provided.\n\t\tif ( ! operators || ! Array.isArray( operators ) ) {\n\t\t\toperators = !! fieldTypeDefinition.filterBy\n\t\t\t\t? fieldTypeDefinition.filterBy.defaultOperators\n\t\t\t\t: [];\n\t\t}\n\n\t\t// Make sure only valid operators are included.\n\t\tlet validOperators = ALL_OPERATORS;\n\t\tif ( typeof fieldTypeDefinition.filterBy === 'object' ) {\n\t\t\tvalidOperators = fieldTypeDefinition.filterBy.validOperators;\n\t\t}\n\t\toperators = operators.filter( ( operator ) =>\n\t\t\tvalidOperators.includes( operator )\n\t\t);\n\n\t\t// The `between` operator is not supported when elements are provided.\n\t\tif ( field.elements && operators.includes( OPERATOR_BETWEEN ) ) {\n\t\t\toperators = operators.filter(\n\t\t\t\t( operator ) => operator !== OPERATOR_BETWEEN\n\t\t\t);\n\t\t}\n\n\t\t// Do not allow mixing single & multiselection operators.\n\t\t// Remove multiselection operators if any of the single selection ones is present.\n\t\tconst hasSingleSelectionOperator = operators.some( ( operator ) =>\n\t\t\tSINGLE_SELECTION_OPERATORS.includes( operator )\n\t\t);\n\t\tif ( hasSingleSelectionOperator ) {\n\t\t\toperators = operators.filter( ( operator ) =>\n\t\t\t\t// The 'Between' operator is unique as it can be combined with single selection operators.\n\t\t\t\t[ ...SINGLE_SELECTION_OPERATORS, OPERATOR_BETWEEN ].includes(\n\t\t\t\t\toperator\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\t// If no operators are left at this point,\n\t\t// the filters should be disabled.\n\t\tif ( operators.length === 0 ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn {\n\t\t\tisPrimary: !! field.filterBy.isPrimary,\n\t\t\toperators,\n\t\t};\n\t}\n\n\tif ( fieldTypeDefinition.filterBy === false ) {\n\t\treturn false;\n\t}\n\n\tlet defaultOperators = fieldTypeDefinition.filterBy.defaultOperators;\n\t// The `between` operator is not supported when elements are provided.\n\tif ( field.elements && defaultOperators.includes( OPERATOR_BETWEEN ) ) {\n\t\tdefaultOperators = defaultOperators.filter(\n\t\t\t( operator ) => operator !== OPERATOR_BETWEEN\n\t\t);\n\t}\n\n\treturn {\n\t\toperators: defaultOperators,\n\t};\n}\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< Item >(\n\t\t\tfield.type\n\t\t);\n\t\tconst getValue = field.getValue || getValueFromId( 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\t...fieldTypeDefinition.isValid,\n\t\t\t...field.isValid,\n\t\t};\n\n\t\tconst Edit = getControl( field, fieldTypeDefinition );\n\n\t\tconst render =\n\t\t\tfield.render ??\n\t\t\tfunction render( {\n\t\t\t\titem,\n\t\t\t\tfield: renderedField,\n\t\t\t}: DataViewRenderFieldProps< Item > ) {\n\t\t\t\treturn (\n\t\t\t\t\tfieldTypeDefinition.render as FunctionComponent<\n\t\t\t\t\t\tDataViewRenderFieldProps< Item >\n\t\t\t\t\t>\n\t\t\t\t )( { item, field: renderedField } );\n\t\t\t};\n\n\t\tconst filterBy = getFilterBy( field, fieldTypeDefinition );\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:\n\t\t\t\tfield.enableSorting ??\n\t\t\t\tfieldTypeDefinition.enableSorting ??\n\t\t\t\ttrue,\n\t\t\tfilterBy,\n\t\t\treadOnly: field.readOnly ?? fieldTypeDefinition.readOnly ?? false,\n\t\t};\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,OAAOA,sBAAsB,MAAM,eAAe;AAQlD,SAASC,UAAU,QAAQ,qBAAqB;AAChD,SACCC,aAAa,EACbC,gBAAgB,EAChBC,0BAA0B,QACpB,aAAa;AAEpB,MAAMC,cAAc,GACjBC,EAAU,IACZ,CAAE;EAAEC;AAAoB,CAAC,KAAM;EAC9B,MAAMC,IAAI,GAAGF,EAAE,CAACG,KAAK,CAAE,GAAI,CAAC;EAC5B,IAAIC,KAAK,GAAGH,IAAI;EAChB,KAAM,MAAMI,OAAO,IAAIH,IAAI,EAAG;IAC7B,IAAKE,KAAK,CAACE,cAAc,CAAED,OAAQ,CAAC,EAAG;MACtCD,KAAK,GAAGA,KAAK,CAAEC,OAAO,CAAE;IACzB,CAAC,M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AK,CAACwC,QAAQ,cAAAf,eAAA,cAAAA,eAAA,GAAIxB,mBAAmB,CAACuC,QAAQ,cAAAhB,KAAA,cAAAA,KAAA,GAAI;IAC7D,CAAC;EACF,CAAE,CAAC;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["getFieldTypeDefinition","getControl","ALL_OPERATORS","OPERATOR_BETWEEN","SINGLE_SELECTION_OPERATORS","getValueFromId","id","item","path","split","value","segment","hasOwnProperty","undefined","setValueFromId","result","current","slice","at","getFilterBy","field","fieldTypeDefinition","filterBy","operators","Array","isArray","defaultOperators","validOperators","filter","operator","includes","elements","hasSingleSelectionOperator","some","length","isPrimary","normalizeFields","fields","map","_field$sort","_field$render","_field$enableHiding","_ref","_field$enableSorting","_ref2","_field$readOnly","type","getValue","setValue","sort","a","b","direction","isValid","Edit","render","renderedField","label","header","enableHiding","enableSorting","readOnly"],"sources":["@wordpress/dataviews/src/normalize-fields.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { FunctionComponent } from 'react';\n\n/**\n * Internal dependencies\n */\nimport getFieldTypeDefinition from './field-types';\nimport type {\n\tDataViewRenderFieldProps,\n\tField,\n\tFieldTypeDefinition,\n\tNormalizedFilterByConfig,\n\tNormalizedField,\n} from './types';\nimport { getControl } from './dataform-controls';\nimport {\n\tALL_OPERATORS,\n\tOPERATOR_BETWEEN,\n\tSINGLE_SELECTION_OPERATORS,\n} from './constants';\n\nconst getValueFromId =\n\t( id: string ) =>\n\t( { item }: { item: any } ) => {\n\t\tconst path = id.split( '.' );\n\t\tlet value = item;\n\t\tfor ( const segment of path ) {\n\t\t\tif ( value.hasOwnProperty( segment ) ) {\n\t\t\t\tvalue = value[ segment ];\n\t\t\t} else {\n\t\t\t\tvalue = undefined;\n\t\t\t}\n\t\t}\n\n\t\treturn value;\n\t};\n\nexport const setValueFromId =\n\t( id: string ) =>\n\t( { value }: { value: any } ) => {\n\t\tconst path = id.split( '.' );\n\t\tconst result: any = {};\n\t\tlet current = result;\n\n\t\tfor ( const segment of path.slice( 0, -1 ) ) {\n\t\t\tcurrent[ segment ] = {};\n\t\t\tcurrent = current[ segment ];\n\t\t}\n\n\t\tcurrent[ path.at( -1 )! ] = value;\n\t\treturn result;\n\t};\n\nfunction getFilterBy< Item >(\n\tfield: Field< Item >,\n\tfieldTypeDefinition: FieldTypeDefinition< Item >\n): NormalizedFilterByConfig | false {\n\tif ( field.filterBy === false ) {\n\t\treturn false;\n\t}\n\n\tif ( typeof field.filterBy === 'object' ) {\n\t\tlet operators = field.filterBy.operators;\n\n\t\t// Assign default values if no operator was provided.\n\t\tif ( ! operators || ! Array.isArray( operators ) ) {\n\t\t\toperators = !! fieldTypeDefinition.filterBy\n\t\t\t\t? fieldTypeDefinition.filterBy.defaultOperators\n\t\t\t\t: [];\n\t\t}\n\n\t\t// Make sure only valid operators are included.\n\t\tlet validOperators = ALL_OPERATORS;\n\t\tif ( typeof fieldTypeDefinition.filterBy === 'object' ) {\n\t\t\tvalidOperators = fieldTypeDefinition.filterBy.validOperators;\n\t\t}\n\t\toperators = operators.filter( ( operator ) =>\n\t\t\tvalidOperators.includes( operator )\n\t\t);\n\n\t\t// The `between` operator is not supported when elements are provided.\n\t\tif ( field.elements && operators.includes( OPERATOR_BETWEEN ) ) {\n\t\t\toperators = operators.filter(\n\t\t\t\t( operator ) => operator !== OPERATOR_BETWEEN\n\t\t\t);\n\t\t}\n\n\t\t// Do not allow mixing single & multiselection operators.\n\t\t// Remove multiselection operators if any of the single selection ones is present.\n\t\tconst hasSingleSelectionOperator = operators.some( ( operator ) =>\n\t\t\tSINGLE_SELECTION_OPERATORS.includes( operator )\n\t\t);\n\t\tif ( hasSingleSelectionOperator ) {\n\t\t\toperators = operators.filter( ( operator ) =>\n\t\t\t\t// The 'Between' operator is unique as it can be combined with single selection operators.\n\t\t\t\t[ ...SINGLE_SELECTION_OPERATORS, OPERATOR_BETWEEN ].includes(\n\t\t\t\t\toperator\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\t// If no operators are left at this point,\n\t\t// the filters should be disabled.\n\t\tif ( operators.length === 0 ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn {\n\t\t\tisPrimary: !! field.filterBy.isPrimary,\n\t\t\toperators,\n\t\t};\n\t}\n\n\tif ( fieldTypeDefinition.filterBy === false ) {\n\t\treturn false;\n\t}\n\n\tlet defaultOperators = fieldTypeDefinition.filterBy.defaultOperators;\n\t// The `between` operator is not supported when elements are provided.\n\tif ( field.elements && defaultOperators.includes( OPERATOR_BETWEEN ) ) {\n\t\tdefaultOperators = defaultOperators.filter(\n\t\t\t( operator ) => operator !== OPERATOR_BETWEEN\n\t\t);\n\t}\n\n\treturn {\n\t\toperators: defaultOperators,\n\t};\n}\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< Item >(\n\t\t\tfield.type\n\t\t);\n\t\tconst getValue = field.getValue || getValueFromId( field.id );\n\t\tconst setValue = field.setValue || setValueFromId( 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\t...fieldTypeDefinition.isValid,\n\t\t\t...field.isValid,\n\t\t};\n\n\t\tconst Edit = getControl( field, fieldTypeDefinition );\n\n\t\tconst render =\n\t\t\tfield.render ??\n\t\t\tfunction render( {\n\t\t\t\titem,\n\t\t\t\tfield: renderedField,\n\t\t\t}: DataViewRenderFieldProps< Item > ) {\n\t\t\t\treturn (\n\t\t\t\t\tfieldTypeDefinition.render as FunctionComponent<\n\t\t\t\t\t\tDataViewRenderFieldProps< Item >\n\t\t\t\t\t>\n\t\t\t\t )( { item, field: renderedField } );\n\t\t\t};\n\n\t\tconst filterBy = getFilterBy( field, fieldTypeDefinition );\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\tsetValue,\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:\n\t\t\t\tfield.enableSorting ??\n\t\t\t\tfieldTypeDefinition.enableSorting ??\n\t\t\t\ttrue,\n\t\t\tfilterBy,\n\t\t\treadOnly: field.readOnly ?? fieldTypeDefinition.readOnly ?? false,\n\t\t};\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,OAAOA,sBAAsB,MAAM,eAAe;AAQlD,SAASC,UAAU,QAAQ,qBAAqB;AAChD,SACCC,aAAa,EACbC,gBAAgB,EAChBC,0BAA0B,QACpB,aAAa;AAEpB,MAAMC,cAAc,GACjBC,EAAU,IACZ,CAAE;EAAEC;AAAoB,CAAC,KAAM;EAC9B,MAAMC,IAAI,GAAGF,EAAE,CAACG,KAAK,CAAE,GAAI,CAAC;EAC5B,IAAIC,KAAK,GAAGH,IAAI;EAChB,KAAM,MAAMI,OAAO,IAAIH,IAAI,EAAG;IAC7B,IAAKE,KAAK,CAACE,cAAc,CAAED,OAAQ,CAAC,EAAG;MACtCD,KAAK,GAAGA,KAAK,CAAEC,OAAO,CAAE;IACzB,CAAC,MAAM;MACND,KAAK,GAAGG,SAAS;IAClB;EACD;EAEA,OAAOH,KAAK;AACb,CAAC;AAEF,OAAO,MAAMI,cAAc,GACxBR,EAAU,IACZ,CAAE;EAAEI;AAAsB,CAAC,KAAM;EAChC,MAAMF,IAAI,GAAGF,EAAE,CAACG,KAAK,CAAE,GAAI,CAAC;EAC5B,MAAMM,MAAW,GAAG,CAAC,CAA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C,QAAQ;MACRO,MAAM;MACNN,IAAI;MACJI,OAAO;MACPC,IAAI;MACJK,YAAY,GAAAlB,mBAAA,GAAErB,KAAK,CAACuC,YAAY,cAAAlB,mBAAA,cAAAA,mBAAA,GAAI,IAAI;MACxCmB,aAAa,GAAAlB,IAAA,IAAAC,oBAAA,GACZvB,KAAK,CAACwC,aAAa,cAAAjB,oBAAA,cAAAA,oBAAA,GACnBtB,mBAAmB,CAACuC,aAAa,cAAAlB,IAAA,cAAAA,IAAA,GACjC,IAAI;MACLpB,QAAQ;MACRuC,QAAQ,GAAAjB,KAAA,IAAAC,eAAA,GAAEzB,KAAK,CAACyC,QAAQ,cAAAhB,eAAA,cAAAA,eAAA,GAAIxB,mBAAmB,CAACwC,QAAQ,cAAAjB,KAAA,cAAAA,KAAA,GAAI;IAC7D,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 {\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| 'password'\n\t| 'telephone'\n\t| 'color'\n\t| 'url'\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 interface ViewPickerGrid extends ViewBase {\n\ttype: 'pickerGrid';\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 | ViewPickerGrid;\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 type ViewPickerBaseProps< Item > = Omit<\n\tViewBaseProps< Item >,\n\t| 'view'\n\t| 'onChangeView'\n\t// The following props are not supported for pickers.\n\t| 'isItemClickable'\n\t| 'onClickItem'\n\t| 'renderItemLink'\n\t| 'getItemLevel'\n> & {\n\tview: View;\n\tonChangeView: ( view: View ) => void;\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 interface ViewPickerGridProps< Item >\n\textends Omit< ViewPickerBaseProps< Item >, 'view' > {\n\tview: ViewPickerGrid;\n}\n\nexport type ViewProps< Item > =\n\t| ViewTableProps< Item >\n\t| ViewGridProps< Item >\n\t| ViewListProps< Item >;\n\nexport type ViewPickerProps< Item > = ViewPickerGridProps< Item >;\n\nexport interface SupportedLayouts {\n\tlist?: Omit< ViewList, 'type' >;\n\tgrid?: Omit< ViewGrid, 'type' >;\n\ttable?: Omit< ViewTable, 'type' >;\n\tpickerGrid?: Omit< ViewPickerGrid, 'type' >;\n}\n\n/**\n * DataForm layouts.\n */\nexport type LayoutType = 'regular' | 'panel' | 'card' | 'row';\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 RowLayout = {\n\ttype: 'row';\n\talignment?: 'start' | 'center' | 'end';\n};\nexport type NormalizedRowLayout = {\n\ttype: 'row';\n\talignment: 'start' | 'center' | 'end';\n};\n\nexport type Layout = RegularLayout | PanelLayout | CardLayout | RowLayout;\nexport type NormalizedLayout =\n\t| NormalizedRegularLayout\n\t| NormalizedPanelLayout\n\t| NormalizedCardLayout\n\t| NormalizedRowLayout;\n\nexport type SimpleFormField = {\n\tid: string;\n\tlayout?: Layout;\n};\n\nexport type CombinedFormField = {\n\tid: string;\n\tlabel?: string;\n\tdescription?: 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\n/**\n * Utility type that makes all properties of T optional recursively.\n * Used by field setValue functions to allow partial item updates.\n */\nexport type DeepPartial< T > = {\n\t[ P in keyof T ]?: T[ P ] extends object ? DeepPartial< T[ P ] > : T[ P ];\n};\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| 'password'\n\t| 'telephone'\n\t| 'color'\n\t| 'url'\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:\n\t\t| ComponentType< DataFormControlProps< Item > >\n\t\t| string\n\t\t| EditConfig\n\t\t| 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 * Edit configuration for textarea controls.\n */\nexport type EditConfigTextarea = {\n\tcontrol: 'textarea';\n\t/**\n\t * Number of rows for the textarea.\n\t */\n\trows?: number;\n};\n\n/**\n * Edit configuration for text controls.\n */\nexport type EditConfigText = {\n\tcontrol: 'text';\n\t/**\n\t * Prefix component to display before the input.\n\t */\n\tprefix?: React.ComponentType;\n\t/**\n\t * Suffix component to display after the input.\n\t */\n\tsuffix?: React.ComponentType;\n};\n\n/**\n * Edit configuration for other control types (excluding 'text' and 'textarea').\n */\nexport type EditConfigGeneric = {\n\tcontrol: Exclude< FieldType, 'text' | 'textarea' >;\n};\n\n/**\n * Edit configuration object with type-safe control options.\n * Each control type has its own specific configuration properties.\n */\nexport type EditConfig =\n\t| EditConfigTextarea\n\t| EditConfigText\n\t| EditConfigGeneric;\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 | EditConfig;\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\t/**\n\t * Callback used to set the value of the field on the item.\n\t * Used for editing operations to update field values.\n\t */\n\tsetValue?: ( args: { item: Item; value: any } ) => DeepPartial< Item >;\n};\n\nexport type NormalizedField< Item > = Omit< Field< Item >, 'Edit' > & {\n\tlabel: string;\n\theader: string | ReactElement;\n\tgetValue: ( args: { item: Item } ) => any;\n\tsetValue: ( args: { item: Item; value: any } ) => DeepPartial< Item >;\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: DeepPartial< Item > ) => 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\t/**\n\t * Configuration object for the control.\n\t */\n\tconfig?: {\n\t\tprefix?: React.ComponentType;\n\t\tsuffix?: React.ComponentType;\n\t\trows?: number;\n\t};\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 interface ViewPickerGrid extends ViewBase {\n\ttype: 'pickerGrid';\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 | ViewPickerGrid;\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 type ViewPickerBaseProps< Item > = Omit<\n\tViewBaseProps< Item >,\n\t| 'view'\n\t| 'onChangeView'\n\t// The following props are not supported for pickers.\n\t| 'isItemClickable'\n\t| 'onClickItem'\n\t| 'renderItemLink'\n\t| 'getItemLevel'\n> & {\n\tview: View;\n\tonChangeView: ( view: View ) => void;\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 interface ViewPickerGridProps< Item >\n\textends Omit< ViewPickerBaseProps< Item >, 'view' > {\n\tview: ViewPickerGrid;\n}\n\nexport type ViewProps< Item > =\n\t| ViewTableProps< Item >\n\t| ViewGridProps< Item >\n\t| ViewListProps< Item >;\n\nexport type ViewPickerProps< Item > = ViewPickerGridProps< Item >;\n\nexport interface SupportedLayouts {\n\tlist?: Omit< ViewList, 'type' >;\n\tgrid?: Omit< ViewGrid, 'type' >;\n\ttable?: Omit< ViewTable, 'type' >;\n\tpickerGrid?: Omit< ViewPickerGrid, 'type' >;\n}\n\n/**\n * DataForm layouts.\n */\nexport type LayoutType = 'regular' | 'panel' | 'card' | 'row';\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 RowLayout = {\n\ttype: 'row';\n\talignment?: 'start' | 'center' | 'end';\n};\nexport type NormalizedRowLayout = {\n\ttype: 'row';\n\talignment: 'start' | 'center' | 'end';\n};\n\nexport type Layout = RegularLayout | PanelLayout | CardLayout | RowLayout;\nexport type NormalizedLayout =\n\t| NormalizedRegularLayout\n\t| NormalizedPanelLayout\n\t| NormalizedCardLayout\n\t| NormalizedRowLayout;\n\nexport type SimpleFormField = {\n\tid: string;\n\tlayout?: Layout;\n};\n\nexport type CombinedFormField = {\n\tid: string;\n\tlabel?: string;\n\tdescription?: string;\n\tlayout?: Layout;\n\tchildren: Array< FormField | string >;\n\tsummary?: string | 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":[]}
|
|
@@ -116,4 +116,7 @@ export declare const Validation: {
|
|
|
116
116
|
export declare const Visibility: {
|
|
117
117
|
render: () => import("react").JSX.Element;
|
|
118
118
|
};
|
|
119
|
+
export declare const DataAdapter: {
|
|
120
|
+
render: () => import("react").JSX.Element;
|
|
121
|
+
};
|
|
119
122
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../../src/components/dataform/stories/index.story.tsx"],"names":[],"mappings":"AAeA;;GAEG;AACH,OAAO,QAAQ,MAAM,UAAU,CAAC;AA+1ChC,QAAA,MAAM,IAAI;;;CAGT,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,UAAU;6BAxfuB;QAAE,UAAU,EAAE,OAAO,CAAA;KAAE;;;;;;;;;;;;CAmgBpE,CAAC;AAEF,eAAO,MAAM,WAAW;yCAtgCrB;QACF,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;QAC/C,aAAa,EAAE,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;QACnD,MAAM,EAAE,SAAS,GAAG,UAAU,GAAG,OAAO,CAAC;KACzC;;;;;;;;;;;;;;;;;CAghCA,CAAC;AAEF,eAAO,MAAM,aAAa;iCAtoCvB;QACF,aAAa,EAAE,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;KACnD;;;;;;;;;;CA6oCA,CAAC;AAEF,eAAO,MAAM,SAAS;6BA1VnB;QACF,SAAS,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;KACtC;;;;;;;;;;;;;CAoWA,CAAC;AAEF,eAAO,MAAM,WAAW;;CAEvB,CAAC;AAEF,eAAO,MAAM,UAAU;0CAn7BpB;QACF,QAAQ,EAAE,OAAO,CAAC;QAClB,MAAM,EAAE,OAAO,CAAC;QAChB,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;KAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;CAq8BA,CAAC;AAEF,eAAO,MAAM,UAAU;;CAEtB,CAAC;AA8MF,eAAO,MAAM,WAAW;;CAEvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../../../src/components/dataviews/stories/fixtures.tsx"],"names":[],"mappings":"AAWA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,EAAE,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../../../src/components/dataviews/stories/fixtures.tsx"],"names":[],"mappings":"AAWA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM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AAG,CAAE,EAAE,CAAC;CACjC;AAED,MAAM,CAAC,OAAO,UAAU,WAAW,CAAE,EACpC,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,MAAM,GACN,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"input-widget.d.ts","sourceRoot":"","sources":["../../../src/components/dataviews-filters/input-widget.tsx"],"names":[],"mappings":"AAYA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG3E,UAAU,oBAAoB;IAC7B,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,gBAAgB,CAAC;IACzB,YAAY,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,IAAI,CAAC;IACrC,MAAM,EAAE,eAAe,CAAE,GAAG,CAAE,EAAE,CAAC;CACjC;AAED,MAAM,CAAC,OAAO,UAAU,WAAW,CAAE,EACpC,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,MAAM,GACN,EAAE,oBAAoB,sCAyGtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/array.tsx"],"names":[],"mappings":"AAMA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAErD,MAAM,CAAC,OAAO,UAAU,YAAY,CAAE,IAAI,EAAI,EAC7C,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,mBAAmB,GACnB,EAAE,oBAAoB,CAAE,IAAI,CAAE,+
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/array.tsx"],"names":[],"mappings":"AAMA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAErD,MAAM,CAAC,OAAO,UAAU,YAAY,CAAE,IAAI,EAAI,EAC7C,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,mBAAmB,GACnB,EAAE,oBAAoB,CAAE,IAAI,CAAE,+BAkE9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/checkbox.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/checkbox.tsx"],"names":[],"mappings":"AAWA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAKrD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAE,IAAI,EAAI,EACzC,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,mBAAmB,GACnB,EAAE,oBAAoB,CAAE,IAAI,CAAE,+BAqD9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/color.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/color.tsx"],"names":[],"mappings":"AAgBA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAqDrD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAE,IAAI,EAAI,EACtC,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,mBAAmB,GACnB,EAAE,oBAAoB,CAAE,IAAI,CAAE,+BAsE9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/date.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/date.tsx"],"names":[],"mappings":"AAyCA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAiZrD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAE,IAAI,EAAI,EAC5C,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,mBAAmB,EACnB,QAAQ,GACR,EAAE,oBAAoB,CAAE,IAAI,CAAE,+BA4E9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datetime.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/datetime.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"datetime.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/datetime.tsx"],"names":[],"mappings":"AAkBA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AA6IrD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAE,IAAI,EAAI,EACzC,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,mBAAmB,EACnB,QAAQ,GACR,EAAE,oBAAoB,CAAE,IAAI,CAAE,+BAwC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/email.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/email.tsx"],"names":[],"mappings":"AASA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGrD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAE,IAAI,EAAI,EACtC,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,mBAAmB,GACnB,EAAE,oBAAoB,CAAE,IAAI,CAAE,+BAiB9B"}
|
|
@@ -6,6 +6,6 @@ import type { ComponentType } from 'react';
|
|
|
6
6
|
* Internal dependencies
|
|
7
7
|
*/
|
|
8
8
|
import type { DataFormControlProps, Field, FieldTypeDefinition } from '../types';
|
|
9
|
-
export declare function getControl<Item>(field: Field<Item>, fieldTypeDefinition: FieldTypeDefinition<Item>): ComponentType<DataFormControlProps<any>> | ComponentType<DataFormControlProps<Item>> | null;
|
|
9
|
+
export declare function getControl<Item>(field: Field<Item>, fieldTypeDefinition: FieldTypeDefinition<Item>): ComponentType<DataFormControlProps<any>> | (<Item_1>(props: DataFormControlProps<Item_1>) => import("react").JSX.Element) | ComponentType<DataFormControlProps<Item>> | null;
|
|
10
10
|
export declare function getControlByType(type: string): ComponentType<DataFormControlProps<any>>;
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C;;GAEG;AACH,OAAO,KAAK,EACX,oBAAoB,EACpB,KAAK,EACL,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C;;GAEG;AACH,OAAO,KAAK,EACX,oBAAoB,EACpB,KAAK,EACL,mBAAmB,EAEnB,MAAM,UAAU,CAAC;AA0DlB,wBAAgB,UAAU,CAAE,IAAI,EAC/B,KAAK,EAAE,KAAK,CAAE,IAAI,CAAE,EACpB,mBAAmB,EAAE,mBAAmB,CAAE,IAAI,CAAE,+DARxC,oBAAoB,CAAE,MAAI,CAAE,qFAmCpC;AAED,wBAAgB,gBAAgB,CAAE,IAAI,EAAE,MAAM,4CAM7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integer.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/integer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"integer.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/integer.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAyDrD,MAAM,CAAC,OAAO,UAAU,OAAO,CAAE,IAAI,EAAI,EACxC,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,mBAAmB,EACnB,QAAQ,GACR,EAAE,oBAAoB,CAAE,IAAI,CAAE,+BAoG9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/radio.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"radio.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/radio.tsx"],"names":[],"mappings":"AAWA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAKrD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAE,IAAI,EAAI,EACtC,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,mBAAmB,GACnB,EAAE,oBAAoB,CAAE,IAAI,CAAE,sCA2D9B"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
export type DateRelative = {
|
|
2
|
+
value?: string | number;
|
|
3
|
+
unit?: string;
|
|
4
|
+
};
|
|
1
5
|
interface RelativeDateControlProps {
|
|
2
6
|
id: string;
|
|
3
|
-
value:
|
|
4
|
-
|
|
5
|
-
unit?: string;
|
|
6
|
-
};
|
|
7
|
-
onChange: (value: any) => void;
|
|
7
|
+
value: DateRelative;
|
|
8
|
+
onChange: (args: DateRelative) => void;
|
|
8
9
|
label: string;
|
|
9
10
|
hideLabelFromVision?: boolean;
|
|
10
11
|
options: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relative-date-control.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/relative-date-control.tsx"],"names":[],"mappings":"AAsBA,
|
|
1
|
+
{"version":3,"file":"relative-date-control.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/relative-date-control.tsx"],"names":[],"mappings":"AAsBA,MAAM,MAAM,YAAY,GAAG;IAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,UAAU,wBAAwB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,EAAE,CAAE,IAAI,EAAE,YAAY,KAAM,IAAI,CAAC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;CAa9B,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAE,EAC5C,EAAE,EACF,KAAK,EACL,QAAQ,EACR,KAAK,EACL,mBAAmB,EACnB,OAAO,EACP,SAAS,GACT,EAAE,wBAAwB,+BA8C1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/select.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/select.tsx"],"names":[],"mappings":"AAYA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAKrD,MAAM,CAAC,OAAO,UAAU,MAAM,CAAE,IAAI,EAAI,EACvC,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,mBAAmB,GACnB,EAAE,oBAAoB,CAAE,IAAI,CAAE,+BAgF9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telephone.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/telephone.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"telephone.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/telephone.tsx"],"names":[],"mappings":"AASA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGrD,MAAM,CAAC,OAAO,UAAU,SAAS,CAAE,IAAI,EAAI,EAC1C,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,mBAAmB,GACnB,EAAE,oBAAoB,CAAE,IAAI,CAAE,+BAiB9B"}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import type { DataFormControlProps } from '../types';
|
|
5
|
-
export default function Text<Item>({ data, field, onChange, hideLabelFromVision, }: DataFormControlProps<Item>): import("react").JSX.Element;
|
|
5
|
+
export default function Text<Item>({ data, field, onChange, hideLabelFromVision, config, }: DataFormControlProps<Item>): import("react").JSX.Element;
|
|
6
6
|
//# sourceMappingURL=text.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/text.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/text.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGrD,MAAM,CAAC,OAAO,UAAU,IAAI,CAAE,IAAI,EAAI,EACrC,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,mBAAmB,EACnB,MAAM,GACN,EAAE,oBAAoB,CAAE,IAAI,CAAE,+BAe9B"}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import type { DataFormControlProps } from '../types';
|
|
5
|
-
export default function Textarea<Item>({ data, field, onChange, hideLabelFromVision, }: DataFormControlProps<Item>): import("react").JSX.Element;
|
|
5
|
+
export default function Textarea<Item>({ data, field, onChange, hideLabelFromVision, config, }: DataFormControlProps<Item>): import("react").JSX.Element;
|
|
6
6
|
//# sourceMappingURL=textarea.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textarea.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/textarea.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"textarea.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/textarea.tsx"],"names":[],"mappings":"AAWA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAKrD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAE,IAAI,EAAI,EACzC,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,mBAAmB,EACnB,MAAM,GACN,EAAE,oBAAoB,CAAE,IAAI,CAAE,+BA2D9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-group.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/toggle-group.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"toggle-group.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/toggle-group.tsx"],"names":[],"mappings":"AAcA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAKrD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAE,IAAI,EAAI,EAC5C,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,mBAAmB,GACnB,EAAE,oBAAoB,CAAE,IAAI,CAAE,sCAuE9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/toggle.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"toggle.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/toggle.tsx"],"names":[],"mappings":"AAWA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAKrD,MAAM,CAAC,OAAO,UAAU,MAAM,CAAE,IAAI,EAAI,EACvC,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,mBAAmB,GACnB,EAAE,oBAAoB,CAAE,IAAI,CAAE,+BAsD9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/url.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/url.tsx"],"names":[],"mappings":"AASA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGrD,MAAM,CAAC,OAAO,UAAU,GAAG,CAAE,IAAI,EAAI,EACpC,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,mBAAmB,GACnB,EAAE,oBAAoB,CAAE,IAAI,CAAE,+BAiB9B"}
|
|
@@ -8,13 +8,13 @@ export type DataFormValidatedTextControlProps<Item> = DataFormControlProps<Item>
|
|
|
8
8
|
*/
|
|
9
9
|
type?: 'text' | 'email' | 'tel' | 'url' | 'password';
|
|
10
10
|
/**
|
|
11
|
-
* Optional
|
|
11
|
+
* Optional prefix element to display before the input.
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
prefix?: React.ReactElement;
|
|
14
14
|
/**
|
|
15
|
-
* Optional
|
|
15
|
+
* Optional suffix element to display after the input.
|
|
16
16
|
*/
|
|
17
17
|
suffix?: React.ReactElement;
|
|
18
18
|
};
|
|
19
|
-
export default function ValidatedText<Item>({ data, field, onChange, hideLabelFromVision, type,
|
|
19
|
+
export default function ValidatedText<Item>({ data, field, onChange, hideLabelFromVision, type, prefix, suffix, }: DataFormValidatedTextControlProps<Item>): import("react").JSX.Element;
|
|
20
20
|
//# sourceMappingURL=validated-input.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validated-input.d.ts","sourceRoot":"","sources":["../../../src/dataform-controls/utils/validated-input.tsx"],"names":[],"mappings":"AAWA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAKxD,MAAM,MAAM,iCAAiC,CAAE,IAAI,IAClD,oBAAoB,CAAE,IAAI,CAAE,GAAG;IAC9B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,UAAU,CAAC;IACrD;;OAEG;IACH,
|
|
1
|
+
{"version":3,"file":"validated-input.d.ts","sourceRoot":"","sources":["../../../src/dataform-controls/utils/validated-input.tsx"],"names":[],"mappings":"AAWA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAKxD,MAAM,MAAM,iCAAiC,CAAE,IAAI,IAClD,oBAAoB,CAAE,IAAI,CAAE,GAAG;IAC9B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,UAAU,CAAC;IACrD;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;IAC5B;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;CAC5B,CAAC;AAEH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAE,IAAI,EAAI,EAC9C,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,mBAAmB,EACnB,IAAI,EACJ,MAAM,EACN,MAAM,GACN,EAAE,iCAAiC,CAAE,IAAI,CAAE,+BAiE3C"}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import type { FormField, NormalizedField } from '../../types';
|
|
5
|
-
declare function PanelDropdown<Item>({ fieldDefinition, popoverAnchor, labelPosition, data, onChange, field, }: {
|
|
5
|
+
declare function PanelDropdown<Item>({ fieldDefinition, summaryFields, popoverAnchor, labelPosition, data, onChange, field, }: {
|
|
6
6
|
fieldDefinition: NormalizedField<Item>;
|
|
7
|
+
summaryFields: NormalizedField<Item>[];
|
|
7
8
|
popoverAnchor: HTMLElement | null;
|
|
8
9
|
labelPosition: 'side' | 'top' | 'none';
|
|
9
10
|
data: Item;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../../src/dataforms-layouts/panel/dropdown.tsx"],"names":[],"mappings":"AAeA;;GAEG;AACH,OAAO,KAAK,EAAQ,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../../src/dataforms-layouts/panel/dropdown.tsx"],"names":[],"mappings":"AAeA;;GAEG;AACH,OAAO,KAAK,EAAQ,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAsCpE,iBAAS,aAAa,CAAE,IAAI,EAAI,EAC/B,eAAe,EACf,aAAa,EACb,aAAa,EACb,aAAsB,EACtB,IAAI,EACJ,QAAQ,EACR,KAAK,GACL,EAAE;IACF,eAAe,EAAE,eAAe,CAAE,IAAI,CAAE,CAAC;IACzC,aAAa,EAAE,eAAe,CAAE,IAAI,CAAE,EAAE,CAAC;IACzC,aAAa,EAAE,WAAW,GAAG,IAAI,CAAC;IAClC,aAAa,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;IACvC,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,CAAE,KAAK,EAAE,GAAG,KAAM,IAAI,CAAC;IACjC,KAAK,EAAE,SAAS,CAAC;CACjB,+BA0EA;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dataforms-layouts/panel/index.tsx"],"names":[],"mappings":"AAcA;;GAEG;AACH,OAAO,KAAK,EACX,gBAAgB,EAGhB,MAAM,aAAa,CAAC;AAOrB,MAAM,CAAC,OAAO,UAAU,cAAc,CAAE,IAAI,EAAI,EAC/C,IAAI,EACJ,KAAK,EACL,QAAQ,GACR,EAAE,gBAAgB,CAAE,IAAI,CAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dataforms-layouts/panel/index.tsx"],"names":[],"mappings":"AAcA;;GAEG;AACH,OAAO,KAAK,EACX,gBAAgB,EAGhB,MAAM,aAAa,CAAC;AAOrB,MAAM,CAAC,OAAO,UAAU,cAAc,CAAE,IAAI,EAAI,EAC/C,IAAI,EACJ,KAAK,EACL,QAAQ,GACR,EAAE,gBAAgB,CAAE,IAAI,CAAE,sCAgI1B"}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import type { FormField, NormalizedField } from '../../types';
|
|
5
|
-
declare function PanelModal<Item>({ fieldDefinition, labelPosition, data, onChange, field, }: {
|
|
5
|
+
declare function PanelModal<Item>({ fieldDefinition, summaryFields, labelPosition, data, onChange, field, }: {
|
|
6
6
|
fieldDefinition: NormalizedField<Item>;
|
|
7
|
+
summaryFields: NormalizedField<Item>[];
|
|
7
8
|
labelPosition: 'side' | 'top' | 'none';
|
|
8
9
|
data: Item;
|
|
9
10
|
onChange: (value: any) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/dataforms-layouts/panel/modal.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/dataforms-layouts/panel/modal.tsx"],"names":[],"mappings":"AAiBA;;GAEG;AACH,OAAO,KAAK,EAAQ,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAkFpE,iBAAS,UAAU,CAAE,IAAI,EAAI,EAC5B,eAAe,EACf,aAAa,EACb,aAAa,EACb,IAAI,EACJ,QAAQ,EACR,KAAK,GACL,EAAE;IACF,eAAe,EAAE,eAAe,CAAE,IAAI,CAAE,CAAC;IACzC,aAAa,EAAE,eAAe,CAAE,IAAI,CAAE,EAAE,CAAC;IACzC,aAAa,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;IACvC,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,CAAE,KAAK,EAAE,GAAG,KAAM,IAAI,CAAC;IACjC,KAAK,EAAE,SAAS,CAAC;CACjB,+BAwCA;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { NormalizedField } from '../../types';
|
|
5
|
+
declare function SummaryButton<Item>({ summaryFields, data, labelPosition, fieldLabel, disabled, onClick, 'aria-expanded': ariaExpanded, }: {
|
|
6
|
+
summaryFields: NormalizedField<Item>[];
|
|
7
|
+
data: Item;
|
|
8
|
+
labelPosition: 'side' | 'top' | 'none';
|
|
9
|
+
fieldLabel?: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
onClick: () => void;
|
|
12
|
+
'aria-expanded'?: boolean;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
14
|
+
export default SummaryButton;
|
|
15
|
+
//# sourceMappingURL=summary-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summary-button.d.ts","sourceRoot":"","sources":["../../../src/dataforms-layouts/panel/summary-button.tsx"],"names":[],"mappings":"AAMA;;GAEG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,iBAAS,aAAa,CAAE,IAAI,EAAI,EAC/B,aAAa,EACb,IAAI,EACJ,aAAa,EACb,UAAU,EACV,QAAQ,EACR,OAAO,EACP,eAAe,EAAE,YAAY,GAC7B,EAAE;IACF,aAAa,EAAE,eAAe,CAAE,IAAI,CAAE,EAAE,CAAC;IACzC,IAAI,EAAE,IAAI,CAAC;IACX,aAAa,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC1B,+BA8DA;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/field-types/stories/index.story.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/field-types/stories/index.story.tsx"],"names":[],"mappings":"AAiBA,OAAO,QAAQ,MAAM,iCAAiC,CAAC;AAIvD,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;CAsCT,CAAC;AACF,eAAe,IAAI,CAAC;AA2apB,KAAK,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC;AACtC,KAAK,YAAY,GACd,SAAS,GACT,OAAO,GACP,UAAU,GACV,OAAO,GACP,MAAM,GACN,UAAU,GACV,OAAO,GACP,SAAS,GACT,UAAU,GACV,OAAO,GACP,QAAQ,GACR,WAAW,GACX,KAAK,GACL,MAAM,GACN,QAAQ,GACR,aAAa,CAAC;AAwHjB,eAAO,MAAM,GAAG,oBAGb;IACF,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,YAAY,CAAC;CACnB,gCAEA,CAAC;AAEF,eAAO,MAAM,IAAI,oBAGd;IACF,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,YAAY,CAAC;CACnB,gCAOA,CAAC;AAEF,eAAO,MAAM,OAAO,oBAGjB;IACF,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,YAAY,CAAC;CACnB,gCASA,CAAC;AAEF,eAAO,MAAM,OAAO,oBAGjB;IACF,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,YAAY,CAAC;CACnB,gCASA,CAAC;AAEF,eAAO,MAAM,QAAQ,oBAGlB;IACF,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,YAAY,CAAC;CACnB,gCASA,CAAC;AAEF,eAAO,MAAM,IAAI,oBAGd;IACF,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,YAAY,CAAC;CACnB,gCAOA,CAAC;AAEF,eAAO,MAAM,KAAK,oBAGf;IACF,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,YAAY,CAAC;CACnB,gCASA,CAAC;AAEF,eAAO,MAAM,SAAS,oBAGnB;IACF,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,YAAY,CAAC;CACnB,gCAaA,CAAC;AAEF,eAAO,MAAM,GAAG,oBAGb;IACF,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,YAAY,CAAC;CACnB,gCAOA,CAAC;AAEF,eAAO,MAAM,KAAK,oBAGf;IACF,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,YAAY,CAAC;CACnB,gCASA,CAAC;AAEF,eAAO,MAAM,KAAK,oBAGf;IACF,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,YAAY,CAAC;CACnB,gCASA,CAAC;AAEF,eAAO,MAAM,KAAK,oBAGf;IACF,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,YAAY,CAAC;CACnB,gCAaA,CAAC;AAEF,eAAO,MAAM,QAAQ,oBAGlB;IACF,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,YAAY,CAAC;CACnB,gCASA,CAAC;AAEF,eAAO,MAAM,MAAM,oBAGhB;IACF,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,YAAY,CAAC;CACnB,gCASA,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-fields.d.ts","sourceRoot":"","sources":["../src/normalize-fields.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAEX,KAAK,EAGL,eAAe,EACf,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"normalize-fields.d.ts","sourceRoot":"","sources":["../src/normalize-fields.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAEX,KAAK,EAGL,eAAe,EACf,MAAM,SAAS,CAAC;AAwBjB,eAAO,MAAM,cAAc,OACpB,MAAM,iBACC;IAAE,KAAK,EAAE,GAAG,CAAA;CAAE,QAY1B,CAAC;AA+EH;;;;;GAKG;AACH,wBAAgB,eAAe,CAAE,IAAI,EACpC,MAAM,EAAE,KAAK,CAAE,IAAI,CAAE,EAAE,GACrB,eAAe,CAAE,IAAI,CAAE,EAAE,CA2D3B"}
|
package/build-types/types.d.ts
CHANGED
|
@@ -10,6 +10,13 @@ import type { SetSelection } from './private-types';
|
|
|
10
10
|
* WordPress dependencies
|
|
11
11
|
*/
|
|
12
12
|
import type { useFocusOnMount } from '@wordpress/compose';
|
|
13
|
+
/**
|
|
14
|
+
* Utility type that makes all properties of T optional recursively.
|
|
15
|
+
* Used by field setValue functions to allow partial item updates.
|
|
16
|
+
*/
|
|
17
|
+
export type DeepPartial<T> = {
|
|
18
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
19
|
+
};
|
|
13
20
|
export type SortDirection = 'asc' | 'desc';
|
|
14
21
|
/**
|
|
15
22
|
* Generic option type.
|
|
@@ -72,7 +79,7 @@ export type FieldTypeDefinition<Item> = {
|
|
|
72
79
|
/**
|
|
73
80
|
* Callback used to render an edit control for the field or control name.
|
|
74
81
|
*/
|
|
75
|
-
Edit: ComponentType<DataFormControlProps<Item>> | string | null;
|
|
82
|
+
Edit: ComponentType<DataFormControlProps<Item>> | string | EditConfig | null;
|
|
76
83
|
/**
|
|
77
84
|
* Callback used to render the field.
|
|
78
85
|
*/
|
|
@@ -95,6 +102,41 @@ export type Rules<Item> = {
|
|
|
95
102
|
required?: boolean;
|
|
96
103
|
custom?: (item: Item, field: NormalizedField<Item>) => null | string;
|
|
97
104
|
};
|
|
105
|
+
/**
|
|
106
|
+
* Edit configuration for textarea controls.
|
|
107
|
+
*/
|
|
108
|
+
export type EditConfigTextarea = {
|
|
109
|
+
control: 'textarea';
|
|
110
|
+
/**
|
|
111
|
+
* Number of rows for the textarea.
|
|
112
|
+
*/
|
|
113
|
+
rows?: number;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Edit configuration for text controls.
|
|
117
|
+
*/
|
|
118
|
+
export type EditConfigText = {
|
|
119
|
+
control: 'text';
|
|
120
|
+
/**
|
|
121
|
+
* Prefix component to display before the input.
|
|
122
|
+
*/
|
|
123
|
+
prefix?: React.ComponentType;
|
|
124
|
+
/**
|
|
125
|
+
* Suffix component to display after the input.
|
|
126
|
+
*/
|
|
127
|
+
suffix?: React.ComponentType;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Edit configuration for other control types (excluding 'text' and 'textarea').
|
|
131
|
+
*/
|
|
132
|
+
export type EditConfigGeneric = {
|
|
133
|
+
control: Exclude<FieldType, 'text' | 'textarea'>;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Edit configuration object with type-safe control options.
|
|
137
|
+
* Each control type has its own specific configuration properties.
|
|
138
|
+
*/
|
|
139
|
+
export type EditConfig = EditConfigTextarea | EditConfigText | EditConfigGeneric;
|
|
98
140
|
/**
|
|
99
141
|
* A dataview field for a specific property of a data type.
|
|
100
142
|
*/
|
|
@@ -131,7 +173,7 @@ export type Field<Item> = {
|
|
|
131
173
|
/**
|
|
132
174
|
* Callback used to render an edit control for the field.
|
|
133
175
|
*/
|
|
134
|
-
Edit?: ComponentType<DataFormControlProps<Item>> | string;
|
|
176
|
+
Edit?: ComponentType<DataFormControlProps<Item>> | string | EditConfig;
|
|
135
177
|
/**
|
|
136
178
|
* Callback used to sort the field.
|
|
137
179
|
*/
|
|
@@ -176,6 +218,14 @@ export type Field<Item> = {
|
|
|
176
218
|
getValue?: (args: {
|
|
177
219
|
item: Item;
|
|
178
220
|
}) => any;
|
|
221
|
+
/**
|
|
222
|
+
* Callback used to set the value of the field on the item.
|
|
223
|
+
* Used for editing operations to update field values.
|
|
224
|
+
*/
|
|
225
|
+
setValue?: (args: {
|
|
226
|
+
item: Item;
|
|
227
|
+
value: any;
|
|
228
|
+
}) => DeepPartial<Item>;
|
|
179
229
|
};
|
|
180
230
|
export type NormalizedField<Item> = Omit<Field<Item>, 'Edit'> & {
|
|
181
231
|
label: string;
|
|
@@ -183,6 +233,10 @@ export type NormalizedField<Item> = Omit<Field<Item>, 'Edit'> & {
|
|
|
183
233
|
getValue: (args: {
|
|
184
234
|
item: Item;
|
|
185
235
|
}) => any;
|
|
236
|
+
setValue: (args: {
|
|
237
|
+
item: Item;
|
|
238
|
+
value: any;
|
|
239
|
+
}) => DeepPartial<Item>;
|
|
186
240
|
render: ComponentType<DataViewRenderFieldProps<Item>>;
|
|
187
241
|
Edit: ComponentType<DataFormControlProps<Item>> | null;
|
|
188
242
|
sort: (a: Item, b: Item, direction: SortDirection) => number;
|
|
@@ -200,7 +254,7 @@ export type Data<Item> = Item[];
|
|
|
200
254
|
export type DataFormControlProps<Item> = {
|
|
201
255
|
data: Item;
|
|
202
256
|
field: NormalizedField<Item>;
|
|
203
|
-
onChange: (value:
|
|
257
|
+
onChange: (value: DeepPartial<Item>) => void;
|
|
204
258
|
hideLabelFromVision?: boolean;
|
|
205
259
|
/**
|
|
206
260
|
* The currently selected filter operator for this field.
|
|
@@ -208,6 +262,14 @@ export type DataFormControlProps<Item> = {
|
|
|
208
262
|
* Used by DataViews filters to determine which control to render based on the operator type.
|
|
209
263
|
*/
|
|
210
264
|
operator?: Operator;
|
|
265
|
+
/**
|
|
266
|
+
* Configuration object for the control.
|
|
267
|
+
*/
|
|
268
|
+
config?: {
|
|
269
|
+
prefix?: React.ComponentType;
|
|
270
|
+
suffix?: React.ComponentType;
|
|
271
|
+
rows?: number;
|
|
272
|
+
};
|
|
211
273
|
};
|
|
212
274
|
export type DataViewRenderFieldProps<Item> = {
|
|
213
275
|
item: Item;
|
|
@@ -599,6 +661,7 @@ export type CombinedFormField = {
|
|
|
599
661
|
description?: string;
|
|
600
662
|
layout?: Layout;
|
|
601
663
|
children: Array<FormField | string>;
|
|
664
|
+
summary?: string | string[];
|
|
602
665
|
};
|
|
603
666
|
export type FormField = SimpleFormField | CombinedFormField;
|
|
604
667
|
/**
|