@particle-academy/fancy-slides 0.5.0 → 0.6.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.
package/dist/index.d.cts CHANGED
@@ -106,7 +106,12 @@ interface SlideViewerProps {
106
106
  autoAdvanceMs?: number;
107
107
  /** Hide the bottom progress bar + slide counter. */
108
108
  hideChrome?: boolean;
109
- /** Optional custom renderer for element types Slide doesn't render natively (chart/code/table/embed). */
109
+ /**
110
+ * Custom renderer for element types Slide doesn't render natively
111
+ * (chart/code/table/embed). Defaults to the built-in
112
+ * `defaultElementRegistry` so decks play fully out of the box; pass your
113
+ * own to override.
114
+ */
110
115
  renderElement?: (element: SlideElement, slideWidthPx: number) => ReactNode | undefined;
111
116
  /** Extra classes on the viewer wrapper. */
112
117
  className?: string;
@@ -190,7 +195,14 @@ interface DeckEditorProps {
190
195
  /** Controlled selected slide id. Uncontrolled by default. */
191
196
  selectedSlideId?: string | null;
192
197
  onSelectedSlideChange?: (id: string | null) => void;
193
- /** Optional renderer for chart / code / table / embed elements (the elements this package doesn't render natively). */
198
+ /**
199
+ * Renderer for chart / code / table / embed elements (the elements this
200
+ * package doesn't render natively). Defaults to the built-in
201
+ * `defaultElementRegistry` so the editor is full out of the box; pass your
202
+ * own to override (it wins entirely). The optional-peer hosts (chart/code)
203
+ * load fancy-echarts/fancy-code via guarded dynamic imports, so the base
204
+ * bundle never statically requires them.
205
+ */
194
206
  renderElement?: (element: SlideElement, slideWidthPx: number) => ReactNode | undefined;
195
207
  /** Hide the slide rail (e.g. for embedded use). */
196
208
  hideRail?: boolean;
package/dist/index.d.ts CHANGED
@@ -106,7 +106,12 @@ interface SlideViewerProps {
106
106
  autoAdvanceMs?: number;
107
107
  /** Hide the bottom progress bar + slide counter. */
108
108
  hideChrome?: boolean;
109
- /** Optional custom renderer for element types Slide doesn't render natively (chart/code/table/embed). */
109
+ /**
110
+ * Custom renderer for element types Slide doesn't render natively
111
+ * (chart/code/table/embed). Defaults to the built-in
112
+ * `defaultElementRegistry` so decks play fully out of the box; pass your
113
+ * own to override.
114
+ */
110
115
  renderElement?: (element: SlideElement, slideWidthPx: number) => ReactNode | undefined;
111
116
  /** Extra classes on the viewer wrapper. */
112
117
  className?: string;
@@ -190,7 +195,14 @@ interface DeckEditorProps {
190
195
  /** Controlled selected slide id. Uncontrolled by default. */
191
196
  selectedSlideId?: string | null;
192
197
  onSelectedSlideChange?: (id: string | null) => void;
193
- /** Optional renderer for chart / code / table / embed elements (the elements this package doesn't render natively). */
198
+ /**
199
+ * Renderer for chart / code / table / embed elements (the elements this
200
+ * package doesn't render natively). Defaults to the built-in
201
+ * `defaultElementRegistry` so the editor is full out of the box; pass your
202
+ * own to override (it wins entirely). The optional-peer hosts (chart/code)
203
+ * load fancy-echarts/fancy-code via guarded dynamic imports, so the base
204
+ * bundle never statically requires them.
205
+ */
194
206
  renderElement?: (element: SlideElement, slideWidthPx: number) => ReactNode | undefined;
195
207
  /** Hide the slide rail (e.g. for embedded use). */
196
208
  hideRail?: boolean;
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { defaultElementRegistry } from './chunk-YEJZYKVB.js';
1
2
  import { isDarkColor, SlideContext } from './chunk-WIUXPQAK.js';
2
3
  export { useIsDarkSlide, useSlideContext, useSlideTheme } from './chunk-WIUXPQAK.js';
3
4
  import { useId, useRef, useState, useEffect, useMemo, useCallback } from 'react';
@@ -676,7 +677,7 @@ function SlideElementHost({
676
677
  touchAction: canMove ? "none" : void 0,
677
678
  ...buildAnimation ? buildEnterStyle(buildAnimation, buildDelay) : null
678
679
  };
679
- const inner = renderInner({ element, theme, slideWidthPx, editing, selected, onContentChange, paraReveal }) ?? renderElement?.(element, slideWidthPx);
680
+ const inner = renderInner({ element, theme, slideWidthPx, editing, selected, onContentChange, paraReveal }) ?? renderElement?.(element, slideWidthPx) ?? elementPlaceholder(element);
680
681
  return /* @__PURE__ */ jsxs(
681
682
  "div",
682
683
  {
@@ -771,6 +772,37 @@ function renderInner({ element, theme, slideWidthPx, editing, selected, onConten
771
772
  return null;
772
773
  }
773
774
  }
775
+ function elementPlaceholder(element) {
776
+ if (element.type !== "chart" && element.type !== "code" && element.type !== "table" && element.type !== "embed") {
777
+ return null;
778
+ }
779
+ const label = element.type.charAt(0).toUpperCase() + element.type.slice(1);
780
+ return /* @__PURE__ */ jsxs(
781
+ "div",
782
+ {
783
+ style: {
784
+ width: "100%",
785
+ height: "100%",
786
+ display: "flex",
787
+ flexDirection: "column",
788
+ alignItems: "center",
789
+ justifyContent: "center",
790
+ gap: "0.35em",
791
+ textAlign: "center",
792
+ padding: "0.5em",
793
+ boxSizing: "border-box",
794
+ border: "1px dashed currentColor",
795
+ borderRadius: 8,
796
+ opacity: 0.55,
797
+ overflow: "hidden"
798
+ },
799
+ children: [
800
+ /* @__PURE__ */ jsx("span", { style: { fontWeight: 600 }, children: label }),
801
+ /* @__PURE__ */ jsx("span", { style: { fontSize: "0.7em", opacity: 0.8 }, children: "Pass renderElement to render" })
802
+ ]
803
+ }
804
+ );
805
+ }
774
806
  function orderedElements(elements) {
775
807
  return [...elements].sort((a, b) => {
776
808
  const az = a.z ?? -1;
@@ -885,7 +917,7 @@ function SlideViewer({
885
917
  onExit,
886
918
  autoAdvanceMs,
887
919
  hideChrome = false,
888
- renderElement,
920
+ renderElement = defaultElementRegistry,
889
921
  className
890
922
  }) {
891
923
  const isControlled = controlledIndex !== void 0;
@@ -2646,7 +2678,7 @@ function DeckEditor({
2646
2678
  onPresent,
2647
2679
  selectedSlideId: controlledSlideId,
2648
2680
  onSelectedSlideChange,
2649
- renderElement,
2681
+ renderElement = defaultElementRegistry,
2650
2682
  hideRail = false,
2651
2683
  hideNotes = false,
2652
2684
  hideToolbar = false,