@measured/puck-plugin-heading-analyzer 0.16.0-canary.6d43ba0 → 0.16.0-canary.72b8720

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,48 +1,10 @@
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 iconTypes = "Smartphone" | "Monitor" | "Tablet";
9
- type Viewport = {
10
- width: number;
11
- height?: number | "auto";
12
- label?: string;
13
- icon?: iconTypes | ReactNode;
14
- };
15
-
16
- type ItemWithId = {
17
- _arrayId: string;
18
- _originalIndex: number;
19
- };
20
- type ArrayState = {
21
- items: ItemWithId[];
22
- openId: string;
23
- };
24
- type UiState = {
25
- leftSideBarVisible: boolean;
26
- rightSideBarVisible: boolean;
27
- itemSelector: ItemSelector | null;
28
- arrayState: Record<string, ArrayState | undefined>;
29
- componentList: Record<string, {
30
- components?: string[];
31
- title?: string;
32
- visible?: boolean;
33
- expanded?: boolean;
34
- }>;
35
- isDragging: boolean;
36
- viewports: {
37
- current: {
38
- width: number;
39
- height: number | "auto";
40
- };
41
- controlsVisible: boolean;
42
- options: Viewport[];
43
- };
44
- };
45
-
46
8
  type FieldOption = {
47
9
  label: string;
48
10
  value: string | number | boolean;
@@ -157,6 +119,36 @@ type FieldProps<ValueType = any, F = Field<any>> = {
157
119
  readOnly?: boolean;
158
120
  };
159
121
 
122
+ type ItemWithId = {
123
+ _arrayId: string;
124
+ _originalIndex: number;
125
+ };
126
+ type ArrayState = {
127
+ items: ItemWithId[];
128
+ openId: string;
129
+ };
130
+ type UiState = {
131
+ leftSideBarVisible: boolean;
132
+ rightSideBarVisible: boolean;
133
+ itemSelector: ItemSelector | null;
134
+ arrayState: Record<string, ArrayState | undefined>;
135
+ componentList: Record<string, {
136
+ components?: string[];
137
+ title?: string;
138
+ visible?: boolean;
139
+ expanded?: boolean;
140
+ }>;
141
+ isDragging: boolean;
142
+ viewports: {
143
+ current: {
144
+ width: number;
145
+ height: number | "auto";
146
+ };
147
+ controlsVisible: boolean;
148
+ options: Viewport[];
149
+ };
150
+ };
151
+
160
152
  type RenderFunc<Props extends {
161
153
  [key: string]: any;
162
154
  } = {
@@ -220,6 +212,14 @@ type FieldRenderFunctions = Omit<{
220
212
  }>;
221
213
  };
222
214
 
215
+ type iconTypes = "Smartphone" | "Monitor" | "Tablet";
216
+ type Viewport = {
217
+ width: number;
218
+ height?: number | "auto";
219
+ label?: string;
220
+ icon?: iconTypes | ReactNode;
221
+ };
222
+
223
223
  type Plugin = {
224
224
  overrides: Partial<Overrides>;
225
225
  };
package/dist/index.d.ts CHANGED
@@ -1,48 +1,10 @@
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 iconTypes = "Smartphone" | "Monitor" | "Tablet";
9
- type Viewport = {
10
- width: number;
11
- height?: number | "auto";
12
- label?: string;
13
- icon?: iconTypes | ReactNode;
14
- };
15
-
16
- type ItemWithId = {
17
- _arrayId: string;
18
- _originalIndex: number;
19
- };
20
- type ArrayState = {
21
- items: ItemWithId[];
22
- openId: string;
23
- };
24
- type UiState = {
25
- leftSideBarVisible: boolean;
26
- rightSideBarVisible: boolean;
27
- itemSelector: ItemSelector | null;
28
- arrayState: Record<string, ArrayState | undefined>;
29
- componentList: Record<string, {
30
- components?: string[];
31
- title?: string;
32
- visible?: boolean;
33
- expanded?: boolean;
34
- }>;
35
- isDragging: boolean;
36
- viewports: {
37
- current: {
38
- width: number;
39
- height: number | "auto";
40
- };
41
- controlsVisible: boolean;
42
- options: Viewport[];
43
- };
44
- };
45
-
46
8
  type FieldOption = {
47
9
  label: string;
48
10
  value: string | number | boolean;
@@ -157,6 +119,36 @@ type FieldProps<ValueType = any, F = Field<any>> = {
157
119
  readOnly?: boolean;
158
120
  };
159
121
 
122
+ type ItemWithId = {
123
+ _arrayId: string;
124
+ _originalIndex: number;
125
+ };
126
+ type ArrayState = {
127
+ items: ItemWithId[];
128
+ openId: string;
129
+ };
130
+ type UiState = {
131
+ leftSideBarVisible: boolean;
132
+ rightSideBarVisible: boolean;
133
+ itemSelector: ItemSelector | null;
134
+ arrayState: Record<string, ArrayState | undefined>;
135
+ componentList: Record<string, {
136
+ components?: string[];
137
+ title?: string;
138
+ visible?: boolean;
139
+ expanded?: boolean;
140
+ }>;
141
+ isDragging: boolean;
142
+ viewports: {
143
+ current: {
144
+ width: number;
145
+ height: number | "auto";
146
+ };
147
+ controlsVisible: boolean;
148
+ options: Viewport[];
149
+ };
150
+ };
151
+
160
152
  type RenderFunc<Props extends {
161
153
  [key: string]: any;
162
154
  } = {
@@ -220,6 +212,14 @@ type FieldRenderFunctions = Omit<{
220
212
  }>;
221
213
  };
222
214
 
215
+ type iconTypes = "Smartphone" | "Monitor" | "Tablet";
216
+ type Viewport = {
217
+ width: number;
218
+ height?: number | "auto";
219
+ label?: string;
220
+ icon?: iconTypes | ReactNode;
221
+ };
222
+
223
223
  type Plugin = {
224
224
  overrides: Partial<Overrides>;
225
225
  };
package/dist/index.js CHANGED
@@ -1419,7 +1419,7 @@ init_react_import();
1419
1419
 
1420
1420
  // src/HeadingAnalyzer.tsx
1421
1421
  init_react_import();
1422
- var import_react6 = require("react");
1422
+ var import_react8 = require("react");
1423
1423
 
1424
1424
  // css-module:/home/runner/work/puck/puck/packages/plugin-heading-analyzer/src/HeadingAnalyzer.module.css#css-module
1425
1425
  init_react_import();
@@ -1542,7 +1542,7 @@ var ChevronRight = createLucideIcon("ChevronRight", [
1542
1542
 
1543
1543
  // ../core/lib/use-breadcrumbs.ts
1544
1544
  init_react_import();
1545
- var import_react5 = require("react");
1545
+ var import_react7 = require("react");
1546
1546
 
1547
1547
  // ../core/components/DropZone/context.tsx
1548
1548
  init_react_import();
@@ -1557,25 +1557,6 @@ var rootDroppableId = "default-zone";
1557
1557
 
1558
1558
  // ../core/lib/setup-zone.ts
1559
1559
  init_react_import();
1560
- var setupZone = (data, zoneKey) => {
1561
- if (zoneKey === rootDroppableId) {
1562
- return data;
1563
- }
1564
- const newData = __spreadValues({}, data);
1565
- newData.zones = data.zones || {};
1566
- newData.zones[zoneKey] = newData.zones[zoneKey] || [];
1567
- return newData;
1568
- };
1569
-
1570
- // ../core/lib/get-item.ts
1571
- var getItem = (selector, data, dynamicProps = {}) => {
1572
- if (!selector.zone || selector.zone === rootDroppableId) {
1573
- const item2 = data.content[selector.index];
1574
- return (item2 == null ? void 0 : item2.props) ? __spreadProps(__spreadValues({}, item2), { props: dynamicProps[item2.props.id] || item2.props }) : void 0;
1575
- }
1576
- const item = setupZone(data, selector.zone).zones[selector.zone][selector.index];
1577
- return (item == null ? void 0 : item.props) ? __spreadProps(__spreadValues({}, item), { props: dynamicProps[item.props.id] || item.props }) : void 0;
1578
- };
1579
1560
 
1580
1561
  // ../core/lib/get-zone-id.ts
1581
1562
  init_react_import();
@@ -1595,7 +1576,7 @@ var dropZoneContext = (0, import_react3.createContext)(null);
1595
1576
 
1596
1577
  // ../core/components/Puck/context.tsx
1597
1578
  init_react_import();
1598
- var import_react4 = require("react");
1579
+ var import_react6 = require("react");
1599
1580
 
1600
1581
  // ../core/components/ViewportControls/default-viewports.ts
1601
1582
  init_react_import();
@@ -1607,6 +1588,31 @@ var defaultViewports = [
1607
1588
 
1608
1589
  // ../core/components/Puck/context.tsx
1609
1590
  var import_ua_parser_js = __toESM(require_ua_parser());
1591
+
1592
+ // ../core/lib/use-resolved-permissions.ts
1593
+ init_react_import();
1594
+ var import_react4 = require("react");
1595
+
1596
+ // ../core/lib/flatten-data.ts
1597
+ init_react_import();
1598
+
1599
+ // ../core/lib/get-changed.ts
1600
+ init_react_import();
1601
+
1602
+ // ../core/lib/use-resolved-data.ts
1603
+ init_react_import();
1604
+ var import_react5 = require("react");
1605
+
1606
+ // ../core/lib/resolve-component-data.ts
1607
+ init_react_import();
1608
+
1609
+ // ../core/lib/apply-dynamic-props.ts
1610
+ init_react_import();
1611
+
1612
+ // ../core/lib/resolve-root-data.ts
1613
+ init_react_import();
1614
+
1615
+ // ../core/components/Puck/context.tsx
1610
1616
  var import_jsx_runtime3 = require("react/jsx-runtime");
1611
1617
  var defaultAppState = {
1612
1618
  data: { content: [], root: {} },
@@ -1632,6 +1638,8 @@ var defaultContext = {
1632
1638
  dispatch: () => null,
1633
1639
  config: { components: {} },
1634
1640
  componentState: {},
1641
+ setComponentState: () => {
1642
+ },
1635
1643
  resolveData: () => {
1636
1644
  },
1637
1645
  plugins: [],
@@ -1648,15 +1656,15 @@ var defaultContext = {
1648
1656
  setStatus: () => null,
1649
1657
  iframe: {},
1650
1658
  safariFallbackMode: false,
1651
- globalPermissions: {}
1659
+ globalPermissions: {},
1660
+ getPermissions: () => ({}),
1661
+ refreshPermissions: () => null
1652
1662
  };
1653
- var appContext = (0, import_react4.createContext)(defaultContext);
1663
+ var appContext = (0, import_react6.createContext)(defaultContext);
1654
1664
  function useAppContext() {
1655
- const mainContext = (0, import_react4.useContext)(appContext);
1656
- const selectedItem = mainContext.state.ui.itemSelector ? getItem(mainContext.state.ui.itemSelector, mainContext.state.data) : void 0;
1665
+ const mainContext = (0, import_react6.useContext)(appContext);
1657
1666
  return __spreadProps(__spreadValues({}, mainContext), {
1658
1667
  // Helpers
1659
- selectedItem,
1660
1668
  setUi: (ui, recordHistory) => {
1661
1669
  return mainContext.dispatch({
1662
1670
  type: "setUi",
@@ -1717,8 +1725,8 @@ var useBreadcrumbs = (renderCount) => {
1717
1725
  state: { data },
1718
1726
  selectedItem
1719
1727
  } = useAppContext();
1720
- const dzContext = (0, import_react5.useContext)(dropZoneContext);
1721
- return (0, import_react5.useMemo)(() => {
1728
+ const dzContext = (0, import_react7.useContext)(dropZoneContext);
1729
+ return (0, import_react7.useMemo)(() => {
1722
1730
  const breadcrumbs = convertPathDataToBreadcrumbs(
1723
1731
  selectedItem,
1724
1732
  dzContext == null ? void 0 : dzContext.pathData,
@@ -1800,6 +1808,7 @@ var SidebarSection = ({
1800
1808
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1801
1809
  "button",
1802
1810
  {
1811
+ type: "button",
1803
1812
  className: getClassName3("breadcrumbLabel"),
1804
1813
  onClick: () => setUi({ itemSelector: breadcrumb.selector }),
1805
1814
  children: breadcrumb.label
@@ -1927,9 +1936,9 @@ function buildHierarchy(frame) {
1927
1936
  }
1928
1937
  var HeadingAnalyzer = () => {
1929
1938
  const { appState } = (0, import_puck.usePuck)();
1930
- const [hierarchy, setHierarchy] = (0, import_react6.useState)([]);
1931
- const [firstRender, setFirstRender] = (0, import_react6.useState)(true);
1932
- (0, import_react6.useEffect)(() => {
1939
+ const [hierarchy, setHierarchy] = (0, import_react8.useState)([]);
1940
+ const [firstRender, setFirstRender] = (0, import_react8.useState)(true);
1941
+ (0, import_react8.useEffect)(() => {
1933
1942
  const frame = getFrame();
1934
1943
  if (!frame) return;
1935
1944
  if (firstRender) {
package/dist/index.mjs CHANGED
@@ -1407,7 +1407,7 @@ init_react_import();
1407
1407
 
1408
1408
  // src/HeadingAnalyzer.tsx
1409
1409
  init_react_import();
1410
- import { useEffect as useEffect2, useState as useState3 } from "react";
1410
+ import { useEffect as useEffect4, useState as useState5 } from "react";
1411
1411
 
1412
1412
  // css-module:/home/runner/work/puck/puck/packages/plugin-heading-analyzer/src/HeadingAnalyzer.module.css#css-module
1413
1413
  init_react_import();
@@ -1549,25 +1549,6 @@ var rootDroppableId = "default-zone";
1549
1549
 
1550
1550
  // ../core/lib/setup-zone.ts
1551
1551
  init_react_import();
1552
- var setupZone = (data, zoneKey) => {
1553
- if (zoneKey === rootDroppableId) {
1554
- return data;
1555
- }
1556
- const newData = __spreadValues({}, data);
1557
- newData.zones = data.zones || {};
1558
- newData.zones[zoneKey] = newData.zones[zoneKey] || [];
1559
- return newData;
1560
- };
1561
-
1562
- // ../core/lib/get-item.ts
1563
- var getItem = (selector, data, dynamicProps = {}) => {
1564
- if (!selector.zone || selector.zone === rootDroppableId) {
1565
- const item2 = data.content[selector.index];
1566
- return (item2 == null ? void 0 : item2.props) ? __spreadProps(__spreadValues({}, item2), { props: dynamicProps[item2.props.id] || item2.props }) : void 0;
1567
- }
1568
- const item = setupZone(data, selector.zone).zones[selector.zone][selector.index];
1569
- return (item == null ? void 0 : item.props) ? __spreadProps(__spreadValues({}, item), { props: dynamicProps[item.props.id] || item.props }) : void 0;
1570
- };
1571
1552
 
1572
1553
  // ../core/lib/get-zone-id.ts
1573
1554
  init_react_import();
@@ -1590,8 +1571,8 @@ init_react_import();
1590
1571
  import {
1591
1572
  createContext as createContext2,
1592
1573
  useContext,
1593
- useEffect,
1594
- useState as useState2
1574
+ useEffect as useEffect3,
1575
+ useState as useState4
1595
1576
  } from "react";
1596
1577
 
1597
1578
  // ../core/components/ViewportControls/default-viewports.ts
@@ -1604,6 +1585,31 @@ var defaultViewports = [
1604
1585
 
1605
1586
  // ../core/components/Puck/context.tsx
1606
1587
  var import_ua_parser_js = __toESM(require_ua_parser());
1588
+
1589
+ // ../core/lib/use-resolved-permissions.ts
1590
+ init_react_import();
1591
+ import { useCallback as useCallback2, useEffect, useState as useState2 } from "react";
1592
+
1593
+ // ../core/lib/flatten-data.ts
1594
+ init_react_import();
1595
+
1596
+ // ../core/lib/get-changed.ts
1597
+ init_react_import();
1598
+
1599
+ // ../core/lib/use-resolved-data.ts
1600
+ init_react_import();
1601
+ import { useCallback as useCallback3, useEffect as useEffect2, useState as useState3 } from "react";
1602
+
1603
+ // ../core/lib/resolve-component-data.ts
1604
+ init_react_import();
1605
+
1606
+ // ../core/lib/apply-dynamic-props.ts
1607
+ init_react_import();
1608
+
1609
+ // ../core/lib/resolve-root-data.ts
1610
+ init_react_import();
1611
+
1612
+ // ../core/components/Puck/context.tsx
1607
1613
  import { jsx as jsx3 } from "react/jsx-runtime";
1608
1614
  var defaultAppState = {
1609
1615
  data: { content: [], root: {} },
@@ -1629,6 +1635,8 @@ var defaultContext = {
1629
1635
  dispatch: () => null,
1630
1636
  config: { components: {} },
1631
1637
  componentState: {},
1638
+ setComponentState: () => {
1639
+ },
1632
1640
  resolveData: () => {
1633
1641
  },
1634
1642
  plugins: [],
@@ -1645,15 +1653,15 @@ var defaultContext = {
1645
1653
  setStatus: () => null,
1646
1654
  iframe: {},
1647
1655
  safariFallbackMode: false,
1648
- globalPermissions: {}
1656
+ globalPermissions: {},
1657
+ getPermissions: () => ({}),
1658
+ refreshPermissions: () => null
1649
1659
  };
1650
1660
  var appContext = createContext2(defaultContext);
1651
1661
  function useAppContext() {
1652
1662
  const mainContext = useContext(appContext);
1653
- const selectedItem = mainContext.state.ui.itemSelector ? getItem(mainContext.state.ui.itemSelector, mainContext.state.data) : void 0;
1654
1663
  return __spreadProps(__spreadValues({}, mainContext), {
1655
1664
  // Helpers
1656
- selectedItem,
1657
1665
  setUi: (ui, recordHistory) => {
1658
1666
  return mainContext.dispatch({
1659
1667
  type: "setUi",
@@ -1797,6 +1805,7 @@ var SidebarSection = ({
1797
1805
  /* @__PURE__ */ jsx5(
1798
1806
  "button",
1799
1807
  {
1808
+ type: "button",
1800
1809
  className: getClassName3("breadcrumbLabel"),
1801
1810
  onClick: () => setUi({ itemSelector: breadcrumb.selector }),
1802
1811
  children: breadcrumb.label
@@ -1924,9 +1933,9 @@ function buildHierarchy(frame) {
1924
1933
  }
1925
1934
  var HeadingAnalyzer = () => {
1926
1935
  const { appState } = usePuck();
1927
- const [hierarchy, setHierarchy] = useState3([]);
1928
- const [firstRender, setFirstRender] = useState3(true);
1929
- useEffect2(() => {
1936
+ const [hierarchy, setHierarchy] = useState5([]);
1937
+ const [firstRender, setFirstRender] = useState5(true);
1938
+ useEffect4(() => {
1930
1939
  const frame = getFrame();
1931
1940
  if (!frame) return;
1932
1941
  if (firstRender) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck-plugin-heading-analyzer",
3
- "version": "0.16.0-canary.6d43ba0",
3
+ "version": "0.16.0-canary.72b8720",
4
4
  "author": "Measured Corporation Ltd <hello@measured.co>",
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.16.0-canary.6d43ba0",
28
+ "@measured/puck": "^0.16.0-canary.72b8720",
29
29
  "@types/react": "^18.2.0",
30
30
  "@types/react-dom": "^18.2.0",
31
31
  "eslint": "^7.32.0",