@defra/forms-model 3.0.504 → 3.0.505

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.
@@ -24,6 +24,16 @@ export function isConditionalType(type) {
24
24
  return !!type && allowedTypes.includes(type);
25
25
  }
26
26
 
27
+ /**
28
+ * Check if the component type is supported for conditional reveal.
29
+ * As of today this is just content types, but we're providing this as a wrapper
30
+ * function for clarity.
31
+ * @param type - Component type to check
32
+ */
33
+ export function isConditionalRevealType(type) {
34
+ return isContentType(type);
35
+ }
36
+
27
37
  /**
28
38
  * Filter known components with content (textarea or list)
29
39
  */
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","names":["ComponentTypes","ComponentType","getComponentDefaults","component","defaults","find","type","Error","structuredClone","hasConditionSupport","isConditionalType","allowedTypes","AutocompleteField","RadiosField","CheckboxesField","DatePartsField","EmailAddressField","MultilineTextField","TelephoneNumberField","NumberField","SelectField","TextField","YesNoField","includes","hasContent","isContentType","hasContentField","deniedTypes","List","Details","Html","Markdown","InsetText","hasFormField","isFormType","hasListField","isListType","hasInputField","hasSelectionFields","hasTitle","hasHint"],"sources":["../../../src/components/helpers.ts"],"sourcesContent":["import { ComponentTypes } from '~/src/components/component-types.js'\nimport { ComponentType } from '~/src/components/enums.js'\nimport {\n type ComponentDef,\n type ConditionalComponentType,\n type ConditionalComponentsDef,\n type ContentComponentsDef,\n type FormComponentsDef,\n type HtmlComponent,\n type InputFieldsComponentsDef,\n type InsetTextComponent,\n type ListComponent,\n type ListComponentsDef,\n type MarkdownComponent,\n type SelectionComponentsDef\n} from '~/src/components/types.js'\n\n/**\n * Return component defaults by type\n */\nexport function getComponentDefaults<FieldType extends ComponentDef>(\n component?: Pick<FieldType, 'type'>\n) {\n const defaults = ComponentTypes.find(({ type }) => type === component?.type)\n\n if (!defaults) {\n throw new Error(\n `Defaults not found for component type '${component?.type}'`\n )\n }\n\n return structuredClone(defaults) as FieldType\n}\n\n/**\n * Filter known components with support for conditions\n */\nexport function hasConditionSupport(\n component?: Partial<ComponentDef>\n): component is ConditionalComponentsDef {\n return isConditionalType(component?.type)\n}\n\nexport function isConditionalType(\n type?: ComponentType\n): type is ConditionalComponentType {\n const allowedTypes = [\n ComponentType.AutocompleteField,\n ComponentType.RadiosField,\n ComponentType.CheckboxesField,\n ComponentType.DatePartsField,\n ComponentType.EmailAddressField,\n ComponentType.MultilineTextField,\n ComponentType.TelephoneNumberField,\n ComponentType.NumberField,\n ComponentType.SelectField,\n ComponentType.TextField,\n ComponentType.YesNoField\n ]\n\n return !!type && allowedTypes.includes(type)\n}\n\n/**\n * Filter known components with content (textarea or list)\n */\nexport function hasContent(\n component?: Partial<ComponentDef>\n): component is ContentComponentsDef {\n return isContentType(component?.type)\n}\n\n/**\n * Filter known components with content textarea\n */\nexport function hasContentField(\n component?: Partial<ComponentDef>\n): component is Exclude<ContentComponentsDef, ListComponent> {\n const deniedTypes = [ComponentType.List]\n return hasContent(component) && !deniedTypes.includes(component.type)\n}\n\nexport function isContentType(\n type?: ComponentType\n): type is ContentComponentsDef['type'] {\n const allowedTypes = [\n ComponentType.Details,\n ComponentType.Html,\n ComponentType.Markdown,\n ComponentType.InsetText,\n ComponentType.List\n ]\n\n return !!type && allowedTypes.includes(type)\n}\n\n/**\n * Filter known components with form fields\n * (includes input fields and selection fields)\n */\nexport function hasFormField(\n component?: Partial<ComponentDef>\n): component is FormComponentsDef {\n return isFormType(component?.type)\n}\n\nexport function isFormType(\n type?: ComponentType\n): type is FormComponentsDef['type'] {\n return !!type && !isContentType(type)\n}\n\n/**\n * Filter known components with lists\n */\nexport function hasListField(\n component?: Partial<ComponentDef>\n): component is ListComponentsDef {\n return isListType(component?.type)\n}\n\nexport function isListType(\n type?: ComponentType\n): type is ListComponentsDef['type'] {\n const allowedTypes = [\n ComponentType.AutocompleteField,\n ComponentType.List,\n ComponentType.RadiosField,\n ComponentType.SelectField,\n ComponentType.CheckboxesField\n ]\n\n return !!type && allowedTypes.includes(type)\n}\n\n/**\n * Filter known form components with input fields\n * (excludes content and selection fields)\n */\nexport function hasInputField(\n component?: Partial<ComponentDef>\n): component is InputFieldsComponentsDef {\n return hasFormField(component) && !hasSelectionFields(component)\n}\n\n/**\n * Filter known form components with selection fields\n * (excludes content and input fields)\n */\nexport function hasSelectionFields(\n component?: Partial<ComponentDef>\n): component is SelectionComponentsDef {\n const allowedTypes = [\n ComponentType.AutocompleteField,\n ComponentType.CheckboxesField,\n ComponentType.RadiosField,\n ComponentType.SelectField,\n ComponentType.YesNoField\n ]\n\n return !!component?.type && allowedTypes.includes(component.type)\n}\n\n/**\n * Filter known components with titles\n */\nexport function hasTitle(\n component?: Partial<ComponentDef>\n): component is Exclude<\n ComponentDef,\n InsetTextComponent | HtmlComponent | MarkdownComponent\n> {\n const deniedTypes = [\n ComponentType.InsetText,\n ComponentType.Html,\n ComponentType.Markdown\n ]\n return !!component?.type && !deniedTypes.includes(component.type)\n}\n\n/**\n * Filter known components with hint text\n */\nexport function hasHint(\n component?: Partial<ComponentDef>\n): component is FormComponentsDef | ListComponent {\n return isFormType(component?.type) || component?.type === ComponentType.List\n}\n"],"mappings":"AAAA,SAASA,cAAc;AACvB,SAASC,aAAa;AAgBtB;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAClCC,SAAmC,EACnC;EACA,MAAMC,QAAQ,GAAGJ,cAAc,CAACK,IAAI,CAAC,CAAC;IAAEC;EAAK,CAAC,KAAKA,IAAI,KAAKH,SAAS,EAAEG,IAAI,CAAC;EAE5E,IAAI,CAACF,QAAQ,EAAE;IACb,MAAM,IAAIG,KAAK,CACb,0CAA0CJ,SAAS,EAAEG,IAAI,GAC3D,CAAC;EACH;EAEA,OAAOE,eAAe,CAACJ,QAAQ,CAAC;AAClC;;AAEA;AACA;AACA;AACA,OAAO,SAASK,mBAAmBA,CACjCN,SAAiC,EACM;EACvC,OAAOO,iBAAiB,CAACP,SAAS,EAAEG,IAAI,CAAC;AAC3C;AAEA,OAAO,SAASI,i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,CAAC8B,QAAQ,CACvB;EACD,OAAO,CAAC,CAAC5B,SAAS,EAAEG,IAAI,IAAI,CAACqB,WAAW,CAACJ,QAAQ,CAACpB,SAAS,CAACG,IAAI,CAAC;AACnE;;AAEA;AACA;AACA;AACA,OAAO,SAASkC,OAAOA,CACrBrC,SAAiC,EACe;EAChD,OAAO+B,UAAU,CAAC/B,SAAS,EAAEG,IAAI,CAAC,IAAIH,SAAS,EAAEG,IAAI,KAAKL,aAAa,CAAC2B,IAAI;AAC9E","ignoreList":[]}
1
+ {"version":3,"file":"helpers.js","names":["ComponentTypes","ComponentType","getComponentDefaults","component","defaults","find","type","Error","structuredClone","hasConditionSupport","isConditionalType","allowedTypes","AutocompleteField","RadiosField","CheckboxesField","DatePartsField","EmailAddressField","MultilineTextField","TelephoneNumberField","NumberField","SelectField","TextField","YesNoField","includes","isConditionalRevealType","isContentType","hasContent","hasContentField","deniedTypes","List","Details","Html","Markdown","InsetText","hasFormField","isFormType","hasListField","isListType","hasInputField","hasSelectionFields","hasTitle","hasHint"],"sources":["../../../src/components/helpers.ts"],"sourcesContent":["import { ComponentTypes } from '~/src/components/component-types.js'\nimport { ComponentType } from '~/src/components/enums.js'\nimport {\n type ComponentDef,\n type ConditionalComponentType,\n type ConditionalComponentsDef,\n type ContentComponentsDef,\n type FormComponentsDef,\n type HtmlComponent,\n type InputFieldsComponentsDef,\n type InsetTextComponent,\n type ListComponent,\n type ListComponentsDef,\n type MarkdownComponent,\n type SelectionComponentsDef\n} from '~/src/components/types.js'\n\n/**\n * Return component defaults by type\n */\nexport function getComponentDefaults<FieldType extends ComponentDef>(\n component?: Pick<FieldType, 'type'>\n) {\n const defaults = ComponentTypes.find(({ type }) => type === component?.type)\n\n if (!defaults) {\n throw new Error(\n `Defaults not found for component type '${component?.type}'`\n )\n }\n\n return structuredClone(defaults) as FieldType\n}\n\n/**\n * Filter known components with support for conditions\n */\nexport function hasConditionSupport(\n component?: Partial<ComponentDef>\n): component is ConditionalComponentsDef {\n return isConditionalType(component?.type)\n}\n\nexport function isConditionalType(\n type?: ComponentType\n): type is ConditionalComponentType {\n const allowedTypes = [\n ComponentType.AutocompleteField,\n ComponentType.RadiosField,\n ComponentType.CheckboxesField,\n ComponentType.DatePartsField,\n ComponentType.EmailAddressField,\n ComponentType.MultilineTextField,\n ComponentType.TelephoneNumberField,\n ComponentType.NumberField,\n ComponentType.SelectField,\n ComponentType.TextField,\n ComponentType.YesNoField\n ]\n\n return !!type && allowedTypes.includes(type)\n}\n\n/**\n * Check if the component type is supported for conditional reveal.\n * As of today this is just content types, but we're providing this as a wrapper\n * function for clarity.\n * @param type - Component type to check\n */\nexport function isConditionalRevealType(type: ComponentType) {\n return isContentType(type)\n}\n\n/**\n * Filter known components with content (textarea or list)\n */\nexport function hasContent(\n component?: Partial<ComponentDef>\n): component is ContentComponentsDef {\n return isContentType(component?.type)\n}\n\n/**\n * Filter known components with content textarea\n */\nexport function hasContentField(\n component?: Partial<ComponentDef>\n): component is Exclude<ContentComponentsDef, ListComponent> {\n const deniedTypes = [ComponentType.List]\n return hasContent(component) && !deniedTypes.includes(component.type)\n}\n\nexport function isContentType(\n type?: ComponentType\n): type is ContentComponentsDef['type'] {\n const allowedTypes = [\n ComponentType.Details,\n ComponentType.Html,\n ComponentType.Markdown,\n ComponentType.InsetText,\n ComponentType.List\n ]\n\n return !!type && allowedTypes.includes(type)\n}\n\n/**\n * Filter known components with form fields\n * (includes input fields and selection fields)\n */\nexport function hasFormField(\n component?: Partial<ComponentDef>\n): component is FormComponentsDef {\n return isFormType(component?.type)\n}\n\nexport function isFormType(\n type?: ComponentType\n): type is FormComponentsDef['type'] {\n return !!type && !isContentType(type)\n}\n\n/**\n * Filter known components with lists\n */\nexport function hasListField(\n component?: Partial<ComponentDef>\n): component is ListComponentsDef {\n return isListType(component?.type)\n}\n\nexport function isListType(\n type?: ComponentType\n): type is ListComponentsDef['type'] {\n const allowedTypes = [\n ComponentType.AutocompleteField,\n ComponentType.List,\n ComponentType.RadiosField,\n ComponentType.SelectField,\n ComponentType.CheckboxesField\n ]\n\n return !!type && allowedTypes.includes(type)\n}\n\n/**\n * Filter known form components with input fields\n * (excludes content and selection fields)\n */\nexport function hasInputField(\n component?: Partial<ComponentDef>\n): component is InputFieldsComponentsDef {\n return hasFormField(component) && !hasSelectionFields(component)\n}\n\n/**\n * Filter known form components with selection fields\n * (excludes content and input fields)\n */\nexport function hasSelectionFields(\n component?: Partial<ComponentDef>\n): component is SelectionComponentsDef {\n const allowedTypes = [\n ComponentType.AutocompleteField,\n ComponentType.CheckboxesField,\n ComponentType.RadiosField,\n ComponentType.SelectField,\n ComponentType.YesNoField\n ]\n\n return !!component?.type && allowedTypes.includes(component.type)\n}\n\n/**\n * Filter known components with titles\n */\nexport function hasTitle(\n component?: Partial<ComponentDef>\n): component is Exclude<\n ComponentDef,\n InsetTextComponent | HtmlComponent | MarkdownComponent\n> {\n const deniedTypes = [\n ComponentType.InsetText,\n ComponentType.Html,\n ComponentType.Markdown\n ]\n return !!component?.type && !deniedTypes.includes(component.type)\n}\n\n/**\n * Filter known components with hint text\n */\nexport function hasHint(\n component?: Partial<ComponentDef>\n): component is FormComponentsDef | ListComponent {\n return isFormType(component?.type) || component?.type === ComponentType.List\n}\n"],"mappings":"AAAA,SAASA,cAAc;AACvB,SAASC,aAAa;AAgBtB;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAClCC,SAAmC,EACnC;EACA,MAAMC,QAAQ,GAAGJ,cAAc,CAACK,IAAI,CAAC,CAAC;IAAEC;EAAK,CAAC,KAAKA,IAAI,KAAKH,SAAS,EAAEG,IAAI,CAAC;EAE5E,IAAI,CAACF,QAAQ,EAAE;IACb,MAAM,IAAIG,KAAK,CACb,0CAA0CJ,SAAS,EAAEG,IAAI,GAC3D,CAAC;EACH;EAEA,OAAOE,eAAe,CAACJ,QAAQ,CAAC;AAClC;;AAEA;AACA;AACA;AACA,OAAO,SAASK,mBAAmBA,CACjCN,SAAiC,EACM;EACvC,OAAO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AAS,CAACG,IAAI,CAAC;AACnE;;AAEA;AACA;AACA;AACA,OAAO,SAASkC,QAAQA,CACtBrC,SAAiC,EAIjC;EACA,MAAMyB,WAAW,GAAG,CAClB3B,aAAa,CAACgC,SAAS,EACvBhC,aAAa,CAAC8B,IAAI,EAClB9B,aAAa,CAAC+B,QAAQ,CACvB;EACD,OAAO,CAAC,CAAC7B,SAAS,EAAEG,IAAI,IAAI,CAACsB,WAAW,CAACL,QAAQ,CAACpB,SAAS,CAACG,IAAI,CAAC;AACnE;;AAEA;AACA;AACA;AACA,OAAO,SAASmC,OAAOA,CACrBtC,SAAiC,EACe;EAChD,OAAOgC,UAAU,CAAChC,SAAS,EAAEG,IAAI,CAAC,IAAIH,SAAS,EAAEG,IAAI,KAAKL,aAAa,CAAC4B,IAAI;AAC9E","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  export { ComponentTypes } from "./component-types.js";
2
- export { getComponentDefaults, hasConditionSupport, hasContent, hasContentField, hasFormField, hasHint, hasInputField, hasListField, hasSelectionFields, hasTitle, isConditionalType, isContentType, isFormType, isListType } from "./helpers.js";
2
+ export { ComponentType } from "./enums.js";
3
3
  export { allDocumentTypes, allImageTypes, allTabularDataTypes } from "./file-types.js";
4
+ export { getComponentDefaults, hasConditionSupport, hasContent, hasContentField, hasFormField, hasHint, hasInputField, hasListField, hasSelectionFields, hasTitle, isConditionalRevealType, isConditionalType, isContentType, isFormType, isListType } from "./helpers.js";
4
5
  export { getYesNoList, yesNoListId, yesNoListName, yesNoListNoItemId, yesNoListYesItemId } from "./yes-no-helper.js";
5
- export { ComponentType } from "./enums.js";
6
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["ComponentTypes","getComponentDefaults","hasConditionSupport","hasContent","hasContentField","hasFormField","hasHint","hasInputField","hasListField","hasSelectionFields","hasTitle","isConditionalType","isContentType","isFormType","isListType","allDocumentTypes","allImageTypes","allTabularDataTypes","getYesNoList","yesNoListId","yesNoListName","yesNoListNoItemId","yesNoListYesItemId","ComponentType"],"sources":["../../../src/components/index.ts"],"sourcesContent":["export { ComponentTypes } from '~/src/components/component-types.js'\nexport {\n getComponentDefaults,\n hasConditionSupport,\n hasContent,\n hasContentField,\n hasFormField,\n hasHint,\n hasInputField,\n hasListField,\n hasSelectionFields,\n hasTitle,\n isConditionalType,\n isContentType,\n isFormType,\n isListType\n} from '~/src/components/helpers.js'\nexport {\n allDocumentTypes,\n allImageTypes,\n allTabularDataTypes\n} from '~/src/components/file-types.js'\nexport {\n getYesNoList,\n yesNoListId,\n yesNoListName,\n yesNoListNoItemId,\n yesNoListYesItemId\n} from '~/src/components/yes-no-helper.js'\nexport { ComponentType } from '~/src/components/enums.js'\n"],"mappings":"AAAA,SAASA,cAAc;AACvB,SACEC,oBAAoB,EACpBC,mBAAmB,EACnBC,UAAU,EACVC,eAAe,EACfC,YAAY,EACZC,OAAO,EACPC,aAAa,EACbC,YAAY,EACZC,kBAAkB,EAClBC,QAAQ,EACRC,iBAAiB,EACjBC,aAAa,EACbC,UAAU,EACVC,UAAU;AAEZ,SACEC,gBAAgB,EAChBC,aAAa,EACbC,mBAAmB;AAErB,SACEC,YAAY,EACZC,WAAW,EACXC,aAAa,EACbC,iBAAiB,EACjBC,kBAAkB;AAEpB,SAASC,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["ComponentTypes","ComponentType","allDocumentTypes","allImageTypes","allTabularDataTypes","getComponentDefaults","hasConditionSupport","hasContent","hasContentField","hasFormField","hasHint","hasInputField","hasListField","hasSelectionFields","hasTitle","isConditionalRevealType","isConditionalType","isContentType","isFormType","isListType","getYesNoList","yesNoListId","yesNoListName","yesNoListNoItemId","yesNoListYesItemId"],"sources":["../../../src/components/index.ts"],"sourcesContent":["export { ComponentTypes } from '~/src/components/component-types.js'\nexport { ComponentType } from '~/src/components/enums.js'\nexport {\n allDocumentTypes,\n allImageTypes,\n allTabularDataTypes\n} from '~/src/components/file-types.js'\nexport {\n getComponentDefaults,\n hasConditionSupport,\n hasContent,\n hasContentField,\n hasFormField,\n hasHint,\n hasInputField,\n hasListField,\n hasSelectionFields,\n hasTitle,\n isConditionalRevealType,\n isConditionalType,\n isContentType,\n isFormType,\n isListType\n} from '~/src/components/helpers.js'\nexport {\n getYesNoList,\n yesNoListId,\n yesNoListName,\n yesNoListNoItemId,\n yesNoListYesItemId\n} from '~/src/components/yes-no-helper.js'\n"],"mappings":"AAAA,SAASA,cAAc;AACvB,SAASC,aAAa;AACtB,SACEC,gBAAgB,EAChBC,aAAa,EACbC,mBAAmB;AAErB,SACEC,oBAAoB,EACpBC,mBAAmB,EACnBC,UAAU,EACVC,eAAe,EACfC,YAAY,EACZC,OAAO,EACPC,aAAa,EACbC,YAAY,EACZC,kBAAkB,EAClBC,QAAQ,EACRC,uBAAuB,EACvBC,iBAAiB,EACjBC,aAAa,EACbC,UAAU,EACVC,UAAU;AAEZ,SACEC,YAAY,EACZC,WAAW,EACXC,aAAa,EACbC,iBAAiB,EACjBC,kBAAkB","ignoreList":[]}
@@ -9,6 +9,13 @@ export declare function getComponentDefaults<FieldType extends ComponentDef>(com
9
9
  */
10
10
  export declare function hasConditionSupport(component?: Partial<ComponentDef>): component is ConditionalComponentsDef;
11
11
  export declare function isConditionalType(type?: ComponentType): type is ConditionalComponentType;
12
+ /**
13
+ * Check if the component type is supported for conditional reveal.
14
+ * As of today this is just content types, but we're providing this as a wrapper
15
+ * function for clarity.
16
+ * @param type - Component type to check
17
+ */
18
+ export declare function isConditionalRevealType(type: ComponentType): type is ComponentType.Html | ComponentType.InsetText | ComponentType.Details | ComponentType.List | ComponentType.Markdown;
12
19
  /**
13
20
  * Filter known components with content (textarea or list)
14
21
  */
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/components/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EACL,KAAK,YAAY,EACjB,K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AAC,YAAY,CAAC,GAChC,SAAS,IAAI,sBAAsB,CAUrC;AAED;;GAEG;AACH,wBAAgB,QAAQ,CACtB,SAAS,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAChC,SAAS,IAAI,OAAO,CACrB,YAAY,EACZ,kBAAkB,GAAG,aAAa,GAAG,iBAAiB,CACvD,CAOA;AAED;;GAEG;AACH,wBAAgB,OAAO,CACrB,SAAS,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAChC,SAAS,IAAI,iBAAiB,GAAG,aAAa,CAEhD"}
@@ -1,6 +1,6 @@
1
1
  export { ComponentTypes } from '../components/component-types.js';
2
- export { getComponentDefaults, hasConditionSupport, hasContent, hasContentField, hasFormField, hasHint, hasInputField, hasListField, hasSelectionFields, hasTitle, isConditionalType, isContentType, isFormType, isListType } from '../components/helpers.js';
2
+ export { ComponentType } from '../components/enums.js';
3
3
  export { allDocumentTypes, allImageTypes, allTabularDataTypes } from '../components/file-types.js';
4
+ export { getComponentDefaults, hasConditionSupport, hasContent, hasContentField, hasFormField, hasHint, hasInputField, hasListField, hasSelectionFields, hasTitle, isConditionalRevealType, isConditionalType, isContentType, isFormType, isListType } from '../components/helpers.js';
4
5
  export { getYesNoList, yesNoListId, yesNoListName, yesNoListNoItemId, yesNoListYesItemId } from '../components/yes-no-helper.js';
5
- export { ComponentType } from '../components/enums.js';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AACpE,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,eAAe,EACf,YAAY,EACZ,OAAO,EACP,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,QAAQ,EACR,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,UAAU,EACX,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACpB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACL,YAAY,EACZ,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACpB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,eAAe,EACf,YAAY,EACZ,OAAO,EACP,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,QAAQ,EACR,uBAAuB,EACvB,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,UAAU,EACX,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,YAAY,EACZ,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,mCAAmC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/forms-model",
3
- "version": "3.0.504",
3
+ "version": "3.0.505",
4
4
  "description": "A hapi plugin providing the model for Defra forms",
5
5
  "homepage": "https://github.com/DEFRA/forms-designer/tree/main/model#readme",
6
6
  "types": "dist/types/index.d.ts",
@@ -61,6 +61,16 @@ export function isConditionalType(
61
61
  return !!type && allowedTypes.includes(type)
62
62
  }
63
63
 
64
+ /**
65
+ * Check if the component type is supported for conditional reveal.
66
+ * As of today this is just content types, but we're providing this as a wrapper
67
+ * function for clarity.
68
+ * @param type - Component type to check
69
+ */
70
+ export function isConditionalRevealType(type: ComponentType) {
71
+ return isContentType(type)
72
+ }
73
+
64
74
  /**
65
75
  * Filter known components with content (textarea or list)
66
76
  */
@@ -1,4 +1,10 @@
1
1
  export { ComponentTypes } from '~/src/components/component-types.js'
2
+ export { ComponentType } from '~/src/components/enums.js'
3
+ export {
4
+ allDocumentTypes,
5
+ allImageTypes,
6
+ allTabularDataTypes
7
+ } from '~/src/components/file-types.js'
2
8
  export {
3
9
  getComponentDefaults,
4
10
  hasConditionSupport,
@@ -10,16 +16,12 @@ export {
10
16
  hasListField,
11
17
  hasSelectionFields,
12
18
  hasTitle,
19
+ isConditionalRevealType,
13
20
  isConditionalType,
14
21
  isContentType,
15
22
  isFormType,
16
23
  isListType
17
24
  } from '~/src/components/helpers.js'
18
- export {
19
- allDocumentTypes,
20
- allImageTypes,
21
- allTabularDataTypes
22
- } from '~/src/components/file-types.js'
23
25
  export {
24
26
  getYesNoList,
25
27
  yesNoListId,
@@ -27,4 +29,3 @@ export {
27
29
  yesNoListNoItemId,
28
30
  yesNoListYesItemId
29
31
  } from '~/src/components/yes-no-helper.js'
30
- export { ComponentType } from '~/src/components/enums.js'