@wordpress/core-data
Version:
Access to and manipulation of core WordPress entities.
8 lines (7 loc) • 1.46 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../src/hooks/utils.ts"],
"sourcesContent": ["import type { ResolutionStatus } from '@wordpress/data';\nimport { Status } from './constants';\n\n/**\n * Normalizes a resolution status from the store into the resolution info\n * shared by the entity record hooks and `useQuerySelect`.\n *\n * @param resolutionStatus Status returned by the `getResolutionState` selector.\n * @return Resolution info object.\n */\nexport function getResolutionStatus( resolutionStatus?: ResolutionStatus ) {\n\tlet status: Status;\n\tswitch ( resolutionStatus ) {\n\t\tcase 'resolving':\n\t\t\tstatus = Status.Resolving;\n\t\t\tbreak;\n\t\tcase 'finished':\n\t\t\tstatus = Status.Success;\n\t\t\tbreak;\n\t\tcase 'error':\n\t\t\tstatus = Status.Error;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tstatus = Status.Idle;\n\t}\n\n\treturn {\n\t\tstatus,\n\t\tisResolving: status === Status.Resolving,\n\t\thasStarted: status !== Status.Idle,\n\t\thasResolved: status === Status.Success || status === Status.Error,\n\t};\n}\n"],
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uBAAuB;AAShB,SAAS,oBAAqB,kBAAsC;AAC1E,MAAI;AACJ,UAAS,kBAAmB;AAAA,IAC3B,KAAK;AACJ,eAAS,wBAAO;AAChB;AAAA,IACD,KAAK;AACJ,eAAS,wBAAO;AAChB;AAAA,IACD,KAAK;AACJ,eAAS,wBAAO;AAChB;AAAA,IACD;AACC,eAAS,wBAAO;AAAA,EAClB;AAEA,SAAO;AAAA,IACN;AAAA,IACA,aAAa,WAAW,wBAAO;AAAA,IAC/B,YAAY,WAAW,wBAAO;AAAA,IAC9B,aAAa,WAAW,wBAAO,WAAW,WAAW,wBAAO;AAAA,EAC7D;AACD;",
"names": []
}