You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
2.6 KiB
1 line
2.6 KiB
1 month ago
|
{"version":3,"file":"index.js","sources":["../../../../../packages/hooks/use-intermediate-render/index.ts"],"sourcesContent":["import { nextTick, unref, watch } from 'vue'\n\nimport type { Ref } from 'vue'\n\nexport type UseDelayedRenderProps = {\n indicator: Ref<boolean>\n intermediateIndicator: Ref<boolean>\n shouldSetIntermediate?: (step: 'show' | 'hide') => boolean\n beforeShow?: () => void\n beforeHide?: () => void\n afterShow?: () => void\n afterHide?: () => void\n}\n\nexport const useDelayedRender = ({\n indicator,\n intermediateIndicator,\n shouldSetIntermediate = () => true,\n beforeShow,\n afterShow,\n afterHide,\n beforeHide,\n}: UseDelayedRenderProps) => {\n watch(\n () => unref(indicator),\n (val) => {\n if (val) {\n beforeShow?.()\n nextTick(() => {\n if (!unref(indicator)) return\n if (shouldSetIntermediate('show')) {\n intermediateIndicator.value = true\n }\n })\n } else {\n beforeHide?.()\n nextTick(() => {\n if (unref(indicator)) return\n\n if (shouldSetIntermediate('hide')) {\n intermediateIndicator.value = false\n }\n })\n }\n }\n )\n\n // because we don't always set the value ourselves, so that we\n // simply watch the value's state, then invoke the corresponding hook.\n watch(\n () => intermediateIndicator.value,\n (val) => {\n if (val) {\n afterShow?.()\n } else {\n afterHide?.()\n }\n }\n )\n}\n"],"names":["watch","unref","nextTick"],"mappings":";;;;;;AACY,MAAC,gBAAgB,GAAG,CAAC;AACjC,EAAE,SAAS;AACX,EAAE,qBAAqB;AACvB,EAAE,qBAAqB,GAAG,MAAM,IAAI;AACpC,EAAE,UAAU;AACZ,EAAE,SAAS;AACX,EAAE,SAAS;AACX,EAAE,UAAU;AACZ,CAAC,KAAK;AACN,EAAEA,SAAK,CAAC,MAAMC,SAAK,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,KAAK;AACzC,IAAI,IAAI,GAAG,EAAE;AACb,MAAM,UAAU,IAAI,IAAI,GAAG,KAAK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