@measured/puck-plugin-heading-analyzer 0.12.0-canary.932e412 → 0.12.0-canary.afd6a9d

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,147 @@
1
- import { Plugin } from '@measured/puck/types/Plugin';
1
+ import { ReactNode, ReactElement } from 'react';
2
+
3
+ type ItemSelector = {
4
+ index: number;
5
+ zone?: string;
6
+ };
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>);
46
+ };
47
+ type SetDataAction = {
48
+ type: "setData";
49
+ data: Partial<Data> | ((previous: Data) => Partial<Data>);
50
+ };
51
+ type SetAction = {
52
+ type: "set";
53
+ state: Partial<AppState>;
54
+ };
55
+ type RegisterZoneAction = {
56
+ type: "registerZone";
57
+ zone: string;
58
+ };
59
+ type UnregisterZoneAction = {
60
+ type: "unregisterZone";
61
+ zone: string;
62
+ };
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;
69
+ };
70
+ type DefaultRootProps = {
71
+ title?: string;
72
+ [key: string]: any;
73
+ };
74
+ type DefaultComponentProps = {
75
+ [key: string]: any;
76
+ editMode?: boolean;
77
+ };
78
+ type Content<Props extends {
79
+ [key: string]: any;
80
+ } = {
81
+ [key: string]: any;
82
+ }> = ComponentData<Props>[];
83
+ type BaseData<Props extends {
84
+ [key: string]: any;
85
+ } = {
86
+ [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
+ };
104
+ type ItemWithId = {
105
+ _arrayId: string;
106
+ data: any;
107
+ };
108
+ type ArrayState = {
109
+ items: ItemWithId[];
110
+ openId: string;
111
+ };
112
+ type UiState = {
113
+ leftSideBarVisible: boolean;
114
+ itemSelector: ItemSelector | null;
115
+ arrayState: Record<string, ArrayState | undefined>;
116
+ componentList: Record<string, {
117
+ components?: string[];
118
+ title?: string;
119
+ visible?: boolean;
120
+ expanded?: boolean;
121
+ }>;
122
+ };
123
+ type AppState = {
124
+ data: Data;
125
+ ui: UiState;
126
+ };
127
+
128
+ type Plugin = {
129
+ renderRootFields?: (props: {
130
+ children: ReactNode;
131
+ dispatch: (action: PuckAction) => void;
132
+ state: AppState;
133
+ }) => ReactElement<any>;
134
+ renderRoot?: (props: {
135
+ children: ReactNode;
136
+ dispatch: (action: PuckAction) => void;
137
+ state: AppState;
138
+ }) => ReactElement<any>;
139
+ renderFields?: (props: {
140
+ children: ReactNode;
141
+ dispatch: (action: PuckAction) => void;
142
+ state: AppState;
143
+ }) => ReactElement<any>;
144
+ };
2
145
 
3
146
  declare const HeadingAnalyzer: Plugin;
4
147
 
package/dist/index.js CHANGED
@@ -1476,6 +1476,7 @@ function ClipLoader(_a) {
1476
1476
  var ClipLoader_default = ClipLoader;
1477
1477
 
1478
1478
  // ../core/components/SidebarSection/index.tsx
1479
+ var import_jsx_runtime3 = require("react/jsx-runtime");
1479
1480
  var getClassName2 = get_class_name_factory_default("SidebarSection", styles_module_default);
1480
1481
  var SidebarSection = ({
1481
1482
  children,
@@ -1487,14 +1488,24 @@ var SidebarSection = ({
1487
1488
  }) => {
1488
1489
  const { setUi } = useAppContext();
1489
1490
  const breadcrumbs = useBreadcrumbs(1);
1490
- return /* @__PURE__ */ import_react.default.createElement("div", { className: getClassName2({ noPadding }), style: { background } }, /* @__PURE__ */ import_react.default.createElement("div", { className: getClassName2("title") }, /* @__PURE__ */ import_react.default.createElement("div", { className: getClassName2("breadcrumbs") }, showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ import_react.default.createElement("div", { key: i, className: getClassName2("breadcrumb") }, /* @__PURE__ */ import_react.default.createElement(
1491
- "div",
1492
- {
1493
- className: getClassName2("breadcrumbLabel"),
1494
- onClick: () => setUi({ itemSelector: breadcrumb.selector })
1495
- },
1496
- breadcrumb.label
1497
- ), /* @__PURE__ */ import_react.default.createElement(chevron_right_default, { size: 16 }))) : null, /* @__PURE__ */ import_react.default.createElement("div", { className: getClassName2("heading") }, /* @__PURE__ */ import_react.default.createElement(Heading, { rank: 2, size: "xs" }, title)))), /* @__PURE__ */ import_react.default.createElement("div", { className: getClassName2("content") }, children), isLoading && /* @__PURE__ */ import_react.default.createElement("div", { className: getClassName2("loadingOverlay") }, /* @__PURE__ */ import_react.default.createElement(ClipLoader_default, null)));
1491
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: getClassName2({ noPadding }), style: { background }, children: [
1492
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName2("title"), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: getClassName2("breadcrumbs"), children: [
1493
+ showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: getClassName2("breadcrumb"), children: [
1494
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1495
+ "div",
1496
+ {
1497
+ className: getClassName2("breadcrumbLabel"),
1498
+ onClick: () => setUi({ itemSelector: breadcrumb.selector }),
1499
+ children: breadcrumb.label
1500
+ }
1501
+ ),
1502
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(chevron_right_default, { size: 16 })
1503
+ ] }, i)) : null,
1504
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName2("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Heading, { rank: 2, size: "xs", children: title }) })
1505
+ ] }) }),
1506
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName2("content"), children }),
1507
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName2("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ClipLoader_default, {}) })
1508
+ ] });
1498
1509
  };
1499
1510
 
1500
1511
  // ../core/components/OutlineList/index.tsx
@@ -1505,23 +1516,24 @@ init_react_import();
1505
1516
  var styles_module_default3 = { "OutlineList": "_OutlineList_pnv2s_1", "OutlineListItem": "_OutlineListItem_pnv2s_21", "OutlineListItem--clickable": "_OutlineListItem--clickable_pnv2s_36" };
1506
1517
 
1507
1518
  // ../core/components/OutlineList/index.tsx
1519
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1508
1520
  var getClassName3 = get_class_name_factory_default("OutlineList", styles_module_default3);
1509
1521
  var getClassNameItem = get_class_name_factory_default("OutlineListItem", styles_module_default3);
1510
1522
  var OutlineList = ({ children }) => {
1511
- return /* @__PURE__ */ import_react.default.createElement("ul", { className: getClassName3() }, children);
1523
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { className: getClassName3(), children });
1512
1524
  };
1513
- OutlineList.Clickable = ({ children }) => /* @__PURE__ */ import_react.default.createElement("div", { className: getClassNameItem({ clickable: true }) }, children);
1525
+ OutlineList.Clickable = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassNameItem({ clickable: true }), children });
1514
1526
  OutlineList.Item = ({
1515
1527
  children,
1516
1528
  onClick
1517
1529
  }) => {
1518
- return /* @__PURE__ */ import_react.default.createElement(
1530
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1519
1531
  "li",
1520
1532
  {
1521
1533
  className: getClassNameItem({ clickable: !!onClick }),
1522
- onClick
1523
- },
1524
- children
1534
+ onClick,
1535
+ children
1536
+ }
1525
1537
  );
1526
1538
  };
1527
1539
 
@@ -1538,7 +1550,7 @@ var scrollIntoView = (el) => {
1538
1550
 
1539
1551
  // src/HeadingAnalyzer.tsx
1540
1552
  var import_react_from_json = __toESM(require("react-from-json"));
1541
- var import_jsx_runtime3 = require("react/jsx-runtime");
1553
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1542
1554
  var dataAttr = "data-puck-heading-analyzer-id";
1543
1555
  var getOutline = ({
1544
1556
  addDataAttr = false
@@ -1608,17 +1620,17 @@ var HeadingOutlineAnalyer = ({
1608
1620
  setHierarchy(buildHierarchy());
1609
1621
  }
1610
1622
  }, [data.content]);
1611
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
1623
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1612
1624
  children,
1613
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(SidebarSection, { title: "Heading Outline", children: [
1614
- hierarchy.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: "No headings." }),
1615
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(OutlineList, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1625
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(SidebarSection, { title: "Heading Outline", children: [
1626
+ hierarchy.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: "No headings." }),
1627
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OutlineList, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1616
1628
  import_react_from_json.default,
1617
1629
  {
1618
1630
  mapping: {
1619
- Root: (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: props.children }),
1620
- OutlineListItem: (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(OutlineList.Item, { children: [
1621
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(OutlineList.Clickable, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1631
+ Root: (props) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: props.children }),
1632
+ OutlineListItem: (props) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(OutlineList.Item, { children: [
1633
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OutlineList.Clickable, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1622
1634
  "small",
1623
1635
  {
1624
1636
  onClick: typeof props.analyzeId == "undefined" ? void 0 : (e) => {
@@ -1637,14 +1649,14 @@ var HeadingOutlineAnalyer = ({
1637
1649
  }, 2e3);
1638
1650
  }
1639
1651
  },
1640
- children: props.missing ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { style: { color: "var(--puck-color-red)" }, children: [
1641
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("b", { children: [
1652
+ children: props.missing ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { style: { color: "var(--puck-color-red)" }, children: [
1653
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("b", { children: [
1642
1654
  "H",
1643
1655
  props.rank
1644
1656
  ] }),
1645
1657
  ": Missing"
1646
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { children: [
1647
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("b", { children: [
1658
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
1659
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("b", { children: [
1648
1660
  "H",
1649
1661
  props.rank
1650
1662
  ] }),
@@ -1653,7 +1665,7 @@ var HeadingOutlineAnalyer = ({
1653
1665
  ] })
1654
1666
  }
1655
1667
  ) }),
1656
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(OutlineList, { children: props.children })
1668
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OutlineList, { children: props.children })
1657
1669
  ] })
1658
1670
  },
1659
1671
  entry: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck-plugin-heading-analyzer",
3
- "version": "0.12.0-canary.932e412",
3
+ "version": "0.12.0-canary.afd6a9d",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -14,7 +14,7 @@
14
14
  "dist"
15
15
  ],
16
16
  "devDependencies": {
17
- "@measured/puck": "^0.12.0-canary.932e412",
17
+ "@measured/puck": "^0.12.0-canary.afd6a9d",
18
18
  "@types/react": "^18.2.0",
19
19
  "@types/react-dom": "^18.2.0",
20
20
  "eslint": "^7.32.0",