@measured/puck-plugin-heading-analyzer 0.13.0-canary.b95050d → 0.13.0-canary.d636605

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.css CHANGED
@@ -1,56 +1,59 @@
1
1
  /* css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css/#css-module-data */
2
- ._SidebarSection_1uyg2_1 {
2
+ ._SidebarSection_170gs_1 {
3
3
  display: flex;
4
4
  position: relative;
5
5
  flex-direction: column;
6
6
  color: black;
7
7
  }
8
- ._SidebarSection_1uyg2_1:last-of-type {
8
+ ._SidebarSection_170gs_1:last-of-type {
9
9
  flex-grow: 1;
10
10
  }
11
- ._SidebarSection-title_1uyg2_12 {
11
+ ._SidebarSection-title_170gs_12 {
12
12
  background: white;
13
13
  padding: 16px;
14
14
  border-bottom: 1px solid var(--puck-color-grey-8);
15
+ border-top: 1px solid var(--puck-color-grey-8);
15
16
  overflow-x: auto;
16
17
  }
17
- ._SidebarSection-content_1uyg2_19 {
18
- border-bottom: 1px solid var(--puck-color-grey-8);
18
+ ._SidebarSection--noBorderTop_170gs_20 > ._SidebarSection-title_170gs_12 {
19
+ border-top: 0px;
20
+ }
21
+ ._SidebarSection-content_170gs_24 {
19
22
  padding: 16px;
20
23
  }
21
- ._SidebarSection--noPadding_1uyg2_24 ._SidebarSection-content_1uyg2_19 {
24
+ ._SidebarSection--noPadding_170gs_28 > ._SidebarSection-content_170gs_24 {
22
25
  padding: 0px;
23
26
  }
24
- ._SidebarSection--noPadding_1uyg2_24 ._SidebarSection-content_1uyg2_19:last-child {
27
+ ._SidebarSection--noPadding_170gs_28 > ._SidebarSection-content_170gs_24:last-child {
25
28
  padding-bottom: 4px;
26
29
  }
27
- ._SidebarSection_1uyg2_1:last-of-type ._SidebarSection-content_1uyg2_19 {
30
+ ._SidebarSection_170gs_1:last-of-type ._SidebarSection-content_170gs_24 {
28
31
  border-bottom: none;
29
32
  flex-grow: 1;
30
33
  }
31
- ._SidebarSection-breadcrumbLabel_1uyg2_37 {
34
+ ._SidebarSection-breadcrumbLabel_170gs_41 {
32
35
  color: var(--puck-color-azure-3);
33
36
  flex-shrink: 0;
34
37
  }
35
- ._SidebarSection-breadcrumbLabel_1uyg2_37:hover {
38
+ ._SidebarSection-breadcrumbLabel_170gs_41:hover {
36
39
  color: var(--puck-color-azure-4);
37
40
  cursor: pointer;
38
41
  text-decoration: underline;
39
42
  }
40
- ._SidebarSection-breadcrumbs_1uyg2_48 {
43
+ ._SidebarSection-breadcrumbs_170gs_52 {
41
44
  align-items: center;
42
45
  display: flex;
43
46
  gap: 4px;
44
47
  }
45
- ._SidebarSection-breadcrumb_1uyg2_37 {
48
+ ._SidebarSection-breadcrumb_170gs_41 {
46
49
  align-items: center;
47
50
  display: flex;
48
51
  gap: 4px;
49
52
  }
50
- ._SidebarSection-heading_1uyg2_60 {
53
+ ._SidebarSection-heading_170gs_64 {
51
54
  padding-right: 16px;
52
55
  }
53
- ._SidebarSection-loadingOverlay_1uyg2_64 {
56
+ ._SidebarSection-loadingOverlay_170gs_68 {
54
57
  background: white;
55
58
  display: flex;
56
59
  justify-content: center;
package/dist/index.d.ts CHANGED
@@ -1,106 +1,108 @@
1
- import { ReactNode, ReactElement } from 'react';
1
+ import { ReactElement, ReactNode } from 'react';
2
2
 
3
3
  type ItemSelector = {
4
4
  index: number;
5
5
  zone?: string;
6
6
  };
7
7
 
8
- type InsertAction = {
9
- type: "insert";
10
- componentType: string;
11
- destinationIndex: number;
12
- destinationZone: string;
13
- };
14
- type DuplicateAction = {
15
- type: "duplicate";
16
- sourceIndex: number;
17
- sourceZone: string;
18
- };
19
- type ReplaceAction = {
20
- type: "replace";
21
- destinationIndex: number;
22
- destinationZone: string;
23
- data: any;
24
- };
25
- type ReorderAction = {
26
- type: "reorder";
27
- sourceIndex: number;
28
- destinationIndex: number;
29
- destinationZone: string;
30
- };
31
- type MoveAction = {
32
- type: "move";
33
- sourceIndex: number;
34
- sourceZone: string;
35
- destinationIndex: number;
36
- destinationZone: string;
37
- };
38
- type RemoveAction = {
39
- type: "remove";
40
- index: number;
41
- zone: string;
42
- };
43
- type SetUiAction = {
44
- type: "setUi";
45
- ui: Partial<UiState> | ((previous: UiState) => Partial<UiState>);
8
+ type BaseField = {
9
+ label?: string;
46
10
  };
47
- type SetDataAction = {
48
- type: "setData";
49
- data: Partial<Data> | ((previous: Data) => Partial<Data>);
11
+ type TextField = BaseField & {
12
+ type: "text";
50
13
  };
51
- type SetAction = {
52
- type: "set";
53
- state: Partial<AppState> | ((previous: AppState) => Partial<AppState>);
14
+ type NumberField = BaseField & {
15
+ type: "number";
54
16
  };
55
- type RegisterZoneAction = {
56
- type: "registerZone";
57
- zone: string;
17
+ type TextareaField = BaseField & {
18
+ type: "textarea";
58
19
  };
59
- type UnregisterZoneAction = {
60
- type: "unregisterZone";
61
- zone: string;
20
+ type SelectField = BaseField & {
21
+ type: "select";
22
+ options: {
23
+ label: string;
24
+ value: string | number | boolean;
25
+ }[];
62
26
  };
63
- type PuckAction = {
64
- recordHistory?: boolean;
65
- } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
66
-
67
- type WithPuckProps<Props> = Props & {
68
- id: string;
27
+ type RadioField = BaseField & {
28
+ type: "radio";
29
+ options: {
30
+ label: string;
31
+ value: string | number | boolean;
32
+ }[];
69
33
  };
70
- type DefaultRootProps = {
71
- title?: string;
34
+ type ArrayField<Props extends {
72
35
  [key: string]: any;
73
- };
74
- type DefaultComponentProps = {
36
+ } = {
75
37
  [key: string]: any;
76
- editMode?: boolean;
77
- };
78
- type Content<Props extends {
38
+ }> = BaseField & {
39
+ type: "array";
40
+ arrayFields: {
41
+ [SubPropName in keyof Props[0]]: Field<Props[0][SubPropName]>;
42
+ };
43
+ defaultItemProps?: Props[0];
44
+ getItemSummary?: (item: Props[0], index?: number) => string;
45
+ };
46
+ type ObjectField<Props extends {
79
47
  [key: string]: any;
80
48
  } = {
81
49
  [key: string]: any;
82
- }> = ComponentData<Props>[];
83
- type BaseData<Props extends {
50
+ }> = BaseField & {
51
+ type: "object";
52
+ objectFields: {
53
+ [SubPropName in keyof Props[0]]: Field<Props[0][SubPropName]>;
54
+ };
55
+ };
56
+ type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, PropShape = TableShape> = {
57
+ name: string;
58
+ fetchList: (adaptorParams?: AdaptorParams) => Promise<TableShape[] | null>;
59
+ mapProp?: (value: TableShape) => PropShape;
60
+ };
61
+ type ExternalFieldWithAdaptor<Props extends {
84
62
  [key: string]: any;
85
63
  } = {
86
64
  [key: string]: any;
87
- }> = {
88
- readOnly?: Partial<Record<keyof Props, boolean>>;
89
- };
90
- type ComponentData<Props extends DefaultComponentProps = DefaultComponentProps> = {
91
- type: keyof Props;
92
- props: WithPuckProps<Props>;
93
- } & BaseData<Props>;
94
- type RootDataWithProps<Props extends DefaultRootProps = DefaultRootProps> = {
95
- props: Props;
96
- };
97
- type RootDataWithoutProps<Props extends DefaultRootProps = DefaultRootProps> = Props;
98
- type RootData<Props extends DefaultRootProps = DefaultRootProps> = BaseData<Props> & Partial<RootDataWithProps<Props>> & Partial<RootDataWithoutProps<Props>>;
99
- type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultRootProps = DefaultRootProps> = {
100
- root: RootData<RootProps>;
101
- content: Content<WithPuckProps<Props>>;
102
- zones?: Record<string, Content<WithPuckProps<Props>>>;
103
- };
65
+ }> = BaseField & {
66
+ type: "external";
67
+ placeholder?: string;
68
+ adaptor: Adaptor<any, any, Props>;
69
+ adaptorParams?: object;
70
+ getItemSummary: (item: Props, index?: number) => string;
71
+ };
72
+ type ExternalField<Props extends {
73
+ [key: string]: any;
74
+ } = {
75
+ [key: string]: any;
76
+ }> = BaseField & {
77
+ type: "external";
78
+ placeholder?: string;
79
+ fetchList: (params: {
80
+ query: string;
81
+ }) => Promise<any[] | null>;
82
+ mapProp?: (value: any) => Props;
83
+ getItemSummary: (item: Props, index?: number) => string;
84
+ showSearch?: boolean;
85
+ initialQuery?: string;
86
+ };
87
+ type CustomField<Props extends {
88
+ [key: string]: any;
89
+ } = {
90
+ [key: string]: any;
91
+ }> = BaseField & {
92
+ type: "custom";
93
+ render: (props: {
94
+ field: CustomField;
95
+ name: string;
96
+ value: any;
97
+ onChange: (value: Props) => void;
98
+ readOnly?: boolean;
99
+ }) => ReactElement;
100
+ };
101
+ type Field<Props extends {
102
+ [key: string]: any;
103
+ } = {
104
+ [key: string]: any;
105
+ }> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<Props> | ObjectField<Props> | ExternalField<Props> | ExternalFieldWithAdaptor<Props> | CustomField;
104
106
  type ItemWithId = {
105
107
  _arrayId: string;
106
108
  _originalIndex: number;
@@ -120,30 +122,74 @@ type UiState = {
120
122
  visible?: boolean;
121
123
  expanded?: boolean;
122
124
  }>;
125
+ isDragging: boolean;
123
126
  };
124
- type AppState = {
125
- data: Data;
126
- ui: UiState;
127
+
128
+ type InputProps<F = Field<any>> = {
129
+ name: string;
130
+ field: F;
131
+ value: any;
132
+ id: string;
133
+ label?: string;
134
+ onChange: (value: any, uiState?: Partial<UiState>) => void;
135
+ readOnly?: boolean;
136
+ readOnlyFields?: Record<string, boolean | undefined>;
127
137
  };
128
138
 
129
- type Plugin = {
130
- renderRootFields?: (props: {
139
+ type RenderFunc<Props extends {
140
+ [key: string]: any;
141
+ } = {
142
+ children: ReactNode;
143
+ }> = React.FunctionComponent<Props>;
144
+ declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "components", "componentItem", "outline", "puck", "preview"];
145
+ type OverrideKey = (typeof overrideKeys)[number];
146
+ type OverridesGeneric<Shape extends {
147
+ [key in OverrideKey]: any;
148
+ }> = Shape;
149
+ type Overrides = OverridesGeneric<{
150
+ fieldTypes: Partial<FieldRenderFunctions>;
151
+ header: RenderFunc<{
152
+ actions: ReactNode;
153
+ children: ReactNode;
154
+ }>;
155
+ headerActions: RenderFunc<{
156
+ children?: ReactNode;
157
+ }>;
158
+ preview: RenderFunc;
159
+ fields: RenderFunc<{
131
160
  children: ReactNode;
132
- dispatch: (action: PuckAction) => void;
133
- state: AppState;
134
- }) => ReactElement<any>;
135
- renderRoot?: (props: {
161
+ isLoading: boolean;
162
+ itemSelector?: ItemSelector | null;
163
+ }>;
164
+ fieldLabel: RenderFunc<{
165
+ children?: ReactNode;
166
+ icon?: ReactNode;
167
+ label: string;
168
+ el?: "label" | "div";
169
+ readOnly?: boolean;
170
+ className?: string;
171
+ }>;
172
+ components: RenderFunc;
173
+ componentItem: RenderFunc;
174
+ outline: RenderFunc;
175
+ puck: RenderFunc;
176
+ }>;
177
+ type FieldRenderFunctions = Omit<{
178
+ [Type in Field["type"]]: React.FunctionComponent<InputProps<Extract<Field, {
179
+ type: Type;
180
+ }>> & {
136
181
  children: ReactNode;
137
- dispatch: (action: PuckAction) => void;
138
- state: AppState;
139
- }) => ReactElement<any>;
140
- renderFields?: (props: {
182
+ }>;
183
+ }, "custom"> & {
184
+ [key: string]: React.FunctionComponent<InputProps<any> & {
141
185
  children: ReactNode;
142
- dispatch: (action: PuckAction) => void;
143
- state: AppState;
144
- }) => ReactElement<any>;
186
+ }>;
187
+ };
188
+
189
+ type Plugin = {
190
+ overrides: Partial<Overrides>;
145
191
  };
146
192
 
147
- declare const HeadingAnalyzer: Plugin;
193
+ declare const headingAnalyzer: Plugin;
148
194
 
149
- export { HeadingAnalyzer as default };
195
+ export { headingAnalyzer as default };