@wrdagency/blockout 1.0.36 → 1.0.37

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.
@@ -1,13 +1,81 @@
1
- import { jsx as n, jsxs as c } from "react/jsx-runtime";
2
- import { cn as v } from "../../utils/css.js";
3
- import { noop as E } from "../../utils/noop.js";
1
+ import { jsxs as l, jsx as r, Fragment as _ } from "react/jsx-runtime";
2
+ import { unique as D } from "../../utils/array.js";
3
+ import { cn as P } from "../../utils/css.js";
4
+ import { noop as j } from "../../utils/noop.js";
5
+ import { titleCase as $ } from "../../utils/string.js";
4
6
  import * as e from "react";
5
- import { useRef as f, useState as H, useEffect as C } from "react";
6
- import { w as _ } from "../../SSRBase.es-BUXS72ra.js";
7
- import { o as y } from "../../SquaresFour.es-iDUIyl5P.js";
8
- import { B as b } from "../../style-nHUEFY3u.js";
9
- import { DASHBOARD_CONTEXT as F } from "./context.js";
10
- const S = /* @__PURE__ */ new Map([
7
+ import { useRef as G, useState as f, useEffect as X } from "react";
8
+ import { w as v } from "../../SSRBase.es-BUXS72ra.js";
9
+ import { B as u, j as I } from "../../style-nHUEFY3u.js";
10
+ import { Dialog as J } from "../dialog/index.js";
11
+ import { DASHBOARD_CONTEXT as K } from "./context.js";
12
+ const Q = /* @__PURE__ */ new Map([
13
+ [
14
+ "bold",
15
+ /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("path", { d: "M78,36a42,42,0,1,0,42,42A42,42,0,0,0,78,36Zm0,60A18,18,0,1,1,96,78,18,18,0,0,1,78,96Zm100,24a42,42,0,1,0-42-42A42,42,0,0,0,178,120Zm0-60a18,18,0,1,1-18,18A18,18,0,0,1,178,60ZM78,136a42,42,0,1,0,42,42A42,42,0,0,0,78,136Zm0,60a18,18,0,1,1,18-18A18,18,0,0,1,78,196Zm100-60a42,42,0,1,0,42,42A42,42,0,0,0,178,136Zm0,60a18,18,0,1,1,18-18A18,18,0,0,1,178,196Z" }))
16
+ ],
17
+ [
18
+ "duotone",
19
+ /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
20
+ "path",
21
+ {
22
+ d: "M112,80A32,32,0,1,1,80,48,32,32,0,0,1,112,80Zm64,32a32,32,0,1,0-32-32A32,32,0,0,0,176,112ZM80,144a32,32,0,1,0,32,32A32,32,0,0,0,80,144Zm96,0a32,32,0,1,0,32,32A32,32,0,0,0,176,144Z",
23
+ opacity: "0.2"
24
+ }
25
+ ), /* @__PURE__ */ e.createElement("path", { d: "M80,40a40,40,0,1,0,40,40A40,40,0,0,0,80,40Zm0,64a24,24,0,1,1,24-24A24,24,0,0,1,80,104Zm96,16a40,40,0,1,0-40-40A40,40,0,0,0,176,120Zm0-64a24,24,0,1,1-24,24A24,24,0,0,1,176,56ZM80,136a40,40,0,1,0,40,40A40,40,0,0,0,80,136Zm0,64a24,24,0,1,1,24-24A24,24,0,0,1,80,200Zm96-64a40,40,0,1,0,40,40A40,40,0,0,0,176,136Zm0,64a24,24,0,1,1,24-24A24,24,0,0,1,176,200Z" }))
26
+ ],
27
+ [
28
+ "fill",
29
+ /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("path", { d: "M120,80A40,40,0,1,1,80,40,40,40,0,0,1,120,80Zm56,40a40,40,0,1,0-40-40A40,40,0,0,0,176,120ZM80,136a40,40,0,1,0,40,40A40,40,0,0,0,80,136Zm96,0a40,40,0,1,0,40,40A40,40,0,0,0,176,136Z" }))
30
+ ],
31
+ [
32
+ "light",
33
+ /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("path", { d: "M80,42a38,38,0,1,0,38,38A38,38,0,0,0,80,42Zm0,64a26,26,0,1,1,26-26A26,26,0,0,1,80,106Zm96,12a38,38,0,1,0-38-38A38,38,0,0,0,176,118Zm0-64a26,26,0,1,1-26,26A26,26,0,0,1,176,54ZM80,138a38,38,0,1,0,38,38A38,38,0,0,0,80,138Zm0,64a26,26,0,1,1,26-26A26,26,0,0,1,80,202Zm96-64a38,38,0,1,0,38,38A38,38,0,0,0,176,138Zm0,64a26,26,0,1,1,26-26A26,26,0,0,1,176,202Z" }))
34
+ ],
35
+ [
36
+ "regular",
37
+ /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("path", { d: "M80,40a40,40,0,1,0,40,40A40,40,0,0,0,80,40Zm0,64a24,24,0,1,1,24-24A24,24,0,0,1,80,104Zm96,16a40,40,0,1,0-40-40A40,40,0,0,0,176,120Zm0-64a24,24,0,1,1-24,24A24,24,0,0,1,176,56ZM80,136a40,40,0,1,0,40,40A40,40,0,0,0,80,136Zm0,64a24,24,0,1,1,24-24A24,24,0,0,1,80,200Zm96-64a40,40,0,1,0,40,40A40,40,0,0,0,176,136Zm0,64a24,24,0,1,1,24-24A24,24,0,0,1,176,200Z" }))
38
+ ],
39
+ [
40
+ "thin",
41
+ /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("path", { d: "M80,44a36,36,0,1,0,36,36A36,36,0,0,0,80,44Zm0,64a28,28,0,1,1,28-28A28,28,0,0,1,80,108Zm96,8a36,36,0,1,0-36-36A36,36,0,0,0,176,116Zm0-64a28,28,0,1,1-28,28A28,28,0,0,1,176,52ZM80,140a36,36,0,1,0,36,36A36,36,0,0,0,80,140Zm0,64a28,28,0,1,1,28-28A28,28,0,0,1,80,204Zm96-64a36,36,0,1,0,36,36A36,36,0,0,0,176,140Zm0,64a28,28,0,1,1,28-28A28,28,0,0,1,176,204Z" }))
42
+ ]
43
+ ]), F = e.forwardRef((n, o) => /* @__PURE__ */ e.createElement(v, { ref: o, ...n, weights: Q }));
44
+ F.displayName = "CirclesFourIcon";
45
+ const U = /* @__PURE__ */ new Map([
46
+ [
47
+ "bold",
48
+ /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("path", { d: "M78,36a42,42,0,1,0,42,42A42,42,0,0,0,78,36Zm0,60A18,18,0,1,1,96,78,18,18,0,0,1,78,96Zm100,24a42,42,0,1,0-42-42A42,42,0,0,0,178,120Zm0-60a18,18,0,1,1-18,18A18,18,0,0,1,178,60ZM78,136a42,42,0,1,0,42,42A42,42,0,0,0,78,136Zm0,60a18,18,0,1,1,18-18A18,18,0,0,1,78,196Zm142-18a12,12,0,0,1-12,12H190v18a12,12,0,0,1-24,0V190H148a12,12,0,0,1,0-24h18V148a12,12,0,0,1,24,0v18h18A12,12,0,0,1,220,178Z" }))
49
+ ],
50
+ [
51
+ "duotone",
52
+ /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
53
+ "path",
54
+ {
55
+ d: "M112,80A32,32,0,1,1,80,48,32,32,0,0,1,112,80Zm64-32a32,32,0,1,0,32,32A32,32,0,0,0,176,48ZM80,144a32,32,0,1,0,32,32A32,32,0,0,0,80,144Z",
56
+ opacity: "0.2"
57
+ }
58
+ ), /* @__PURE__ */ e.createElement("path", { d: "M80,40a40,40,0,1,0,40,40A40,40,0,0,0,80,40Zm0,64a24,24,0,1,1,24-24A24,24,0,0,1,80,104Zm96,16a40,40,0,1,0-40-40A40,40,0,0,0,176,120Zm0-64a24,24,0,1,1-24,24A24,24,0,0,1,176,56ZM80,136a40,40,0,1,0,40,40A40,40,0,0,0,80,136Zm0,64a24,24,0,1,1,24-24A24,24,0,0,1,80,200Zm136-24a8,8,0,0,1-8,8H184v24a8,8,0,0,1-16,0V184H144a8,8,0,0,1,0-16h24V144a8,8,0,0,1,16,0v24h24A8,8,0,0,1,216,176Z" }))
59
+ ],
60
+ [
61
+ "fill",
62
+ /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("path", { d: "M120,80A40,40,0,1,1,80,40,40,40,0,0,1,120,80Zm56,40a40,40,0,1,0-40-40A40,40,0,0,0,176,120ZM80,136a40,40,0,1,0,40,40A40,40,0,0,0,80,136Zm128,32H184V144a8,8,0,0,0-16,0v24H144a8,8,0,0,0,0,16h24v24a8,8,0,0,0,16,0V184h24a8,8,0,0,0,0-16Z" }))
63
+ ],
64
+ [
65
+ "light",
66
+ /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("path", { d: "M80,42a38,38,0,1,0,38,38A38,38,0,0,0,80,42Zm0,64a26,26,0,1,1,26-26A26,26,0,0,1,80,106Zm96,12a38,38,0,1,0-38-38A38,38,0,0,0,176,118Zm0-64a26,26,0,1,1-26,26A26,26,0,0,1,176,54ZM80,138a38,38,0,1,0,38,38A38,38,0,0,0,80,138Zm0,64a26,26,0,1,1,26-26A26,26,0,0,1,80,202Zm134-26a6,6,0,0,1-6,6H182v26a6,6,0,0,1-12,0V182H144a6,6,0,0,1,0-12h26V144a6,6,0,0,1,12,0v26h26A6,6,0,0,1,214,176Z" }))
67
+ ],
68
+ [
69
+ "regular",
70
+ /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("path", { d: "M80,40a40,40,0,1,0,40,40A40,40,0,0,0,80,40Zm0,64a24,24,0,1,1,24-24A24,24,0,0,1,80,104Zm96,16a40,40,0,1,0-40-40A40,40,0,0,0,176,120Zm0-64a24,24,0,1,1-24,24A24,24,0,0,1,176,56ZM80,136a40,40,0,1,0,40,40A40,40,0,0,0,80,136Zm0,64a24,24,0,1,1,24-24A24,24,0,0,1,80,200Zm136-24a8,8,0,0,1-8,8H184v24a8,8,0,0,1-16,0V184H144a8,8,0,0,1,0-16h24V144a8,8,0,0,1,16,0v24h24A8,8,0,0,1,216,176Z" }))
71
+ ],
72
+ [
73
+ "thin",
74
+ /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("path", { d: "M80,44a36,36,0,1,0,36,36A36,36,0,0,0,80,44Zm0,64a28,28,0,1,1,28-28A28,28,0,0,1,80,108Zm96,8a36,36,0,1,0-36-36A36,36,0,0,0,176,116Zm0-64a28,28,0,1,1-28,28A28,28,0,0,1,176,52ZM80,140a36,36,0,1,0,36,36A36,36,0,0,0,80,140Zm0,64a28,28,0,1,1,28-28A28,28,0,0,1,80,204Zm132-28a4,4,0,0,1-4,4H180v28a4,4,0,0,1-8,0V180H144a4,4,0,0,1,0-8h28V144a4,4,0,0,1,8,0v28h28A4,4,0,0,1,212,176Z" }))
75
+ ]
76
+ ]), b = e.forwardRef((n, o) => /* @__PURE__ */ e.createElement(v, { ref: o, ...n, weights: U }));
77
+ b.displayName = "CirclesThreePlusIcon";
78
+ const Y = /* @__PURE__ */ new Map([
11
79
  [
12
80
  "bold",
13
81
  /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("path", { d: "M222.14,69.17,186.83,33.86A19.86,19.86,0,0,0,172.69,28H48A20,20,0,0,0,28,48V208a20,20,0,0,0,20,20H208a20,20,0,0,0,20-20V83.31A19.86,19.86,0,0,0,222.14,69.17ZM164,204H92V160h72Zm40,0H188V156a20,20,0,0,0-20-20H88a20,20,0,0,0-20,20v48H52V52H171l33,33ZM164,84a12,12,0,0,1-12,12H96a12,12,0,0,1,0-24h56A12,12,0,0,1,164,84Z" }))
@@ -38,15 +106,15 @@ const S = /* @__PURE__ */ new Map([
38
106
  "thin",
39
107
  /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("path", { d: "M216.49,74.83,181.17,39.51A11.93,11.93,0,0,0,172.69,36H48A12,12,0,0,0,36,48V208a12,12,0,0,0,12,12H208a12,12,0,0,0,12-12V83.31A11.93,11.93,0,0,0,216.49,74.83ZM172,212H84V152a4,4,0,0,1,4-4h80a4,4,0,0,1,4,4Zm40-4a4,4,0,0,1-4,4H180V152a12,12,0,0,0-12-12H88a12,12,0,0,0-12,12v60H48a4,4,0,0,1-4-4V48a4,4,0,0,1,4-4H172.69a4,4,0,0,1,2.82,1.17l35.32,35.32A4,4,0,0,1,212,83.31ZM156,72a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h56A4,4,0,0,1,156,72Z" }))
40
108
  ]
41
- ]), h = e.forwardRef((r, i) => /* @__PURE__ */ e.createElement(_, { ref: i, ...r, weights: S }));
42
- h.displayName = "FloppyDiskIcon";
43
- const j = ({
44
- layout: r,
45
- onLayoutChange: i = E,
46
- className: u,
47
- children: p
109
+ ]), k = e.forwardRef((n, o) => /* @__PURE__ */ e.createElement(v, { ref: o, ...n, weights: Y }));
110
+ k.displayName = "FloppyDiskIcon";
111
+ const d0 = ({
112
+ layout: n,
113
+ onLayoutChange: o = j,
114
+ className: N,
115
+ children: y
48
116
  }) => {
49
- const t = f(null), [o, d] = H(!1), [m, g] = H({
117
+ const c = G(null), [A, g] = f(!1), [R, H] = f(!1), [h, S] = f({
50
118
  rowCount: 1,
51
119
  columnCount: 4,
52
120
  columnWidth: 0,
@@ -57,67 +125,142 @@ const j = ({
57
125
  width: 0,
58
126
  height: 0
59
127
  }
60
- }), V = () => {
61
- d((a) => !a);
128
+ }), x = () => {
129
+ g(!0);
130
+ }, W = () => {
131
+ g(!1), H(!1);
132
+ }, L = () => {
133
+ H(!0);
134
+ }, O = (t) => {
135
+ const Z = n.filter((a) => !a.hidden), M = Math.max(1, h.columnCount - 2 + 1), d = (a, i) => Z.some((s) => {
136
+ const z = a < s.column + s.width && a + 2 > s.column, B = i < s.row + s.height && i + 2 > s.row;
137
+ return z && B;
138
+ }), p = Math.max(
139
+ h.rowCount,
140
+ ...Z.map((a) => a.row + a.height - 1)
141
+ );
142
+ let E = 1, w = 1, V = !1;
143
+ for (let a = 1; a <= p; a += 1) {
144
+ for (let i = 1; i <= M; i += 1)
145
+ if (!d(i, a)) {
146
+ E = i, w = a, V = !0;
147
+ break;
148
+ }
149
+ if (V)
150
+ break;
151
+ }
152
+ V || (w = p + 1, E = 1), o(
153
+ n.map(
154
+ (a) => a.id === t.id ? {
155
+ ...a,
156
+ hidden: !1,
157
+ column: E,
158
+ row: w,
159
+ width: 2,
160
+ height: 2
161
+ } : a
162
+ )
163
+ );
62
164
  };
63
- return C(() => {
64
- const a = () => {
65
- const s = window.getComputedStyle(t.current).gridTemplateColumns.split(" ").length, A = parseFloat(
66
- window.getComputedStyle(t.current).gridTemplateColumns.split(" ")[0]
67
- ), w = window.getComputedStyle(t.current).gridTemplateRows.split(" ").length, Z = parseFloat(
68
- window.getComputedStyle(t.current).gridAutoRows
69
- ), l = t.current.getBoundingClientRect(), M = {
70
- x: l.x,
71
- y: l.y,
72
- width: l.width,
73
- height: l.height
165
+ X(() => {
166
+ const t = () => {
167
+ const m = window.getComputedStyle(c.current).gridTemplateColumns.split(" ").length, C = parseFloat(
168
+ window.getComputedStyle(c.current).gridTemplateColumns.split(" ")[0]
169
+ ), Z = window.getComputedStyle(c.current).gridTemplateRows.split(" ").length, M = parseFloat(
170
+ window.getComputedStyle(c.current).gridAutoRows
171
+ ), d = c.current.getBoundingClientRect(), p = {
172
+ x: d.x,
173
+ y: d.y,
174
+ width: d.width,
175
+ height: d.height
74
176
  };
75
- g({ rowCount: w, columnCount: s, columnWidth: A, rowHeight: Z, bounds: M });
177
+ S({ rowCount: Z, columnCount: m, columnWidth: C, rowHeight: M, bounds: p });
76
178
  };
77
- return a(), window.addEventListener("resize", a), () => {
78
- window.removeEventListener("resize", a);
179
+ return t(), window.addEventListener("resize", t), () => {
180
+ window.removeEventListener("resize", t);
79
181
  };
80
- }, [r]), /* @__PURE__ */ n(
81
- F,
182
+ }, [n]);
183
+ const T = n.filter((t) => !t.hidden).length === 0, q = n.map((t) => t.category).filter(D);
184
+ return /* @__PURE__ */ l(
185
+ K,
82
186
  {
83
187
  value: {
84
- layout: r,
85
- setLayout: i,
86
- isEditing: o,
87
- setIsEditing: d,
88
- ...m
188
+ layout: n,
189
+ setLayout: o,
190
+ isEditing: A,
191
+ setIsEditing: g,
192
+ ...h
89
193
  },
90
- children: /* @__PURE__ */ c(
91
- "div",
92
- {
93
- className: v(
94
- "component-dashboard",
95
- o && "component-dashboard--editing",
96
- u
97
- ),
98
- children: [
99
- /* @__PURE__ */ c("div", { className: "component-dashboard__grid", ref: t, children: [
100
- p,
101
- o && /* @__PURE__ */ n("div", { className: "component-dashboard__grid__overlay", children: [...Array(m.rowCount * m.columnCount)].map(
102
- (a, s) => /* @__PURE__ */ n(
103
- "div",
104
- {
105
- className: "component-dashboard__grid__overlay__cell"
106
- },
107
- s
108
- )
109
- ) })
110
- ] }),
111
- /* @__PURE__ */ n("div", { className: "component-dashboard__footer", children: /* @__PURE__ */ c(b, { onClick: V, variant: "quiet", children: [
112
- o ? /* @__PURE__ */ n(h, {}) : /* @__PURE__ */ n(y, {}),
113
- o ? "Save Changes" : "Customise"
114
- ] }) })
115
- ]
116
- }
117
- )
194
+ children: [
195
+ /* @__PURE__ */ l(
196
+ "div",
197
+ {
198
+ className: P(
199
+ "component-dashboard",
200
+ A && "component-dashboard--editing",
201
+ N
202
+ ),
203
+ children: [
204
+ /* @__PURE__ */ l("div", { className: "component-dashboard__grid", ref: c, children: [
205
+ y,
206
+ (A || T) && /* @__PURE__ */ r("div", { className: "component-dashboard__grid__overlay", children: [...Array(h.rowCount * h.columnCount)].map(
207
+ (t, m) => /* @__PURE__ */ r(
208
+ "div",
209
+ {
210
+ className: "component-dashboard__grid__overlay__cell"
211
+ },
212
+ m
213
+ )
214
+ ) })
215
+ ] }),
216
+ /* @__PURE__ */ r("div", { className: "component-dashboard__footer", children: A ? /* @__PURE__ */ l(_, { children: [
217
+ /* @__PURE__ */ l(u, { onClick: L, variant: "quiet", children: [
218
+ /* @__PURE__ */ r(b, {}),
219
+ "Add Widget"
220
+ ] }),
221
+ /* @__PURE__ */ l(u, { onClick: W, variant: "neutral", children: [
222
+ /* @__PURE__ */ r(k, {}),
223
+ "Save Changes"
224
+ ] })
225
+ ] }) : /* @__PURE__ */ r(_, { children: /* @__PURE__ */ l(u, { onClick: x, variant: "quiet", children: [
226
+ /* @__PURE__ */ r(F, {}),
227
+ "Customise"
228
+ ] }) }) })
229
+ ]
230
+ }
231
+ ),
232
+ /* @__PURE__ */ r(
233
+ J,
234
+ {
235
+ title: "Add a Widget",
236
+ open: R,
237
+ onOpenChange: H,
238
+ className: "component-dashboard-picker",
239
+ align: "top",
240
+ edgeless: !0,
241
+ children: q.map((t) => /* @__PURE__ */ l("div", { className: "component-dashboard-picker__category", children: [
242
+ /* @__PURE__ */ r("div", { className: "component-dashboard-picker__category__title", children: $(t) }),
243
+ /* @__PURE__ */ r("div", { className: "component-dashboard-picker__category__items", children: n.filter((m) => m.category === t).map((m) => /* @__PURE__ */ l(
244
+ u,
245
+ {
246
+ className: "component-dashboard-picker__item",
247
+ onClick: () => O(m),
248
+ disabled: !m.hidden,
249
+ wide: !0,
250
+ variant: "quiet",
251
+ children: [
252
+ /* @__PURE__ */ r(I, {}),
253
+ m.name
254
+ ]
255
+ }
256
+ )) })
257
+ ] }, t))
258
+ }
259
+ )
260
+ ]
118
261
  }
119
262
  );
120
263
  };
121
264
  export {
122
- j as Grid
265
+ d0 as Grid
123
266
  };