@bccampus/ui-components 0.3.0 → 0.4.0
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/composite.d.ts +151 -0
- package/dist/composite.js +472 -0
- package/dist/generate-tiles-DuagGD1d.js +244 -0
- package/dist/icon-generator.js +43 -270
- package/dist/igenerate-tiles.d.ts +43 -0
- package/dist/igenerate-tiles.js +7 -0
- package/package.json +12 -1
- package/src/components/ui/composite/CompositeData.ts +215 -0
- package/src/components/ui/composite/CompositeDataItem.ts +144 -0
- package/src/components/ui/composite/composite-component-item.tsx +50 -0
- package/src/components/ui/composite/composite-component.tsx +100 -0
- package/src/components/ui/composite/composite-data-context.tsx +31 -0
- package/src/components/ui/composite/index.ts +4 -0
- package/src/components/ui/composite/types.ts +81 -0
- package/src/components/ui/popover.tsx +46 -0
- package/src/hooks/use-effect-after-mount.ts +27 -0
- package/src/hooks/use-id.ts +5 -0
- package/src/hooks/use-keyboard-event.ts +144 -0
- package/src/lib/object.ts +48 -0
- package/src/lib/set-operations.ts +52 -0
- package/tsconfig.node.json +25 -25
- package/vite.config.ts +2 -0
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { c as m } from "./utils-CRiPKpXj.js";
|
|
3
|
+
const r = {
|
|
4
|
+
Blank: 0,
|
|
5
|
+
Rand: 1,
|
|
6
|
+
Mosaic: 2,
|
|
7
|
+
MosaicCircle: 3,
|
|
8
|
+
MosaicDiamond: 4,
|
|
9
|
+
Square: 6,
|
|
10
|
+
Circle: 7,
|
|
11
|
+
Diamond: 8,
|
|
12
|
+
Hexagon: 9,
|
|
13
|
+
RandBasic: 10,
|
|
14
|
+
TriangleSE: 11,
|
|
15
|
+
TriangleSW: 12,
|
|
16
|
+
TriangleNW: 13,
|
|
17
|
+
TriangleNE: 14,
|
|
18
|
+
TriangleRand: 15,
|
|
19
|
+
CaretN: 16,
|
|
20
|
+
CaretE: 17,
|
|
21
|
+
CaretS: 18,
|
|
22
|
+
CaretW: 19,
|
|
23
|
+
CaretRand: 20,
|
|
24
|
+
PieSE: 21,
|
|
25
|
+
PieSW: 22,
|
|
26
|
+
PieNW: 23,
|
|
27
|
+
PieNE: 24,
|
|
28
|
+
PieRand: 25
|
|
29
|
+
}, p = [
|
|
30
|
+
r.Square,
|
|
31
|
+
r.Circle,
|
|
32
|
+
r.Diamond,
|
|
33
|
+
r.Hexagon,
|
|
34
|
+
r.TriangleSE,
|
|
35
|
+
r.TriangleSW,
|
|
36
|
+
r.TriangleNW,
|
|
37
|
+
r.TriangleNE,
|
|
38
|
+
r.PieSE,
|
|
39
|
+
r.PieSW,
|
|
40
|
+
r.PieNW,
|
|
41
|
+
r.PieNE
|
|
42
|
+
], h = {
|
|
43
|
+
[r.Blank]: () => null,
|
|
44
|
+
[r.Rand]: (c, $, a, s) => h[p[Math.floor(Math.random() * p.length)]](c, $, a, s),
|
|
45
|
+
[r.Mosaic]: (c, $, a, s) => h[Math.random() > 0.8 ? r.Blank : r.Square](c, $, a, s),
|
|
46
|
+
[r.MosaicCircle]: (c, $, a, s) => h[Math.random() > 0.8 ? r.Blank : r.Circle](c, $, a, s),
|
|
47
|
+
[r.MosaicDiamond]: (c, $, a, s) => h[Math.random() > 0.8 ? r.Blank : r.Diamond](c, $, a, s),
|
|
48
|
+
[r.Square]: (c, $, a, s) => /* @__PURE__ */ n(
|
|
49
|
+
"rect",
|
|
50
|
+
{
|
|
51
|
+
x: a * c,
|
|
52
|
+
y: a * $,
|
|
53
|
+
width: a * s.scale,
|
|
54
|
+
height: a * s.scale,
|
|
55
|
+
className: m("fill-current stroke-none", s?.className)
|
|
56
|
+
},
|
|
57
|
+
`tile-${c}-${$}`
|
|
58
|
+
),
|
|
59
|
+
[r.Circle]: (c, $, a, s) => /* @__PURE__ */ n(
|
|
60
|
+
"circle",
|
|
61
|
+
{
|
|
62
|
+
cx: a * (c + 0.5 * s.scale),
|
|
63
|
+
cy: a * ($ + 0.5 * s.scale),
|
|
64
|
+
r: a / 2 * s.scale,
|
|
65
|
+
className: m("fill-current stroke-none", s?.className)
|
|
66
|
+
},
|
|
67
|
+
`tile-${c}-${$}`
|
|
68
|
+
),
|
|
69
|
+
[r.Diamond]: (c, $, a, s) => /* @__PURE__ */ n(
|
|
70
|
+
"path",
|
|
71
|
+
{
|
|
72
|
+
d: `M ${a * (c + 0.5 * s.scale)} ${a * $}
|
|
73
|
+
L ${a * (c + s.scale)} ${a * ($ + 0.5 * s.scale)}
|
|
74
|
+
L ${a * (c + 0.5 * s.scale)} ${a * ($ + s.scale)}
|
|
75
|
+
L ${a * c} ${a * ($ + 0.5 * s.scale)} Z`,
|
|
76
|
+
className: m("fill-current stroke-none", s?.className)
|
|
77
|
+
},
|
|
78
|
+
`tile-${c}-${$}`
|
|
79
|
+
),
|
|
80
|
+
[r.Hexagon]: (c, $, a, s) => {
|
|
81
|
+
const d = a / Math.sqrt(3), N = (a - d) / 2;
|
|
82
|
+
return /* @__PURE__ */ n(
|
|
83
|
+
"path",
|
|
84
|
+
{
|
|
85
|
+
rotate: 45,
|
|
86
|
+
d: `M ${a * c + N * s.scale} ${a * $}
|
|
87
|
+
L ${a * c + (N + d) * s.scale} ${a * $}
|
|
88
|
+
L ${a * (c + s.scale)} ${a * ($ + 0.5 * s.scale)}
|
|
89
|
+
L ${a * c + (N + d) * s.scale} ${a * ($ + s.scale)}
|
|
90
|
+
L ${a * c + N * s.scale} ${a * ($ + s.scale)}
|
|
91
|
+
L ${a * c} ${a * ($ + 0.5 * s.scale)} Z`,
|
|
92
|
+
className: m("fill-current stroke-none", s?.className)
|
|
93
|
+
},
|
|
94
|
+
`tile-${c}-${$}`
|
|
95
|
+
);
|
|
96
|
+
},
|
|
97
|
+
[r.RandBasic]: (c, $, a, s) => h[r.Square + Math.floor(Math.random() * 4)](c, $, a, s),
|
|
98
|
+
[r.TriangleSE]: (c, $, a, s) => /* @__PURE__ */ n(
|
|
99
|
+
"path",
|
|
100
|
+
{
|
|
101
|
+
d: `M ${a * (c + s.scale)} ${a * $}
|
|
102
|
+
L ${a * c} ${a * ($ + s.scale)}
|
|
103
|
+
L ${a * (c + s.scale)} ${a * ($ + s.scale)} Z`,
|
|
104
|
+
className: m("fill-current stroke-none", s?.className)
|
|
105
|
+
},
|
|
106
|
+
`tile-${c}-${$}`
|
|
107
|
+
),
|
|
108
|
+
[r.TriangleSW]: (c, $, a, s) => /* @__PURE__ */ n(
|
|
109
|
+
"path",
|
|
110
|
+
{
|
|
111
|
+
d: `M ${a * c} ${a * $}
|
|
112
|
+
L ${a * (c + s.scale)} ${a * ($ + s.scale)}
|
|
113
|
+
L ${a * c} ${a * ($ + s.scale)} Z`,
|
|
114
|
+
className: m("fill-current stroke-none", s?.className)
|
|
115
|
+
},
|
|
116
|
+
`tile-${c}-${$}`
|
|
117
|
+
),
|
|
118
|
+
[r.TriangleNW]: (c, $, a, s) => /* @__PURE__ */ n(
|
|
119
|
+
"path",
|
|
120
|
+
{
|
|
121
|
+
d: `M ${a * (c + s.scale)} ${a * $}
|
|
122
|
+
L ${a * c} ${a * ($ + s.scale)}
|
|
123
|
+
L ${a * c} ${a * $} Z`,
|
|
124
|
+
className: m("fill-current stroke-none", s?.className)
|
|
125
|
+
},
|
|
126
|
+
`tile-${c}-${$}`
|
|
127
|
+
),
|
|
128
|
+
[r.TriangleNE]: (c, $, a, s) => /* @__PURE__ */ n(
|
|
129
|
+
"path",
|
|
130
|
+
{
|
|
131
|
+
d: `M ${a * c} ${a * $}
|
|
132
|
+
L ${a * (c + s.scale)} ${a * ($ + s.scale)}
|
|
133
|
+
L ${a * (c + s.scale)} ${a * $} Z`,
|
|
134
|
+
className: m("fill-current stroke-none", s?.className)
|
|
135
|
+
},
|
|
136
|
+
`tile-${c}-${$}`
|
|
137
|
+
),
|
|
138
|
+
[r.TriangleRand]: (c, $, a, s) => h[r.TriangleSE + Math.floor(Math.random() * 4)](
|
|
139
|
+
c,
|
|
140
|
+
$,
|
|
141
|
+
a,
|
|
142
|
+
s
|
|
143
|
+
),
|
|
144
|
+
[r.CaretN]: (c, $, a, s) => /* @__PURE__ */ n(
|
|
145
|
+
"path",
|
|
146
|
+
{
|
|
147
|
+
d: `M ${a * c} ${a * ($ + s.scale)}
|
|
148
|
+
L ${a * (c + s.scale)} ${a * ($ + s.scale)}
|
|
149
|
+
L ${a * (c + 0.5 * s.scale)} ${a * $} Z`,
|
|
150
|
+
className: m("fill-current stroke-none", s?.className)
|
|
151
|
+
},
|
|
152
|
+
`tile-${c}-${$}`
|
|
153
|
+
),
|
|
154
|
+
[r.CaretE]: (c, $, a, s) => /* @__PURE__ */ n(
|
|
155
|
+
"path",
|
|
156
|
+
{
|
|
157
|
+
d: `M ${a * c} ${a * $}
|
|
158
|
+
L ${a * (c + s.scale)} ${a * ($ + 0.5 * s.scale)}
|
|
159
|
+
L ${a * c} ${a * ($ + s.scale)} Z`,
|
|
160
|
+
className: m("fill-current stroke-none", s?.className)
|
|
161
|
+
},
|
|
162
|
+
`tile-${c}-${$}`
|
|
163
|
+
),
|
|
164
|
+
[r.CaretS]: (c, $, a, s) => /* @__PURE__ */ n(
|
|
165
|
+
"path",
|
|
166
|
+
{
|
|
167
|
+
d: `M ${a * c} ${a * $}
|
|
168
|
+
L ${a * (c + s.scale)} ${a * $}
|
|
169
|
+
L ${a * (c + 0.5 * s.scale)} ${a * ($ + s.scale)} Z`,
|
|
170
|
+
className: m("fill-current stroke-none", s?.className)
|
|
171
|
+
},
|
|
172
|
+
`tile-${c}-${$}`
|
|
173
|
+
),
|
|
174
|
+
[r.CaretW]: (c, $, a, s) => /* @__PURE__ */ n(
|
|
175
|
+
"path",
|
|
176
|
+
{
|
|
177
|
+
d: `M ${a * (c + s.scale)} ${a * $}
|
|
178
|
+
L ${a * c} ${a * ($ + 0.5 * s.scale)}
|
|
179
|
+
L ${a * (c + s.scale)} ${a * ($ + s.scale)} Z`,
|
|
180
|
+
className: m("fill-current stroke-none", s?.className)
|
|
181
|
+
},
|
|
182
|
+
`tile-${c}-${$}`
|
|
183
|
+
),
|
|
184
|
+
[r.CaretRand]: (c, $, a, s) => h[r.CaretN + Math.floor(Math.random() * 4)](c, $, a, s),
|
|
185
|
+
[r.PieSE]: (c, $, a, s) => /* @__PURE__ */ n(
|
|
186
|
+
"path",
|
|
187
|
+
{
|
|
188
|
+
d: `M ${a * s.scale + a * c} ${a * $}
|
|
189
|
+
A ${a * s.scale} ${a * s.scale}, 0, 0, 0, ${a * c} ${a * s.scale + a * $}
|
|
190
|
+
L ${a * s.scale + a * c} ${a * s.scale + a * $} Z`,
|
|
191
|
+
className: m("fill-current stroke-none", s?.className)
|
|
192
|
+
},
|
|
193
|
+
`tile-${c}-${$}`
|
|
194
|
+
),
|
|
195
|
+
[r.PieSW]: (c, $, a, s) => /* @__PURE__ */ n(
|
|
196
|
+
"path",
|
|
197
|
+
{
|
|
198
|
+
d: `M ${a * s.scale + a * c} ${a * s.scale + a * $}
|
|
199
|
+
A ${a * s.scale} ${a * s.scale}, 0, 0, 0, ${a * c} ${a * $}
|
|
200
|
+
L ${a * c} ${a * s.scale + a * $} Z`,
|
|
201
|
+
className: m("fill-current stroke-none", s?.className)
|
|
202
|
+
},
|
|
203
|
+
`tile-${c}-${$}`
|
|
204
|
+
),
|
|
205
|
+
[r.PieNW]: (c, $, a, s) => /* @__PURE__ */ n(
|
|
206
|
+
"path",
|
|
207
|
+
{
|
|
208
|
+
d: `M ${a * c} ${a * s.scale + a * $}
|
|
209
|
+
A ${a * s.scale} ${a * s.scale}, 0, 0, 0, ${a * s.scale + a * c} ${a * $}
|
|
210
|
+
L ${a * c} ${a * $} Z`,
|
|
211
|
+
className: m("fill-current stroke-none", s?.className)
|
|
212
|
+
},
|
|
213
|
+
`tile-${c}-${$}`
|
|
214
|
+
),
|
|
215
|
+
[r.PieNE]: (c, $, a, s) => /* @__PURE__ */ n(
|
|
216
|
+
"path",
|
|
217
|
+
{
|
|
218
|
+
d: `M ${a * c} ${a * $}
|
|
219
|
+
A ${a * s.scale} ${a * s.scale}, 0, 0, 0, ${a * s.scale + a * c} ${a * s.scale + a * $}
|
|
220
|
+
L ${a * s.scale + a * c} ${a * $} Z`,
|
|
221
|
+
className: m("fill-current stroke-none", s?.className)
|
|
222
|
+
},
|
|
223
|
+
`tile-${c}-${$}`
|
|
224
|
+
),
|
|
225
|
+
[r.PieRand]: (c, $, a, s) => h[r.PieSE + Math.floor(Math.random() * 4)](c, $, a, s)
|
|
226
|
+
}, o = (c, $, a) => {
|
|
227
|
+
const s = [];
|
|
228
|
+
for (let d = 0; d < $; d++) {
|
|
229
|
+
s[d] = [];
|
|
230
|
+
for (let N = 0; N < c; N++)
|
|
231
|
+
s[d].push(a);
|
|
232
|
+
}
|
|
233
|
+
return s;
|
|
234
|
+
}, T = (c, $, a) => c.map(
|
|
235
|
+
(s, d) => s.map((N, L) => {
|
|
236
|
+
const M = typeof N == "object" ? { className: m(a, N.className), scale: N.scale ?? 1, shape: N.shape } : { className: a, scale: 1, shape: N };
|
|
237
|
+
return h[M.shape](L, d, $, M);
|
|
238
|
+
})
|
|
239
|
+
).flat();
|
|
240
|
+
export {
|
|
241
|
+
r as T,
|
|
242
|
+
o as a,
|
|
243
|
+
T as g
|
|
244
|
+
};
|
package/dist/icon-generator.js
CHANGED
|
@@ -1,303 +1,76 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
MosaicCircle: 3,
|
|
9
|
-
MosaicDiamond: 4,
|
|
10
|
-
Square: 6,
|
|
11
|
-
Circle: 7,
|
|
12
|
-
Diamond: 8,
|
|
13
|
-
Hexagon: 9,
|
|
14
|
-
RandBasic: 10,
|
|
15
|
-
TriangleSE: 11,
|
|
16
|
-
TriangleSW: 12,
|
|
17
|
-
TriangleNW: 13,
|
|
18
|
-
TriangleNE: 14,
|
|
19
|
-
TriangleRand: 15,
|
|
20
|
-
CaretN: 16,
|
|
21
|
-
CaretE: 17,
|
|
22
|
-
CaretS: 18,
|
|
23
|
-
CaretW: 19,
|
|
24
|
-
CaretRand: 20,
|
|
25
|
-
PieSE: 21,
|
|
26
|
-
PieSW: 22,
|
|
27
|
-
PieNW: 23,
|
|
28
|
-
PieNE: 24,
|
|
29
|
-
PieRand: 25
|
|
30
|
-
}, p = [
|
|
31
|
-
$.Square,
|
|
32
|
-
$.Circle,
|
|
33
|
-
$.Diamond,
|
|
34
|
-
$.Hexagon,
|
|
35
|
-
$.TriangleSE,
|
|
36
|
-
$.TriangleSW,
|
|
37
|
-
$.TriangleNW,
|
|
38
|
-
$.TriangleNE,
|
|
39
|
-
$.PieSE,
|
|
40
|
-
$.PieSW,
|
|
41
|
-
$.PieNW,
|
|
42
|
-
$.PieNE
|
|
43
|
-
], N = {
|
|
44
|
-
[$.Blank]: () => null,
|
|
45
|
-
[$.Rand]: (c, r, a, s) => N[p[Math.floor(Math.random() * p.length)]](c, r, a, s),
|
|
46
|
-
[$.Mosaic]: (c, r, a, s) => N[Math.random() > 0.8 ? $.Blank : $.Square](c, r, a, s),
|
|
47
|
-
[$.MosaicCircle]: (c, r, a, s) => N[Math.random() > 0.8 ? $.Blank : $.Circle](c, r, a, s),
|
|
48
|
-
[$.MosaicDiamond]: (c, r, a, s) => N[Math.random() > 0.8 ? $.Blank : $.Diamond](c, r, a, s),
|
|
49
|
-
[$.Square]: (c, r, a, s) => /* @__PURE__ */ h(
|
|
50
|
-
"rect",
|
|
51
|
-
{
|
|
52
|
-
x: a * c,
|
|
53
|
-
y: a * r,
|
|
54
|
-
width: a * s.scale,
|
|
55
|
-
height: a * s.scale,
|
|
56
|
-
className: d("fill-current stroke-none", s?.className)
|
|
57
|
-
},
|
|
58
|
-
`tile-${c}-${r}`
|
|
59
|
-
),
|
|
60
|
-
[$.Circle]: (c, r, a, s) => /* @__PURE__ */ h(
|
|
61
|
-
"circle",
|
|
62
|
-
{
|
|
63
|
-
cx: a * (c + 0.5 * s.scale),
|
|
64
|
-
cy: a * (r + 0.5 * s.scale),
|
|
65
|
-
r: a / 2 * s.scale,
|
|
66
|
-
className: d("fill-current stroke-none", s?.className)
|
|
67
|
-
},
|
|
68
|
-
`tile-${c}-${r}`
|
|
69
|
-
),
|
|
70
|
-
[$.Diamond]: (c, r, a, s) => /* @__PURE__ */ h(
|
|
71
|
-
"path",
|
|
72
|
-
{
|
|
73
|
-
d: `M ${a * (c + 0.5 * s.scale)} ${a * r}
|
|
74
|
-
L ${a * (c + s.scale)} ${a * (r + 0.5 * s.scale)}
|
|
75
|
-
L ${a * (c + 0.5 * s.scale)} ${a * (r + s.scale)}
|
|
76
|
-
L ${a * c} ${a * (r + 0.5 * s.scale)} Z`,
|
|
77
|
-
className: d("fill-current stroke-none", s?.className)
|
|
78
|
-
},
|
|
79
|
-
`tile-${c}-${r}`
|
|
80
|
-
),
|
|
81
|
-
[$.Hexagon]: (c, r, a, s) => {
|
|
82
|
-
const o = a / Math.sqrt(3), m = (a - o) / 2;
|
|
83
|
-
return /* @__PURE__ */ h(
|
|
84
|
-
"path",
|
|
85
|
-
{
|
|
86
|
-
rotate: 45,
|
|
87
|
-
d: `M ${a * c + m * s.scale} ${a * r}
|
|
88
|
-
L ${a * c + (m + o) * s.scale} ${a * r}
|
|
89
|
-
L ${a * (c + s.scale)} ${a * (r + 0.5 * s.scale)}
|
|
90
|
-
L ${a * c + (m + o) * s.scale} ${a * (r + s.scale)}
|
|
91
|
-
L ${a * c + m * s.scale} ${a * (r + s.scale)}
|
|
92
|
-
L ${a * c} ${a * (r + 0.5 * s.scale)} Z`,
|
|
93
|
-
className: d("fill-current stroke-none", s?.className)
|
|
94
|
-
},
|
|
95
|
-
`tile-${c}-${r}`
|
|
96
|
-
);
|
|
97
|
-
},
|
|
98
|
-
[$.RandBasic]: (c, r, a, s) => N[$.Square + Math.floor(Math.random() * 4)](c, r, a, s),
|
|
99
|
-
[$.TriangleSE]: (c, r, a, s) => /* @__PURE__ */ h(
|
|
100
|
-
"path",
|
|
101
|
-
{
|
|
102
|
-
d: `M ${a * (c + s.scale)} ${a * r}
|
|
103
|
-
L ${a * c} ${a * (r + s.scale)}
|
|
104
|
-
L ${a * (c + s.scale)} ${a * (r + s.scale)} Z`,
|
|
105
|
-
className: d("fill-current stroke-none", s?.className)
|
|
106
|
-
},
|
|
107
|
-
`tile-${c}-${r}`
|
|
108
|
-
),
|
|
109
|
-
[$.TriangleSW]: (c, r, a, s) => /* @__PURE__ */ h(
|
|
110
|
-
"path",
|
|
111
|
-
{
|
|
112
|
-
d: `M ${a * c} ${a * r}
|
|
113
|
-
L ${a * (c + s.scale)} ${a * (r + s.scale)}
|
|
114
|
-
L ${a * c} ${a * (r + s.scale)} Z`,
|
|
115
|
-
className: d("fill-current stroke-none", s?.className)
|
|
116
|
-
},
|
|
117
|
-
`tile-${c}-${r}`
|
|
118
|
-
),
|
|
119
|
-
[$.TriangleNW]: (c, r, a, s) => /* @__PURE__ */ h(
|
|
120
|
-
"path",
|
|
121
|
-
{
|
|
122
|
-
d: `M ${a * (c + s.scale)} ${a * r}
|
|
123
|
-
L ${a * c} ${a * (r + s.scale)}
|
|
124
|
-
L ${a * c} ${a * r} Z`,
|
|
125
|
-
className: d("fill-current stroke-none", s?.className)
|
|
126
|
-
},
|
|
127
|
-
`tile-${c}-${r}`
|
|
128
|
-
),
|
|
129
|
-
[$.TriangleNE]: (c, r, a, s) => /* @__PURE__ */ h(
|
|
130
|
-
"path",
|
|
131
|
-
{
|
|
132
|
-
d: `M ${a * c} ${a * r}
|
|
133
|
-
L ${a * (c + s.scale)} ${a * (r + s.scale)}
|
|
134
|
-
L ${a * (c + s.scale)} ${a * r} Z`,
|
|
135
|
-
className: d("fill-current stroke-none", s?.className)
|
|
136
|
-
},
|
|
137
|
-
`tile-${c}-${r}`
|
|
138
|
-
),
|
|
139
|
-
[$.TriangleRand]: (c, r, a, s) => N[$.TriangleSE + Math.floor(Math.random() * 4)](
|
|
140
|
-
c,
|
|
141
|
-
r,
|
|
142
|
-
a,
|
|
143
|
-
s
|
|
144
|
-
),
|
|
145
|
-
[$.CaretN]: (c, r, a, s) => /* @__PURE__ */ h(
|
|
146
|
-
"path",
|
|
147
|
-
{
|
|
148
|
-
d: `M ${a * c} ${a * (r + s.scale)}
|
|
149
|
-
L ${a * (c + s.scale)} ${a * (r + s.scale)}
|
|
150
|
-
L ${a * (c + 0.5 * s.scale)} ${a * r} Z`,
|
|
151
|
-
className: d("fill-current stroke-none", s?.className)
|
|
152
|
-
},
|
|
153
|
-
`tile-${c}-${r}`
|
|
154
|
-
),
|
|
155
|
-
[$.CaretE]: (c, r, a, s) => /* @__PURE__ */ h(
|
|
156
|
-
"path",
|
|
157
|
-
{
|
|
158
|
-
d: `M ${a * c} ${a * r}
|
|
159
|
-
L ${a * (c + s.scale)} ${a * (r + 0.5 * s.scale)}
|
|
160
|
-
L ${a * c} ${a * (r + s.scale)} Z`,
|
|
161
|
-
className: d("fill-current stroke-none", s?.className)
|
|
162
|
-
},
|
|
163
|
-
`tile-${c}-${r}`
|
|
164
|
-
),
|
|
165
|
-
[$.CaretS]: (c, r, a, s) => /* @__PURE__ */ h(
|
|
166
|
-
"path",
|
|
167
|
-
{
|
|
168
|
-
d: `M ${a * c} ${a * r}
|
|
169
|
-
L ${a * (c + s.scale)} ${a * r}
|
|
170
|
-
L ${a * (c + 0.5 * s.scale)} ${a * (r + s.scale)} Z`,
|
|
171
|
-
className: d("fill-current stroke-none", s?.className)
|
|
172
|
-
},
|
|
173
|
-
`tile-${c}-${r}`
|
|
174
|
-
),
|
|
175
|
-
[$.CaretW]: (c, r, a, s) => /* @__PURE__ */ h(
|
|
176
|
-
"path",
|
|
177
|
-
{
|
|
178
|
-
d: `M ${a * (c + s.scale)} ${a * r}
|
|
179
|
-
L ${a * c} ${a * (r + 0.5 * s.scale)}
|
|
180
|
-
L ${a * (c + s.scale)} ${a * (r + s.scale)} Z`,
|
|
181
|
-
className: d("fill-current stroke-none", s?.className)
|
|
182
|
-
},
|
|
183
|
-
`tile-${c}-${r}`
|
|
184
|
-
),
|
|
185
|
-
[$.CaretRand]: (c, r, a, s) => N[$.CaretN + Math.floor(Math.random() * 4)](c, r, a, s),
|
|
186
|
-
[$.PieSE]: (c, r, a, s) => /* @__PURE__ */ h(
|
|
187
|
-
"path",
|
|
188
|
-
{
|
|
189
|
-
d: `M ${a * s.scale + a * c} ${a * r}
|
|
190
|
-
A ${a * s.scale} ${a * s.scale}, 0, 0, 0, ${a * c} ${a * s.scale + a * r}
|
|
191
|
-
L ${a * s.scale + a * c} ${a * s.scale + a * r} Z`,
|
|
192
|
-
className: d("fill-current stroke-none", s?.className)
|
|
193
|
-
},
|
|
194
|
-
`tile-${c}-${r}`
|
|
195
|
-
),
|
|
196
|
-
[$.PieSW]: (c, r, a, s) => /* @__PURE__ */ h(
|
|
197
|
-
"path",
|
|
198
|
-
{
|
|
199
|
-
d: `M ${a * s.scale + a * c} ${a * s.scale + a * r}
|
|
200
|
-
A ${a * s.scale} ${a * s.scale}, 0, 0, 0, ${a * c} ${a * r}
|
|
201
|
-
L ${a * c} ${a * s.scale + a * r} Z`,
|
|
202
|
-
className: d("fill-current stroke-none", s?.className)
|
|
203
|
-
},
|
|
204
|
-
`tile-${c}-${r}`
|
|
205
|
-
),
|
|
206
|
-
[$.PieNW]: (c, r, a, s) => /* @__PURE__ */ h(
|
|
207
|
-
"path",
|
|
208
|
-
{
|
|
209
|
-
d: `M ${a * c} ${a * s.scale + a * r}
|
|
210
|
-
A ${a * s.scale} ${a * s.scale}, 0, 0, 0, ${a * s.scale + a * c} ${a * r}
|
|
211
|
-
L ${a * c} ${a * r} Z`,
|
|
212
|
-
className: d("fill-current stroke-none", s?.className)
|
|
213
|
-
},
|
|
214
|
-
`tile-${c}-${r}`
|
|
215
|
-
),
|
|
216
|
-
[$.PieNE]: (c, r, a, s) => /* @__PURE__ */ h(
|
|
217
|
-
"path",
|
|
218
|
-
{
|
|
219
|
-
d: `M ${a * c} ${a * r}
|
|
220
|
-
A ${a * s.scale} ${a * s.scale}, 0, 0, 0, ${a * s.scale + a * c} ${a * s.scale + a * r}
|
|
221
|
-
L ${a * s.scale + a * c} ${a * r} Z`,
|
|
222
|
-
className: d("fill-current stroke-none", s?.className)
|
|
223
|
-
},
|
|
224
|
-
`tile-${c}-${r}`
|
|
225
|
-
),
|
|
226
|
-
[$.PieRand]: (c, r, a, s) => N[$.PieSE + Math.floor(Math.random() * 4)](c, r, a, s)
|
|
227
|
-
}, w = (c, r, a) => c.map(
|
|
228
|
-
(s, o) => s.map((m, L) => {
|
|
229
|
-
const n = typeof m == "object" ? { className: d(a, m.className), scale: m.scale ?? 1, shape: m.shape } : { className: a, scale: 1, shape: m };
|
|
230
|
-
return N[n.shape](L, o, r, n);
|
|
231
|
-
})
|
|
232
|
-
).flat(), R = [
|
|
233
|
-
[$.PieRand, $.PieRand],
|
|
234
|
-
[$.PieRand, $.PieRand]
|
|
1
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as r } from "react";
|
|
3
|
+
import { T as o, g as l } from "./generate-tiles-DuagGD1d.js";
|
|
4
|
+
import { c as m } from "./utils-CRiPKpXj.js";
|
|
5
|
+
const k = [
|
|
6
|
+
[o.PieRand, o.PieRand],
|
|
7
|
+
[o.PieRand, o.PieRand]
|
|
235
8
|
];
|
|
236
|
-
function
|
|
237
|
-
pattern:
|
|
238
|
-
tileSize:
|
|
239
|
-
tileClassName:
|
|
240
|
-
tileBgClassName:
|
|
241
|
-
renderChildren:
|
|
242
|
-
fit:
|
|
243
|
-
...
|
|
9
|
+
function b({
|
|
10
|
+
pattern: e = k,
|
|
11
|
+
tileSize: h = 64,
|
|
12
|
+
tileClassName: s,
|
|
13
|
+
tileBgClassName: c,
|
|
14
|
+
renderChildren: d,
|
|
15
|
+
fit: i = "none",
|
|
16
|
+
...g
|
|
244
17
|
}) {
|
|
245
|
-
const
|
|
18
|
+
const t = r(
|
|
246
19
|
() => ({
|
|
247
|
-
width:
|
|
248
|
-
height:
|
|
20
|
+
width: e.reduce((n, v) => Math.max(n, v.length), 0) * h,
|
|
21
|
+
height: e.length * h
|
|
249
22
|
}),
|
|
250
|
-
[
|
|
251
|
-
),
|
|
252
|
-
const
|
|
253
|
-
return
|
|
254
|
-
/* @__PURE__ */
|
|
23
|
+
[e, h]
|
|
24
|
+
), a = r(() => {
|
|
25
|
+
const n = l(e, h, s);
|
|
26
|
+
return c && n.unshift(
|
|
27
|
+
/* @__PURE__ */ u(
|
|
255
28
|
"rect",
|
|
256
29
|
{
|
|
257
30
|
x: 0,
|
|
258
31
|
y: 0,
|
|
259
|
-
width:
|
|
260
|
-
height:
|
|
261
|
-
className:
|
|
32
|
+
width: t.width,
|
|
33
|
+
height: t.height,
|
|
34
|
+
className: m("fill-black stroke-2 stroke-black", c)
|
|
262
35
|
},
|
|
263
36
|
"svg-mask-invert"
|
|
264
37
|
)
|
|
265
|
-
),
|
|
266
|
-
}, [
|
|
267
|
-
switch (
|
|
38
|
+
), n;
|
|
39
|
+
}, [e, t, s, c, h]), w = r(() => {
|
|
40
|
+
switch (i) {
|
|
268
41
|
case "fill":
|
|
269
|
-
return
|
|
42
|
+
return t.width <= t.height ? "100%" : void 0;
|
|
270
43
|
case "width":
|
|
271
44
|
return "100%";
|
|
272
45
|
case "none":
|
|
273
|
-
return
|
|
46
|
+
return t.width;
|
|
274
47
|
default:
|
|
275
48
|
return;
|
|
276
49
|
}
|
|
277
|
-
}, [
|
|
278
|
-
switch (
|
|
50
|
+
}, [i, t]), f = r(() => {
|
|
51
|
+
switch (i) {
|
|
279
52
|
case "fill":
|
|
280
|
-
return
|
|
53
|
+
return t.height < t.width ? "100%" : void 0;
|
|
281
54
|
case "height":
|
|
282
55
|
return "100%";
|
|
283
56
|
case "none":
|
|
284
|
-
return
|
|
57
|
+
return t.height;
|
|
285
58
|
default:
|
|
286
59
|
return;
|
|
287
60
|
}
|
|
288
|
-
}, [
|
|
289
|
-
return /* @__PURE__ */
|
|
61
|
+
}, [i, t]);
|
|
62
|
+
return /* @__PURE__ */ u(
|
|
290
63
|
"svg",
|
|
291
64
|
{
|
|
292
|
-
width:
|
|
293
|
-
height:
|
|
294
|
-
viewBox: `0 0 ${
|
|
65
|
+
width: w,
|
|
66
|
+
height: f,
|
|
67
|
+
viewBox: `0 0 ${t.width} ${t.height}`,
|
|
295
68
|
overflow: "visible",
|
|
296
|
-
...
|
|
297
|
-
children:
|
|
69
|
+
...g,
|
|
70
|
+
children: d ? d(a, t.width, t.height) : a
|
|
298
71
|
}
|
|
299
72
|
);
|
|
300
73
|
}
|
|
301
74
|
export {
|
|
302
|
-
|
|
75
|
+
b as IconGenerator
|
|
303
76
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
|
|
3
|
+
export declare const generateIconPattern: (width: number, height: number, tileConfig: TileShape | TileConfig) => (TileShape | TileConfig)[][];
|
|
4
|
+
|
|
5
|
+
export declare const generateTiles: (pattern: (TileShape | TileConfig)[][], tileSize: number, tileClassName?: string) => (JSX.Element | null)[];
|
|
6
|
+
|
|
7
|
+
declare interface TileConfig {
|
|
8
|
+
shape: TileShape;
|
|
9
|
+
scale?: number;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare const TileShape: {
|
|
14
|
+
readonly Blank: 0;
|
|
15
|
+
readonly Rand: 1;
|
|
16
|
+
readonly Mosaic: 2;
|
|
17
|
+
readonly MosaicCircle: 3;
|
|
18
|
+
readonly MosaicDiamond: 4;
|
|
19
|
+
readonly Square: 6;
|
|
20
|
+
readonly Circle: 7;
|
|
21
|
+
readonly Diamond: 8;
|
|
22
|
+
readonly Hexagon: 9;
|
|
23
|
+
readonly RandBasic: 10;
|
|
24
|
+
readonly TriangleSE: 11;
|
|
25
|
+
readonly TriangleSW: 12;
|
|
26
|
+
readonly TriangleNW: 13;
|
|
27
|
+
readonly TriangleNE: 14;
|
|
28
|
+
readonly TriangleRand: 15;
|
|
29
|
+
readonly CaretN: 16;
|
|
30
|
+
readonly CaretE: 17;
|
|
31
|
+
readonly CaretS: 18;
|
|
32
|
+
readonly CaretW: 19;
|
|
33
|
+
readonly CaretRand: 20;
|
|
34
|
+
readonly PieSE: 21;
|
|
35
|
+
readonly PieSW: 22;
|
|
36
|
+
readonly PieNW: 23;
|
|
37
|
+
readonly PieNE: 24;
|
|
38
|
+
readonly PieRand: 25;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
declare type TileShape = (typeof TileShape)[keyof typeof TileShape];
|
|
42
|
+
|
|
43
|
+
export { }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bccampus/ui-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"packageManager": "yarn@4.10.3",
|
|
6
6
|
"exports": {
|
|
@@ -8,10 +8,18 @@
|
|
|
8
8
|
"types": "./dist/ui-components.d.ts",
|
|
9
9
|
"import": "./dist/ui-components.js"
|
|
10
10
|
},
|
|
11
|
+
"./composite": {
|
|
12
|
+
"types": "./dist/composite.d.ts",
|
|
13
|
+
"import": "./dist/composite.js"
|
|
14
|
+
},
|
|
11
15
|
"./icon-generator": {
|
|
12
16
|
"types": "./dist/icon-generator.d.ts",
|
|
13
17
|
"import": "./dist/icon-generator.js"
|
|
14
18
|
},
|
|
19
|
+
"./generate-tiles": {
|
|
20
|
+
"types": "./dist/generate-tiles.d.ts",
|
|
21
|
+
"import": "./dist/generate-tiles.js"
|
|
22
|
+
},
|
|
15
23
|
"./masked-image-generator": {
|
|
16
24
|
"types": "./dist/masked-image-generator.d.ts",
|
|
17
25
|
"import": "./dist/masked-image-generator.js"
|
|
@@ -89,11 +97,14 @@
|
|
|
89
97
|
"@bcgov/bc-sans": "^2.1.0",
|
|
90
98
|
"@fontsource-variable/inter-tight": "^5.2.7",
|
|
91
99
|
"@ladle/react": "^5.0.3",
|
|
100
|
+
"@nanostores/react": "^1.0.0",
|
|
92
101
|
"@radix-ui/react-navigation-menu": "^1.2.14",
|
|
102
|
+
"@radix-ui/react-popover": "^1.1.15",
|
|
93
103
|
"@radix-ui/react-slot": "^1.2.3",
|
|
94
104
|
"class-variance-authority": "^0.7.1",
|
|
95
105
|
"clsx": "^2.1.1",
|
|
96
106
|
"lucide-react": "^0.544.0",
|
|
107
|
+
"nanostores": "^1.0.1",
|
|
97
108
|
"react": "^19.1.1",
|
|
98
109
|
"react-dom": "^19.1.1",
|
|
99
110
|
"tailwind-merge": "^3.3.1",
|