@jfdevelops/react-layout 1.1.0 → 1.2.0

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.
@@ -178,7 +178,7 @@ function defineResourceLayoutImpl(options, inheritedStateScope) {
178
178
  for (const [stateName, input] of Object.entries(renderStates)) if (input === source.input) return stateName === "default" ? Component : stateComponents[stateName];
179
179
  let reference = referenceComponents.get(source.input);
180
180
  if (!reference) {
181
- reference = createStateComponent(source.name, source.input, false);
181
+ reference = createStateComponent(source.name, source.input, false, source.fallbackStateName);
182
182
  referenceComponents.set(source.input, reference);
183
183
  }
184
184
  return reference;
@@ -271,7 +271,8 @@ function defineResourceLayoutImpl(options, inheritedStateScope) {
271
271
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_state_composable.StateComposableContext.Provider, {
272
272
  value: {
273
273
  scope: stateScope,
274
- props: layoutRenderProps
274
+ props: layoutRenderProps,
275
+ definitions: mergedResolvedInProps
275
276
  },
276
277
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderDefaultState, { renderProps: layoutRenderProps })
277
278
  })
@@ -293,12 +294,12 @@ function defineResourceLayoutImpl(options, inheritedStateScope) {
293
294
  if (!compositionOptions.components) return {};
294
295
  return { makeComposable: createComposableLayout(compositionOptions) };
295
296
  }
296
- function createStateComponent(stateName, input, validateStateName = true) {
297
+ function createStateComponent(stateName, input, validateStateName = true, fallbackStateName = stateName) {
297
298
  if (require_render_state.isLazyRenderState(input)) {
298
299
  const loadState = input[require_render_state.lazyRenderStateSymbol];
299
300
  function createLazyState() {
300
301
  return (0, react.lazy)(async () => {
301
- const stateDefinition = require_render_state.findDefinedRenderState(await loadState().catch((error) => {
302
+ const stateDefinition = await require_render_state.findDefinedRenderState(await loadState().catch((error) => {
302
303
  throw new require_resource_state_error.ResourceModuleLoadError(String(layoutContext.resource), error);
303
304
  }));
304
305
  if (validateStateName && stateDefinition.state !== void 0 && stateDefinition.state !== stateName) throw new require_layout_configuration_error.LayoutConfigurationError(`Lazy render state "${stateDefinition.state}" cannot be used as "${stateName}"`);
@@ -309,8 +310,8 @@ function defineResourceLayoutImpl(options, inheritedStateScope) {
309
310
  const [, rerender] = (0, react.useReducer)((version) => version + 1, 0);
310
311
  const LazyState = (0, react.useRef)(createLazyState());
311
312
  const CurrentLazyState = LazyState.current;
312
- const LoadingComponent = stateName === "Loading" ? void 0 : stateComponents.Loading;
313
- const ErrorComponent = stateName === "Error" ? void 0 : stateComponents.Error;
313
+ const LoadingComponent = fallbackStateName === "Loading" ? void 0 : stateComponents.Loading;
314
+ const ErrorComponent = fallbackStateName === "Error" ? void 0 : stateComponents.Error;
314
315
  function retry() {
315
316
  LazyState.current = createLazyState();
316
317
  rerender();
@@ -339,8 +340,8 @@ function defineResourceLayoutImpl(options, inheritedStateScope) {
339
340
  if (!require_render_state.isDeferredRenderState(input)) return StateComponent;
340
341
  const DeferredState = (0, react.lazy)(() => Promise.resolve({ default: StateComponent }));
341
342
  function DeferredStateComponent(props) {
342
- const LoadingComponent = stateName === "Loading" ? void 0 : stateComponents.Loading;
343
- const ErrorComponent = stateName === "Error" ? void 0 : stateComponents.Error;
343
+ const LoadingComponent = fallbackStateName === "Loading" ? void 0 : stateComponents.Loading;
344
+ const ErrorComponent = fallbackStateName === "Error" ? void 0 : stateComponents.Error;
344
345
  const rendered = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Suspense, {
345
346
  fallback: LoadingComponent ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LoadingComponent, {}) : null,
346
347
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DeferredState, { ...props })