UNPKG

@wordpress/global-styles-ui

Version:
26 lines (25 loc) • 843 B
import { useSetting } from "../hooks.mjs"; // packages/global-styles-ui/src/presets/use-presets.ts const EMPTY_ARRAY = []; /** * Read + mutate the preset array stored at `${settingsPath}.${origin}`. * * `presets` reflects the merged (user-edited) value; `basePresets` is read * explicitly from the theme base, used to compare against or reset to the * theme-provided values. * * @param settingsPath Origin-keyed base path, e.g. 'shadow.presets'. * @param origin 'default' | 'theme' | 'custom'. */ function usePresets(settingsPath, origin) { const path = `${settingsPath}.${origin}`; const [presets = EMPTY_ARRAY, setPresets] = useSetting(path); const [basePresets = EMPTY_ARRAY] = useSetting(path, void 0, "base"); return { presets, basePresets, setPresets }; } export { usePresets }; //# sourceMappingURL=use-presets.mjs.map