@bccampus/ui-components 0.3.0 → 0.4.1

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.
@@ -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
+ };
@@ -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 { }
@@ -0,0 +1,7 @@
1
+ import "react/jsx-runtime";
2
+ import "./utils-CRiPKpXj.js";
3
+ import { a as o, g as n } from "./generate-tiles-DuagGD1d.js";
4
+ export {
5
+ o as generateIconPattern,
6
+ n as generateTiles
7
+ };
@@ -0,0 +1,76 @@
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]
8
+ ];
9
+ function b({
10
+ pattern: e = k,
11
+ tileSize: h = 64,
12
+ tileClassName: c,
13
+ tileBgClassName: s,
14
+ renderChildren: d,
15
+ fit: i = "none",
16
+ ...g
17
+ }) {
18
+ const t = r(
19
+ () => ({
20
+ width: e.reduce((n, v) => Math.max(n, v.length), 0) * h,
21
+ height: e.length * h
22
+ }),
23
+ [e, h]
24
+ ), a = r(() => {
25
+ const n = l(e, h, c);
26
+ return s && n.unshift(
27
+ /* @__PURE__ */ u(
28
+ "rect",
29
+ {
30
+ x: 0,
31
+ y: 0,
32
+ width: t.width,
33
+ height: t.height,
34
+ className: m("fill-black stroke-2 stroke-black", s)
35
+ },
36
+ "svg-mask-invert"
37
+ )
38
+ ), n;
39
+ }, [e, t, c, s, h]), w = r(() => {
40
+ switch (i) {
41
+ case "fill":
42
+ return t.width <= t.height ? "100%" : void 0;
43
+ case "width":
44
+ return "100%";
45
+ case "none":
46
+ return t.width;
47
+ default:
48
+ return;
49
+ }
50
+ }, [i, t]), f = r(() => {
51
+ switch (i) {
52
+ case "fill":
53
+ return t.height < t.width ? "100%" : void 0;
54
+ case "height":
55
+ return "100%";
56
+ case "none":
57
+ return t.height;
58
+ default:
59
+ return;
60
+ }
61
+ }, [i, t]);
62
+ return /* @__PURE__ */ u(
63
+ "svg",
64
+ {
65
+ width: w,
66
+ height: f,
67
+ viewBox: `0 0 ${t.width} ${t.height}`,
68
+ overflow: "visible",
69
+ ...g,
70
+ children: d ? d(a, t.width, t.height) : a
71
+ }
72
+ );
73
+ }
74
+ export {
75
+ b as I
76
+ };
@@ -3,7 +3,7 @@ import { JSX as JSX_2 } from 'react/jsx-runtime';
3
3
 
4
4
  export declare function IconGenerator({ pattern, tileSize, tileClassName, tileBgClassName, renderChildren, fit, ...props }: IconGeneratorProps): JSX_2.Element;
5
5
 
6
- declare interface IconGeneratorProps extends Omit<React.ComponentProps<"svg">, "children" | "width" | "height" | "overflow"> {
6
+ export declare interface IconGeneratorProps extends Omit<React.ComponentProps<"svg">, "children" | "width" | "height" | "overflow"> {
7
7
  pattern?: (TileShape | TileConfig)[][];
8
8
  tileSize?: number;
9
9
  tileClassName?: string;
@@ -12,13 +12,20 @@ declare interface IconGeneratorProps extends Omit<React.ComponentProps<"svg">, "
12
12
  renderChildren?: (paths: (JSX.Element | null)[], width: number, height: number) => React.ReactNode;
13
13
  }
14
14
 
15
- declare interface TileConfig {
15
+ export declare interface MaskedImageGeneratorProps extends IconGeneratorProps {
16
+ src: string;
17
+ imageFit?: "cover" | "contain" | "fill";
18
+ imagePosition?: "top" | "center" | "bottom";
19
+ maskType?: "alpha" | "luminance";
20
+ }
21
+
22
+ export declare interface TileConfig {
16
23
  shape: TileShape;
17
24
  scale?: number;
18
25
  className?: string;
19
26
  }
20
27
 
21
- declare const TileShape: {
28
+ export declare const TileShape: {
22
29
  readonly Blank: 0;
23
30
  readonly Rand: 1;
24
31
  readonly Mosaic: 2;
@@ -46,6 +53,6 @@ declare const TileShape: {
46
53
  readonly PieRand: 25;
47
54
  };
48
55
 
49
- declare type TileShape = (typeof TileShape)[keyof typeof TileShape];
56
+ export declare type TileShape = (typeof TileShape)[keyof typeof TileShape];
50
57
 
51
58
  export { }