UNPKG

@dark-engine/core

Version:

The lightweight and powerful UI rendering engine without dependencies and written in TypeScript (Browser, Node.js, Android, iOS, Windows, Linux, macOS)

26 lines (25 loc) 974 B
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); exports.Suspense = void 0; const internal_1 = require('../internal'); const use_update_1 = require('../use-update'); const component_1 = require('../component'); const fragment_1 = require('../fragment'); const shadow_1 = require('../shadow'); const Suspense = (0, component_1.component)( ({ fallback = null, slot }) => { const cursor = (0, internal_1.__useCursor)(); const update = (0, use_update_1.useUpdate)(); const isPending = cursor.hook.getIsPending(); const content = [ isPending ? (0, fragment_1.Fragment)({ key: 1, slot: fallback }) : null, (0, shadow_1.Shadow)({ key: 2, isOpen: !isPending, slot }), ].filter(Boolean); cursor.hook.setIsSuspense(true); cursor.hook.setUpdate(update); return (0, fragment_1.Fragment)({ slot: content }); }, { displayName: 'Suspense' }, ); exports.Suspense = Suspense; //# sourceMappingURL=suspense.js.map