@payloadcms/ui 3.0.0-canary.0ff7f07 → 3.0.0-canary.1331796

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.
Files changed (63) hide show
  1. package/dist/elements/Logout/index.d.ts.map +1 -1
  2. package/dist/elements/Logout/index.js +2 -1
  3. package/dist/elements/Logout/index.js.map +1 -1
  4. package/dist/elements/ReactSelect/DropdownIndicator/index.js +1 -1
  5. package/dist/elements/ReactSelect/DropdownIndicator/index.js.map +1 -1
  6. package/dist/elements/StepNav/index.d.ts.map +1 -1
  7. package/dist/elements/StepNav/index.js +1 -1
  8. package/dist/elements/StepNav/index.js.map +1 -1
  9. package/dist/elements/Table/DefaultCell/fields/index.d.ts +4 -4
  10. package/dist/exports/client/{CodeEditor-LQX4VBTA.js → CodeEditor-UTZFZWZG.js} +14 -2
  11. package/dist/exports/client/{CodeEditor-LQX4VBTA.js.map → CodeEditor-UTZFZWZG.js.map} +2 -1
  12. package/dist/exports/client/DatePicker-CBQPW5J5.js +30 -0
  13. package/dist/exports/client/{DatePicker-AXHBRRH5.js.map → DatePicker-CBQPW5J5.js.map} +2 -1
  14. package/dist/exports/client/{chunk-S57FL4TE.js → chunk-5LKBKI4T.js} +13 -1
  15. package/dist/exports/client/{chunk-S57FL4TE.js.map → chunk-5LKBKI4T.js.map} +1 -0
  16. package/dist/exports/client/{chunk-3YOZFV77.js → chunk-DODCWLCH.js} +14 -2
  17. package/dist/exports/client/{chunk-3YOZFV77.js.map → chunk-DODCWLCH.js.map} +2 -1
  18. package/dist/exports/client/{chunk-TLG7P5PN.js → chunk-QJ5EJH4V.js} +13 -1
  19. package/dist/exports/client/{chunk-TLG7P5PN.js.map → chunk-QJ5EJH4V.js.map} +2 -1
  20. package/dist/exports/client/index.d.ts +14 -6
  21. package/dist/exports/client/index.d.ts.map +1 -1
  22. package/dist/exports/client/index.js +38 -18
  23. package/dist/exports/client/index.js.map +5 -4
  24. package/dist/exports/shared/index.d.ts +2 -1
  25. package/dist/exports/shared/index.d.ts.map +1 -1
  26. package/dist/exports/shared/index.js +2 -2
  27. package/dist/exports/shared/index.js.map +4 -4
  28. package/dist/fields/Array/index.d.ts +1 -2
  29. package/dist/fields/Array/index.d.ts.map +1 -1
  30. package/dist/fields/Array/index.js +2 -3
  31. package/dist/fields/Array/index.js.map +1 -1
  32. package/dist/fields/Blocks/index.d.ts +2 -3
  33. package/dist/fields/Blocks/index.d.ts.map +1 -1
  34. package/dist/fields/Blocks/index.js +5 -5
  35. package/dist/fields/Blocks/index.js.map +1 -1
  36. package/dist/fields/Collapsible/index.d.ts +0 -2
  37. package/dist/fields/Collapsible/index.d.ts.map +1 -1
  38. package/dist/fields/Collapsible/index.js.map +1 -1
  39. package/dist/fields/Group/index.d.ts +0 -2
  40. package/dist/fields/Group/index.d.ts.map +1 -1
  41. package/dist/fields/Group/index.js.map +1 -1
  42. package/dist/fields/Tabs/index.d.ts +0 -2
  43. package/dist/fields/Tabs/index.d.ts.map +1 -1
  44. package/dist/fields/Tabs/index.js +2 -2
  45. package/dist/fields/Tabs/index.js.map +1 -1
  46. package/dist/forms/Form/getDataByPath.d.ts.map +1 -1
  47. package/dist/forms/Form/getDataByPath.js +1 -2
  48. package/dist/forms/Form/getDataByPath.js.map +1 -1
  49. package/dist/forms/Form/getSiblingData.d.ts.map +1 -1
  50. package/dist/forms/Form/getSiblingData.js +2 -5
  51. package/dist/forms/Form/getSiblingData.js.map +1 -1
  52. package/dist/utilities/reduceFieldsToValues.d.ts.map +1 -1
  53. package/dist/utilities/reduceFieldsToValues.js +2 -5
  54. package/dist/utilities/reduceFieldsToValues.js.map +1 -1
  55. package/dist/utilities/reduceFieldsToValuesWithValidation.d.ts.map +1 -1
  56. package/dist/utilities/reduceFieldsToValuesWithValidation.js +2 -5
  57. package/dist/utilities/reduceFieldsToValuesWithValidation.js.map +1 -1
  58. package/dist/utilities/unflatten.d.ts +9 -0
  59. package/dist/utilities/unflatten.d.ts.map +1 -0
  60. package/dist/utilities/unflatten.js +58 -0
  61. package/dist/utilities/unflatten.js.map +1 -0
  62. package/package.json +46 -56
  63. package/dist/exports/client/DatePicker-AXHBRRH5.js +0 -18
@@ -1,4 +1,3 @@
1
- import type { FieldPermissions } from 'payload';
2
1
  import React from 'react';
3
2
  import './index.scss';
4
3
  import type { FieldMap } from '../../providers/ComponentMap/buildComponentMap/types.js';
@@ -6,7 +5,6 @@ import type { FormFieldBase } from '../shared/index.js';
6
5
  export type CollapsibleFieldProps = FormFieldBase & {
7
6
  fieldMap: FieldMap;
8
7
  initCollapsed?: boolean;
9
- permissions: FieldPermissions;
10
8
  width?: string;
11
9
  };
12
10
  export declare const Collapsible: React.FC<CollapsibleFieldProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Collapsible/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAuB,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAEpE,OAAO,KAAqD,MAAM,OAAO,CAAA;AAazE,OAAO,cAAc,CAAA;AAIrB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yDAAyD,CAAA;AACvF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAKvD,MAAM,MAAM,qBAAqB,GAAG,aAAa,GAAG;IAClD,QAAQ,EAAE,QAAQ,CAAA;IAClB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,WAAW,EAAE,gBAAgB,CAAA;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAwID,eAAO,MAAM,WAAW,iCAAkC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Collapsible/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAqD,MAAM,OAAO,CAAA;AAazE,OAAO,cAAc,CAAA;AAIrB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yDAAyD,CAAA;AACvF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAKvD,MAAM,MAAM,qBAAqB,GAAG,aAAa,GAAG;IAClD,QAAQ,EAAE,QAAQ,CAAA;IAClB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAwID,eAAO,MAAM,WAAW,iCAAkC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Collapsible/index.tsx"],"sourcesContent":["'use client'\nimport type { DocumentPreferences, FieldPermissions } from 'payload'\n\nimport React, { Fragment, useCallback, useEffect, useState } from 'react'\n\nimport { Collapsible as CollapsibleElement } from '../../elements/Collapsible/index.js'\nimport { ErrorPill } from '../../elements/ErrorPill/index.js'\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { RenderFields } from '../../forms/RenderFields/index.js'\nimport { RowLabel } from '../../forms/RowLabel/index.js'\nimport { WatchChildErrors } from '../../forms/WatchChildErrors/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { usePreferences } from '../../providers/Preferences/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst baseClass = 'collapsible-field'\n\nimport type { FieldMap } from '../../providers/ComponentMap/buildComponentMap/types.js'\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useFormInitializing, useFormProcessing } from '../../forms/Form/context.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\n\nexport type CollapsibleFieldProps = FormFieldBase & {\n fieldMap: FieldMap\n initCollapsed?: boolean\n permissions: FieldPermissions\n width?: string\n}\n\nconst CollapsibleField: React.FC<CollapsibleFieldProps> = (props) => {\n const {\n CustomDescription,\n CustomLabel,\n className,\n descriptionProps,\n fieldMap,\n initCollapsed = false,\n label,\n path: pathFromProps,\n readOnly: readOnlyFromProps,\n } = props\n\n const {\n indexPath,\n path: pathFromContext,\n readOnly: readOnlyFromContext,\n schemaPath,\n siblingPermissions,\n } = useFieldProps()\n\n const formInitializing = useFormInitializing()\n const formProcessing = useFormProcessing()\n\n const path = pathFromContext ?? pathFromProps\n\n const { i18n } = useTranslation()\n const { getPreference, setPreference } = usePreferences()\n const { preferencesKey } = useDocumentInfo()\n const [collapsedOnMount, setCollapsedOnMount] = useState<boolean>()\n const fieldPreferencesKey = `collapsible-${indexPath.replace(/\\./g, '__')}`\n const [errorCount, setErrorCount] = useState(0)\n const fieldHasErrors = errorCount > 0\n\n const onToggle = useCallback(\n async (newCollapsedState: boolean) => {\n const existingPreferences: DocumentPreferences = await getPreference(preferencesKey)\n\n if (preferencesKey) {\n void setPreference(preferencesKey, {\n ...existingPreferences,\n ...(path\n ? {\n fields: {\n ...(existingPreferences?.fields || {}),\n [path]: {\n ...existingPreferences?.fields?.[path],\n collapsed: newCollapsedState,\n },\n },\n }\n : {\n fields: {\n ...(existingPreferences?.fields || {}),\n [fieldPreferencesKey]: {\n ...existingPreferences?.fields?.[fieldPreferencesKey],\n collapsed: newCollapsedState,\n },\n },\n }),\n })\n }\n },\n [preferencesKey, fieldPreferencesKey, getPreference, setPreference, path],\n )\n\n useEffect(() => {\n const fetchInitialState = async () => {\n if (preferencesKey) {\n const preferences = await getPreference(preferencesKey)\n const specificPreference = path\n ? preferences?.fields?.[path]?.collapsed\n : preferences?.fields?.[fieldPreferencesKey]?.collapsed\n\n if (specificPreference !== undefined) {\n setCollapsedOnMount(Boolean(specificPreference))\n } else {\n setCollapsedOnMount(typeof initCollapsed === 'boolean' ? initCollapsed : false)\n }\n } else {\n setCollapsedOnMount(typeof initCollapsed === 'boolean' ? initCollapsed : false)\n }\n }\n\n void fetchInitialState()\n }, [getPreference, preferencesKey, fieldPreferencesKey, initCollapsed, path])\n\n if (typeof collapsedOnMount !== 'boolean') return null\n\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n return (\n <Fragment>\n <WatchChildErrors fieldMap={fieldMap} path={path} setErrorCount={setErrorCount} />\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n fieldHasErrors ? `${baseClass}--has-error` : `${baseClass}--has-no-error`,\n ]\n .filter(Boolean)\n .join(' ')}\n id={`field-${fieldPreferencesKey}${path ? `-${path.replace(/\\./g, '__')}` : ''}`}\n >\n <CollapsibleElement\n className={`${baseClass}__collapsible`}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n header={\n <div className={`${baseClass}__row-label-wrap`}>\n <RowLabel RowLabelComponent={CustomLabel} i18n={i18n} path={path} rowLabel={label} />\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n }\n initCollapsed={collapsedOnMount}\n onToggle={onToggle}\n >\n <RenderFields\n fieldMap={fieldMap}\n forceRender\n indexPath={indexPath}\n margins=\"small\"\n path={path}\n permissions={siblingPermissions}\n readOnly={disabled}\n schemaPath={schemaPath}\n />\n </CollapsibleElement>\n <FieldDescription CustomDescription={CustomDescription} {...(descriptionProps || {})} />\n </div>\n </Fragment>\n )\n}\n\nexport const Collapsible = withCondition(CollapsibleField)\n"],"names":["React","Fragment","useCallback","useEffect","useState","Collapsible","CollapsibleElement","ErrorPill","useFieldProps","RenderFields","RowLabel","WatchChildErrors","withCondition","useDocumentInfo","usePreferences","useTranslation","fieldBaseClass","baseClass","useFormInitializing","useFormProcessing","FieldDescription","CollapsibleField","props","CustomDescription","CustomLabel","className","descriptionProps","fieldMap","initCollapsed","label","path","pathFromProps","readOnly","readOnlyFromProps","indexPath","pathFromContext","readOnlyFromContext","schemaPath","siblingPermissions","formInitializing","formProcessing","i18n","getPreference","setPreference","preferencesKey","collapsedOnMount","setCollapsedOnMount","fieldPreferencesKey","replace","errorCount","setErrorCount","fieldHasErrors","onToggle","newCollapsedState","existingPreferences","fields","collapsed","fetchInitialState","preferences","specificPreference","undefined","Boolean","disabled","div","filter","join","id","collapsibleStyle","header","RowLabelComponent","rowLabel","count","withMessage","force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cO,cAAcS,kBAAiB"}
1
+ {"version":3,"sources":["../../../src/fields/Collapsible/index.tsx"],"sourcesContent":["'use client'\nimport type { DocumentPreferences, FieldPermissions } from 'payload'\n\nimport React, { Fragment, useCallback, useEffect, useState } from 'react'\n\nimport { Collapsible as CollapsibleElement } from '../../elements/Collapsible/index.js'\nimport { ErrorPill } from '../../elements/ErrorPill/index.js'\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { RenderFields } from '../../forms/RenderFields/index.js'\nimport { RowLabel } from '../../forms/RowLabel/index.js'\nimport { WatchChildErrors } from '../../forms/WatchChildErrors/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { usePreferences } from '../../providers/Preferences/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst baseClass = 'collapsible-field'\n\nimport type { FieldMap } from '../../providers/ComponentMap/buildComponentMap/types.js'\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useFormInitializing, useFormProcessing } from '../../forms/Form/context.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\n\nexport type CollapsibleFieldProps = FormFieldBase & {\n fieldMap: FieldMap\n initCollapsed?: boolean\n width?: string\n}\n\nconst CollapsibleField: React.FC<CollapsibleFieldProps> = (props) => {\n const {\n CustomDescription,\n CustomLabel,\n className,\n descriptionProps,\n fieldMap,\n initCollapsed = false,\n label,\n path: pathFromProps,\n readOnly: readOnlyFromProps,\n } = props\n\n const {\n indexPath,\n path: pathFromContext,\n readOnly: readOnlyFromContext,\n schemaPath,\n siblingPermissions,\n } = useFieldProps()\n\n const formInitializing = useFormInitializing()\n const formProcessing = useFormProcessing()\n\n const path = pathFromContext ?? pathFromProps\n\n const { i18n } = useTranslation()\n const { getPreference, setPreference } = usePreferences()\n const { preferencesKey } = useDocumentInfo()\n const [collapsedOnMount, setCollapsedOnMount] = useState<boolean>()\n const fieldPreferencesKey = `collapsible-${indexPath.replace(/\\./g, '__')}`\n const [errorCount, setErrorCount] = useState(0)\n const fieldHasErrors = errorCount > 0\n\n const onToggle = useCallback(\n async (newCollapsedState: boolean) => {\n const existingPreferences: DocumentPreferences = await getPreference(preferencesKey)\n\n if (preferencesKey) {\n void setPreference(preferencesKey, {\n ...existingPreferences,\n ...(path\n ? {\n fields: {\n ...(existingPreferences?.fields || {}),\n [path]: {\n ...existingPreferences?.fields?.[path],\n collapsed: newCollapsedState,\n },\n },\n }\n : {\n fields: {\n ...(existingPreferences?.fields || {}),\n [fieldPreferencesKey]: {\n ...existingPreferences?.fields?.[fieldPreferencesKey],\n collapsed: newCollapsedState,\n },\n },\n }),\n })\n }\n },\n [preferencesKey, fieldPreferencesKey, getPreference, setPreference, path],\n )\n\n useEffect(() => {\n const fetchInitialState = async () => {\n if (preferencesKey) {\n const preferences = await getPreference(preferencesKey)\n const specificPreference = path\n ? preferences?.fields?.[path]?.collapsed\n : preferences?.fields?.[fieldPreferencesKey]?.collapsed\n\n if (specificPreference !== undefined) {\n setCollapsedOnMount(Boolean(specificPreference))\n } else {\n setCollapsedOnMount(typeof initCollapsed === 'boolean' ? initCollapsed : false)\n }\n } else {\n setCollapsedOnMount(typeof initCollapsed === 'boolean' ? initCollapsed : false)\n }\n }\n\n void fetchInitialState()\n }, [getPreference, preferencesKey, fieldPreferencesKey, initCollapsed, path])\n\n if (typeof collapsedOnMount !== 'boolean') return null\n\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n return (\n <Fragment>\n <WatchChildErrors fieldMap={fieldMap} path={path} setErrorCount={setErrorCount} />\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n fieldHasErrors ? `${baseClass}--has-error` : `${baseClass}--has-no-error`,\n ]\n .filter(Boolean)\n .join(' ')}\n id={`field-${fieldPreferencesKey}${path ? `-${path.replace(/\\./g, '__')}` : ''}`}\n >\n <CollapsibleElement\n className={`${baseClass}__collapsible`}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n header={\n <div className={`${baseClass}__row-label-wrap`}>\n <RowLabel RowLabelComponent={CustomLabel} i18n={i18n} path={path} rowLabel={label} />\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n }\n initCollapsed={collapsedOnMount}\n onToggle={onToggle}\n >\n <RenderFields\n fieldMap={fieldMap}\n forceRender\n indexPath={indexPath}\n margins=\"small\"\n path={path}\n permissions={siblingPermissions}\n readOnly={disabled}\n schemaPath={schemaPath}\n />\n </CollapsibleElement>\n <FieldDescription CustomDescription={CustomDescription} {...(descriptionProps || {})} />\n </div>\n </Fragment>\n )\n}\n\nexport const Collapsible = withCondition(CollapsibleField)\n"],"names":["React","Fragment","useCallback","useEffect","useState","Collapsible","CollapsibleElement","ErrorPill","useFieldProps","RenderFields","RowLabel","WatchChildErrors","withCondition","useDocumentInfo","usePreferences","useTranslation","fieldBaseClass","baseClass","useFormInitializing","useFormProcessing","FieldDescription","CollapsibleField","props","CustomDescription","CustomLabel","className","descriptionProps","fieldMap","initCollapsed","label","path","pathFromProps","readOnly","readOnlyFromProps","indexPath","pathFromContext","readOnlyFromContext","schemaPath","siblingPermissions","formInitializing","formProcessing","i18n","getPreference","setPreference","preferencesKey","collapsedOnMount","setCollapsedOnMount","fieldPreferencesKey","replace","errorCount","setErrorCount","fieldHasErrors","onToggle","newCollapsedState","existingPreferences","fields","collapsed","fetchInitialState","preferences","specificPreference","undefined","Boolean","disabled","div","filter","join","id","collapsibleStyle","header","RowLabelComponent","rowLabel","count","withMessage","forceRender","margins","permissions"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAGA,OAAOA,SAASC,QAAQ,EAAEC,WAA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iBgB,UAAUA;gBAAUG,MAAMA;gBAAMoB,eAAeA;;0BACjE,MAACa;gBACCtC,WAAW;oBACTT;oBACAC;oBACAQ;oBACA0B,iBAAiB,CAAC,EAAElC,UAAU,WAAW,CAAC,GAAG,CAAC,EAAEA,UAAU,cAAc,CAAC;iBAC1E,CACE+C,MAAM,CAACH,SACPI,IAAI,CAAC;gBACRC,IAAI,CAAC,MAAM,EAAEnB,oBAAoB,EAAEjB,OAAO,CAAC,CAAC,EAAEA,KAAKkB,OAAO,CAAC,OAAO,MAAM,CAAC,GAAG,GAAG,CAAC;;kCAEhF,KAAC1C;wBACCmB,WAAW,CAAC,EAAER,UAAU,aAAa,CAAC;wBACtCkD,kBAAkBhB,iBAAiB,UAAU;wBAC7CiB,sBACE,MAACL;4BAAItC,WAAW,CAAC,EAAER,UAAU,gBAAgB,CAAC;;8CAC5C,KAACP;oCAAS2D,mBAAmB7C;oCAAaiB,MAAMA;oCAAMX,MAAMA;oCAAMwC,UAAUzC;;gCAC3EsB,gCAAkB,KAAC5C;oCAAUgE,OAAOtB;oCAAYR,MAAMA;oCAAM+B,WAAW;;;;wBAG5E5C,eAAeiB;wBACfO,UAAUA;kCAEV,cAAA,KAAC3C;4BACCkB,UAAUA;4BACV8C,WAAW;4BACXvC,WAAWA;4BACXwC,SAAQ;4BACR5C,MAAMA;4BACN6C,aAAarC;4BACbN,UAAU8B;4BACVzB,YAAYA;;;kCAGhB,KAACjB;wBAAiBG,mBAAmBA;wBAAoB,GAAIG,oBAAoB,CAAC,CAAC;;;;;;AAI3F;AAEA,OAAO,MAAMrB,cAAcO,cAAcS,kBAAiB"}
@@ -1,4 +1,3 @@
1
- import type { FieldPermissions } from 'payload';
2
1
  import React from 'react';
3
2
  import type { FieldMap } from '../../providers/ComponentMap/buildComponentMap/types.js';
4
3
  import type { FormFieldBase } from '../shared/index.js';
@@ -9,7 +8,6 @@ export type GroupFieldProps = FormFieldBase & {
9
8
  forceRender?: boolean;
10
9
  hideGutter?: boolean;
11
10
  name?: string;
12
- permissions: FieldPermissions;
13
11
  width?: string;
14
12
  };
15
13
  export { GroupProvider, useGroup };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Group/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAG/C,OAAO,KAAmB,MAAM,OAAO,CAAA;AAEvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yDAAyD,CAAA;AACvF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAkBvD,OAAO,cAAc,CAAA;AACrB,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAIvD,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,QAAQ,EAAE,QAAQ,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,gBAAgB,CAAA;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAyFD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAA;AAElC,eAAO,MAAM,KAAK,2BAA4B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Group/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAEvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yDAAyD,CAAA;AACvF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAkBvD,OAAO,cAAc,CAAA;AACrB,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAIvD,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,QAAQ,EAAE,QAAQ,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAyFD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAA;AAElC,eAAO,MAAM,KAAK,2BAA4B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Group/index.tsx"],"sourcesContent":["'use client'\nimport type { FieldPermissions } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { Fragment } from 'react'\n\nimport type { FieldMap } from '../../providers/ComponentMap/buildComponentMap/types.js'\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useCollapsible } from '../../elements/Collapsible/provider.js'\nimport { ErrorPill } from '../../elements/ErrorPill/index.js'\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport {\n useFormInitializing,\n useFormProcessing,\n useFormSubmitted,\n} from '../../forms/Form/context.js'\nimport { RenderFields } from '../../forms/RenderFields/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { useRow } from '../Row/provider.js'\nimport { useTabs } from '../Tabs/provider.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\nimport { GroupProvider, useGroup } from './provider.js'\n\nconst baseClass = 'group-field'\n\nexport type GroupFieldProps = FormFieldBase & {\n fieldMap: FieldMap\n forceRender?: boolean\n hideGutter?: boolean\n name?: string\n permissions: FieldPermissions\n width?: string\n}\n\nconst GroupField: React.FC<GroupFieldProps> = (props) => {\n const {\n CustomDescription,\n CustomLabel,\n className,\n descriptionProps,\n fieldMap,\n hideGutter,\n label,\n readOnly: readOnlyFromProps,\n style,\n width,\n } = props\n\n const { path, permissions, readOnly: readOnlyFromContext, schemaPath } = useFieldProps()\n const { i18n } = useTranslation()\n const { isWithinCollapsible } = useCollapsible()\n const isWithinGroup = useGroup()\n const isWithinRow = useRow()\n const isWithinTab = useTabs()\n const { errorPaths } = useField({ path })\n const formInitializing = useFormInitializing()\n const formProcessing = useFormProcessing()\n const submitted = useFormSubmitted()\n const errorCount = errorPaths.length\n const fieldHasErrors = submitted && errorCount > 0\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n const isTopLevel = !(isWithinCollapsible || isWithinGroup || isWithinRow)\n\n return (\n <Fragment>\n <div\n className={[\n fieldBaseClass,\n baseClass,\n isTopLevel && `${baseClass}--top-level`,\n isWithinCollapsible && `${baseClass}--within-collapsible`,\n isWithinGroup && `${baseClass}--within-group`,\n isWithinRow && `${baseClass}--within-row`,\n isWithinTab && `${baseClass}--within-tab`,\n !hideGutter && isWithinGroup && `${baseClass}--gutter`,\n fieldHasErrors && `${baseClass}--has-error`,\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n id={`field-${path?.replace(/\\./g, '__')}`}\n style={{\n ...style,\n width,\n }}\n >\n <GroupProvider>\n <div className={`${baseClass}__wrap`}>\n <div className={`${baseClass}__header`}>\n {(CustomLabel || CustomDescription || label) && (\n <header>\n {CustomLabel !== undefined ? (\n CustomLabel\n ) : label ? (\n <h3 className={`${baseClass}__title`}>{getTranslation(label, i18n)}</h3>\n ) : null}\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </header>\n )}\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n <RenderFields\n fieldMap={fieldMap}\n margins=\"small\"\n path={path}\n permissions={permissions?.fields}\n readOnly={disabled}\n schemaPath={schemaPath}\n />\n </div>\n </GroupProvider>\n </div>\n </Fragment>\n )\n}\n\nexport { GroupProvider, useGroup }\n\nexport const Group = withCondition(GroupField)\n"],"names":["getTranslation","React","Fragment","useCollapsible","ErrorPill","useFieldProps","useFormInitializing","useFormProcessing","useFormSubmitted","RenderFields","useField","withCondition","useTranslation","FieldDescription","useRow","useTabs","fieldBaseClass","GroupProvider","useGroup","baseClass","GroupField","props","CustomDescription","CustomLabel","className","descriptionProps","fieldMap","hideGutter","label","readOnly","readOnlyFromProps","style","width","path","permissions","readOnlyFromContext","schemaPath","i18n","isWithinCollapsible","isWithinGroup","isWithinRow","isWithinTab","errorPaths","formInitializing","formProcessing","submitted","errorCount","length","fieldHasErrors","disabled","isTopLevel","div","filter","Boolean","join","id","replace","header","undefined","h3","count","withMessage","margins","fields","Group"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,SAASC,QAAQ,QAAQ,QAAO;AAKvC,SAASC,cAAc,QAAQ,yCAAwC;AACvE,SAASC,SAAS,QAAQ,oCAAmC;AAC7D,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SACEC,mBAAmB,EACnBC,iBAAiB,EACjBC,gBAAgB,QACX,8BAA6B;AACpC,SAASC,YAAY,QAAQ,oCAAmC;AAChE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,gBAAgB,QAAQ,+BAA8B;AAC/D,SAASC,MAAM,QAAQ,qBAAoB;AAC3C,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,cAAc,QAAQ,qBAAoB;AACnD,OAAO,eAAc;AACrB,SAASC,aAAa,EAAEC,QAAQ,QAAQ,gBAAe;AAEvD,MAAMC,YAAY;AAWlB,MAAMC,aAAwC,CAACC;IAC7C,MAAM,EACJC,iBAAiB,EACjBC,WAAW,EACXC,SAAS,EACTC,gBAAgB,EAChBC,QAAQ,EACRC,UAAU,EACVC,KAAK,EACLC,UAAUC,iBAA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kC;oBAAI3B,WAAW,CAAC,EAAEL,UAAU,MAAM,CAAC;;sCAClC,MAACgC;4BAAI3B,WAAW,CAAC,EAAEL,UAAU,QAAQ,CAAC;;gCAClCI,CAAAA,eAAeD,qBAAqBM,KAAI,mBACxC,MAAC6B;;wCACElC,gBAAgBmC,YACfnC,cACEK,sBACF,KAAC+B;4CAAGnC,WAAW,CAAC,EAAEL,UAAU,OAAO,CAAC;sDAAGnB,eAAe4B,OAAOS;6CAC3D;wCACHf,sBAAsBoC,YACrBpC,kCAEA,KAACT;4CAAkB,GAAIY,oBAAoB,CAAC,CAAC;;;;gCAIlDuB,gCAAkB,KAAC5C;oCAAUwD,OAAOd;oCAAYT,MAAMA;oCAAMwB,WAAW;;;;sCAE1E,KAACpD;4BACCiB,UAAUA;4BACVoC,SAAQ;4BACR7B,MAAMA;4BACNC,aAAaA,aAAa6B;4BAC1BlC,UAAUoB;4BACVb,YAAYA;;;;;;;AAO1B;AAEA,SAASnB,aAAa,EAAEC,QAAQ,GAAE;AAElC,OAAO,MAAM8C,QAAQrD,cAAcS,YAAW"}
1
+ {"version":3,"sources":["../../../src/fields/Group/index.tsx"],"sourcesContent":["'use client'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { Fragment } from 'react'\n\nimport type { FieldMap } from '../../providers/ComponentMap/buildComponentMap/types.js'\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useCollapsible } from '../../elements/Collapsible/provider.js'\nimport { ErrorPill } from '../../elements/ErrorPill/index.js'\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport {\n useFormInitializing,\n useFormProcessing,\n useFormSubmitted,\n} from '../../forms/Form/context.js'\nimport { RenderFields } from '../../forms/RenderFields/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { useRow } from '../Row/provider.js'\nimport { useTabs } from '../Tabs/provider.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\nimport { GroupProvider, useGroup } from './provider.js'\n\nconst baseClass = 'group-field'\n\nexport type GroupFieldProps = FormFieldBase & {\n fieldMap: FieldMap\n forceRender?: boolean\n hideGutter?: boolean\n name?: string\n width?: string\n}\n\nconst GroupField: React.FC<GroupFieldProps> = (props) => {\n const {\n CustomDescription,\n CustomLabel,\n className,\n descriptionProps,\n fieldMap,\n hideGutter,\n label,\n readOnly: readOnlyFromProps,\n style,\n width,\n } = props\n\n const { path, permissions, readOnly: readOnlyFromContext, schemaPath } = useFieldProps()\n const { i18n } = useTranslation()\n const { isWithinCollapsible } = useCollapsible()\n const isWithinGroup = useGroup()\n const isWithinRow = useRow()\n const isWithinTab = useTabs()\n const { errorPaths } = useField({ path })\n const formInitializing = useFormInitializing()\n const formProcessing = useFormProcessing()\n const submitted = useFormSubmitted()\n const errorCount = errorPaths.length\n const fieldHasErrors = submitted && errorCount > 0\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n const isTopLevel = !(isWithinCollapsible || isWithinGroup || isWithinRow)\n\n return (\n <Fragment>\n <div\n className={[\n fieldBaseClass,\n baseClass,\n isTopLevel && `${baseClass}--top-level`,\n isWithinCollapsible && `${baseClass}--within-collapsible`,\n isWithinGroup && `${baseClass}--within-group`,\n isWithinRow && `${baseClass}--within-row`,\n isWithinTab && `${baseClass}--within-tab`,\n !hideGutter && isWithinGroup && `${baseClass}--gutter`,\n fieldHasErrors && `${baseClass}--has-error`,\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n id={`field-${path?.replace(/\\./g, '__')}`}\n style={{\n ...style,\n width,\n }}\n >\n <GroupProvider>\n <div className={`${baseClass}__wrap`}>\n <div className={`${baseClass}__header`}>\n {(CustomLabel || CustomDescription || label) && (\n <header>\n {CustomLabel !== undefined ? (\n CustomLabel\n ) : label ? (\n <h3 className={`${baseClass}__title`}>{getTranslation(label, i18n)}</h3>\n ) : null}\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </header>\n )}\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n <RenderFields\n fieldMap={fieldMap}\n margins=\"small\"\n path={path}\n permissions={permissions?.fields}\n readOnly={disabled}\n schemaPath={schemaPath}\n />\n </div>\n </GroupProvider>\n </div>\n </Fragment>\n )\n}\n\nexport { GroupProvider, useGroup }\n\nexport const Group = withCondition(GroupField)\n"],"names":["getTranslation","React","Fragment","useCollapsible","ErrorPill","useFieldProps","useFormInitializing","useFormProcessing","useFormSubmitted","RenderFields","useField","withCondition","useTranslation","FieldDescription","useRow","useTabs","fieldBaseClass","GroupProvider","useGroup","baseClass","GroupField","props","CustomDescription","CustomLabel","className","descriptionProps","fieldMap","hideGutter","label","readOnly","readOnlyFromProps","style","width","path","permissions","readOnlyFromContext","schemaPath","i18n","isWithinCollapsible","isWithinGroup","isWithinRow","isWithinTab","errorPaths","formInitializing","formProcessing","submitted","errorCount","length","fieldHasErrors","disabled","isTopLevel","div","filter","Boolean","join","id","replace","header","undefined","h3","count","withMessage","margins","fields","Group"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAEA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,SAASC,QAAQ,QAAQ,QAAO;AAKvC,SAASC,cAAc,QAAQ,yCAAwC;AACvE,SAASC,SAAS,QAAQ,oCAAmC;AAC7D,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SACEC,mBAAmB,EACnBC,iBAAiB,EACjBC,gBAAgB,QACX,8BAA6B;AACpC,SAASC,YAAY,QAAQ,oCAAmC;AAChE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,cAAc,QA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AAC,EAAErB,UAAU,YAAY,CAAC;gBACzCsB,eAAe,CAAC,EAAEtB,UAAU,YAAY,CAAC;gBACzC,CAACQ,cAAcY,iBAAiB,CAAC,EAAEpB,UAAU,QAAQ,CAAC;gBACtD6B,kBAAkB,CAAC,EAAE7B,UAAU,WAAW,CAAC;gBAC3CK;aACD,CACE4B,MAAM,CAACC,SACPC,IAAI,CAAC;YACRC,IAAI,CAAC,MAAM,EAAEtB,MAAMuB,QAAQ,OAAO,MAAM,CAAC;YACzCzB,OAAO;gBACL,GAAGA,KAAK;gBACRC;YACF;sBAEA,cAAA,KAACf;0BACC,cAAA,MAACkC;oBAAI3B,WAAW,CAAC,EAAEL,UAAU,MAAM,CAAC;;sCAClC,MAACgC;4BAAI3B,WAAW,CAAC,EAAEL,UAAU,QAAQ,CAAC;;gCAClCI,CAAAA,eAAeD,qBAAqBM,KAAI,mBACxC,MAAC6B;;wCACElC,gBAAgBmC,YACfnC,cACEK,sBACF,KAAC+B;4CAAGnC,WAAW,CAAC,EAAEL,UAAU,OAAO,CAAC;sDAAGnB,eAAe4B,OAAOS;6CAC3D;wCACHf,sBAAsBoC,YACrBpC,kCAEA,KAACT;4CAAkB,GAAIY,oBAAoB,CAAC,CAAC;;;;gCAIlDuB,gCAAkB,KAAC5C;oCAAUwD,OAAOd;oCAAYT,MAAMA;oCAAMwB,WAAW;;;;sCAE1E,KAACpD;4BACCiB,UAAUA;4BACVoC,SAAQ;4BACR7B,MAAMA;4BACNC,aAAaA,aAAa6B;4BAC1BlC,UAAUoB;4BACVb,YAAYA;;;;;;;AAO1B;AAEA,SAASnB,aAAa,EAAEC,QAAQ,GAAE;AAElC,OAAO,MAAM8C,QAAQrD,cAAcS,YAAW"}
@@ -1,4 +1,3 @@
1
- import type { FieldPermissions } from 'payload';
2
1
  import React from 'react';
3
2
  import type { MappedTab } from '../../providers/ComponentMap/buildComponentMap/types.js';
4
3
  import type { FormFieldBase } from '../shared/index.js';
@@ -9,7 +8,6 @@ export type TabsFieldProps = FormFieldBase & {
9
8
  forceRender?: boolean;
10
9
  name?: string;
11
10
  path?: string;
12
- permissions: FieldPermissions;
13
11
  tabs?: MappedTab[];
14
12
  width?: string;
15
13
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Tabs/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAuB,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAIpE,OAAO,KAA2C,MAAM,OAAO,CAAA;AAE/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yDAAyD,CAAA;AACxF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAYvD,OAAO,cAAc,CAAA;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAI5C,OAAO,EAAE,YAAY,EAAE,CAAA;AAEvB,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG;IAC3C,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,gBAAgB,CAAA;IAC7B,IAAI,CAAC,EAAE,SAAS,EAAE,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAoKD,eAAO,MAAM,IAAI,0BAA2B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Tabs/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAE/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yDAAyD,CAAA;AACxF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAYvD,OAAO,cAAc,CAAA;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAI5C,OAAO,EAAE,YAAY,EAAE,CAAA;AAEvB,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG;IAC3C,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,SAAS,EAAE,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAoKD,eAAO,MAAM,IAAI,0BAA2B,CAAA"}
@@ -19,7 +19,7 @@ const baseClass = 'tabs-field';
19
19
  export { TabsProvider };
20
20
  const TabsField = (props)=>{
21
21
  const { name, CustomDescription, className, descriptionProps, forceRender = false, path: pathFromProps, readOnly: readOnlyFromProps, tabs = [] } = props;
22
- const { indexPath, path: pathFromContext, permissions, readOnly: readOnlyFromContext, schemaPath } = useFieldProps();
22
+ const { indexPath, path: pathFromContext, readOnly: readOnlyFromContext, schemaPath, siblingPermissions } = useFieldProps();
23
23
  const readOnly = readOnlyFromProps || readOnlyFromContext;
24
24
  const path = pathFromContext ?? pathFromProps ?? name;
25
25
  const { getPreference, setPreference } = usePreferences();
@@ -125,7 +125,7 @@ const TabsField = (props)=>{
125
125
  forceRender: forceRender,
126
126
  margins: "small",
127
127
  path: generateTabPath(),
128
- permissions: 'name' in activeTabConfig && permissions?.fields?.[activeTabConfig.name]?.fields ? permissions?.fields?.[activeTabConfig.name]?.fields : permissions?.fields,
128
+ permissions: 'name' in activeTabConfig && siblingPermissions?.[activeTabConfig.name]?.fields ? siblingPermissions[activeTabConfig.name]?.fields : siblingPermissions,
129
129
  readOnly: readOnly,
130
130
  schemaPath: `${schemaPath ? `${schemaPath}` : ''}${activeTabConfig.name ? `.${activeTabConfig.name}` : ''}`
131
131
  }, activeTabConfig.label ? getTranslation(activeTabConfig.label, i18n) : activeTabConfig['name'])
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Tabs/index.tsx"],"sourcesContent":["'use client'\nimport type { DocumentPreferences, FieldPermissions } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { toKebabCase } from 'payload/shared'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { MappedTab } from '../../providers/ComponentMap/buildComponentMap/types.js'\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useCollapsible } from '../../elements/Collapsible/provider.js'\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { RenderFields } from '../../forms/RenderFields/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { usePreferences } from '../../providers/Preferences/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport { TabComponent } from './Tab/index.js'\nimport './index.scss'\nimport { TabsProvider } from './provider.js'\n\nconst baseClass = 'tabs-field'\n\nexport { TabsProvider }\n\nexport type TabsFieldProps = FormFieldBase & {\n forceRender?: boolean\n name?: string\n path?: string\n permissions: FieldPermissions\n tabs?: MappedTab[]\n width?: string\n}\n\nconst TabsField: React.FC<TabsFieldProps> = (props) => {\n const {\n name,\n CustomDescription,\n className,\n descriptionProps,\n forceRender = false,\n path: pathFromProps,\n readOnly: readOnlyFromProps,\n tabs = [],\n } = props\n\n const {\n indexPath,\n path: pathFromContext,\n permissions,\n readOnly: readOnlyFromContext,\n schemaPath,\n } = useFieldProps()\n\n const readOnly = readOnlyFromProps || readOnlyFromContext\n const path = pathFromContext ?? pathFromProps ?? name\n const { getPreference, setPreference } = usePreferences()\n const { preferencesKey } = useDocumentInfo()\n const { i18n } = useTranslation()\n const { isWithinCollapsible } = useCollapsible()\n const [activeTabIndex, setActiveTabIndex] = useState<number>(0)\n const tabsPrefKey = `tabs-${indexPath}`\n\n useEffect(() => {\n if (preferencesKey) {\n const getInitialPref = async () => {\n const existingPreferences: DocumentPreferences = await getPreference(preferencesKey)\n const initialIndex = path\n ? existingPreferences?.fields?.[path]?.tabIndex\n : existingPreferences?.fields?.[tabsPrefKey]?.tabIndex\n setActiveTabIndex(initialIndex || 0)\n }\n void getInitialPref()\n }\n }, [path, getPreference, preferencesKey, tabsPrefKey])\n\n const handleTabChange = useCallback(\n async (incomingTabIndex: number) => {\n setActiveTabIndex(incomingTabIndex)\n\n const existingPreferences: DocumentPreferences = await getPreference(preferencesKey)\n\n if (preferencesKey) {\n void setPreference(preferencesKey, {\n ...existingPreferences,\n ...(path\n ? {\n fields: {\n ...(existingPreferences?.fields || {}),\n [path]: {\n ...existingPreferences?.fields?.[path],\n tabIndex: incomingTabIndex,\n },\n },\n }\n : {\n fields: {\n ...existingPreferences?.fields,\n [tabsPrefKey]: {\n ...existingPreferences?.fields?.[tabsPrefKey],\n tabIndex: incomingTabIndex,\n },\n },\n }),\n })\n }\n },\n [preferencesKey, getPreference, setPreference, path, tabsPrefKey],\n )\n\n const activeTabConfig = tabs[activeTabIndex]\n\n function generateTabPath() {\n let tabPath = path\n if (path && activeTabConfig.name) {\n tabPath = `${path}.${activeTabConfig.name}`\n } else if (!path && activeTabConfig.name) {\n tabPath = activeTabConfig.name\n }\n\n return tabPath\n }\n\n return (\n <div\n className={[\n fieldBaseClass,\n className,\n baseClass,\n isWithinCollapsible && `${baseClass}--within-collapsible`,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <TabsProvider>\n <div className={`${baseClass}__tabs-wrap`}>\n <div className={`${baseClass}__tabs`}>\n {tabs.map((tab, tabIndex) => {\n return (\n <TabComponent\n isActive={activeTabIndex === tabIndex}\n key={tabIndex}\n parentPath={path}\n setIsActive={() => handleTabChange(tabIndex)}\n tab={tab}\n />\n )\n })}\n </div>\n </div>\n <div className={`${baseClass}__content-wrap`}>\n {activeTabConfig && (\n <React.Fragment>\n <div\n className={[\n `${baseClass}__tab`,\n activeTabConfig.label &&\n `${baseClass}__tabConfigLabel-${toKebabCase(\n getTranslation(activeTabConfig.label, i18n),\n )}`,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {CustomDescription ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n <RenderFields\n fieldMap={activeTabConfig.fieldMap}\n forceRender={forceRender}\n key={\n activeTabConfig.label\n ? getTranslation(activeTabConfig.label, i18n)\n : activeTabConfig['name']\n }\n margins=\"small\"\n path={generateTabPath()}\n permissions={\n 'name' in activeTabConfig && permissions?.fields?.[activeTabConfig.name]?.fields\n ? permissions?.fields?.[activeTabConfig.name]?.fields\n : permissions?.fields\n }\n readOnly={readOnly}\n schemaPath={`${schemaPath ? `${schemaPath}` : ''}${activeTabConfig.name ? `.${activeTabConfig.name}` : ''}`}\n />\n </div>\n </React.Fragment>\n )}\n </div>\n </TabsProvider>\n </div>\n )\n}\n\nexport const Tabs = withCondition(TabsField)\n"],"names":["getTranslation","toKebabCase","React","useCallback","useEffect","useState","useCollapsible","useFieldProps","RenderFields","withCondition","useDocumentInfo","usePreferences","useTranslation","FieldDescription","fieldBaseClass","TabComponent","TabsProvider","baseClass","TabsField","props","name","CustomDescription","className","descriptionProps","forceRender","path","pathFromProps","readOnly","readOnlyFromProps","tabs","indexPath","pathFromContext","permissions","readOnlyFromContext","schemaPath","getPreference","setPreference","preferencesKey","i18n","isWithinCollapsible","activeTabIndex","setActiveTabIndex","tabsPrefKey","getInitialPref","existingPreferences","initialIndex","fields","tabIndex","handleTabChange","incomingTabIndex","activeTabConfig","generateTabPath","tabPath","div","filter","Boolean","join","map","tab","isActive","parentPath","setIsActive","Fragment","label","fieldMap","margins","Tabs"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,WAAW,QAAQ,iBAAgB;AAC5C,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAK/D,SAASC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AAO,MAAMgB,OAAOzD,cAAcS,WAAU"}
1
+ {"version":3,"sources":["../../../src/fields/Tabs/index.tsx"],"sourcesContent":["'use client'\nimport type { DocumentPreferences } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { toKebabCase } from 'payload/shared'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { MappedTab } from '../../providers/ComponentMap/buildComponentMap/types.js'\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useCollapsible } from '../../elements/Collapsible/provider.js'\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { RenderFields } from '../../forms/RenderFields/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { usePreferences } from '../../providers/Preferences/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport { TabComponent } from './Tab/index.js'\nimport './index.scss'\nimport { TabsProvider } from './provider.js'\n\nconst baseClass = 'tabs-field'\n\nexport { TabsProvider }\n\nexport type TabsFieldProps = FormFieldBase & {\n forceRender?: boolean\n name?: string\n path?: string\n tabs?: MappedTab[]\n width?: string\n}\n\nconst TabsField: React.FC<TabsFieldProps> = (props) => {\n const {\n name,\n CustomDescription,\n className,\n descriptionProps,\n forceRender = false,\n path: pathFromProps,\n readOnly: readOnlyFromProps,\n tabs = [],\n } = props\n\n const {\n indexPath,\n path: pathFromContext,\n readOnly: readOnlyFromContext,\n schemaPath,\n siblingPermissions,\n } = useFieldProps()\n\n const readOnly = readOnlyFromProps || readOnlyFromContext\n const path = pathFromContext ?? pathFromProps ?? name\n const { getPreference, setPreference } = usePreferences()\n const { preferencesKey } = useDocumentInfo()\n const { i18n } = useTranslation()\n const { isWithinCollapsible } = useCollapsible()\n const [activeTabIndex, setActiveTabIndex] = useState<number>(0)\n const tabsPrefKey = `tabs-${indexPath}`\n\n useEffect(() => {\n if (preferencesKey) {\n const getInitialPref = async () => {\n const existingPreferences: DocumentPreferences = await getPreference(preferencesKey)\n const initialIndex = path\n ? existingPreferences?.fields?.[path]?.tabIndex\n : existingPreferences?.fields?.[tabsPrefKey]?.tabIndex\n setActiveTabIndex(initialIndex || 0)\n }\n void getInitialPref()\n }\n }, [path, getPreference, preferencesKey, tabsPrefKey])\n\n const handleTabChange = useCallback(\n async (incomingTabIndex: number) => {\n setActiveTabIndex(incomingTabIndex)\n\n const existingPreferences: DocumentPreferences = await getPreference(preferencesKey)\n\n if (preferencesKey) {\n void setPreference(preferencesKey, {\n ...existingPreferences,\n ...(path\n ? {\n fields: {\n ...(existingPreferences?.fields || {}),\n [path]: {\n ...existingPreferences?.fields?.[path],\n tabIndex: incomingTabIndex,\n },\n },\n }\n : {\n fields: {\n ...existingPreferences?.fields,\n [tabsPrefKey]: {\n ...existingPreferences?.fields?.[tabsPrefKey],\n tabIndex: incomingTabIndex,\n },\n },\n }),\n })\n }\n },\n [preferencesKey, getPreference, setPreference, path, tabsPrefKey],\n )\n\n const activeTabConfig = tabs[activeTabIndex]\n\n function generateTabPath() {\n let tabPath = path\n if (path && activeTabConfig.name) {\n tabPath = `${path}.${activeTabConfig.name}`\n } else if (!path && activeTabConfig.name) {\n tabPath = activeTabConfig.name\n }\n\n return tabPath\n }\n\n return (\n <div\n className={[\n fieldBaseClass,\n className,\n baseClass,\n isWithinCollapsible && `${baseClass}--within-collapsible`,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <TabsProvider>\n <div className={`${baseClass}__tabs-wrap`}>\n <div className={`${baseClass}__tabs`}>\n {tabs.map((tab, tabIndex) => {\n return (\n <TabComponent\n isActive={activeTabIndex === tabIndex}\n key={tabIndex}\n parentPath={path}\n setIsActive={() => handleTabChange(tabIndex)}\n tab={tab}\n />\n )\n })}\n </div>\n </div>\n <div className={`${baseClass}__content-wrap`}>\n {activeTabConfig && (\n <React.Fragment>\n <div\n className={[\n `${baseClass}__tab`,\n activeTabConfig.label &&\n `${baseClass}__tabConfigLabel-${toKebabCase(\n getTranslation(activeTabConfig.label, i18n),\n )}`,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {CustomDescription ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n <RenderFields\n fieldMap={activeTabConfig.fieldMap}\n forceRender={forceRender}\n key={\n activeTabConfig.label\n ? getTranslation(activeTabConfig.label, i18n)\n : activeTabConfig['name']\n }\n margins=\"small\"\n path={generateTabPath()}\n permissions={\n 'name' in activeTabConfig && siblingPermissions?.[activeTabConfig.name]?.fields\n ? siblingPermissions[activeTabConfig.name]?.fields\n : siblingPermissions\n }\n readOnly={readOnly}\n schemaPath={`${schemaPath ? `${schemaPath}` : ''}${activeTabConfig.name ? `.${activeTabConfig.name}` : ''}`}\n />\n </div>\n </React.Fragment>\n )}\n </div>\n </TabsProvider>\n </div>\n )\n}\n\nexport const Tabs = withCondition(TabsField)\n"],"names":["getTranslation","toKebabCase","React","useCallback","useEffect","useState","useCollapsible","useFieldProps","RenderFields","withCondition","useDocumentInfo","usePreferences","useTranslation","FieldDescription","fieldBaseClass","TabComponent","TabsProvider","baseClass","TabsField","props","name","CustomDescription","className","descriptionProps","forceRender","path","pathFromProps","readOnly","readOnlyFromProps","tabs","indexPath","pathFromContext","readOnlyFromContext","schemaPath","siblingPermissions","getPreference","setPreference","preferencesKey","i18n","isWithinCollapsible","activeTabIndex","setActiveTabIndex","tabsPrefKey","getInitialPref","existingPreferences","initialIndex","fields","tabIndex","handleTabChange","incomingTabIndex","activeTabConfig","generateTabPath","tabPath","div","filter","Boolean","join","map","tab","isActive","parentPath","setIsActive","Fragment","label","fieldMap","margins","permissions","Tabs"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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B,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;mCAZzG8B,gBAAgBa,KAAK,GACjB/D,eAAekD,gBAAgBa,KAAK,EAAEzB,QACtCY,eAAe,CAAC,OAAO;;;;;;;;AAmB/C;AAEA,OAAO,MAAMiB,OAAO1D,cAAcS,WAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"getDataByPath.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/getDataByPath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAKxC,eAAO,MAAM,aAAa,wBAAyB,SAAS,QAAQ,MAAM,KAAG,CAkB5E,CAAA"}
1
+ {"version":3,"file":"getDataByPath.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/getDataByPath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAIxC,eAAO,MAAM,aAAa,wBAAyB,SAAS,QAAQ,MAAM,KAAG,CAkB5E,CAAA"}
@@ -1,5 +1,4 @@
1
- import flatleyImport from 'flatley';
2
- const { unflatten } = flatleyImport;
1
+ import { unflatten } from '../../utilities/unflatten.js';
3
2
  export const getDataByPath = (fields, path)=>{
4
3
  const pathPrefixToRemove = path.substring(0, path.lastIndexOf('.') + 1);
5
4
  const name = path.split('.').pop();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/forms/Form/getDataByPath.ts"],"sourcesContent":["import type { FormState } from 'payload'\n\nimport flatleyImport from 'flatley'\nconst { unflatten } = flatleyImport\n\nexport const getDataByPath = <T = unknown>(fields: FormState, path: string): T => {\n const pathPrefixToRemove = path.substring(0, path.lastIndexOf('.') + 1)\n const name = path.split('.').pop()\n\n const data = {}\n Object.keys(fields).forEach((key) => {\n if (!fields[key].disableFormData && (key.indexOf(`${path}.`) === 0 || key === path)) {\n data[key.replace(pathPrefixToRemove, '')] = fields[key].value\n\n if (fields[key]?.rows && fields[key].rows.length === 0) {\n data[key.replace(pathPrefixToRemove, '')] = []\n }\n }\n })\n\n const unflattenedData = unflatten(data)\n\n return unflattenedData?.[name]\n}\n"],"names":["flatleyImport","unflatten","getDataByPath","fields","path","pathPrefixToRemove","substring","lastIndexOf","name","split","pop","data","Object","keys","forEach","key","disableFormData","indexOf","replace","value","rows","length","unflattenedData"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,mBAAmB,UAAS;AACnC,MAAM,EAAEC,SAAS,EAAE,GAAGD;AAEtB,OAAO,MAAME,gBAAgB,CAAcC,QAAmBC;IAC5D,MAAMC,qBAAqBD,KAAKE,SAAS,CAAC,GAAGF,KAAKG,WAAW,CAAC,OAAO;IACrE,MAAMC,OAAOJ,KAAKK,KAAK,CAAC,KAAKC,GAAG;IAEhC,MAAMC,OAAO,CAAC;IACdC,OAAOC,IAAI,CAACV,QAAQW,OAAO,CAAC,CAACC;QAC3B,IAAI,CAACZ,MAAM,CAACY,IAAI,CAACC,eAAe,IAAKD,CAAAA,IAAIE,OAAO,CAAC,CAAC,EAAEb,KAAK,CAAC,CAAC,MAAM,KAAKW,QAAQX,IAAG,GAAI;YACnFO,IAAI,CAACI,IAAIG,OAAO,CAACb,oBAAoB,IAAI,GAAGF,MAAM,CAACY,IAAI,CAACI,KAAK;YAE7D,IAAIhB,MAAM,CAACY,IAAI,EAAEK,QAAQjB,MAAM,CAACY,IAAI,CAACK,IAAI,CAACC,MAAM,KAAK,GAAG;gBACtDV,IAAI,CAACI,IAAIG,OAAO,CAACb,oBAAoB,IAAI,GAAG,EAAE;YAChD;QACF;IACF;IAEA,MAAMiB,kBAAkBrB,UAAUU;IAElC,OAAOW,iBAAiB,CAACd,KAAK;AAChC,EAAC"}
1
+ {"version":3,"sources":["../../../src/forms/Form/getDataByPath.ts"],"sourcesContent":["import type { FormState } from 'payload'\n\nimport { unflatten } from '../../utilities/unflatten.js'\n\nexport const getDataByPath = <T = unknown>(fields: FormState, path: string): T => {\n const pathPrefixToRemove = path.substring(0, path.lastIndexOf('.') + 1)\n const name = path.split('.').pop()\n\n const data = {}\n Object.keys(fields).forEach((key) => {\n if (!fields[key].disableFormData && (key.indexOf(`${path}.`) === 0 || key === path)) {\n data[key.replace(pathPrefixToRemove, '')] = fields[key].value\n\n if (fields[key]?.rows && fields[key].rows.length === 0) {\n data[key.replace(pathPrefixToRemove, '')] = []\n }\n }\n })\n\n const unflattenedData = unflatten(data)\n\n return unflattenedData?.[name]\n}\n"],"names":["unflatten","getDataByPath","fields","path","pathPrefixToRemove","substring","lastIndexOf","name","split","pop","data","Object","keys","forEach","key","disableFormData","indexOf","replace","value","rows","length","unflattenedData"],"rangeMappings":";;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,SAAS,QAAQ,+BAA8B;AAExD,OAAO,MAAMC,gBAAgB,CAAcC,QAAmBC;IAC5D,MAAMC,qBAAqBD,KAAKE,SAAS,CAAC,GAAGF,KAAKG,WAAW,CAAC,OAAO;IACrE,MAAMC,OAAOJ,KAAKK,KAAK,CAAC,KAAKC,GAAG;IAEhC,MAAMC,OAAO,CAAC;IACdC,OAAOC,IAAI,CAACV,QAAQW,OAAO,CAAC,CAACC;QAC3B,IAAI,CAACZ,MAAM,CAACY,IAAI,CAACC,eAAe,IAAKD,CAAAA,IAAIE,OAAO,CAAC,CAAC,EAAEb,KAAK,CAAC,CAAC,MAAM,KAAKW,QAAQX,IAAG,GAAI;YACnFO,IAAI,CAACI,IAAIG,OAAO,CAACb,oBAAoB,IAAI,GAAGF,MAAM,CAACY,IAAI,CAACI,KAAK;YAE7D,IAAIhB,MAAM,CAACY,IAAI,EAAEK,QAAQjB,MAAM,CAACY,IAAI,CAACK,IAAI,CAACC,MAAM,KAAK,GAAG;gBACtDV,IAAI,CAACI,IAAIG,OAAO,CAACb,oBAAoB,IAAI,GAAG,EAAE;YAChD;QACF;IACF;IAEA,MAAMiB,kBAAkBrB,UAAUU;IAElC,OAAOW,iBAAiB,CAACd,KAAK;AAChC,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"getSiblingData.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/getSiblingData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAO9C,eAAO,MAAM,cAAc,WAAY,SAAS,QAAQ,MAAM,KAAG,IAmChE,CAAA"}
1
+ {"version":3,"file":"getSiblingData.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/getSiblingData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAK9C,eAAO,MAAM,cAAc,WAAY,SAAS,QAAQ,MAAM,KAAG,IAmChE,CAAA"}
@@ -1,6 +1,5 @@
1
- import flatleyImport from 'flatley';
2
- const { unflatten } = flatleyImport;
3
1
  import { reduceFieldsToValues } from '../../utilities/reduceFieldsToValues.js';
2
+ import { unflatten } from '../../utilities/unflatten.js';
4
3
  export const getSiblingData = (fields, path)=>{
5
4
  if (!fields) return null;
6
5
  if (path.indexOf('.') === -1) {
@@ -28,9 +27,7 @@ export const getSiblingData = (fields, path)=>{
28
27
  siblingFields[fieldKey.replace(parentFieldPath, '')] = fields[fieldKey].value;
29
28
  }
30
29
  });
31
- return unflatten(siblingFields, {
32
- safe: true
33
- });
30
+ return unflatten(siblingFields);
34
31
  };
35
32
 
36
33
  //# sourceMappingURL=getSiblingData.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/forms/Form/getSiblingData.ts"],"sourcesContent":["import type { Data, FormState } from 'payload'\n\nimport flatleyImport from 'flatley'\nconst { unflatten } = flatleyImport\n\nimport { reduceFieldsToValues } from '../../utilities/reduceFieldsToValues.js'\n\nexport const getSiblingData = (fields: FormState, path: string): Data => {\n if (!fields) return null\n\n if (path.indexOf('.') === -1) {\n return reduceFieldsToValues(fields, true)\n }\n\n const siblingFields = {}\n\n // Determine if the last segment of the path is an array-based row\n const pathSegments = path.split('.')\n const lastSegment = pathSegments[pathSegments.length - 1]\n const lastSegmentIsRowIndex = !Number.isNaN(Number(lastSegment))\n\n let parentFieldPath: string\n\n if (lastSegmentIsRowIndex) {\n // If the last segment is a row index,\n // the sibling data is that row's contents\n // so create a parent field path that will\n // retrieve all contents of that row index only\n parentFieldPath = `${path}.`\n } else {\n // Otherwise, the last path segment is a field name\n // and it should be removed\n parentFieldPath = path.substring(0, path.lastIndexOf('.') + 1)\n }\n\n Object.keys(fields).forEach((fieldKey) => {\n if (!fields[fieldKey].disableFormData && fieldKey.indexOf(parentFieldPath) === 0) {\n siblingFields[fieldKey.replace(parentFieldPath, '')] = fields[fieldKey].value\n }\n })\n\n return unflatten(siblingFields, { safe: true })\n}\n"],"names":["flatleyImport","unflatten","reduceFieldsToValues","getSiblingData","fields","path","indexOf","siblingFields","pathSegments","split","lastSegment","length","lastSegmentIsRowIndex","Number","isNaN","parentFieldPath","substring","lastIndexOf","Object","keys","forEach","fieldKey","disableFormData","replace","value","safe"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,mBAAmB,UAAS;AACnC,MAAM,EAAEC,SAAS,EAAE,GAAGD;AAEtB,SAASE,oBAAoB,QAAQ,0CAAyC;AAE9E,OAAO,MAAMC,iBAAiB,CAACC,QAAmBC;IAChD,IAAI,CAACD,QAAQ,OAAO;IAEpB,IAAIC,KAAKC,OAAO,CAAC,SAAS,CAAC,GAAG;QAC5B,OAAOJ,qBAAqBE,QAAQ;IACtC;IAEA,MAAMG,gBAAgB,CAAC;IAEvB,kEAAkE;IAClE,MAAMC,eAAeH,KAAKI,KAAK,CAAC;IAChC,MAAMC,cAAcF,YAAY,CAACA,aAAaG,MAAM,GAAG,EAAE;IACzD,MAAMC,wBAAwB,CAACC,OAAOC,KAAK,CAACD,OAAOH;IAEnD,IAAIK;IAEJ,IAAIH,uBAAuB;QACzB,sCAAsC;QACtC,0CAA0C;QAC1C,0CAA0C;QAC1C,+CAA+C;QAC/CG,kBAAkB,CAAC,EAAEV,KAAK,CAAC,CAAC;IAC9B,OAAO;QACL,mDAAmD;QACnD,2BAA2B;QAC3BU,kBAAkBV,KAAKW,SAAS,CAAC,GAAGX,KAAKY,WAAW,CAAC,OAAO;IAC9D;IAEAC,OAAOC,IAAI,CAACf,QAAQgB,OAAO,CAAC,CAACC;QAC3B,IAAI,CAACjB,MAAM,CAACiB,SAAS,CAACC,eAAe,IAAID,SAASf,OAAO,CAACS,qBAAqB,GAAG;YAChFR,aAAa,CAACc,SAASE,OAAO,CAACR,iBAAiB,IAAI,GAAGX,MAAM,CAACiB,SAAS,CAACG,KAAK;QAC/E;IACF;IAEA,OAAOvB,UAAUM,eAAe;QAAEkB,MAAM;IAAK;AAC/C,EAAC"}
1
+ {"version":3,"sources":["../../../src/forms/Form/getSiblingData.ts"],"sourcesContent":["import type { Data, FormState } from 'payload'\n\nimport { reduceFieldsToValues } from '../../utilities/reduceFieldsToValues.js'\nimport { unflatten } from '../../utilities/unflatten.js'\n\nexport const getSiblingData = (fields: FormState, path: string): Data => {\n if (!fields) return null\n\n if (path.indexOf('.') === -1) {\n return reduceFieldsToValues(fields, true)\n }\n\n const siblingFields = {}\n\n // Determine if the last segment of the path is an array-based row\n const pathSegments = path.split('.')\n const lastSegment = pathSegments[pathSegments.length - 1]\n const lastSegmentIsRowIndex = !Number.isNaN(Number(lastSegment))\n\n let parentFieldPath: string\n\n if (lastSegmentIsRowIndex) {\n // If the last segment is a row index,\n // the sibling data is that row's contents\n // so create a parent field path that will\n // retrieve all contents of that row index only\n parentFieldPath = `${path}.`\n } else {\n // Otherwise, the last path segment is a field name\n // and it should be removed\n parentFieldPath = path.substring(0, path.lastIndexOf('.') + 1)\n }\n\n Object.keys(fields).forEach((fieldKey) => {\n if (!fields[fieldKey].disableFormData && fieldKey.indexOf(parentFieldPath) === 0) {\n siblingFields[fieldKey.replace(parentFieldPath, '')] = fields[fieldKey].value\n }\n })\n\n return unflatten(siblingFields)\n}\n"],"names":["reduceFieldsToValues","unflatten","getSiblingData","fields","path","indexOf","siblingFields","pathSegments","split","lastSegment","length","lastSegmentIsRowIndex","Number","isNaN","parentFieldPath","substring","lastIndexOf","Object","keys","forEach","fieldKey","disableFormData","replace","value"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,oBAAoB,QAAQ,0CAAyC;AAC9E,SAASC,SAAS,QAAQ,+BAA8B;AAExD,OAAO,MAAMC,iBAAiB,CAACC,QAAmBC;IAChD,IAAI,CAACD,QAAQ,OAAO;IAEpB,IAAIC,KAAKC,OAAO,CAAC,SAAS,CAAC,GAAG;QAC5B,OAAOL,qBAAqBG,QAAQ;IACtC;IAEA,MAAMG,gBAAgB,CAAC;IAEvB,kEAAkE;IAClE,MAAMC,eAAeH,KAAKI,KAAK,CAAC;IAChC,MAAMC,cAAcF,YAAY,CAACA,aAAaG,MAAM,GAAG,EAAE;IACzD,MAAMC,wBAAwB,CAACC,OAAOC,KAAK,CAACD,OAAOH;IAEnD,IAAIK;IAEJ,IAAIH,uBAAuB;QACzB,sCAAsC;QACtC,0CAA0C;QAC1C,0CAA0C;QAC1C,+CAA+C;QAC/CG,kBAAkB,CAAC,EAAEV,KAAK,CAAC,CAAC;IAC9B,OAAO;QACL,mDAAmD;QACnD,2BAA2B;QAC3BU,kBAAkBV,KAAKW,SAAS,CAAC,GAAGX,KAAKY,WAAW,CAAC,OAAO;IAC9D;IAEAC,OAAOC,IAAI,CAACf,QAAQgB,OAAO,CAAC,CAACC;QAC3B,IAAI,CAACjB,MAAM,CAACiB,SAAS,CAACC,eAAe,IAAID,SAASf,OAAO,CAACS,qBAAqB,GAAG;YAChFR,aAAa,CAACc,SAASE,OAAO,CAACR,iBAAiB,IAAI,GAAGX,MAAM,CAACiB,SAAS,CAACG,KAAK;QAC/E;IACF;IAEA,OAAOtB,UAAUK;AACnB,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"reduceFieldsToValues.d.ts","sourceRoot":"","sources":["../../src/utilities/reduceFieldsToValues.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAI9C;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,WACvB,SAAS,cACL,OAAO,0BACK,OAAO,KAC9B,IAgBF,CAAA"}
1
+ {"version":3,"file":"reduceFieldsToValues.d.ts","sourceRoot":"","sources":["../../src/utilities/reduceFieldsToValues.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAG9C;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,WACvB,SAAS,cACL,OAAO,0BACK,OAAO,KAC9B,IAgBF,CAAA"}
@@ -1,5 +1,4 @@
1
- import flatleyImport from 'flatley';
2
- const { unflatten: flatleyUnflatten } = flatleyImport;
1
+ import { unflatten as flatleyUnflatten } from './unflatten.js';
3
2
  /**
4
3
  * Reduce flattened form fields (Fields) to just map to the respective values instead of the full FormField object
5
4
  *
@@ -15,9 +14,7 @@ const { unflatten: flatleyUnflatten } = flatleyImport;
15
14
  }
16
15
  });
17
16
  if (unflatten) {
18
- data = flatleyUnflatten(data, {
19
- safe: true
20
- });
17
+ data = flatleyUnflatten(data);
21
18
  }
22
19
  return data;
23
20
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/reduceFieldsToValues.ts"],"sourcesContent":["import type { Data, FormState } from 'payload'\n\nimport flatleyImport from 'flatley'\nconst { unflatten: flatleyUnflatten } = flatleyImport\n/**\n * Reduce flattened form fields (Fields) to just map to the respective values instead of the full FormField object\n *\n * @param unflatten This also unflattens the data if `unflatten` is true. The unflattened data should match the original data structure\n * @param ignoreDisableFormData - if true, will include fields that have `disableFormData` set to true, for example, blocks or arrays fields.\n *\n */\nexport const reduceFieldsToValues = (\n fields: FormState,\n unflatten?: boolean,\n ignoreDisableFormData?: boolean,\n): Data => {\n let data = {}\n\n if (!fields) return data\n\n Object.keys(fields).forEach((key) => {\n if (ignoreDisableFormData === true || !fields[key]?.disableFormData) {\n data[key] = fields[key]?.value\n }\n })\n\n if (unflatten) {\n data = flatleyUnflatten(data, { safe: true })\n }\n\n return data\n}\n"],"names":["flatleyImport","unflatten","flatleyUnflatten","reduceFieldsToValues","fields","ignoreDisableFormData","data","Object","keys","forEach","key","disableFormData","value","safe"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,mBAAmB,UAAS;AACnC,MAAM,EAAEC,WAAWC,gBAAgB,EAAE,GAAGF;AACxC;;;;;;CAMC,GACD,OAAO,MAAMG,uBAAuB,CAClCC,QACAH,WACAI;IAEA,IAAIC,OAAO,CAAC;IAEZ,IAAI,CAACF,QAAQ,OAAOE;IAEpBC,OAAOC,IAAI,CAACJ,QAAQK,OAAO,CAAC,CAACC;QAC3B,IAAIL,0BAA0B,QAAQ,CAACD,MAAM,CAACM,IAAI,EAAEC,iBAAiB;YACnEL,IAAI,CAACI,IAAI,GAAGN,MAAM,CAACM,IAAI,EAAEE;QAC3B;IACF;IAEA,IAAIX,WAAW;QACbK,OAAOJ,iBAAiBI,MAAM;YAAEO,MAAM;QAAK;IAC7C;IAEA,OAAOP;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/reduceFieldsToValues.ts"],"sourcesContent":["import type { Data, FormState } from 'payload'\n\nimport { unflatten as flatleyUnflatten } from './unflatten.js'\n/**\n * Reduce flattened form fields (Fields) to just map to the respective values instead of the full FormField object\n *\n * @param unflatten This also unflattens the data if `unflatten` is true. The unflattened data should match the original data structure\n * @param ignoreDisableFormData - if true, will include fields that have `disableFormData` set to true, for example, blocks or arrays fields.\n *\n */\nexport const reduceFieldsToValues = (\n fields: FormState,\n unflatten?: boolean,\n ignoreDisableFormData?: boolean,\n): Data => {\n let data = {}\n\n if (!fields) return data\n\n Object.keys(fields).forEach((key) => {\n if (ignoreDisableFormData === true || !fields[key]?.disableFormData) {\n data[key] = fields[key]?.value\n }\n })\n\n if (unflatten) {\n data = flatleyUnflatten(data)\n }\n\n return data\n}\n"],"names":["unflatten","flatleyUnflatten","reduceFieldsToValues","fields","ignoreDisableFormData","data","Object","keys","forEach","key","disableFormData","value"],"rangeMappings":";;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,aAAaC,gBAAgB,QAAQ,iBAAgB;AAC9D;;;;;;CAMC,GACD,OAAO,MAAMC,uBAAuB,CAClCC,QACAH,WACAI;IAEA,IAAIC,OAAO,CAAC;IAEZ,IAAI,CAACF,QAAQ,OAAOE;IAEpBC,OAAOC,IAAI,CAACJ,QAAQK,OAAO,CAAC,CAACC;QAC3B,IAAIL,0BAA0B,QAAQ,CAACD,MAAM,CAACM,IAAI,EAAEC,iBAAiB;YACnEL,IAAI,CAACI,IAAI,GAAGN,MAAM,CAACM,IAAI,EAAEE;QAC3B;IACF;IAEA,IAAIX,WAAW;QACbK,OAAOJ,iBAAiBI;IAC1B;IAEA,OAAOA;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"reduceFieldsToValuesWithValidation.d.ts","sourceRoot":"","sources":["../../src/utilities/reduceFieldsToValuesWithValidation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAK9C,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,IAAI,CAAA;IACV,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,kCAAkC,WACrC,SAAS,cACL,OAAO,0BACK,OAAO,KAC9B,UAoBF,CAAA"}
1
+ {"version":3,"file":"reduceFieldsToValuesWithValidation.d.ts","sourceRoot":"","sources":["../../src/utilities/reduceFieldsToValuesWithValidation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAI9C,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,IAAI,CAAA;IACV,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,kCAAkC,WACrC,SAAS,cACL,OAAO,0BACK,OAAO,KAC9B,UAoBF,CAAA"}
@@ -1,5 +1,4 @@
1
- import flatleyImport from 'flatley';
2
- const { unflatten: flatleyUnflatten } = flatleyImport;
1
+ import { unflatten as flatleyUnflatten } from './unflatten.js';
3
2
  /**
4
3
  * Reduce flattened form fields (Fields) to just map to the respective values instead of the full FormField object
5
4
  *
@@ -19,9 +18,7 @@ const { unflatten: flatleyUnflatten } = flatleyImport;
19
18
  }
20
19
  });
21
20
  if (unflatten) {
22
- state.data = flatleyUnflatten(state.data, {
23
- safe: true
24
- });
21
+ state.data = flatleyUnflatten(state.data);
25
22
  }
26
23
  return state;
27
24
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/reduceFieldsToValuesWithValidation.ts"],"sourcesContent":["import type { Data, FormState } from 'payload'\n\nimport flatleyImport from 'flatley'\nconst { unflatten: flatleyUnflatten } = flatleyImport\n\ntype ReturnType = {\n data: Data\n valid: boolean\n}\n\n/**\n * Reduce flattened form fields (Fields) to just map to the respective values instead of the full FormField object\n *\n * @param unflatten This also unflattens the data if `unflatten` is true. The unflattened data should match the original data structure\n * @param ignoreDisableFormData - if true, will include fields that have `disableFormData` set to true, for example, blocks or arrays fields.\n *\n */\nexport const reduceFieldsToValuesWithValidation = (\n fields: FormState,\n unflatten?: boolean,\n ignoreDisableFormData?: boolean,\n): ReturnType => {\n const state: ReturnType = {\n data: {},\n valid: true,\n }\n\n if (!fields) return state\n\n Object.keys(fields).forEach((key) => {\n if (ignoreDisableFormData === true || !fields[key]?.disableFormData) {\n state.data[key] = fields[key]?.value\n if (!fields[key].valid) state.valid = false\n }\n })\n\n if (unflatten) {\n state.data = flatleyUnflatten(state.data, { safe: true })\n }\n\n return state\n}\n"],"names":["flatleyImport","unflatten","flatleyUnflatten","reduceFieldsToValuesWithValidation","fields","ignoreDisableFormData","state","data","valid","Object","keys","forEach","key","disableFormData","value","safe"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,mBAAmB,UAAS;AACnC,MAAM,EAAEC,WAAWC,gBAAgB,EAAE,GAAGF;AAOxC;;;;;;CAMC,GACD,OAAO,MAAMG,qCAAqC,CAChDC,QACAH,WACAI;IAEA,MAAMC,QAAoB;QACxBC,MAAM,CAAC;QACPC,OAAO;IACT;IAEA,IAAI,CAACJ,QAAQ,OAAOE;IAEpBG,OAAOC,IAAI,CAACN,QAAQO,OAAO,CAAC,CAACC;QAC3B,IAAIP,0BAA0B,QAAQ,CAACD,MAAM,CAACQ,IAAI,EAAEC,iBAAiB;YACnEP,MAAMC,IAAI,CAACK,IAAI,GAAGR,MAAM,CAACQ,IAAI,EAAEE;YAC/B,IAAI,CAACV,MAAM,CAACQ,IAAI,CAACJ,KAAK,EAAEF,MAAME,KAAK,GAAG;QACxC;IACF;IAEA,IAAIP,WAAW;QACbK,MAAMC,IAAI,GAAGL,iBAAiBI,MAAMC,IAAI,EAAE;YAAEQ,MAAM;QAAK;IACzD;IAEA,OAAOT;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/reduceFieldsToValuesWithValidation.ts"],"sourcesContent":["import type { Data, FormState } from 'payload'\n\nimport { unflatten as flatleyUnflatten } from './unflatten.js'\n\ntype ReturnType = {\n data: Data\n valid: boolean\n}\n\n/**\n * Reduce flattened form fields (Fields) to just map to the respective values instead of the full FormField object\n *\n * @param unflatten This also unflattens the data if `unflatten` is true. The unflattened data should match the original data structure\n * @param ignoreDisableFormData - if true, will include fields that have `disableFormData` set to true, for example, blocks or arrays fields.\n *\n */\nexport const reduceFieldsToValuesWithValidation = (\n fields: FormState,\n unflatten?: boolean,\n ignoreDisableFormData?: boolean,\n): ReturnType => {\n const state: ReturnType = {\n data: {},\n valid: true,\n }\n\n if (!fields) return state\n\n Object.keys(fields).forEach((key) => {\n if (ignoreDisableFormData === true || !fields[key]?.disableFormData) {\n state.data[key] = fields[key]?.value\n if (!fields[key].valid) state.valid = false\n }\n })\n\n if (unflatten) {\n state.data = flatleyUnflatten(state.data)\n }\n\n return state\n}\n"],"names":["unflatten","flatleyUnflatten","reduceFieldsToValuesWithValidation","fields","ignoreDisableFormData","state","data","valid","Object","keys","forEach","key","disableFormData","value"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,aAAaC,gBAAgB,QAAQ,iBAAgB;AAO9D;;;;;;CAMC,GACD,OAAO,MAAMC,qCAAqC,CAChDC,QACAH,WACAI;IAEA,MAAMC,QAAoB;QACxBC,MAAM,CAAC;QACPC,OAAO;IACT;IAEA,IAAI,CAACJ,QAAQ,OAAOE;IAEpBG,OAAOC,IAAI,CAACN,QAAQO,OAAO,CAAC,CAACC;QAC3B,IAAIP,0BAA0B,QAAQ,CAACD,MAAM,CAACQ,IAAI,EAAEC,iBAAiB;YACnEP,MAAMC,IAAI,CAACK,IAAI,GAAGR,MAAM,CAACQ,IAAI,EAAEE;YAC/B,IAAI,CAACV,MAAM,CAACQ,IAAI,CAACJ,KAAK,EAAEF,MAAME,KAAK,GAAG;QACxC;IACF;IAEA,IAAIP,WAAW;QACbK,MAAMC,IAAI,GAAGL,iBAAiBI,MAAMC,IAAI;IAC1C;IAEA,OAAOD;AACT,EAAC"}
@@ -0,0 +1,9 @@
1
+ interface Opts {
2
+ delimiter?: string;
3
+ object?: any;
4
+ overwrite?: boolean;
5
+ recursive?: boolean;
6
+ }
7
+ export declare const unflatten: (target: any, opts?: Opts) => any;
8
+ export {};
9
+ //# sourceMappingURL=unflatten.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unflatten.d.ts","sourceRoot":"","sources":["../../src/utilities/unflatten.ts"],"names":[],"mappings":"AAcA,UAAU,IAAI;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,GAAG,CAAA;IACZ,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,eAAO,MAAM,SAAS,uBAAmB,IAAI,QA0D5C,CAAA"}
@@ -0,0 +1,58 @@
1
+ /*
2
+ * Copyright (c) 2014, Hugh Kennedy
3
+ * All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
+ * 3. Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9
+ *
10
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11
+ */ import isBuffer from 'is-buffer';
12
+ export const unflatten = (target, opts)=>{
13
+ opts = opts || {};
14
+ const delimiter = opts.delimiter || '.';
15
+ const overwrite = opts.overwrite || false;
16
+ const recursive = opts.recursive || false;
17
+ const result = {};
18
+ const isbuffer = isBuffer(target);
19
+ if (isbuffer || Object.prototype.toString.call(target) !== '[object Object]') {
20
+ return target;
21
+ }
22
+ // safely ensure that the key is an integer.
23
+ const getkey = (key)=>{
24
+ const parsedKey = Number(key);
25
+ return isNaN(parsedKey) || key.indexOf('.') !== -1 || opts.object ? key : parsedKey;
26
+ };
27
+ const sortedKeys = Object.keys(target).sort((keyA, keyB)=>keyA.length - keyB.length);
28
+ sortedKeys.forEach((key)=>{
29
+ const split = key.split(delimiter);
30
+ let key1 = getkey(split.shift());
31
+ let key2 = getkey(split[0]);
32
+ let recipient = result;
33
+ while(key2 !== undefined){
34
+ if (key1 === '__proto__') {
35
+ return;
36
+ }
37
+ const type = Object.prototype.toString.call(recipient[key1]);
38
+ const isobject = type === '[object Object]' || type === '[object Array]';
39
+ // do not write over falsey, non-undefined values if overwrite is false
40
+ if (!overwrite && !isobject && typeof recipient[key1] !== 'undefined') {
41
+ return;
42
+ }
43
+ if (overwrite && !isobject || !overwrite && recipient[key1] == null) {
44
+ recipient[key1] = typeof key2 === 'number' && !opts.object ? [] : {};
45
+ }
46
+ recipient = recipient[key1];
47
+ if (split.length > 0) {
48
+ key1 = getkey(split.shift());
49
+ key2 = getkey(split[0]);
50
+ }
51
+ }
52
+ // unflatten again for 'messy objects'
53
+ recipient[key1] = recursive ? unflatten(target[key], opts) : target[key];
54
+ });
55
+ return result;
56
+ };
57
+
58
+ //# sourceMappingURL=unflatten.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/unflatten.ts"],"sourcesContent":["/*\n * Copyright (c) 2014, Hugh Kennedy\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport isBuffer from 'is-buffer'\n\ninterface Opts {\n delimiter?: string\n object?: any\n overwrite?: boolean\n recursive?: boolean\n}\n\nexport const unflatten = (target, opts?: Opts) => {\n opts = opts || {}\n\n const delimiter = opts.delimiter || '.'\n const overwrite = opts.overwrite || false\n const recursive = opts.recursive || false\n const result = {}\n\n const isbuffer = isBuffer(target)\n\n if (isbuffer || Object.prototype.toString.call(target) !== '[object Object]') {\n return target\n }\n\n // safely ensure that the key is an integer.\n const getkey = (key) => {\n const parsedKey = Number(key)\n return isNaN(parsedKey) || key.indexOf('.') !== -1 || opts.object ? key : parsedKey\n }\n\n const sortedKeys = Object.keys(target).sort((keyA, keyB) => keyA.length - keyB.length)\n\n sortedKeys.forEach((key) => {\n const split = key.split(delimiter)\n let key1 = getkey(split.shift())\n let key2 = getkey(split[0])\n let recipient = result\n\n while (key2 !== undefined) {\n if (key1 === '__proto__') {\n return\n }\n\n const type = Object.prototype.toString.call(recipient[key1])\n const isobject = type === '[object Object]' || type === '[object Array]'\n\n // do not write over falsey, non-undefined values if overwrite is false\n if (!overwrite && !isobject && typeof recipient[key1] !== 'undefined') {\n return\n }\n\n if ((overwrite && !isobject) || (!overwrite && recipient[key1] == null)) {\n recipient[key1] = typeof key2 === 'number' && !opts.object ? [] : {}\n }\n\n recipient = recipient[key1]\n\n if (split.length > 0) {\n key1 = getkey(split.shift())\n key2 = getkey(split[0])\n }\n }\n\n // unflatten again for 'messy objects'\n recipient[key1] = recursive ? unflatten(target[key], opts) : target[key]\n })\n\n return result\n}\n"],"names":["isBuffer","unflatten","target","opts","delimiter","overwrite","recursive","result","isbuffer","Object","prototype","toString","call","getkey","key","parsedKey","Number","isNaN","indexOf","object","sortedKeys","keys","sort","keyA","keyB","length","forEach","split","key1","shift","key2","recipient","undefined","type","isobject"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;;;;;;;;;CAUC,GAED,OAAOA,cAAc,YAAW;AAShC,OAAO,MAAMC,YAAY,CAACC,QAAQC;IAChCA,OAAOA,QAAQ,CAAC;IAEhB,MAAMC,YAAYD,KAAKC,SAAS,IAAI;IACpC,MAAMC,YAAYF,KAAKE,SAAS,IAAI;IACpC,MAAMC,YAAYH,KAAKG,SAAS,IAAI;IACpC,MAAMC,SAAS,CAAC;IAEhB,MAAMC,WAAWR,SAASE;IAE1B,IAAIM,YAAYC,OAAOC,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACV,YAAY,mBAAmB;QAC5E,OAAOA;IACT;IAEA,4CAA4C;IAC5C,MAAMW,SAAS,CAACC;QACd,MAAMC,YAAYC,OAAOF;QACzB,OAAOG,MAAMF,cAAcD,IAAII,OAAO,CAAC,SAAS,CAAC,KAAKf,KAAKgB,MAAM,GAAGL,MAAMC;IAC5E;IAEA,MAAMK,aAAaX,OAAOY,IAAI,CAACnB,QAAQoB,IAAI,CAAC,CA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