@wordpress/dataviews 7.0.1-next.0f6f9d12c.0 → 7.0.1-next.f34ab90e9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -1
- package/build/components/dataviews-item-actions/index.js +1 -10
- package/build/components/dataviews-item-actions/index.js.map +1 -1
- package/build/dataform-controls/boolean.js +15 -7
- package/build/dataform-controls/boolean.js.map +1 -1
- package/build/dataform-controls/email.js +14 -7
- package/build/dataform-controls/email.js.map +1 -1
- package/build/dataform-controls/integer.js +14 -7
- package/build/dataform-controls/integer.js.map +1 -1
- package/build/dataform-controls/text.js +14 -7
- package/build/dataform-controls/text.js.map +1 -1
- package/build/dataforms-layouts/panel/dropdown.js +124 -0
- package/build/dataforms-layouts/panel/dropdown.js.map +1 -0
- package/build/dataforms-layouts/panel/index.js +19 -127
- package/build/dataforms-layouts/panel/index.js.map +1 -1
- package/build/dataforms-layouts/panel/modal.js +125 -0
- package/build/dataforms-layouts/panel/modal.js.map +1 -0
- package/build/normalize-form-fields.js +3 -2
- package/build/normalize-form-fields.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build-module/components/dataviews-item-actions/index.js +1 -10
- package/build-module/components/dataviews-item-actions/index.js.map +1 -1
- package/build-module/dataform-controls/boolean.js +15 -7
- package/build-module/dataform-controls/boolean.js.map +1 -1
- package/build-module/dataform-controls/email.js +15 -8
- package/build-module/dataform-controls/email.js.map +1 -1
- package/build-module/dataform-controls/integer.js +15 -8
- package/build-module/dataform-controls/integer.js.map +1 -1
- package/build-module/dataform-controls/text.js +15 -8
- package/build-module/dataform-controls/text.js.map +1 -1
- package/build-module/dataforms-layouts/panel/dropdown.js +118 -0
- package/build-module/dataforms-layouts/panel/dropdown.js.map +1 -0
- package/build-module/dataforms-layouts/panel/index.js +23 -131
- package/build-module/dataforms-layouts/panel/index.js.map +1 -1
- package/build-module/dataforms-layouts/panel/modal.js +119 -0
- package/build-module/dataforms-layouts/panel/modal.js.map +1 -0
- package/build-module/normalize-form-fields.js +3 -2
- package/build-module/normalize-form-fields.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-style/style-rtl.css +4 -0
- package/build-style/style.css +4 -0
- package/build-types/components/dataform/stories/index.story.d.ts +58 -25
- package/build-types/components/dataform/stories/index.story.d.ts.map +1 -1
- package/build-types/components/dataviews-item-actions/index.d.ts.map +1 -1
- package/build-types/dataform-controls/boolean.d.ts.map +1 -1
- package/build-types/dataform-controls/email.d.ts.map +1 -1
- package/build-types/dataform-controls/integer.d.ts.map +1 -1
- package/build-types/dataform-controls/text.d.ts.map +1 -1
- package/build-types/dataforms-layouts/panel/dropdown.d.ts +14 -0
- package/build-types/dataforms-layouts/panel/dropdown.d.ts.map +1 -0
- package/build-types/dataforms-layouts/panel/index.d.ts.map +1 -1
- package/build-types/dataforms-layouts/panel/modal.d.ts +13 -0
- package/build-types/dataforms-layouts/panel/modal.d.ts.map +1 -0
- package/build-types/normalize-form-fields.d.ts.map +1 -1
- package/build-types/types.d.ts +2 -0
- package/build-types/types.d.ts.map +1 -1
- package/build-wp/index.js +394 -178
- package/package.json +15 -15
- package/src/components/dataform/stories/index.story.tsx +354 -219
- package/src/components/dataviews-item-actions/index.tsx +7 -16
- package/src/dataform-controls/boolean.tsx +24 -10
- package/src/dataform-controls/email.tsx +24 -11
- package/src/dataform-controls/integer.tsx +27 -13
- package/src/dataform-controls/text.tsx +24 -11
- package/src/dataforms-layouts/panel/dropdown.tsx +160 -0
- package/src/dataforms-layouts/panel/index.tsx +28 -172
- package/src/dataforms-layouts/panel/modal.tsx +165 -0
- package/src/dataforms-layouts/panel/style.scss +4 -0
- package/src/normalize-form-fields.ts +1 -0
- package/src/test/dataform.tsx +169 -0
- package/src/test/normalize-form-fields.ts +15 -3
- package/src/types.ts +2 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","__experimentalVStack","VStack","__experimentalHStack","HStack","__experimentalHeading","Heading","__experimentalSpacer","Spacer","Dropdown","Button","sprintf","__","_x","useState","useMemo","useContext","closeSmall","DataFormContext","DataFormLayout","isCombinedField","DEFAULT_LAYOUT","normalizeLayout","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","DropdownHeader","title","onClose","className","spacing","children","alignment","level","size","label","icon","onClick","PanelDropdown","fieldDefinition","popoverAnchor","labelPosition","data","onChange","field","fieldLabel","form","layout","fields","id","popoverProps","anchor","placement","offset","shift","contentClassName","focusOnMount","toggleProps","variant","tooltipPosition","renderToggle","isOpen","onToggle","includes","disabled","readOnly","accessibleWhenDisabled","render","item","renderContent","FieldLayout","nestedField","_form$fields","hideLabelFromVision","length","FormPanelField","find","_field","simpleChildren","filter","child","firstChildFieldId","setPopoverAnchor","type","labelClassName","style","paddingBottom","ref"],"sources":["@wordpress/dataviews/src/dataforms-layouts/panel/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n\t__experimentalHeading as Heading,\n\t__experimentalSpacer as Spacer,\n\tDropdown,\n\tButton,\n} from '@wordpress/components';\nimport { sprintf, __, _x } from '@wordpress/i18n';\nimport { useState, useMemo, useContext } from '@wordpress/element';\nimport { closeSmall } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tForm,\n\tFormField,\n\tFieldLayoutProps,\n\tNormalizedPanelLayout,\n\tNormalizedField,\n\tSimpleFormField,\n} from '../../types';\nimport DataFormContext from '../../components/dataform-context';\nimport { DataFormLayout } from '../data-form-layout';\nimport { isCombinedField } from '../is-combined-field';\nimport { DEFAULT_LAYOUT, normalizeLayout } from '../../normalize-form-fields';\n\nfunction DropdownHeader( {\n\ttitle,\n\tonClose,\n}: {\n\ttitle?: string;\n\tonClose: () => void;\n} ) {\n\treturn (\n\t\t<VStack\n\t\t\tclassName=\"dataforms-layouts-panel__dropdown-header\"\n\t\t\tspacing={ 4 }\n\t\t>\n\t\t\t<HStack alignment=\"center\">\n\t\t\t\t{ title && (\n\t\t\t\t\t<Heading level={ 2 } size={ 13 }>\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</Heading>\n\t\t\t\t) }\n\t\t\t\t<Spacer />\n\t\t\t\t{ onClose && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tlabel={ __( 'Close' ) }\n\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t</VStack>\n\t);\n}\n\nfunction PanelDropdown< Item >( {\n\tfieldDefinition,\n\tpopoverAnchor,\n\tlabelPosition = 'side',\n\tdata,\n\tonChange,\n\tfield,\n}: {\n\tfieldDefinition: NormalizedField< Item >;\n\tpopoverAnchor: HTMLElement | null;\n\tlabelPosition: 'side' | 'top' | 'none';\n\tdata: Item;\n\tonChange: ( value: any ) => void;\n\tfield: FormField;\n} ) {\n\tconst fieldLabel = isCombinedField( field )\n\t\t? field.label\n\t\t: fieldDefinition?.label;\n\n\tconst form: Form = useMemo(\n\t\t(): Form => ( {\n\t\t\tlayout: DEFAULT_LAYOUT,\n\t\t\tfields: isCombinedField( field )\n\t\t\t\t? field.children\n\t\t\t\t: // If not explicit children return the field id itself.\n\t\t\t\t [ { id: field.id } ],\n\t\t} ),\n\t\t[ field ]\n\t);\n\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\n\treturn (\n\t\t<Dropdown\n\t\t\tcontentClassName=\"dataforms-layouts-panel__field-dropdown\"\n\t\t\tpopoverProps={ popoverProps }\n\t\t\tfocusOnMount\n\t\t\ttoggleProps={ {\n\t\t\t\tsize: 'compact',\n\t\t\t\tvariant: 'tertiary',\n\t\t\t\ttooltipPosition: 'middle left',\n\t\t\t} }\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"dataforms-layouts-panel__field-control\"\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\tvariant={\n\t\t\t\t\t\t[ 'none', 'top' ].includes( labelPosition )\n\t\t\t\t\t\t\t? 'link'\n\t\t\t\t\t\t\t: 'tertiary'\n\t\t\t\t\t}\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t// translators: %s: Field name.\n\t\t\t\t\t\t_x( 'Edit %s', 'field' ),\n\t\t\t\t\t\tfieldLabel || ''\n\t\t\t\t\t) }\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\tdisabled={ fieldDefinition.readOnly === true }\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t>\n\t\t\t\t\t<fieldDefinition.render\n\t\t\t\t\t\titem={ data }\n\t\t\t\t\t\tfield={ fieldDefinition }\n\t\t\t\t\t/>\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<DropdownHeader title={ fieldLabel } onClose={ onClose } />\n\t\t\t\t\t<DataFormLayout\n\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\tform={ form }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ( FieldLayout, nestedField ) => (\n\t\t\t\t\t\t\t<FieldLayout\n\t\t\t\t\t\t\t\tkey={ nestedField.id }\n\t\t\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\t\t\tfield={ nestedField }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\thideLabelFromVision={\n\t\t\t\t\t\t\t\t\t( form?.fields ?? [] ).length < 2\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</DataFormLayout>\n\t\t\t\t</>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default function FormPanelField< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n}: FieldLayoutProps< Item > ) {\n\tconst { fields } = useContext( DataFormContext );\n\tconst fieldDefinition = fields.find( ( _field ) => {\n\t\t// Default to the first simple child if it is a combined field.\n\t\tif ( isCombinedField( field ) ) {\n\t\t\tconst simpleChildren = field.children.filter(\n\t\t\t\t( child ): child is string | SimpleFormField =>\n\t\t\t\t\ttypeof child === 'string' || ! isCombinedField( child )\n\t\t\t);\n\n\t\t\tif ( simpleChildren.length === 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst firstChildFieldId =\n\t\t\t\ttypeof simpleChildren[ 0 ] === 'string'\n\t\t\t\t\t? simpleChildren[ 0 ]\n\t\t\t\t\t: simpleChildren[ 0 ].id;\n\t\t\treturn _field.id === firstChildFieldId;\n\t\t}\n\n\t\treturn _field.id === field.id;\n\t} );\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState< HTMLElement | null >(\n\t\tnull\n\t);\n\n\tif ( ! fieldDefinition ) {\n\t\treturn null;\n\t}\n\n\tconst layout: NormalizedPanelLayout = normalizeLayout( {\n\t\t...field.layout,\n\t\ttype: 'panel',\n\t} ) as NormalizedPanelLayout;\n\n\tconst labelPosition = layout.labelPosition;\n\tconst labelClassName = clsx(\n\t\t'dataforms-layouts-panel__field-label',\n\t\t`dataforms-layouts-panel__field-label--label-position-${ labelPosition }`\n\t);\n\tconst fieldLabel = isCombinedField( field )\n\t\t? field.label\n\t\t: fieldDefinition?.label;\n\n\tif ( labelPosition === 'top' ) {\n\t\treturn (\n\t\t\t<VStack className=\"dataforms-layouts-panel__field\" spacing={ 0 }>\n\t\t\t\t<div\n\t\t\t\t\tclassName={ labelClassName }\n\t\t\t\t\tstyle={ { paddingBottom: 0 } }\n\t\t\t\t>\n\t\t\t\t\t{ fieldLabel }\n\t\t\t\t</div>\n\t\t\t\t<div className=\"dataforms-layouts-panel__field-control\">\n\t\t\t\t\t<PanelDropdown\n\t\t\t\t\t\tfield={ field }\n\t\t\t\t\t\tpopoverAnchor={ popoverAnchor }\n\t\t\t\t\t\tfieldDefinition={ fieldDefinition }\n\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tlabelPosition={ labelPosition }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</VStack>\n\t\t);\n\t}\n\n\tif ( labelPosition === 'none' ) {\n\t\treturn (\n\t\t\t<div className=\"dataforms-layouts-panel__field\">\n\t\t\t\t<PanelDropdown\n\t\t\t\t\tfield={ field }\n\t\t\t\t\tpopoverAnchor={ popoverAnchor }\n\t\t\t\t\tfieldDefinition={ fieldDefinition }\n\t\t\t\t\tdata={ data }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tlabelPosition={ labelPosition }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Defaults to label position side.\n\treturn (\n\t\t<HStack\n\t\t\tref={ setPopoverAnchor }\n\t\t\tclassName=\"dataforms-layouts-panel__field\"\n\t\t>\n\t\t\t<div className={ labelClassName }>{ fieldLabel }</div>\n\t\t\t<div className=\"dataforms-layouts-panel__field-control\">\n\t\t\t\t<PanelDropdown\n\t\t\t\t\tfield={ field }\n\t\t\t\t\tpopoverAnchor={ popoverAnchor }\n\t\t\t\t\tfieldDefinition={ fieldDefinition }\n\t\t\t\t\tdata={ data }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tlabelPosition={ labelPosition }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</HStack>\n\t);\n}\n"],"mappings":"A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AAE;QAAE,CAAG;QAAAvD,QAAA,EAE5Bc;MAAU,CACR,CAAC,eACNxB,IAAA;QAAKQ,SAAS,EAAC,wCAAwC;QAAAE,QAAA,eACtDV,IAAA,CAACiB,aAAa;UACbM,KAAK,EAAGA,KAAO;UACfJ,aAAa,EAAGA,aAAe;UAC/BD,eAAe,EAAGA,eAAiB;UACnCG,IAAI,EAAGA,IAAM;UACbC,QAAQ,EAAGA,QAAU;UACrBF,aAAa,EAAGA;QAAe,CAC/B;MAAC,CACE,CAAC;IAAA,CACC,CAAC;EAEX;EAEA,IAAKA,aAAa,KAAK,MAAM,EAAG;IAC/B,oBACCpB,IAAA;MAAKQ,SAAS,EAAC,gCAAgC;MAAAE,QAAA,eAC9CV,IAAA,CAACiB,aAAa;QACbM,KAAK,EAAGA,KAAO;QACfJ,aAAa,EAAGA,aAAe;QAC/BD,eAAe,EAAGA,eAAiB;QACnCG,IAAI,EAAGA,IAAM;QACbC,QAAQ,EAAGA,QAAU;QACrBF,aAAa,EAAGA;MAAe,CAC/B;IAAC,CACE,CAAC;EAER;;EAEA;EACA,oBACClB,KAAA,CAACtB,MAAM;IACNsF,GAAG,EAAGL,gBAAkB;IACxBrD,SAAS,EAAC,gCAAgC;IAAAE,QAAA,gBAE1CV,IAAA;MAAKQ,SAAS,EAAGuD,cAAgB;MAAArD,QAAA,EAAGc;IAAU,CAAO,CAAC,eACtDxB,IAAA;MAAKQ,SAAS,EAAC,wCAAwC;MAAAE,QAAA,eACtDV,IAAA,CAACiB,aAAa;QACbM,KAAK,EAAGA,KAAO;QACfJ,aAAa,EAAGA,aAAe;QAC/BD,eAAe,EAAGA,eAAiB;QACnCG,IAAI,EAAGA,IAAM;QACbC,QAAQ,EAAGA,QAAU;QACrBF,aAAa,EAAGA;MAAe,CAC/B;IAAC,CACE,CAAC;EAAA,CACC,CAAC;AAEX","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","__experimentalVStack","VStack","__experimentalHStack","HStack","useState","useContext","DataFormContext","isCombinedField","normalizeLayout","PanelDropdown","PanelModal","jsx","_jsx","jsxs","_jsxs","FormPanelField","data","field","onChange","fields","fieldDefinition","find","_field","simpleChildren","children","filter","child","length","firstChildFieldId","id","popoverAnchor","setPopoverAnchor","layout","type","labelPosition","labelClassName","fieldLabel","label","renderedControl","openAs","className","spacing","style","paddingBottom","ref"],"sources":["@wordpress/dataviews/src/dataforms-layouts/panel/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { useState, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tFieldLayoutProps,\n\tNormalizedPanelLayout,\n\tSimpleFormField,\n} from '../../types';\nimport DataFormContext from '../../components/dataform-context';\nimport { isCombinedField } from '../is-combined-field';\nimport { normalizeLayout } from '../../normalize-form-fields';\nimport PanelDropdown from './dropdown';\nimport PanelModal from './modal';\n\nexport default function FormPanelField< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n}: FieldLayoutProps< Item > ) {\n\tconst { fields } = useContext( DataFormContext );\n\tconst fieldDefinition = fields.find( ( _field ) => {\n\t\t// Default to the first simple child if it is a combined field.\n\t\tif ( isCombinedField( field ) ) {\n\t\t\tconst simpleChildren = field.children.filter(\n\t\t\t\t( child ): child is string | SimpleFormField =>\n\t\t\t\t\ttypeof child === 'string' || ! isCombinedField( child )\n\t\t\t);\n\n\t\t\tif ( simpleChildren.length === 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst firstChildFieldId =\n\t\t\t\ttypeof simpleChildren[ 0 ] === 'string'\n\t\t\t\t\t? simpleChildren[ 0 ]\n\t\t\t\t\t: simpleChildren[ 0 ].id;\n\n\t\t\treturn _field.id === firstChildFieldId;\n\t\t}\n\n\t\treturn _field.id === field.id;\n\t} );\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState< HTMLElement | null >(\n\t\tnull\n\t);\n\n\tif ( ! fieldDefinition ) {\n\t\treturn null;\n\t}\n\n\tconst layout: NormalizedPanelLayout = normalizeLayout( {\n\t\t...field.layout,\n\t\ttype: 'panel',\n\t} ) as NormalizedPanelLayout;\n\n\tconst labelPosition = layout.labelPosition;\n\tconst labelClassName = clsx(\n\t\t'dataforms-layouts-panel__field-label',\n\t\t`dataforms-layouts-panel__field-label--label-position-${ labelPosition }`\n\t);\n\tconst fieldLabel = isCombinedField( field )\n\t\t? field.label\n\t\t: fieldDefinition?.label;\n\n\tconst renderedControl =\n\t\tlayout.openAs === 'modal' ? (\n\t\t\t<PanelModal\n\t\t\t\tfield={ field }\n\t\t\t\tfieldDefinition={ fieldDefinition }\n\t\t\t\tdata={ data }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tlabelPosition={ labelPosition }\n\t\t\t/>\n\t\t) : (\n\t\t\t<PanelDropdown\n\t\t\t\tfield={ field }\n\t\t\t\tpopoverAnchor={ popoverAnchor }\n\t\t\t\tfieldDefinition={ fieldDefinition }\n\t\t\t\tdata={ data }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tlabelPosition={ labelPosition }\n\t\t\t/>\n\t\t);\n\n\tif ( labelPosition === 'top' ) {\n\t\treturn (\n\t\t\t<VStack className=\"dataforms-layouts-panel__field\" spacing={ 0 }>\n\t\t\t\t<div\n\t\t\t\t\tclassName={ labelClassName }\n\t\t\t\t\tstyle={ { paddingBottom: 0 } }\n\t\t\t\t>\n\t\t\t\t\t{ fieldLabel }\n\t\t\t\t</div>\n\t\t\t\t<div className=\"dataforms-layouts-panel__field-control\">\n\t\t\t\t\t{ renderedControl }\n\t\t\t\t</div>\n\t\t\t</VStack>\n\t\t);\n\t}\n\n\tif ( labelPosition === 'none' ) {\n\t\treturn (\n\t\t\t<div className=\"dataforms-layouts-panel__field\">\n\t\t\t\t{ renderedControl }\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Defaults to label position side.\n\treturn (\n\t\t<HStack\n\t\t\tref={ setPopoverAnchor }\n\t\t\tclassName=\"dataforms-layouts-panel__field\"\n\t\t>\n\t\t\t<div className={ labelClassName }>{ fieldLabel }</div>\n\t\t\t<div className=\"dataforms-layouts-panel__field-control\">\n\t\t\t\t{ renderedControl }\n\t\t\t</div>\n\t\t</HStack>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SACCC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,QAAQ,EAAEC,UAAU,QAAQ,oBAAoB;;AAEzD;AACA;AACA;;AAMA,OAAOC,eAAe,MAAM,mCAAmC;AAC/D,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,eAAe,QAAQ,6BAA6B;AAC7D,OAAOC,aAAa,MAAM,YAAY;AACtC,OAAOC,UAAU,MAAM,SAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAEjC,eAAe,SAASC,cAAcA,CAAU;EAC/CC,IAAI;EACJC,KAAK;EACLC;AACyB,CAAC,EAAG;EAC7B,MAAM;IAAEC;EAAO,CAAC,GAAGd,UAAU,CAAEC,eAAgB,CAAC;EAChD,MAAMc,eAAe,GAAGD,MAAM,CAACE,IAAI,CAAIC,MAAM,IAAM;IAClD;IACA,IAAKf,eAAe,CAAEU,KAAM,CAAC,EAAG;MAC/B,MAAMM,cAAc,GAAGN,KAAK,CAACO,QAAQ,CAACC,MAAM,CACzCC,KAAK,IACN,OAAOA,KAAK,KAAK,QAAQ,IAAI,CAAEnB,eAAe,CAAEmB,KAAM,CACxD,CAAC;MAED,IAAKH,cAAc,CAACI,MAAM,KAAK,CAAC,EAAG;QAClC,OAAO,KAAK;MACb;MAEA,MAAMC,iBAAiB,GACtB,OAAOL,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AAM;MAACuC,SAAS,EAAC,gCAAgC;MAACC,OAAO,EAAG,CAAG;MAAAjB,QAAA,gBAC/DZ,IAAA;QACC4B,SAAS,EAAGL,cAAgB;QAC5BO,KAAK,EAAG;UAAEC,aAAa,EAAE;QAAE,CAAG;QAAAnB,QAAA,EAE5BY;MAAU,CACR,CAAC,eACNxB,IAAA;QAAK4B,SAAS,EAAC,wCAAwC;QAAAhB,QAAA,EACpDc;MAAe,CACb,CAAC;IAAA,CACC,CAAC;EAEX;EAEA,IAAKJ,aAAa,KAAK,MAAM,EAAG;IAC/B,oBACCtB,IAAA;MAAK4B,SAAS,EAAC,gCAAgC;MAAAhB,QAAA,EAC5Cc;IAAe,CACb,CAAC;EAER;;EAEA;EACA,oBACCxB,KAAA,CAACX,MAAM;IACNyC,GAAG,EAAGb,gBAAkB;IACxBS,SAAS,EAAC,gCAAgC;IAAAhB,QAAA,gBAE1CZ,IAAA;MAAK4B,SAAS,EAAGL,cAAgB;MAAAX,QAAA,EAAGY;IAAU,CAAO,CAAC,eACtDxB,IAAA;MAAK4B,SAAS,EAAC,wCAAwC;MAAAhB,QAAA,EACpDc;IAAe,CACb,CAAC;EAAA,CACC,CAAC;AAEX","ignoreList":[]}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __experimentalHStack as HStack, __experimentalSpacer as Spacer, Button, Modal } from '@wordpress/components';
|
|
5
|
+
import { __, sprintf, _x } from '@wordpress/i18n';
|
|
6
|
+
import { useState, useMemo } from '@wordpress/element';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { DataFormLayout } from '../data-form-layout';
|
|
13
|
+
import { isCombinedField } from '../is-combined-field';
|
|
14
|
+
import { DEFAULT_LAYOUT } from '../../normalize-form-fields';
|
|
15
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
16
|
+
function ModalContent({
|
|
17
|
+
data,
|
|
18
|
+
form,
|
|
19
|
+
fieldLabel,
|
|
20
|
+
onChange,
|
|
21
|
+
onClose
|
|
22
|
+
}) {
|
|
23
|
+
const [changes, setChanges] = useState({});
|
|
24
|
+
const onApply = () => {
|
|
25
|
+
onChange(changes);
|
|
26
|
+
onClose();
|
|
27
|
+
};
|
|
28
|
+
const handleOnChange = value => {
|
|
29
|
+
setChanges(prev => ({
|
|
30
|
+
...prev,
|
|
31
|
+
...value
|
|
32
|
+
}));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// Merge original data with local changes for display
|
|
36
|
+
const displayData = {
|
|
37
|
+
...data,
|
|
38
|
+
...changes
|
|
39
|
+
};
|
|
40
|
+
return /*#__PURE__*/_jsxs(Modal, {
|
|
41
|
+
className: "dataforms-layouts-panel__modal",
|
|
42
|
+
onRequestClose: onClose,
|
|
43
|
+
isFullScreen: false,
|
|
44
|
+
title: fieldLabel,
|
|
45
|
+
size: "medium",
|
|
46
|
+
children: [/*#__PURE__*/_jsx(DataFormLayout, {
|
|
47
|
+
data: displayData,
|
|
48
|
+
form: form,
|
|
49
|
+
onChange: handleOnChange,
|
|
50
|
+
children: (FieldLayout, nestedField) => {
|
|
51
|
+
var _form$fields;
|
|
52
|
+
return /*#__PURE__*/_jsx(FieldLayout, {
|
|
53
|
+
data: displayData,
|
|
54
|
+
field: nestedField,
|
|
55
|
+
onChange: handleOnChange,
|
|
56
|
+
hideLabelFromVision: ((_form$fields = form?.fields) !== null && _form$fields !== void 0 ? _form$fields : []).length < 2
|
|
57
|
+
}, nestedField.id);
|
|
58
|
+
}
|
|
59
|
+
}), /*#__PURE__*/_jsxs(HStack, {
|
|
60
|
+
className: "dataforms-layouts-panel__modal-footer",
|
|
61
|
+
spacing: 3,
|
|
62
|
+
children: [/*#__PURE__*/_jsx(Spacer, {}), /*#__PURE__*/_jsx(Button, {
|
|
63
|
+
variant: "tertiary",
|
|
64
|
+
onClick: onClose,
|
|
65
|
+
__next40pxDefaultSize: true,
|
|
66
|
+
children: __('Cancel')
|
|
67
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
68
|
+
variant: "primary",
|
|
69
|
+
onClick: onApply,
|
|
70
|
+
__next40pxDefaultSize: true,
|
|
71
|
+
children: __('Apply')
|
|
72
|
+
})]
|
|
73
|
+
})]
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function PanelModal({
|
|
77
|
+
fieldDefinition,
|
|
78
|
+
labelPosition,
|
|
79
|
+
data,
|
|
80
|
+
onChange,
|
|
81
|
+
field
|
|
82
|
+
}) {
|
|
83
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
84
|
+
const fieldLabel = isCombinedField(field) ? field.label : fieldDefinition?.label;
|
|
85
|
+
const form = useMemo(() => ({
|
|
86
|
+
layout: DEFAULT_LAYOUT,
|
|
87
|
+
fields: isCombinedField(field) ? field.children :
|
|
88
|
+
// If not explicit children return the field id itself.
|
|
89
|
+
[{
|
|
90
|
+
id: field.id
|
|
91
|
+
}]
|
|
92
|
+
}), [field]);
|
|
93
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
94
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
95
|
+
className: "dataforms-layouts-modal__field-control",
|
|
96
|
+
size: "compact",
|
|
97
|
+
variant: ['none', 'top'].includes(labelPosition) ? 'link' : 'tertiary',
|
|
98
|
+
"aria-expanded": isOpen,
|
|
99
|
+
"aria-label": sprintf(
|
|
100
|
+
// translators: %s: Field name.
|
|
101
|
+
_x('Edit %s', 'field'), fieldLabel || ''),
|
|
102
|
+
onClick: () => setIsOpen(true),
|
|
103
|
+
disabled: fieldDefinition.readOnly === true,
|
|
104
|
+
accessibleWhenDisabled: true,
|
|
105
|
+
children: /*#__PURE__*/_jsx(fieldDefinition.render, {
|
|
106
|
+
item: data,
|
|
107
|
+
field: fieldDefinition
|
|
108
|
+
})
|
|
109
|
+
}), isOpen && /*#__PURE__*/_jsx(ModalContent, {
|
|
110
|
+
data: data,
|
|
111
|
+
form: form,
|
|
112
|
+
fieldLabel: fieldLabel !== null && fieldLabel !== void 0 ? fieldLabel : '',
|
|
113
|
+
onChange: onChange,
|
|
114
|
+
onClose: () => setIsOpen(false)
|
|
115
|
+
})]
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
export default PanelModal;
|
|
119
|
+
//# sourceMappingURL=modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__experimentalHStack","HStack","__experimentalSpacer","Spacer","Button","Modal","__","sprintf","_x","useState","useMemo","DataFormLayout","isCombinedField","DEFAULT_LAYOUT","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","ModalContent","data","form","fieldLabel","onChange","onClose","changes","setChanges","onApply","handleOnChange","value","prev","displayData","className","onRequestClose","isFullScreen","title","size","children","FieldLayout","nestedField","_form$fields","field","hideLabelFromVision","fields","length","id","spacing","variant","onClick","__next40pxDefaultSize","PanelModal","fieldDefinition","labelPosition","isOpen","setIsOpen","label","layout","includes","disabled","readOnly","accessibleWhenDisabled","render","item"],"sources":["@wordpress/dataviews/src/dataforms-layouts/panel/modal.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalSpacer as Spacer,\n\tButton,\n\tModal,\n} from '@wordpress/components';\nimport { __, sprintf, _x } from '@wordpress/i18n';\nimport { useState, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { Form, FormField, NormalizedField } from '../../types';\nimport { DataFormLayout } from '../data-form-layout';\nimport { isCombinedField } from '../is-combined-field';\nimport { DEFAULT_LAYOUT } from '../../normalize-form-fields';\n\nfunction ModalContent< Item >( {\n\tdata,\n\tform,\n\tfieldLabel,\n\tonChange,\n\tonClose,\n}: {\n\tdata: Item;\n\tform: Form;\n\tfieldLabel: string;\n\tonChange: ( data: Partial< Item > ) => void;\n\tonClose: () => void;\n} ) {\n\tconst [ changes, setChanges ] = useState< Partial< Item > >( {} );\n\n\tconst onApply = () => {\n\t\tonChange( changes );\n\t\tonClose();\n\t};\n\n\tconst handleOnChange = ( value: Partial< Item > ) => {\n\t\tsetChanges( ( prev ) => ( { ...prev, ...value } ) );\n\t};\n\n\t// Merge original data with local changes for display\n\tconst displayData = { ...data, ...changes };\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"dataforms-layouts-panel__modal\"\n\t\t\tonRequestClose={ onClose }\n\t\t\tisFullScreen={ false }\n\t\t\ttitle={ fieldLabel }\n\t\t\tsize=\"medium\"\n\t\t>\n\t\t\t<DataFormLayout\n\t\t\t\tdata={ displayData }\n\t\t\t\tform={ form }\n\t\t\t\tonChange={ handleOnChange }\n\t\t\t>\n\t\t\t\t{ ( FieldLayout, nestedField ) => (\n\t\t\t\t\t<FieldLayout\n\t\t\t\t\t\tkey={ nestedField.id }\n\t\t\t\t\t\tdata={ displayData }\n\t\t\t\t\t\tfield={ nestedField }\n\t\t\t\t\t\tonChange={ handleOnChange }\n\t\t\t\t\t\thideLabelFromVision={\n\t\t\t\t\t\t\t( form?.fields ?? [] ).length < 2\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</DataFormLayout>\n\t\t\t<HStack\n\t\t\t\tclassName=\"dataforms-layouts-panel__modal-footer\"\n\t\t\t\tspacing={ 3 }\n\t\t\t>\n\t\t\t\t<Spacer />\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t</Button>\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tonClick={ onApply }\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Apply' ) }\n\t\t\t\t</Button>\n\t\t\t</HStack>\n\t\t</Modal>\n\t);\n}\n\nfunction PanelModal< Item >( {\n\tfieldDefinition,\n\tlabelPosition,\n\tdata,\n\tonChange,\n\tfield,\n}: {\n\tfieldDefinition: NormalizedField< Item >;\n\tlabelPosition: 'side' | 'top' | 'none';\n\tdata: Item;\n\tonChange: ( value: any ) => void;\n\tfield: FormField;\n} ) {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\n\tconst fieldLabel = isCombinedField( field )\n\t\t? field.label\n\t\t: fieldDefinition?.label;\n\n\tconst form: Form = useMemo(\n\t\t(): Form => ( {\n\t\t\tlayout: DEFAULT_LAYOUT,\n\t\t\tfields: isCombinedField( field )\n\t\t\t\t? field.children\n\t\t\t\t: // If not explicit children return the field id itself.\n\t\t\t\t [ { id: field.id } ],\n\t\t} ),\n\t\t[ field ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tclassName=\"dataforms-layouts-modal__field-control\"\n\t\t\t\tsize=\"compact\"\n\t\t\t\tvariant={\n\t\t\t\t\t[ 'none', 'top' ].includes( labelPosition )\n\t\t\t\t\t\t? 'link'\n\t\t\t\t\t\t: 'tertiary'\n\t\t\t\t}\n\t\t\t\taria-expanded={ isOpen }\n\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t// translators: %s: Field name.\n\t\t\t\t\t_x( 'Edit %s', 'field' ),\n\t\t\t\t\tfieldLabel || ''\n\t\t\t\t) }\n\t\t\t\tonClick={ () => setIsOpen( true ) }\n\t\t\t\tdisabled={ fieldDefinition.readOnly === true }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t>\n\t\t\t\t<fieldDefinition.render\n\t\t\t\t\titem={ data }\n\t\t\t\t\tfield={ fieldDefinition }\n\t\t\t\t/>\n\t\t\t</Button>\n\t\t\t{ isOpen && (\n\t\t\t\t<ModalContent\n\t\t\t\t\tdata={ data }\n\t\t\t\t\tform={ form as Form }\n\t\t\t\t\tfieldLabel={ fieldLabel ?? '' }\n\t\t\t\t\tonChange={ onChange }\n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izeLayout(layout) {
|
|
|
22
22
|
labelPosition: (_layout$labelPosition = layout?.labelPosition) !== null && _layout$labelPosition !== void 0 ? _layout$labelPosition : 'top'
|
|
23
23
|
};
|
|
24
24
|
} else if (layout?.type === 'panel') {
|
|
25
|
-
var _layout$labelPosition2;
|
|
25
|
+
var _layout$labelPosition2, _layout$openAs;
|
|
26
26
|
normalizedLayout = {
|
|
27
27
|
type: 'panel',
|
|
28
|
-
labelPosition: (_layout$labelPosition2 = layout?.labelPosition) !== null && _layout$labelPosition2 !== void 0 ? _layout$labelPosition2 : 'side'
|
|
28
|
+
labelPosition: (_layout$labelPosition2 = layout?.labelPosition) !== null && _layout$labelPosition2 !== void 0 ? _layout$labelPosition2 : 'side',
|
|
29
|
+
openAs: (_layout$openAs = layout?.openAs) !== null && _layout$openAs !== void 0 ? _layout$openAs : 'dropdown'
|
|
29
30
|
};
|
|
30
31
|
} else if (layout?.type === 'card') {
|
|
31
32
|
if (layout.withHeader === false) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DEFAULT_LAYOUT","type","labelPosition","normalizeLayout","layout","normalizedLayout","_layout$labelPosition","_layout$labelPosition2","withHeader","isOpened","normalizeFormFields","form","_form$fields","formLayout","fields","map","field","id","fieldLayout"],"sources":["@wordpress/dataviews/src/normalize-form-fields.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type {\n\tForm,\n\tLayout,\n\tNormalizedLayout,\n\tNormalizedRegularLayout,\n\tNormalizedPanelLayout,\n\tNormalizedCardLayout,\n} from './types';\n\ninterface NormalizedFormField {\n\tid: string;\n\tlayout: Layout;\n}\n\nexport const DEFAULT_LAYOUT: NormalizedLayout = {\n\ttype: 'regular',\n\tlabelPosition: 'top',\n};\n\n/**\n * Normalizes a layout configuration based on its type.\n *\n * @param layout The layout object to normalize.\n * @return The normalized layout object.\n */\nexport function normalizeLayout( layout?: Layout ): NormalizedLayout {\n\tlet normalizedLayout = DEFAULT_LAYOUT;\n\n\tif ( layout?.type === 'regular' ) {\n\t\tnormalizedLayout = {\n\t\t\ttype: 'regular',\n\t\t\tlabelPosition: layout?.labelPosition ?? 'top',\n\t\t} satisfies NormalizedRegularLayout;\n\t} else if ( layout?.type === 'panel' ) {\n\t\tnormalizedLayout = {\n\t\t\ttype: 'panel',\n\t\t\tlabelPosition: layout?.labelPosition ?? 'side',\n\t\t} satisfies NormalizedPanelLayout;\n\t} else if ( layout?.type === 'card' ) {\n\t\tif ( layout.withHeader === false ) {\n\t\t\t// Don't let isOpened be false if withHeader is false.\n\t\t\t// Otherwise, the card will not be visible.\n\t\t\tnormalizedLayout = {\n\t\t\t\ttype: 'card',\n\t\t\t\twithHeader: false,\n\t\t\t\tisOpened: true,\n\t\t\t} satisfies NormalizedCardLayout;\n\t\t} else {\n\t\t\tnormalizedLayout = {\n\t\t\t\ttype: 'card',\n\t\t\t\twithHeader: true,\n\t\t\t\tisOpened:\n\t\t\t\t\ttypeof layout.isOpened === 'boolean'\n\t\t\t\t\t\t? layout.isOpened\n\t\t\t\t\t\t: true,\n\t\t\t} satisfies NormalizedCardLayout;\n\t\t}\n\t}\n\n\treturn normalizedLayout;\n}\n\nexport default function normalizeFormFields(\n\tform: Form\n): NormalizedFormField[] {\n\tconst formLayout = normalizeLayout( form?.layout );\n\n\treturn ( form.fields ?? [] ).map( ( field ) => {\n\t\tif ( typeof field === 'string' ) {\n\t\t\treturn {\n\t\t\t\tid: field,\n\t\t\t\tlayout: formLayout,\n\t\t\t};\n\t\t}\n\n\t\tconst fieldLayout = field.layout\n\t\t\t? normalizeLayout( field.layout )\n\t\t\t: formLayout;\n\t\treturn {\n\t\t\t...field,\n\t\t\tlayout: fieldLayout,\n\t\t};\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;;AAeA,OAAO,MAAMA,cAAgC,GAAG;EAC/CC,IAAI,EAAE,SAAS;EACfC,aAAa,EAAE;AAChB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAAEC,MAAe,EAAqB;EACpE,IAAIC,gBAAgB,GAAGL,cAAc;EAErC,IAAKI,MAAM,EAAEH,IAAI,KAAK,SAAS,EAAG;IAAA,IAAAK,qBAAA;IACjCD,gBAAgB,GAAG;MAClBJ,IAAI,EAAE,SAAS;MACfC,aAAa,GAAAI,qBAAA,GAAEF,MAAM,EAAEF,aAAa,cAAAI,qBAAA,cAAAA,qBAAA,GAAI;IACzC,CAAmC;EACpC,CAAC,MAAM,IAAKF,MAAM,EAAEH,IAAI,KAAK,OAAO,EAAG;IAAA,IAAAM,sBAAA;
|
|
1
|
+
{"version":3,"names":["DEFAULT_LAYOUT","type","labelPosition","normalizeLayout","layout","normalizedLayout","_layout$labelPosition","_layout$labelPosition2","_layout$openAs","openAs","withHeader","isOpened","normalizeFormFields","form","_form$fields","formLayout","fields","map","field","id","fieldLayout"],"sources":["@wordpress/dataviews/src/normalize-form-fields.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type {\n\tForm,\n\tLayout,\n\tNormalizedLayout,\n\tNormalizedRegularLayout,\n\tNormalizedPanelLayout,\n\tNormalizedCardLayout,\n} from './types';\n\ninterface NormalizedFormField {\n\tid: string;\n\tlayout: Layout;\n}\n\nexport const DEFAULT_LAYOUT: NormalizedLayout = {\n\ttype: 'regular',\n\tlabelPosition: 'top',\n};\n\n/**\n * Normalizes a layout configuration based on its type.\n *\n * @param layout The layout object to normalize.\n * @return The normalized layout object.\n */\nexport function normalizeLayout( layout?: Layout ): NormalizedLayout {\n\tlet normalizedLayout = DEFAULT_LAYOUT;\n\n\tif ( layout?.type === 'regular' ) {\n\t\tnormalizedLayout = {\n\t\t\ttype: 'regular',\n\t\t\tlabelPosition: layout?.labelPosition ?? 'top',\n\t\t} satisfies NormalizedRegularLayout;\n\t} else if ( layout?.type === 'panel' ) {\n\t\tnormalizedLayout = {\n\t\t\ttype: 'panel',\n\t\t\tlabelPosition: layout?.labelPosition ?? 'side',\n\t\t\topenAs: layout?.openAs ?? 'dropdown',\n\t\t} satisfies NormalizedPanelLayout;\n\t} else if ( layout?.type === 'card' ) {\n\t\tif ( layout.withHeader === false ) {\n\t\t\t// Don't let isOpened be false if withHeader is false.\n\t\t\t// Otherwise, the card will not be visible.\n\t\t\tnormalizedLayout = {\n\t\t\t\ttype: 'card',\n\t\t\t\twithHeader: false,\n\t\t\t\tisOpened: true,\n\t\t\t} satisfies NormalizedCardLayout;\n\t\t} else {\n\t\t\tnormalizedLayout = {\n\t\t\t\ttype: 'card',\n\t\t\t\twithHeader: true,\n\t\t\t\tisOpened:\n\t\t\t\t\ttypeof layout.isOpened === 'boolean'\n\t\t\t\t\t\t? layout.isOpened\n\t\t\t\t\t\t: true,\n\t\t\t} satisfies NormalizedCardLayout;\n\t\t}\n\t}\n\n\treturn normalizedLayout;\n}\n\nexport default function normalizeFormFields(\n\tform: Form\n): NormalizedFormField[] {\n\tconst formLayout = normalizeLayout( form?.layout );\n\n\treturn ( form.fields ?? [] ).map( ( field ) => {\n\t\tif ( typeof field === 'string' ) {\n\t\t\treturn {\n\t\t\t\tid: field,\n\t\t\t\tlayout: formLayout,\n\t\t\t};\n\t\t}\n\n\t\tconst fieldLayout = field.layout\n\t\t\t? normalizeLayout( field.layout )\n\t\t\t: formLayout;\n\t\treturn {\n\t\t\t...field,\n\t\t\tlayout: fieldLayout,\n\t\t};\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;;AAeA,OAAO,MAAMA,cAAgC,GAAG;EAC/CC,IAAI,EAAE,SAAS;EACfC,aAAa,EAAE;AAChB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAAEC,MAAe,EAAqB;EACpE,IAAIC,gBAAgB,GAAGL,cAAc;EAErC,IAAKI,MAAM,EAAEH,IAAI,KAAK,SAAS,EAAG;IAAA,IAAAK,qBAAA;IACjCD,gBAAgB,GAAG;MAClBJ,IAAI,EAAE,SAAS;MACfC,aAAa,GAAAI,qBAAA,GAAEF,MAAM,EAA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K,WAAW,GAAGF,KAAK,CAACd,MAAM,GAC7BD,eAAe,CAAEe,KAAK,CAACd,MAAO,CAAC,GAC/BW,UAAU;IACb,OAAO;MACN,GAAGG,KAAK;MACRd,MAAM,EAAEgB;IACT,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| 'array';\n\n/**\n * An abstract interface for Field based on the field type.\n */\nexport type FieldTypeDefinition< Item > = {\n\t/**\n\t * Callback used to sort the field.\n\t */\n\tsort: ( a: Item, b: Item, direction: SortDirection ) => number;\n\n\t/**\n\t * Callback used to validate the field.\n\t */\n\tisValid: Rules< Item >;\n\n\t/**\n\t * Callback used to render an edit control for the field or control name.\n\t */\n\tEdit: ComponentType< DataFormControlProps< Item > > | string | null;\n\n\t/**\n\t * Callback used to render the field.\n\t */\n\trender: ComponentType< DataViewRenderFieldProps< Item > >;\n\n\t/**\n\t * The filter config for the field.\n\t */\n\tfilterBy: FilterConfigForType | false;\n\n\t/**\n\t * Whether the field is readOnly.\n\t * If `true`, the value will be rendered using the `render` callback.\n\t */\n\treadOnly?: boolean;\n\n\t/**\n\t * Whether the field is sortable.\n\t */\n\tenableSorting: boolean;\n};\n\nexport type Rules< Item > = {\n\trequired?: boolean;\n\tcustom?: ( item: Item, field: NormalizedField< Item > ) => null | string;\n};\n\n/**\n * A dataview field for a specific property of a data type.\n */\nexport type Field< Item > = {\n\t/**\n\t * Type of the fields.\n\t */\n\ttype?: FieldType;\n\n\t/**\n\t * The unique identifier of the field.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the field. Defaults to the id.\n\t */\n\tlabel?: string;\n\n\t/**\n\t * The header of the field. Defaults to the label.\n\t * It allows the usage of a React Element to render the field labels.\n\t */\n\theader?: string | ReactElement;\n\n\t/**\n\t * A description of the field.\n\t */\n\tdescription?: string;\n\n\t/**\n\t * Placeholder for the field.\n\t */\n\tplaceholder?: string;\n\n\t/**\n\t * Callback used to render the field. Defaults to `field.getValue`.\n\t */\n\trender?: ComponentType< DataViewRenderFieldProps< Item > >;\n\n\t/**\n\t * Callback used to render an edit control for the field.\n\t */\n\tEdit?: ComponentType< DataFormControlProps< Item > > | string;\n\n\t/**\n\t * Callback used to sort the field.\n\t */\n\tsort?: ( a: Item, b: Item, direction: SortDirection ) => number;\n\n\t/**\n\t * Callback used to validate the field.\n\t */\n\tisValid?: Rules< Item >;\n\n\t/**\n\t * Callback used to decide if a field should be displayed.\n\t */\n\tisVisible?: ( item: Item ) => boolean;\n\n\t/**\n\t * Whether the field is sortable.\n\t */\n\tenableSorting?: boolean;\n\n\t/**\n\t * Whether the field is searchable.\n\t */\n\tenableGlobalSearch?: boolean;\n\n\t/**\n\t * Whether the field is filterable.\n\t */\n\tenableHiding?: boolean;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements?: Option[];\n\n\t/**\n\t * Filter config for the field.\n\t */\n\tfilterBy?: FilterByConfig | false;\n\n\t/**\n\t * Whether the field is readOnly.\n\t * If `true`, the value will be rendered using the `render` callback.\n\t */\n\treadOnly?: boolean;\n\n\t/**\n\t * Callback used to retrieve the value of the field from the item.\n\t * Defaults to `item[ field.id ]`.\n\t */\n\tgetValue?: ( args: { item: Item } ) => any;\n};\n\nexport type NormalizedField< Item > = Omit< Field< Item >, 'Edit' > & {\n\tlabel: string;\n\theader: string | ReactElement;\n\tgetValue: ( args: { item: Item } ) => any;\n\trender: ComponentType< DataViewRenderFieldProps< Item > >;\n\tEdit: ComponentType< DataFormControlProps< Item > > | null;\n\tsort: ( a: Item, b: Item, direction: SortDirection ) => number;\n\tisValid: Rules< Item >;\n\tenableHiding: boolean;\n\tenableSorting: boolean;\n\tfilterBy: NormalizedFilterByConfig | false;\n\treadOnly: boolean;\n};\n\n/**\n * A collection of dataview fields for a data type.\n */\nexport type Fields< Item > = Field< Item >[];\n\nexport type Data< Item > = Item[];\n\nexport type DataFormControlProps< Item > = {\n\tdata: Item;\n\tfield: NormalizedField< Item >;\n\tonChange: ( value: Record< string, any > ) => void;\n\thideLabelFromVision?: boolean;\n\t/**\n\t * The currently selected filter operator for this field.\n\t *\n\t * Used by DataViews filters to determine which control to render based on the operator type.\n\t */\n\toperator?: Operator;\n};\n\nexport type DataViewRenderFieldProps< Item > = {\n\titem: Item;\n\tfield: NormalizedField< Item >;\n\tconfig?: {\n\t\tsizes: string;\n\t};\n};\n\n/**\n * The filters applied to the dataset.\n */\nexport interface Filter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The operator to use.\n\t */\n\toperator: Operator;\n\n\t/**\n\t * The value to filter by.\n\t */\n\tvalue: any;\n\n\t/**\n\t * Whether the filter can be edited by the user.\n\t */\n\tisLocked?: boolean;\n}\n\nexport interface NormalizedFilter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The field name.\n\t */\n\tname: string;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements: Option[];\n\n\t/**\n\t * Is a single selection filter.\n\t */\n\tsingleSelection: boolean;\n\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators: Operator[];\n\n\t/**\n\t * Whether the filter is visible.\n\t */\n\tisVisible: boolean;\n\n\t/**\n\t * Whether it is a primary filter.\n\t */\n\tisPrimary: boolean;\n\n\t/**\n\t * Whether the filter can be edited by the user.\n\t */\n\tisLocked: boolean;\n}\n\ninterface ViewBase {\n\t/**\n\t * The layout of the view.\n\t */\n\ttype: string;\n\n\t/**\n\t * The global search term.\n\t */\n\tsearch?: string;\n\n\t/**\n\t * The filters to apply.\n\t */\n\tfilters?: Filter[];\n\n\t/**\n\t * The sorting configuration.\n\t */\n\tsort?: {\n\t\t/**\n\t\t * The field to sort by.\n\t\t */\n\t\tfield: string;\n\n\t\t/**\n\t\t * The direction to sort by.\n\t\t */\n\t\tdirection: SortDirection;\n\t};\n\n\t/**\n\t * The active page\n\t */\n\tpage?: number;\n\n\t/**\n\t * The number of items per page\n\t */\n\tperPage?: number;\n\n\t/**\n\t * The fields to render\n\t */\n\tfields?: string[];\n\n\t/**\n\t * Title field\n\t */\n\ttitleField?: string;\n\n\t/**\n\t * Media field\n\t */\n\tmediaField?: string;\n\n\t/**\n\t * Description field\n\t */\n\tdescriptionField?: string;\n\n\t/**\n\t * Whether to show the title\n\t */\n\tshowTitle?: boolean;\n\n\t/**\n\t * Whether to show the media\n\t */\n\tshowMedia?: boolean;\n\n\t/**\n\t * Whether to show the description\n\t */\n\tshowDescription?: boolean;\n\n\t/**\n\t * Whether to show the hierarchical levels.\n\t */\n\tshowLevels?: boolean;\n\n\t/**\n\t * The field to group by.\n\t */\n\tgroupByField?: string;\n\n\t/**\n\t * Whether infinite scroll is enabled.\n\t */\n\tinfiniteScrollEnabled?: boolean;\n}\n\nexport interface ColumnStyle {\n\t/**\n\t * The width of the field column.\n\t */\n\twidth?: string | number;\n\n\t/**\n\t * The minimum width of the field column.\n\t */\n\tmaxWidth?: string | number;\n\n\t/**\n\t * The maximum width of the field column.\n\t */\n\tminWidth?: string | number;\n\n\t/**\n\t * The alignment of the field column, defaults to left.\n\t */\n\talign?: 'start' | 'center' | 'end';\n}\n\nexport type Density = 'compact' | 'balanced' | 'comfortable';\n\nexport interface ViewTable extends ViewBase {\n\ttype: 'table';\n\n\tlayout?: {\n\t\t/**\n\t\t * The styles for the columns.\n\t\t */\n\t\tstyles?: Record< string, ColumnStyle >;\n\n\t\t/**\n\t\t * The density of the view.\n\t\t */\n\t\tdensity?: Density;\n\n\t\t/**\n\t\t * Whether the view allows column moving.\n\t\t */\n\t\tenableMoving?: boolean;\n\t};\n}\n\nexport interface ViewList extends ViewBase {\n\ttype: 'list';\n}\n\nexport interface ViewGrid extends ViewBase {\n\ttype: 'grid';\n\n\tlayout?: {\n\t\t/**\n\t\t * The fields to use as badge fields.\n\t\t */\n\t\tbadgeFields?: string[];\n\n\t\t/**\n\t\t * The preview size of the grid.\n\t\t */\n\t\tpreviewSize?: number;\n\t};\n}\n\nexport type View = ViewList | ViewGrid | ViewTable;\n\ninterface ActionBase< Item > {\n\t/**\n\t * The unique identifier of the action.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the action.\n\t * In case we want to adjust the label based on the selected items,\n\t * a function can be provided.\n\t */\n\tlabel: string | ( ( items: Item[] ) => string );\n\n\t/**\n\t * The icon of the action. (Either a string or an SVG element)\n\t * This should be IconType from the components package\n\t * but that import is breaking typescript build for the moment.\n\t */\n\ticon?: any;\n\n\t/**\n\t * Whether the action is disabled.\n\t */\n\tdisabled?: boolean;\n\n\t/**\n\t * Whether the action is destructive.\n\t */\n\tisDestructive?: boolean;\n\n\t/**\n\t * Whether the action is a primary action.\n\t */\n\tisPrimary?: boolean;\n\n\t/**\n\t * Whether the item passed as an argument supports the current action.\n\t */\n\tisEligible?: ( item: Item ) => boolean;\n\n\t/**\n\t * Whether the action can be used as a bulk action.\n\t */\n\tsupportsBulk?: boolean;\n\n\t/**\n\t * The context in which the action is visible.\n\t * This is only a \"meta\" information for now.\n\t */\n\tcontext?: 'list' | 'single';\n}\n\nexport interface RenderModalProps< Item > {\n\titems: Item[];\n\tcloseModal?: () => void;\n\tonActionPerformed?: ( items: Item[] ) => void;\n}\n\nexport interface ActionModal< Item > extends ActionBase< Item > {\n\t/**\n\t * Modal to render when the action is triggered.\n\t */\n\tRenderModal: ( {\n\t\titems,\n\t\tcloseModal,\n\t\tonActionPerformed,\n\t}: RenderModalProps< Item > ) => ReactElement;\n\n\t/**\n\t * Whether to hide the modal header.\n\t */\n\thideModalHeader?: boolean;\n\n\t/**\n\t * The header of the modal.\n\t */\n\tmodalHeader?: string;\n\n\t/**\n\t * The size of the modal.\n\t *\n\t * @default 'medium'\n\t */\n\tmodalSize?: 'small' | 'medium' | 'large' | 'fill';\n\n\t/**\n\t * The focus on mount property of the modal.\n\t */\n\tmodalFocusOnMount?:\n\t\t| Parameters< typeof useFocusOnMount >[ 0 ]\n\t\t| 'firstContentElement';\n}\n\nexport interface ActionButton< Item > extends ActionBase< Item > {\n\t/**\n\t * The callback to execute when the action is triggered.\n\t */\n\tcallback: (\n\t\titems: Item[],\n\t\tcontext: {\n\t\t\tregistry: any;\n\t\t\tonActionPerformed?: ( items: Item[] ) => void;\n\t\t}\n\t) => void;\n}\n\nexport type Action< Item > = ActionModal< Item > | ActionButton< Item >;\n\nexport interface ViewBaseProps< Item > {\n\tclassName?: string;\n\tactions: Action< Item >[];\n\tdata: Item[];\n\tfields: NormalizedField< Item >[];\n\tgetItemId: ( item: Item ) => string;\n\tgetItemLevel?: ( item: Item ) => number;\n\tisLoading?: boolean;\n\tonChangeView: ( view: View ) => void;\n\tonChangeSelection: SetSelection;\n\tselection: string[];\n\tsetOpenedFilter: ( fieldId: string ) => void;\n\tonClickItem?: ( item: Item ) => void;\n\trenderItemLink?: (\n\t\tprops: {\n\t\t\titem: Item;\n\t\t} & ComponentProps< 'a' >\n\t) => ReactElement;\n\tisItemClickable: ( item: Item ) => boolean;\n\tview: View;\n\tempty: ReactNode;\n}\n\nexport interface ViewTableProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewTable;\n}\n\nexport interface ViewListProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewList;\n}\n\nexport interface ViewGridProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewGrid;\n}\n\nexport type ViewProps< Item > =\n\t| ViewTableProps< Item >\n\t| ViewGridProps< Item >\n\t| ViewListProps< Item >;\n\nexport interface SupportedLayouts {\n\tlist?: Omit< ViewList, 'type' >;\n\tgrid?: Omit< ViewGrid, 'type' >;\n\ttable?: Omit< ViewTable, 'type' >;\n}\n\n/**\n * DataForm layouts.\n */\nexport type LayoutType = 'regular' | 'panel' | 'card';\nexport type LabelPosition = 'top' | 'side' | 'none';\n\nexport type RegularLayout = {\n\ttype: 'regular';\n\tlabelPosition?: LabelPosition;\n};\nexport type NormalizedRegularLayout = {\n\ttype: 'regular';\n\tlabelPosition: LabelPosition;\n};\n\nexport type PanelLayout = {\n\ttype: 'panel';\n\tlabelPosition?: LabelPosition;\n};\nexport type NormalizedPanelLayout = {\n\ttype: 'panel';\n\tlabelPosition: LabelPosition;\n};\n\nexport type CardLayout =\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader: false;\n\t\t\t// isOpened cannot be false if withHeader is false as well.\n\t\t\t// Otherwise, the card would not be visible.\n\t\t\tisOpened?: true;\n\t }\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader?: true | undefined;\n\t\t\tisOpened?: boolean;\n\t };\nexport type NormalizedCardLayout =\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader: false;\n\t\t\t// isOpened cannot be false if withHeader is false as well.\n\t\t\t// Otherwise, the card would not be visible.\n\t\t\tisOpened: true;\n\t }\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader: true;\n\t\t\tisOpened: boolean;\n\t };\n\nexport type Layout = RegularLayout | PanelLayout | CardLayout;\nexport type NormalizedLayout =\n\t| NormalizedRegularLayout\n\t| NormalizedPanelLayout\n\t| NormalizedCardLayout;\n\nexport type SimpleFormField = {\n\tid: string;\n\tlayout?: Layout;\n};\n\nexport type CombinedFormField = {\n\tid: string;\n\tlabel?: string;\n\tlayout?: Layout;\n\tchildren: Array< FormField | string >;\n};\n\nexport type FormField = SimpleFormField | CombinedFormField;\n\n/**\n * The form configuration.\n */\nexport type Form = {\n\tlayout?: Layout;\n\tfields?: Array< FormField | string >;\n};\n\nexport interface DataFormProps< Item > {\n\tdata: Item;\n\tfields: Field< Item >[];\n\tform: Form;\n\tonChange: ( value: Record< string, any > ) => void;\n}\n\nexport interface FieldLayoutProps< Item > {\n\tdata: Item;\n\tfield: FormField;\n\tonChange: ( value: any ) => void;\n\thideLabelFromVision?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/dataviews/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type {\n\tReactElement,\n\tReactNode,\n\tComponentType,\n\tComponentProps,\n} from 'react';\n\n/**\n * Internal dependencies\n */\nimport type { SetSelection } from './private-types';\n\n/**\n * WordPress dependencies\n */\nimport type { useFocusOnMount } from '@wordpress/compose';\n\nexport type SortDirection = 'asc' | 'desc';\n\n/**\n * Generic option type.\n */\nexport interface Option< Value extends any = any > {\n\tvalue: Value;\n\tlabel: string;\n\tdescription?: string;\n}\n\nexport interface FilterByConfig {\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators?: Operator[];\n\n\t/**\n\t * Whether it is a primary filter.\n\t *\n\t * A primary filter is always visible and is not listed in the \"Add filter\" component,\n\t * except for the list layout where it behaves like a secondary filter.\n\t */\n\tisPrimary?: boolean;\n}\n\nexport interface NormalizedFilterByConfig {\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators: Operator[];\n\n\t/**\n\t * Whether it is a primary filter.\n\t *\n\t * A primary filter is always visible and is not listed in the \"Add filter\" component,\n\t * except for the list layout where it behaves like a secondary filter.\n\t */\n\tisPrimary?: boolean;\n}\n\ninterface FilterConfigForType {\n\t/**\n\t * What operators are used by default.\n\t */\n\tdefaultOperators: Operator[];\n\n\t/**\n\t * What operators are supported by the field.\n\t */\n\tvalidOperators: Operator[];\n}\n\nexport type Operator =\n\t| 'is'\n\t| 'isNot'\n\t| 'isAny'\n\t| 'isNone'\n\t| 'isAll'\n\t| 'isNotAll'\n\t| 'lessThan'\n\t| 'greaterThan'\n\t| 'lessThanOrEqual'\n\t| 'greaterThanOrEqual'\n\t| 'before'\n\t| 'after'\n\t| 'beforeInc'\n\t| 'afterInc'\n\t| 'contains'\n\t| 'notContains'\n\t| 'startsWith'\n\t| 'between'\n\t| 'on'\n\t| 'notOn'\n\t| 'inThePast'\n\t| 'over';\n\nexport type FieldType =\n\t| 'text'\n\t| 'integer'\n\t| 'datetime'\n\t| 'date'\n\t| 'media'\n\t| 'boolean'\n\t| 'email'\n\t| 'array';\n\n/**\n * An abstract interface for Field based on the field type.\n */\nexport type FieldTypeDefinition< Item > = {\n\t/**\n\t * Callback used to sort the field.\n\t */\n\tsort: ( a: Item, b: Item, direction: SortDirection ) => number;\n\n\t/**\n\t * Callback used to validate the field.\n\t */\n\tisValid: Rules< Item >;\n\n\t/**\n\t * Callback used to render an edit control for the field or control name.\n\t */\n\tEdit: ComponentType< DataFormControlProps< Item > > | string | null;\n\n\t/**\n\t * Callback used to render the field.\n\t */\n\trender: ComponentType< DataViewRenderFieldProps< Item > >;\n\n\t/**\n\t * The filter config for the field.\n\t */\n\tfilterBy: FilterConfigForType | false;\n\n\t/**\n\t * Whether the field is readOnly.\n\t * If `true`, the value will be rendered using the `render` callback.\n\t */\n\treadOnly?: boolean;\n\n\t/**\n\t * Whether the field is sortable.\n\t */\n\tenableSorting: boolean;\n};\n\nexport type Rules< Item > = {\n\trequired?: boolean;\n\tcustom?: ( item: Item, field: NormalizedField< Item > ) => null | string;\n};\n\n/**\n * A dataview field for a specific property of a data type.\n */\nexport type Field< Item > = {\n\t/**\n\t * Type of the fields.\n\t */\n\ttype?: FieldType;\n\n\t/**\n\t * The unique identifier of the field.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the field. Defaults to the id.\n\t */\n\tlabel?: string;\n\n\t/**\n\t * The header of the field. Defaults to the label.\n\t * It allows the usage of a React Element to render the field labels.\n\t */\n\theader?: string | ReactElement;\n\n\t/**\n\t * A description of the field.\n\t */\n\tdescription?: string;\n\n\t/**\n\t * Placeholder for the field.\n\t */\n\tplaceholder?: string;\n\n\t/**\n\t * Callback used to render the field. Defaults to `field.getValue`.\n\t */\n\trender?: ComponentType< DataViewRenderFieldProps< Item > >;\n\n\t/**\n\t * Callback used to render an edit control for the field.\n\t */\n\tEdit?: ComponentType< DataFormControlProps< Item > > | string;\n\n\t/**\n\t * Callback used to sort the field.\n\t */\n\tsort?: ( a: Item, b: Item, direction: SortDirection ) => number;\n\n\t/**\n\t * Callback used to validate the field.\n\t */\n\tisValid?: Rules< Item >;\n\n\t/**\n\t * Callback used to decide if a field should be displayed.\n\t */\n\tisVisible?: ( item: Item ) => boolean;\n\n\t/**\n\t * Whether the field is sortable.\n\t */\n\tenableSorting?: boolean;\n\n\t/**\n\t * Whether the field is searchable.\n\t */\n\tenableGlobalSearch?: boolean;\n\n\t/**\n\t * Whether the field is filterable.\n\t */\n\tenableHiding?: boolean;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements?: Option[];\n\n\t/**\n\t * Filter config for the field.\n\t */\n\tfilterBy?: FilterByConfig | false;\n\n\t/**\n\t * Whether the field is readOnly.\n\t * If `true`, the value will be rendered using the `render` callback.\n\t */\n\treadOnly?: boolean;\n\n\t/**\n\t * Callback used to retrieve the value of the field from the item.\n\t * Defaults to `item[ field.id ]`.\n\t */\n\tgetValue?: ( args: { item: Item } ) => any;\n};\n\nexport type NormalizedField< Item > = Omit< Field< Item >, 'Edit' > & {\n\tlabel: string;\n\theader: string | ReactElement;\n\tgetValue: ( args: { item: Item } ) => any;\n\trender: ComponentType< DataViewRenderFieldProps< Item > >;\n\tEdit: ComponentType< DataFormControlProps< Item > > | null;\n\tsort: ( a: Item, b: Item, direction: SortDirection ) => number;\n\tisValid: Rules< Item >;\n\tenableHiding: boolean;\n\tenableSorting: boolean;\n\tfilterBy: NormalizedFilterByConfig | false;\n\treadOnly: boolean;\n};\n\n/**\n * A collection of dataview fields for a data type.\n */\nexport type Fields< Item > = Field< Item >[];\n\nexport type Data< Item > = Item[];\n\nexport type DataFormControlProps< Item > = {\n\tdata: Item;\n\tfield: NormalizedField< Item >;\n\tonChange: ( value: Record< string, any > ) => void;\n\thideLabelFromVision?: boolean;\n\t/**\n\t * The currently selected filter operator for this field.\n\t *\n\t * Used by DataViews filters to determine which control to render based on the operator type.\n\t */\n\toperator?: Operator;\n};\n\nexport type DataViewRenderFieldProps< Item > = {\n\titem: Item;\n\tfield: NormalizedField< Item >;\n\tconfig?: {\n\t\tsizes: string;\n\t};\n};\n\n/**\n * The filters applied to the dataset.\n */\nexport interface Filter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The operator to use.\n\t */\n\toperator: Operator;\n\n\t/**\n\t * The value to filter by.\n\t */\n\tvalue: any;\n\n\t/**\n\t * Whether the filter can be edited by the user.\n\t */\n\tisLocked?: boolean;\n}\n\nexport interface NormalizedFilter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The field name.\n\t */\n\tname: string;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements: Option[];\n\n\t/**\n\t * Is a single selection filter.\n\t */\n\tsingleSelection: boolean;\n\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators: Operator[];\n\n\t/**\n\t * Whether the filter is visible.\n\t */\n\tisVisible: boolean;\n\n\t/**\n\t * Whether it is a primary filter.\n\t */\n\tisPrimary: boolean;\n\n\t/**\n\t * Whether the filter can be edited by the user.\n\t */\n\tisLocked: boolean;\n}\n\ninterface ViewBase {\n\t/**\n\t * The layout of the view.\n\t */\n\ttype: string;\n\n\t/**\n\t * The global search term.\n\t */\n\tsearch?: string;\n\n\t/**\n\t * The filters to apply.\n\t */\n\tfilters?: Filter[];\n\n\t/**\n\t * The sorting configuration.\n\t */\n\tsort?: {\n\t\t/**\n\t\t * The field to sort by.\n\t\t */\n\t\tfield: string;\n\n\t\t/**\n\t\t * The direction to sort by.\n\t\t */\n\t\tdirection: SortDirection;\n\t};\n\n\t/**\n\t * The active page\n\t */\n\tpage?: number;\n\n\t/**\n\t * The number of items per page\n\t */\n\tperPage?: number;\n\n\t/**\n\t * The fields to render\n\t */\n\tfields?: string[];\n\n\t/**\n\t * Title field\n\t */\n\ttitleField?: string;\n\n\t/**\n\t * Media field\n\t */\n\tmediaField?: string;\n\n\t/**\n\t * Description field\n\t */\n\tdescriptionField?: string;\n\n\t/**\n\t * Whether to show the title\n\t */\n\tshowTitle?: boolean;\n\n\t/**\n\t * Whether to show the media\n\t */\n\tshowMedia?: boolean;\n\n\t/**\n\t * Whether to show the description\n\t */\n\tshowDescription?: boolean;\n\n\t/**\n\t * Whether to show the hierarchical levels.\n\t */\n\tshowLevels?: boolean;\n\n\t/**\n\t * The field to group by.\n\t */\n\tgroupByField?: string;\n\n\t/**\n\t * Whether infinite scroll is enabled.\n\t */\n\tinfiniteScrollEnabled?: boolean;\n}\n\nexport interface ColumnStyle {\n\t/**\n\t * The width of the field column.\n\t */\n\twidth?: string | number;\n\n\t/**\n\t * The minimum width of the field column.\n\t */\n\tmaxWidth?: string | number;\n\n\t/**\n\t * The maximum width of the field column.\n\t */\n\tminWidth?: string | number;\n\n\t/**\n\t * The alignment of the field column, defaults to left.\n\t */\n\talign?: 'start' | 'center' | 'end';\n}\n\nexport type Density = 'compact' | 'balanced' | 'comfortable';\n\nexport interface ViewTable extends ViewBase {\n\ttype: 'table';\n\n\tlayout?: {\n\t\t/**\n\t\t * The styles for the columns.\n\t\t */\n\t\tstyles?: Record< string, ColumnStyle >;\n\n\t\t/**\n\t\t * The density of the view.\n\t\t */\n\t\tdensity?: Density;\n\n\t\t/**\n\t\t * Whether the view allows column moving.\n\t\t */\n\t\tenableMoving?: boolean;\n\t};\n}\n\nexport interface ViewList extends ViewBase {\n\ttype: 'list';\n}\n\nexport interface ViewGrid extends ViewBase {\n\ttype: 'grid';\n\n\tlayout?: {\n\t\t/**\n\t\t * The fields to use as badge fields.\n\t\t */\n\t\tbadgeFields?: string[];\n\n\t\t/**\n\t\t * The preview size of the grid.\n\t\t */\n\t\tpreviewSize?: number;\n\t};\n}\n\nexport type View = ViewList | ViewGrid | ViewTable;\n\ninterface ActionBase< Item > {\n\t/**\n\t * The unique identifier of the action.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the action.\n\t * In case we want to adjust the label based on the selected items,\n\t * a function can be provided.\n\t */\n\tlabel: string | ( ( items: Item[] ) => string );\n\n\t/**\n\t * The icon of the action. (Either a string or an SVG element)\n\t * This should be IconType from the components package\n\t * but that import is breaking typescript build for the moment.\n\t */\n\ticon?: any;\n\n\t/**\n\t * Whether the action is disabled.\n\t */\n\tdisabled?: boolean;\n\n\t/**\n\t * Whether the action is destructive.\n\t */\n\tisDestructive?: boolean;\n\n\t/**\n\t * Whether the action is a primary action.\n\t */\n\tisPrimary?: boolean;\n\n\t/**\n\t * Whether the item passed as an argument supports the current action.\n\t */\n\tisEligible?: ( item: Item ) => boolean;\n\n\t/**\n\t * Whether the action can be used as a bulk action.\n\t */\n\tsupportsBulk?: boolean;\n\n\t/**\n\t * The context in which the action is visible.\n\t * This is only a \"meta\" information for now.\n\t */\n\tcontext?: 'list' | 'single';\n}\n\nexport interface RenderModalProps< Item > {\n\titems: Item[];\n\tcloseModal?: () => void;\n\tonActionPerformed?: ( items: Item[] ) => void;\n}\n\nexport interface ActionModal< Item > extends ActionBase< Item > {\n\t/**\n\t * Modal to render when the action is triggered.\n\t */\n\tRenderModal: ( {\n\t\titems,\n\t\tcloseModal,\n\t\tonActionPerformed,\n\t}: RenderModalProps< Item > ) => ReactElement;\n\n\t/**\n\t * Whether to hide the modal header.\n\t */\n\thideModalHeader?: boolean;\n\n\t/**\n\t * The header of the modal.\n\t */\n\tmodalHeader?: string;\n\n\t/**\n\t * The size of the modal.\n\t *\n\t * @default 'medium'\n\t */\n\tmodalSize?: 'small' | 'medium' | 'large' | 'fill';\n\n\t/**\n\t * The focus on mount property of the modal.\n\t */\n\tmodalFocusOnMount?:\n\t\t| Parameters< typeof useFocusOnMount >[ 0 ]\n\t\t| 'firstContentElement';\n}\n\nexport interface ActionButton< Item > extends ActionBase< Item > {\n\t/**\n\t * The callback to execute when the action is triggered.\n\t */\n\tcallback: (\n\t\titems: Item[],\n\t\tcontext: {\n\t\t\tregistry: any;\n\t\t\tonActionPerformed?: ( items: Item[] ) => void;\n\t\t}\n\t) => void;\n}\n\nexport type Action< Item > = ActionModal< Item > | ActionButton< Item >;\n\nexport interface ViewBaseProps< Item > {\n\tclassName?: string;\n\tactions: Action< Item >[];\n\tdata: Item[];\n\tfields: NormalizedField< Item >[];\n\tgetItemId: ( item: Item ) => string;\n\tgetItemLevel?: ( item: Item ) => number;\n\tisLoading?: boolean;\n\tonChangeView: ( view: View ) => void;\n\tonChangeSelection: SetSelection;\n\tselection: string[];\n\tsetOpenedFilter: ( fieldId: string ) => void;\n\tonClickItem?: ( item: Item ) => void;\n\trenderItemLink?: (\n\t\tprops: {\n\t\t\titem: Item;\n\t\t} & ComponentProps< 'a' >\n\t) => ReactElement;\n\tisItemClickable: ( item: Item ) => boolean;\n\tview: View;\n\tempty: ReactNode;\n}\n\nexport interface ViewTableProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewTable;\n}\n\nexport interface ViewListProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewList;\n}\n\nexport interface ViewGridProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewGrid;\n}\n\nexport type ViewProps< Item > =\n\t| ViewTableProps< Item >\n\t| ViewGridProps< Item >\n\t| ViewListProps< Item >;\n\nexport interface SupportedLayouts {\n\tlist?: Omit< ViewList, 'type' >;\n\tgrid?: Omit< ViewGrid, 'type' >;\n\ttable?: Omit< ViewTable, 'type' >;\n}\n\n/**\n * DataForm layouts.\n */\nexport type LayoutType = 'regular' | 'panel' | 'card';\nexport type LabelPosition = 'top' | 'side' | 'none';\n\nexport type RegularLayout = {\n\ttype: 'regular';\n\tlabelPosition?: LabelPosition;\n};\nexport type NormalizedRegularLayout = {\n\ttype: 'regular';\n\tlabelPosition: LabelPosition;\n};\n\nexport type PanelLayout = {\n\ttype: 'panel';\n\tlabelPosition?: LabelPosition;\n\topenAs?: 'dropdown' | 'modal';\n};\nexport type NormalizedPanelLayout = {\n\ttype: 'panel';\n\tlabelPosition: LabelPosition;\n\topenAs: 'dropdown' | 'modal';\n};\n\nexport type CardLayout =\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader: false;\n\t\t\t// isOpened cannot be false if withHeader is false as well.\n\t\t\t// Otherwise, the card would not be visible.\n\t\t\tisOpened?: true;\n\t }\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader?: true | undefined;\n\t\t\tisOpened?: boolean;\n\t };\nexport type NormalizedCardLayout =\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader: false;\n\t\t\t// isOpened cannot be false if withHeader is false as well.\n\t\t\t// Otherwise, the card would not be visible.\n\t\t\tisOpened: true;\n\t }\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader: true;\n\t\t\tisOpened: boolean;\n\t };\n\nexport type Layout = RegularLayout | PanelLayout | CardLayout;\nexport type NormalizedLayout =\n\t| NormalizedRegularLayout\n\t| NormalizedPanelLayout\n\t| NormalizedCardLayout;\n\nexport type SimpleFormField = {\n\tid: string;\n\tlayout?: Layout;\n};\n\nexport type CombinedFormField = {\n\tid: string;\n\tlabel?: string;\n\tlayout?: Layout;\n\tchildren: Array< FormField | string >;\n};\n\nexport type FormField = SimpleFormField | CombinedFormField;\n\n/**\n * The form configuration.\n */\nexport type Form = {\n\tlayout?: Layout;\n\tfields?: Array< FormField | string >;\n};\n\nexport interface DataFormProps< Item > {\n\tdata: Item;\n\tfields: Field< Item >[];\n\tform: Form;\n\tonChange: ( value: Record< string, any > ) => void;\n}\n\nexport interface FieldLayoutProps< Item > {\n\tdata: Item;\n\tfield: FormField;\n\tonChange: ( value: any ) => void;\n\thideLabelFromVision?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1704,6 +1704,10 @@ div.dataviews-view-list {
|
|
|
1704
1704
|
margin-bottom: 16px;
|
|
1705
1705
|
}
|
|
1706
1706
|
|
|
1707
|
+
.dataforms-layouts-panel__modal-footer {
|
|
1708
|
+
margin-top: 16px;
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1707
1711
|
.components-popover.components-dropdown__content.dataforms-layouts-panel__field-dropdown {
|
|
1708
1712
|
z-index: 159990;
|
|
1709
1713
|
}
|
package/build-style/style.css
CHANGED
|
@@ -1704,6 +1704,10 @@ div.dataviews-view-list {
|
|
|
1704
1704
|
margin-bottom: 16px;
|
|
1705
1705
|
}
|
|
1706
1706
|
|
|
1707
|
+
.dataforms-layouts-panel__modal-footer {
|
|
1708
|
+
margin-top: 16px;
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1707
1711
|
.components-popover.components-dropdown__content.dataforms-layouts-panel__field-dropdown {
|
|
1708
1712
|
z-index: 159990;
|
|
1709
1713
|
}
|
|
@@ -5,6 +5,13 @@ import DataForm from '../index';
|
|
|
5
5
|
declare const meta: {
|
|
6
6
|
title: string;
|
|
7
7
|
component: typeof DataForm;
|
|
8
|
+
};
|
|
9
|
+
export default meta;
|
|
10
|
+
export declare const Default: {
|
|
11
|
+
render: ({ type, labelPosition, }: {
|
|
12
|
+
type?: "default" | "regular" | "panel" | "card";
|
|
13
|
+
labelPosition: "default" | "top" | "side" | "none";
|
|
14
|
+
}) => import("react").JSX.Element;
|
|
8
15
|
argTypes: {
|
|
9
16
|
type: {
|
|
10
17
|
control: {
|
|
@@ -13,35 +20,39 @@ declare const meta: {
|
|
|
13
20
|
description: string;
|
|
14
21
|
options: string[];
|
|
15
22
|
};
|
|
16
|
-
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare const LayoutCard: {
|
|
26
|
+
render: ({ withHeader }: {
|
|
27
|
+
withHeader: boolean;
|
|
28
|
+
}) => import("react").JSX.Element;
|
|
29
|
+
argTypes: {
|
|
30
|
+
withHeader: {
|
|
17
31
|
control: {
|
|
18
32
|
type: string;
|
|
19
33
|
};
|
|
20
34
|
description: string;
|
|
21
|
-
options: string[];
|
|
22
35
|
};
|
|
23
36
|
};
|
|
37
|
+
args: {
|
|
38
|
+
withHeader: boolean;
|
|
39
|
+
};
|
|
24
40
|
};
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
type: "default" | "regular" | "panel" | "card";
|
|
28
|
-
labelPosition: "default" | "top" | "side" | "none";
|
|
29
|
-
}) => import("react").JSX.Element;
|
|
30
|
-
export declare const CombinedFields: {
|
|
31
|
-
title: string;
|
|
32
|
-
render: ({ type, labelPosition, }: {
|
|
41
|
+
export declare const LayoutPanel: {
|
|
42
|
+
render: ({ labelPosition, openAs, }: {
|
|
33
43
|
type: "default" | "regular" | "panel" | "card";
|
|
34
44
|
labelPosition: "default" | "top" | "side" | "none";
|
|
45
|
+
openAs: "default" | "dropdown" | "modal";
|
|
35
46
|
}) => import("react").JSX.Element;
|
|
36
47
|
argTypes: {
|
|
37
|
-
|
|
48
|
+
labelPosition: {
|
|
38
49
|
control: {
|
|
39
50
|
type: string;
|
|
40
51
|
};
|
|
41
52
|
description: string;
|
|
42
53
|
options: string[];
|
|
43
54
|
};
|
|
44
|
-
|
|
55
|
+
openAs: {
|
|
45
56
|
control: {
|
|
46
57
|
type: string;
|
|
47
58
|
};
|
|
@@ -49,14 +60,30 @@ export declare const CombinedFields: {
|
|
|
49
60
|
options: string[];
|
|
50
61
|
};
|
|
51
62
|
};
|
|
52
|
-
|
|
53
|
-
|
|
63
|
+
};
|
|
64
|
+
export declare const LayoutRegular: {
|
|
65
|
+
render: ({ type, labelPosition, }: {
|
|
66
|
+
type?: "default" | "regular" | "panel" | "card";
|
|
67
|
+
labelPosition: "default" | "top" | "side" | "none";
|
|
68
|
+
}) => import("react").JSX.Element;
|
|
69
|
+
argTypes: {
|
|
70
|
+
labelPosition: {
|
|
71
|
+
control: {
|
|
72
|
+
type: string;
|
|
73
|
+
};
|
|
74
|
+
description: string;
|
|
75
|
+
options: string[];
|
|
76
|
+
};
|
|
54
77
|
};
|
|
55
78
|
};
|
|
79
|
+
export declare const LayoutMixed: {
|
|
80
|
+
render: () => import("react").JSX.Element;
|
|
81
|
+
};
|
|
56
82
|
export declare const Validation: {
|
|
57
|
-
|
|
58
|
-
render: ({ required }: {
|
|
83
|
+
render: ({ required, type, custom, }: {
|
|
59
84
|
required: boolean;
|
|
85
|
+
custom: boolean;
|
|
86
|
+
type: "regular" | "panel";
|
|
60
87
|
}) => import("react").JSX.Element;
|
|
61
88
|
argTypes: {
|
|
62
89
|
required: {
|
|
@@ -65,21 +92,27 @@ export declare const Validation: {
|
|
|
65
92
|
};
|
|
66
93
|
description: string;
|
|
67
94
|
};
|
|
95
|
+
type: {
|
|
96
|
+
control: {
|
|
97
|
+
type: string;
|
|
98
|
+
};
|
|
99
|
+
description: string;
|
|
100
|
+
options: string[];
|
|
101
|
+
};
|
|
102
|
+
custom: {
|
|
103
|
+
control: {
|
|
104
|
+
type: string;
|
|
105
|
+
};
|
|
106
|
+
description: string;
|
|
107
|
+
};
|
|
68
108
|
};
|
|
69
109
|
args: {
|
|
70
110
|
required: boolean;
|
|
111
|
+
type: string;
|
|
112
|
+
custom: boolean;
|
|
71
113
|
};
|
|
72
114
|
};
|
|
73
115
|
export declare const Visibility: {
|
|
74
|
-
title: string;
|
|
75
|
-
render: () => import("react").JSX.Element;
|
|
76
|
-
};
|
|
77
|
-
export declare const LayoutCard: {
|
|
78
|
-
title: string;
|
|
79
|
-
render: () => import("react").JSX.Element;
|
|
80
|
-
};
|
|
81
|
-
export declare const LayoutMixed: {
|
|
82
|
-
title: string;
|
|
83
116
|
render: () => import("react").JSX.Element;
|
|
84
117
|
};
|
|
85
118
|
//# 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":"AAUA;;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":"AAUA;;GAEG;AACH,OAAO,QAAQ,MAAM,UAAU,CAAC;AA6xBhC,QAAA,MAAM,IAAI;;;CAGT,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,OAAO;uCAjoBjB;QACF,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,OAA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,EACJ,QAAQ,EACR,oBAAoB,GACpB,EAAE,qBAAqB,CAAE,IAAI,CAAE,+BAmB/B;AAED,MAAM,CAAC,OAAO,UAAU,WAAW,CAAE,IAAI,EAAI,EAC5C,IAAI,EACJ,OAAO,EACP,SAAS,GACT,EAAE,gBAAgB,CAAE,IAAI,CAAE,+BAoD1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/boolean.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/boolean.tsx"],"names":[],"mappings":"AAMA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAKrD,MAAM,CAAC,OAAO,UAAU,OAAO,CAAE,IAAI,EAAI,EACxC,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,mBAAmB,GACnB,EAAE,oBAAoB,CAAE,IAAI,CAAE,+BAyC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/email.tsx"],"names":[],"mappings":"AAMA;;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,+
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/email.tsx"],"names":[],"mappings":"AAMA;;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,+BAoD9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integer.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/integer.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AA6DrD,MAAM,CAAC,OAAO,UAAU,OAAO,CAAE,IAAI,EAAI,EACxC,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,mBAAmB,EACnB,QAAQ,GACR,EAAE,oBAAoB,CAAE,IAAI,CAAE,+
|
|
1
|
+
{"version":3,"file":"integer.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/integer.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AA6DrD,MAAM,CAAC,OAAO,UAAU,OAAO,CAAE,IAAI,EAAI,EACxC,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,mBAAmB,EACnB,QAAQ,GACR,EAAE,oBAAoB,CAAE,IAAI,CAAE,+BAoE9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/text.tsx"],"names":[],"mappings":"AAMA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAKrD,MAAM,CAAC,OAAO,UAAU,IAAI,CAAE,IAAI,EAAI,EACrC,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,mBAAmB,GACnB,EAAE,oBAAoB,CAAE,IAAI,CAAE,+
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/dataform-controls/text.tsx"],"names":[],"mappings":"AAMA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAKrD,MAAM,CAAC,OAAO,UAAU,IAAI,CAAE,IAAI,EAAI,EACrC,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,mBAAmB,GACnB,EAAE,oBAAoB,CAAE,IAAI,CAAE,+BAmD9B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { FormField, NormalizedField } from '../../types';
|
|
5
|
+
declare function PanelDropdown<Item>({ fieldDefinition, popoverAnchor, labelPosition, data, onChange, field, }: {
|
|
6
|
+
fieldDefinition: NormalizedField<Item>;
|
|
7
|
+
popoverAnchor: HTMLElement | null;
|
|
8
|
+
labelPosition: 'side' | 'top' | 'none';
|
|
9
|
+
data: Item;
|
|
10
|
+
onChange: (value: any) => void;
|
|
11
|
+
field: FormField;
|
|
12
|
+
}): import("react").JSX.Element;
|
|
13
|
+
export default PanelDropdown;
|
|
14
|
+
//# sourceMappingURL=dropdown.d.ts.map
|
|
@@ -0,0 +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;AAqCpE,iBAAS,aAAa,CAAE,IAAI,EAAI,EAC/B,eAAe,EACf,aAAa,EACb,aAAsB,EACtB,IAAI,EACJ,QAAQ,EACR,KAAK,GACL,EAAE;IACF,eAAe,EAAE,eAAe,CAAE,IAAI,CAAE,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,+BAwFA;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -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":"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,sCAyG1B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { FormField, NormalizedField } from '../../types';
|
|
5
|
+
declare function PanelModal<Item>({ fieldDefinition, labelPosition, data, onChange, field, }: {
|
|
6
|
+
fieldDefinition: NormalizedField<Item>;
|
|
7
|
+
labelPosition: 'side' | 'top' | 'none';
|
|
8
|
+
data: Item;
|
|
9
|
+
onChange: (value: any) => void;
|
|
10
|
+
field: FormField;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
12
|
+
export default PanelModal;
|
|
13
|
+
//# sourceMappingURL=modal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/dataforms-layouts/panel/modal.tsx"],"names":[],"mappings":"AAYA;;GAEG;AACH,OAAO,KAAK,EAAQ,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAiFpE,iBAAS,UAAU,CAAE,IAAI,EAAI,EAC5B,eAAe,EACf,aAAa,EACb,IAAI,EACJ,QAAQ,EACR,KAAK,GACL,EAAE;IACF,eAAe,EAAE,eAAe,CAAE,IAAI,CAAE,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,+BAsDA;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-form-fields.d.ts","sourceRoot":"","sources":["../src/normalize-form-fields.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EACX,IAAI,EACJ,MAAM,EACN,gBAAgB,EAIhB,MAAM,SAAS,CAAC;AAEjB,UAAU,mBAAmB;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,cAAc,EAAE,gBAG5B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAE,MAAM,CAAC,EAAE,MAAM,GAAI,gBAAgB,
|
|
1
|
+
{"version":3,"file":"normalize-form-fields.d.ts","sourceRoot":"","sources":["../src/normalize-form-fields.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EACX,IAAI,EACJ,MAAM,EACN,gBAAgB,EAIhB,MAAM,SAAS,CAAC;AAEjB,UAAU,mBAAmB;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,cAAc,EAAE,gBAG5B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAE,MAAM,CAAC,EAAE,MAAM,GAAI,gBAAgB,CAoCnE;AAED,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAC1C,IAAI,EAAE,IAAI,GACR,mBAAmB,EAAE,CAmBvB"}
|
package/build-types/types.d.ts
CHANGED
|
@@ -532,10 +532,12 @@ export type NormalizedRegularLayout = {
|
|
|
532
532
|
export type PanelLayout = {
|
|
533
533
|
type: 'panel';
|
|
534
534
|
labelPosition?: LabelPosition;
|
|
535
|
+
openAs?: 'dropdown' | 'modal';
|
|
535
536
|
};
|
|
536
537
|
export type NormalizedPanelLayout = {
|
|
537
538
|
type: 'panel';
|
|
538
539
|
labelPosition: LabelPosition;
|
|
540
|
+
openAs: 'dropdown' | 'modal';
|
|
539
541
|
};
|
|
540
542
|
export type CardLayout = {
|
|
541
543
|
type: 'card';
|