@measured/puck-plugin-heading-analyzer 0.20.0-canary.3da831b0 → 0.20.0-canary.93d525c5

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
@@ -39,11 +39,11 @@ type RadioField = BaseField & {
39
39
  type: "radio";
40
40
  options: FieldOptions;
41
41
  };
42
- type ArrayField<Props extends {
42
+ type ArrayField<Props extends any = {
43
43
  [key: string]: any;
44
- } = {
44
+ }> = Props extends {
45
45
  [key: string]: any;
46
- }> = BaseField & {
46
+ } ? BaseField & {
47
47
  type: "array";
48
48
  arrayFields: {
49
49
  [SubPropName in keyof Props[0]]: Field<Props[0][SubPropName]>;
@@ -52,14 +52,12 @@ type ArrayField<Props extends {
52
52
  getItemSummary?: (item: Props[0], index?: number) => string;
53
53
  max?: number;
54
54
  min?: number;
55
- };
56
- type ObjectField<Props extends {
57
- [key: string]: any;
58
- } = {
55
+ } : never;
56
+ type ObjectField<Props extends any = {
59
57
  [key: string]: any;
60
58
  }> = BaseField & {
61
59
  type: "object";
62
- objectFields: Props extends any[] ? never : {
60
+ objectFields: {
63
61
  [SubPropName in keyof Props]: Field<Props[SubPropName]>;
64
62
  };
65
63
  };
@@ -68,20 +66,17 @@ type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, Pr
68
66
  fetchList: (adaptorParams?: AdaptorParams) => Promise<TableShape[] | null>;
69
67
  mapProp?: (value: TableShape) => PropShape;
70
68
  };
71
- type ExternalFieldWithAdaptor<Props extends {
72
- [key: string]: any;
73
- } = {
69
+ type NotUndefined<T> = T extends undefined ? Record<string, any> : T;
70
+ type ExternalFieldWithAdaptor<Props extends any = {
74
71
  [key: string]: any;
75
72
  }> = BaseField & {
76
73
  type: "external";
77
74
  placeholder?: string;
78
75
  adaptor: Adaptor<any, any, Props>;
79
76
  adaptorParams?: object;
80
- getItemSummary: (item: Props, index?: number) => string;
77
+ getItemSummary: (item: NotUndefined<Props>, index?: number) => string;
81
78
  };
82
- type ExternalField<Props extends {
83
- [key: string]: any;
84
- } = {
79
+ type ExternalField<Props extends any = {
85
80
  [key: string]: any;
86
81
  }> = BaseField & {
87
82
  type: "external";
@@ -92,7 +87,7 @@ type ExternalField<Props extends {
92
87
  }) => Promise<any[] | null>;
93
88
  mapProp?: (value: any) => Props;
94
89
  mapRow?: (value: any) => Record<string, string | number | ReactElement>;
95
- getItemSummary?: (item: Props, index?: number) => string;
90
+ getItemSummary?: (item: NotUndefined<Props>, index?: number) => string;
96
91
  showSearch?: boolean;
97
92
  renderFooter?: (props: {
98
93
  items: any[];
@@ -118,15 +113,7 @@ type SlotField = BaseField & {
118
113
  allow?: string[];
119
114
  disallow?: string[];
120
115
  };
121
- type Field<Props extends any = any> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<Props extends {
122
- [key: string]: any;
123
- } ? Props : any> | ObjectField<Props extends {
124
- [key: string]: any;
125
- } ? Props : any> | ExternalField<Props extends {
126
- [key: string]: any;
127
- } ? Props : any> | ExternalFieldWithAdaptor<Props extends {
128
- [key: string]: any;
129
- } ? Props : any> | CustomField<Props> | SlotField;
116
+ type Field<ValueType = any> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType> | ObjectField<ValueType> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
130
117
  type FieldProps<F = Field<any>, ValueType = any> = {
131
118
  field: F;
132
119
  value: ValueType;
package/dist/index.d.ts CHANGED
@@ -39,11 +39,11 @@ type RadioField = BaseField & {
39
39
  type: "radio";
40
40
  options: FieldOptions;
41
41
  };
42
- type ArrayField<Props extends {
42
+ type ArrayField<Props extends any = {
43
43
  [key: string]: any;
44
- } = {
44
+ }> = Props extends {
45
45
  [key: string]: any;
46
- }> = BaseField & {
46
+ } ? BaseField & {
47
47
  type: "array";
48
48
  arrayFields: {
49
49
  [SubPropName in keyof Props[0]]: Field<Props[0][SubPropName]>;
@@ -52,14 +52,12 @@ type ArrayField<Props extends {
52
52
  getItemSummary?: (item: Props[0], index?: number) => string;
53
53
  max?: number;
54
54
  min?: number;
55
- };
56
- type ObjectField<Props extends {
57
- [key: string]: any;
58
- } = {
55
+ } : never;
56
+ type ObjectField<Props extends any = {
59
57
  [key: string]: any;
60
58
  }> = BaseField & {
61
59
  type: "object";
62
- objectFields: Props extends any[] ? never : {
60
+ objectFields: {
63
61
  [SubPropName in keyof Props]: Field<Props[SubPropName]>;
64
62
  };
65
63
  };
@@ -68,20 +66,17 @@ type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, Pr
68
66
  fetchList: (adaptorParams?: AdaptorParams) => Promise<TableShape[] | null>;
69
67
  mapProp?: (value: TableShape) => PropShape;
70
68
  };
71
- type ExternalFieldWithAdaptor<Props extends {
72
- [key: string]: any;
73
- } = {
69
+ type NotUndefined<T> = T extends undefined ? Record<string, any> : T;
70
+ type ExternalFieldWithAdaptor<Props extends any = {
74
71
  [key: string]: any;
75
72
  }> = BaseField & {
76
73
  type: "external";
77
74
  placeholder?: string;
78
75
  adaptor: Adaptor<any, any, Props>;
79
76
  adaptorParams?: object;
80
- getItemSummary: (item: Props, index?: number) => string;
77
+ getItemSummary: (item: NotUndefined<Props>, index?: number) => string;
81
78
  };
82
- type ExternalField<Props extends {
83
- [key: string]: any;
84
- } = {
79
+ type ExternalField<Props extends any = {
85
80
  [key: string]: any;
86
81
  }> = BaseField & {
87
82
  type: "external";
@@ -92,7 +87,7 @@ type ExternalField<Props extends {
92
87
  }) => Promise<any[] | null>;
93
88
  mapProp?: (value: any) => Props;
94
89
  mapRow?: (value: any) => Record<string, string | number | ReactElement>;
95
- getItemSummary?: (item: Props, index?: number) => string;
90
+ getItemSummary?: (item: NotUndefined<Props>, index?: number) => string;
96
91
  showSearch?: boolean;
97
92
  renderFooter?: (props: {
98
93
  items: any[];
@@ -118,15 +113,7 @@ type SlotField = BaseField & {
118
113
  allow?: string[];
119
114
  disallow?: string[];
120
115
  };
121
- type Field<Props extends any = any> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<Props extends {
122
- [key: string]: any;
123
- } ? Props : any> | ObjectField<Props extends {
124
- [key: string]: any;
125
- } ? Props : any> | ExternalField<Props extends {
126
- [key: string]: any;
127
- } ? Props : any> | ExternalFieldWithAdaptor<Props extends {
128
- [key: string]: any;
129
- } ? Props : any> | CustomField<Props> | SlotField;
116
+ type Field<ValueType = any> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType> | ObjectField<ValueType> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
130
117
  type FieldProps<F = Field<any>, ValueType = any> = {
131
118
  field: F;
132
119
  value: ValueType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck-plugin-heading-analyzer",
3
- "version": "0.20.0-canary.3da831b0",
3
+ "version": "0.20.0-canary.93d525c5",
4
4
  "author": "Chris Villa <chris@puckeditor.com>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",
@@ -25,7 +25,7 @@
25
25
  "dist"
26
26
  ],
27
27
  "devDependencies": {
28
- "@measured/puck": "^0.20.0-canary.3da831b0",
28
+ "@measured/puck": "^0.20.0-canary.93d525c5",
29
29
  "@types/react": "^19.0.1",
30
30
  "@types/react-dom": "^19.0.2",
31
31
  "eslint": "^7.32.0",