@puckeditor/plugin-emotion-cache 0.23.0-canary.fb9392de → 0.24.0-canary.34794e5d

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.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { ReactElement, CSSProperties, ReactNode, ElementType, Ref, JSX } from 'react';
1
+ import { ElementType, CSSProperties, Ref, ComponentPropsWithoutRef, ReactElement, ReactNode, JSX } from 'react';
2
2
  import { EditorStateSnapshot, Editor, Extensions } from '@tiptap/react';
3
3
  import { BlockquoteOptions } from '@tiptap/extension-blockquote';
4
4
  import { BoldOptions } from '@tiptap/extension-bold';
@@ -20,6 +20,62 @@ type ItemSelector = {
20
20
  zone?: string;
21
21
  };
22
22
 
23
+ /**
24
+ * Props consumed by Puck internally that are shared between DropZones and slots.
25
+ */
26
+ type DropZoneSharedProps<ComponentType extends ElementType = "div"> = {
27
+ allow?: string[];
28
+ disallow?: string[];
29
+ style?: CSSProperties;
30
+ minEmptyHeight?: CSSProperties["minHeight"] | number;
31
+ className?: string;
32
+ collisionAxis?: DragAxis;
33
+ ref?: Ref<any>;
34
+ as?: ComponentType;
35
+ };
36
+ /**
37
+ * All props consumed by Puck for a DropZone component. `zone` lives here only.
38
+ *
39
+ * On slots `zone` is injected internally, so slots use {@link SlotProps} instead.
40
+ */
41
+ type DropZoneOwnProps<ComponentType extends ElementType = "div"> = DropZoneSharedProps<ComponentType> & {
42
+ zone: string;
43
+ };
44
+ /**
45
+ * Unsupported additional props that are never forwarded to `as`.
46
+ *
47
+ * Omitted from the public types AND stripped at runtime.
48
+ */
49
+ type NonForwardableProps = {
50
+ children?: unknown;
51
+ dangerouslySetInnerHTML?: unknown;
52
+ };
53
+ /**
54
+ * Keys internally consumed by Puck and never forwarded to `as`.
55
+ */
56
+ type ConsumedPropKey = keyof DropZoneOwnProps | "as" | "content" | "config" | "metadata";
57
+ /**
58
+ * Additional props forwarded to the element or component provided via `as`,
59
+ * typed against it.
60
+ *
61
+ * Puck-internal/unsupported props are stripped so they don't leak onto the DOM.
62
+ */
63
+ type ForwardedProps<ComponentType extends ElementType> = Omit<ComponentPropsWithoutRef<ComponentType>, ConsumedPropKey | keyof NonForwardableProps>;
64
+ /**
65
+ * Props for a `DropZone` component.
66
+ *
67
+ * Any additional props not consumed by Puck are forwarded to the element or
68
+ * component provided via `as` (defaulting to a `div`), typed against it.
69
+ */
70
+ type DropZoneProps<ComponentType extends ElementType = "div"> = DropZoneOwnProps<ComponentType> & ForwardedProps<ComponentType>;
71
+ /**
72
+ * Props for a `slot` render component.
73
+ *
74
+ * Any additional props not consumed by Puck are forwarded to the element or
75
+ * component provided via `as` (defaulting to a `div`), typed against it.
76
+ */
77
+ type SlotProps<ComponentType extends ElementType = "div"> = DropZoneSharedProps<ComponentType> & ForwardedProps<ComponentType>;
78
+
23
79
  declare const defaultEditorState: (ctx: EditorStateSnapshot, readOnly: boolean) => {
24
80
  isAlignLeft?: undefined;
25
81
  canAlignLeft?: undefined;
@@ -338,20 +394,11 @@ type FieldProps<F = Field<any>, ValueType = any> = {
338
394
  readOnly?: boolean;
339
395
  };
340
396
 
341
- type DropZoneProps = {
342
- zone: string;
343
- allow?: string[];
344
- disallow?: string[];
345
- style?: CSSProperties;
346
- minEmptyHeight?: CSSProperties["minHeight"] | number;
347
- className?: string;
348
- collisionAxis?: DragAxis;
349
- as?: ElementType;
350
- ref?: Ref<any>;
351
- };
352
-
353
397
  type PuckContext = {
354
- renderDropZone: (props: DropZoneProps) => React.ReactNode;
398
+ /**
399
+ * @deprecated Use {@link https://puckeditor.com/docs/api-reference/fields/slot Slots} instead.
400
+ */
401
+ renderDropZone: <ComponentType extends ElementType = "div">(props: DropZoneProps<ComponentType>) => React.ReactNode;
355
402
  metadata: Metadata;
356
403
  isEditing: boolean;
357
404
  dragRef: ((element: Element | null) => void) | null;
@@ -359,6 +406,12 @@ type PuckContext = {
359
406
  type DefaultRootFieldProps = {
360
407
  title?: string;
361
408
  };
409
+ /**
410
+ * Merge the default root field props into user-provided root props, letting
411
+ * the user's props take precedence. Using a plain intersection would turn an
412
+ * overridden `title` (e.g. `number`) into `never` (`number & string`).
413
+ */
414
+ type WithDefaultRootFieldProps<RootProps> = RootProps & Omit<DefaultRootFieldProps, keyof RootProps>;
362
415
  type DefaultComponentProps = {
363
416
  [key: string]: any;
364
417
  };
@@ -378,7 +431,7 @@ type UserGenerics<UserConfig extends Config = Config, UserParams extends Extract
378
431
  UserConfig: UserConfig;
379
432
  UserParams: UserParams;
380
433
  UserProps: UserParams["props"];
381
- UserRootProps: UserParams["rootProps"] & DefaultRootFieldProps;
434
+ UserRootProps: WithDefaultRootFieldProps<UserParams["rootProps"]>;
382
435
  UserData: UserData;
383
436
  UserAppState: UserAppState;
384
437
  UserPublicAppState: UserPublicAppState;
@@ -391,7 +444,7 @@ type ExtractField<UserField extends {
391
444
  type: T;
392
445
  }>;
393
446
 
394
- type SlotComponent = (props?: Omit<DropZoneProps, "zone">) => ReactNode;
447
+ type SlotComponent = <ComponentType extends ElementType = "div">(props?: SlotProps<ComponentType>) => ReactNode;
395
448
  type PuckComponent<Props> = (props: WithId<WithPuckProps<{
396
449
  [K in keyof Props]: WithDeepSlots<Props[K], SlotComponent>;
397
450
  }>>) => JSX.Element;
@@ -462,7 +515,7 @@ type DefaultComponents = Record<string, any>;
462
515
  type Config<PropsOrParams extends LeftOrExactRight<PropsOrParams, DefaultComponents, ConfigParams> = DefaultComponents | ConfigParams, RootProps extends DefaultComponentProps = any, CategoryName extends string = string> = PropsOrParams extends ConfigParams<infer ParamComponents, infer ParamRoot, infer ParamCategoryName, never> ? ConfigInternal<ParamComponents, ParamRoot, ParamCategoryName[number]> : PropsOrParams extends ConfigParams<infer ParamComponents, infer ParamRoot, infer ParamCategoryName, infer ParamFields> ? ConfigInternal<ParamComponents, ParamRoot, ParamCategoryName[number], ParamFields[keyof ParamFields] & BaseField> : PropsOrParams extends ConfigParams<infer ParamComponents, infer ParamRoot, infer ParamCategoryName, any> ? ConfigInternal<ParamComponents, ParamRoot, ParamCategoryName[number], {}> : ConfigInternal<PropsOrParams, RootProps, CategoryName>;
463
516
  type ExtractConfigParams<UserConfig extends ConfigInternal> = UserConfig extends ConfigInternal<infer PropsOrParams, infer RootProps, infer CategoryName, infer UserField> ? {
464
517
  props: PropsOrParams;
465
- rootProps: RootProps & DefaultRootFieldProps;
518
+ rootProps: WithDefaultRootFieldProps<RootProps>;
466
519
  categoryNames: CategoryName;
467
520
  field: UserField extends {
468
521
  type: string;
@@ -545,6 +598,8 @@ type UiState = {
545
598
  expanded?: boolean;
546
599
  }>;
547
600
  isDragging: boolean;
601
+ /** Outline items whose children are shown, keyed by item id */
602
+ itemExpanded?: Record<string, boolean>;
548
603
  viewports: {
549
604
  current: {
550
605
  width: number | "100%";
@@ -690,12 +745,12 @@ type Overrides<UserConfig extends Config = Config> = OverridesGeneric<{
690
745
  }>;
691
746
  type FieldRenderFunctions<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends {
692
747
  type: string;
693
- } = Field | G["UserField"]> = Omit<{
748
+ } = Field | G["UserField"]> = {
694
749
  [Type in UserField["type"]]: React.FunctionComponent<FieldProps<ExtractField<UserField, Type>, any> & {
695
750
  children: ReactNode;
696
751
  name: string;
697
- }>;
698
- }, "custom">;
752
+ }> | null;
753
+ };
699
754
 
700
755
  type DragAxis = "dynamic" | "y" | "x";
701
756
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ReactElement, CSSProperties, ReactNode, ElementType, Ref, JSX } from 'react';
1
+ import { ElementType, CSSProperties, Ref, ComponentPropsWithoutRef, ReactElement, ReactNode, JSX } from 'react';
2
2
  import { EditorStateSnapshot, Editor, Extensions } from '@tiptap/react';
3
3
  import { BlockquoteOptions } from '@tiptap/extension-blockquote';
4
4
  import { BoldOptions } from '@tiptap/extension-bold';
@@ -20,6 +20,62 @@ type ItemSelector = {
20
20
  zone?: string;
21
21
  };
22
22
 
23
+ /**
24
+ * Props consumed by Puck internally that are shared between DropZones and slots.
25
+ */
26
+ type DropZoneSharedProps<ComponentType extends ElementType = "div"> = {
27
+ allow?: string[];
28
+ disallow?: string[];
29
+ style?: CSSProperties;
30
+ minEmptyHeight?: CSSProperties["minHeight"] | number;
31
+ className?: string;
32
+ collisionAxis?: DragAxis;
33
+ ref?: Ref<any>;
34
+ as?: ComponentType;
35
+ };
36
+ /**
37
+ * All props consumed by Puck for a DropZone component. `zone` lives here only.
38
+ *
39
+ * On slots `zone` is injected internally, so slots use {@link SlotProps} instead.
40
+ */
41
+ type DropZoneOwnProps<ComponentType extends ElementType = "div"> = DropZoneSharedProps<ComponentType> & {
42
+ zone: string;
43
+ };
44
+ /**
45
+ * Unsupported additional props that are never forwarded to `as`.
46
+ *
47
+ * Omitted from the public types AND stripped at runtime.
48
+ */
49
+ type NonForwardableProps = {
50
+ children?: unknown;
51
+ dangerouslySetInnerHTML?: unknown;
52
+ };
53
+ /**
54
+ * Keys internally consumed by Puck and never forwarded to `as`.
55
+ */
56
+ type ConsumedPropKey = keyof DropZoneOwnProps | "as" | "content" | "config" | "metadata";
57
+ /**
58
+ * Additional props forwarded to the element or component provided via `as`,
59
+ * typed against it.
60
+ *
61
+ * Puck-internal/unsupported props are stripped so they don't leak onto the DOM.
62
+ */
63
+ type ForwardedProps<ComponentType extends ElementType> = Omit<ComponentPropsWithoutRef<ComponentType>, ConsumedPropKey | keyof NonForwardableProps>;
64
+ /**
65
+ * Props for a `DropZone` component.
66
+ *
67
+ * Any additional props not consumed by Puck are forwarded to the element or
68
+ * component provided via `as` (defaulting to a `div`), typed against it.
69
+ */
70
+ type DropZoneProps<ComponentType extends ElementType = "div"> = DropZoneOwnProps<ComponentType> & ForwardedProps<ComponentType>;
71
+ /**
72
+ * Props for a `slot` render component.
73
+ *
74
+ * Any additional props not consumed by Puck are forwarded to the element or
75
+ * component provided via `as` (defaulting to a `div`), typed against it.
76
+ */
77
+ type SlotProps<ComponentType extends ElementType = "div"> = DropZoneSharedProps<ComponentType> & ForwardedProps<ComponentType>;
78
+
23
79
  declare const defaultEditorState: (ctx: EditorStateSnapshot, readOnly: boolean) => {
24
80
  isAlignLeft?: undefined;
25
81
  canAlignLeft?: undefined;
@@ -338,20 +394,11 @@ type FieldProps<F = Field<any>, ValueType = any> = {
338
394
  readOnly?: boolean;
339
395
  };
340
396
 
341
- type DropZoneProps = {
342
- zone: string;
343
- allow?: string[];
344
- disallow?: string[];
345
- style?: CSSProperties;
346
- minEmptyHeight?: CSSProperties["minHeight"] | number;
347
- className?: string;
348
- collisionAxis?: DragAxis;
349
- as?: ElementType;
350
- ref?: Ref<any>;
351
- };
352
-
353
397
  type PuckContext = {
354
- renderDropZone: (props: DropZoneProps) => React.ReactNode;
398
+ /**
399
+ * @deprecated Use {@link https://puckeditor.com/docs/api-reference/fields/slot Slots} instead.
400
+ */
401
+ renderDropZone: <ComponentType extends ElementType = "div">(props: DropZoneProps<ComponentType>) => React.ReactNode;
355
402
  metadata: Metadata;
356
403
  isEditing: boolean;
357
404
  dragRef: ((element: Element | null) => void) | null;
@@ -359,6 +406,12 @@ type PuckContext = {
359
406
  type DefaultRootFieldProps = {
360
407
  title?: string;
361
408
  };
409
+ /**
410
+ * Merge the default root field props into user-provided root props, letting
411
+ * the user's props take precedence. Using a plain intersection would turn an
412
+ * overridden `title` (e.g. `number`) into `never` (`number & string`).
413
+ */
414
+ type WithDefaultRootFieldProps<RootProps> = RootProps & Omit<DefaultRootFieldProps, keyof RootProps>;
362
415
  type DefaultComponentProps = {
363
416
  [key: string]: any;
364
417
  };
@@ -378,7 +431,7 @@ type UserGenerics<UserConfig extends Config = Config, UserParams extends Extract
378
431
  UserConfig: UserConfig;
379
432
  UserParams: UserParams;
380
433
  UserProps: UserParams["props"];
381
- UserRootProps: UserParams["rootProps"] & DefaultRootFieldProps;
434
+ UserRootProps: WithDefaultRootFieldProps<UserParams["rootProps"]>;
382
435
  UserData: UserData;
383
436
  UserAppState: UserAppState;
384
437
  UserPublicAppState: UserPublicAppState;
@@ -391,7 +444,7 @@ type ExtractField<UserField extends {
391
444
  type: T;
392
445
  }>;
393
446
 
394
- type SlotComponent = (props?: Omit<DropZoneProps, "zone">) => ReactNode;
447
+ type SlotComponent = <ComponentType extends ElementType = "div">(props?: SlotProps<ComponentType>) => ReactNode;
395
448
  type PuckComponent<Props> = (props: WithId<WithPuckProps<{
396
449
  [K in keyof Props]: WithDeepSlots<Props[K], SlotComponent>;
397
450
  }>>) => JSX.Element;
@@ -462,7 +515,7 @@ type DefaultComponents = Record<string, any>;
462
515
  type Config<PropsOrParams extends LeftOrExactRight<PropsOrParams, DefaultComponents, ConfigParams> = DefaultComponents | ConfigParams, RootProps extends DefaultComponentProps = any, CategoryName extends string = string> = PropsOrParams extends ConfigParams<infer ParamComponents, infer ParamRoot, infer ParamCategoryName, never> ? ConfigInternal<ParamComponents, ParamRoot, ParamCategoryName[number]> : PropsOrParams extends ConfigParams<infer ParamComponents, infer ParamRoot, infer ParamCategoryName, infer ParamFields> ? ConfigInternal<ParamComponents, ParamRoot, ParamCategoryName[number], ParamFields[keyof ParamFields] & BaseField> : PropsOrParams extends ConfigParams<infer ParamComponents, infer ParamRoot, infer ParamCategoryName, any> ? ConfigInternal<ParamComponents, ParamRoot, ParamCategoryName[number], {}> : ConfigInternal<PropsOrParams, RootProps, CategoryName>;
463
516
  type ExtractConfigParams<UserConfig extends ConfigInternal> = UserConfig extends ConfigInternal<infer PropsOrParams, infer RootProps, infer CategoryName, infer UserField> ? {
464
517
  props: PropsOrParams;
465
- rootProps: RootProps & DefaultRootFieldProps;
518
+ rootProps: WithDefaultRootFieldProps<RootProps>;
466
519
  categoryNames: CategoryName;
467
520
  field: UserField extends {
468
521
  type: string;
@@ -545,6 +598,8 @@ type UiState = {
545
598
  expanded?: boolean;
546
599
  }>;
547
600
  isDragging: boolean;
601
+ /** Outline items whose children are shown, keyed by item id */
602
+ itemExpanded?: Record<string, boolean>;
548
603
  viewports: {
549
604
  current: {
550
605
  width: number | "100%";
@@ -690,12 +745,12 @@ type Overrides<UserConfig extends Config = Config> = OverridesGeneric<{
690
745
  }>;
691
746
  type FieldRenderFunctions<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends {
692
747
  type: string;
693
- } = Field | G["UserField"]> = Omit<{
748
+ } = Field | G["UserField"]> = {
694
749
  [Type in UserField["type"]]: React.FunctionComponent<FieldProps<ExtractField<UserField, Type>, any> & {
695
750
  children: ReactNode;
696
751
  name: string;
697
- }>;
698
- }, "custom">;
752
+ }> | null;
753
+ };
699
754
 
700
755
  type DragAxis = "dynamic" | "y" | "x";
701
756
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@puckeditor/plugin-emotion-cache",
3
- "version": "0.23.0-canary.fb9392de",
3
+ "version": "0.24.0-canary.34794e5d",
4
4
  "author": "Chris Villa <chris@puckeditor.com>",
5
5
  "repository": "puckeditor/puck",
6
6
  "bugs": "https://github.com/puckeditor/puck/issues",
@@ -24,7 +24,7 @@
24
24
  ],
25
25
  "devDependencies": {
26
26
  "@emotion/react": "^11.13.3",
27
- "@puckeditor/core": "^0.23.0-canary.fb9392de",
27
+ "@puckeditor/core": "^0.24.0-canary.34794e5d",
28
28
  "@types/minimatch": "3.0.5",
29
29
  "@types/react": "^19.2.7",
30
30
  "@types/react-dom": "^19.0.2",