hs-uix 1.5.0 → 1.6.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/README.md +221 -0
- package/common-components.d.ts +127 -0
- package/dist/common-components.js +491 -16
- package/dist/common-components.mjs +465 -10
- package/dist/datatable.js +3 -3
- package/dist/datatable.mjs +5 -4
- package/dist/form.js +18 -1
- package/dist/form.mjs +18 -1
- package/dist/index.js +1745 -17
- package/dist/index.mjs +1760 -20
- package/dist/kanban.js +1410 -0
- package/dist/kanban.mjs +1408 -0
- package/dist/utils.js +60 -0
- package/dist/utils.mjs +58 -0
- package/form.d.ts +1 -0
- package/index.d.ts +65 -0
- package/kanban.d.ts +1 -0
- package/package.json +9 -1
|
@@ -31,8 +31,28 @@ var common_components_exports = {};
|
|
|
31
31
|
__export(common_components_exports, {
|
|
32
32
|
AutoStatusTag: () => AutoStatusTag,
|
|
33
33
|
AutoTag: () => AutoTag,
|
|
34
|
+
AvatarStack: () => AvatarStack,
|
|
35
|
+
DEFAULT_SVG_FONT_WEIGHT: () => DEFAULT_SVG_FONT_WEIGHT,
|
|
36
|
+
HS_DATE_DIRECTION_LABELS: () => HS_DATE_DIRECTION_LABELS,
|
|
37
|
+
HS_DATE_PRESETS: () => HS_DATE_PRESETS,
|
|
38
|
+
HS_FONT_FAMILY: () => HS_FONT_FAMILY,
|
|
39
|
+
HS_MUTED_TEXT: () => HS_MUTED_TEXT,
|
|
40
|
+
HS_NEUTRAL_CHIP: () => HS_NEUTRAL_CHIP,
|
|
41
|
+
HS_SUBTLE_BG: () => HS_SUBTLE_BG,
|
|
42
|
+
HS_TAG_BORDER_RADIUS: () => HS_TAG_BORDER_RADIUS,
|
|
43
|
+
HS_TAG_BORDER_WIDTH: () => HS_TAG_BORDER_WIDTH,
|
|
44
|
+
HS_TAG_FONT_SIZE: () => HS_TAG_FONT_SIZE,
|
|
45
|
+
HS_TAG_LINE_HEIGHT: () => HS_TAG_LINE_HEIGHT,
|
|
46
|
+
HS_TAG_PADDING_X: () => HS_TAG_PADDING_X,
|
|
47
|
+
HS_TAG_PADDING_Y: () => HS_TAG_PADDING_Y,
|
|
48
|
+
HS_TAG_SUBTLE_BORDER: () => HS_TAG_SUBTLE_BORDER,
|
|
49
|
+
HS_TAG_TEXT_COLOR: () => HS_TAG_TEXT_COLOR,
|
|
50
|
+
HS_TEXT_COLOR: () => HS_TEXT_COLOR,
|
|
34
51
|
KeyValueList: () => KeyValueList,
|
|
35
|
-
SectionHeader: () => SectionHeader
|
|
52
|
+
SectionHeader: () => SectionHeader,
|
|
53
|
+
StyledText: () => StyledText,
|
|
54
|
+
makeAvatarStackDataUri: () => makeAvatarStackDataUri,
|
|
55
|
+
makeStyledTextDataUri: () => makeStyledTextDataUri
|
|
36
56
|
});
|
|
37
57
|
module.exports = __toCommonJS(common_components_exports);
|
|
38
58
|
|
|
@@ -194,13 +214,190 @@ var AutoStatusTag = ({
|
|
|
194
214
|
);
|
|
195
215
|
};
|
|
196
216
|
|
|
197
|
-
// src/common-components/
|
|
217
|
+
// src/common-components/AvatarStack.js
|
|
198
218
|
var import_react3 = __toESM(require("react"));
|
|
199
219
|
var import_ui_extensions3 = require("@hubspot/ui-extensions");
|
|
220
|
+
|
|
221
|
+
// src/common-components/svgDefaults.js
|
|
222
|
+
var HS_FONT_FAMILY = '"Lexend Deca", Helvetica, Arial, sans-serif';
|
|
223
|
+
var HS_TEXT_COLOR = "#33475b";
|
|
224
|
+
var HS_SUBTLE_BG = "#F5F8FA";
|
|
225
|
+
var HS_MUTED_TEXT = "#7C98B6";
|
|
226
|
+
var HS_NEUTRAL_CHIP = "#CBD6E2";
|
|
227
|
+
var HS_TAG_SUBTLE_BORDER = "#7C98B6";
|
|
228
|
+
var HS_TAG_TEXT_COLOR = HS_TEXT_COLOR;
|
|
229
|
+
var HS_TAG_FONT_SIZE = 12;
|
|
230
|
+
var HS_TAG_LINE_HEIGHT = 22;
|
|
231
|
+
var HS_TAG_PADDING_X = 8;
|
|
232
|
+
var HS_TAG_PADDING_Y = 0;
|
|
233
|
+
var HS_TAG_BORDER_RADIUS = 0;
|
|
234
|
+
var HS_TAG_BORDER_WIDTH = 1;
|
|
235
|
+
var DEFAULT_SVG_FONT_WEIGHT = 600;
|
|
236
|
+
|
|
237
|
+
// src/common-components/AvatarStack.js
|
|
238
|
+
var DEFAULT_COLORS = [
|
|
239
|
+
"#0091ae",
|
|
240
|
+
"#8B0000",
|
|
241
|
+
"#ff5c35",
|
|
242
|
+
"#00bda5",
|
|
243
|
+
"#fdcc00",
|
|
244
|
+
"#516f90",
|
|
245
|
+
"#003366",
|
|
246
|
+
"#8e7cc3"
|
|
247
|
+
];
|
|
248
|
+
var SIZE_TOKENS = {
|
|
249
|
+
xs: 16,
|
|
250
|
+
"extra-small": 16,
|
|
251
|
+
sm: 20,
|
|
252
|
+
"small": 20,
|
|
253
|
+
md: 24,
|
|
254
|
+
"med": 24,
|
|
255
|
+
"medium": 24,
|
|
256
|
+
lg: 32,
|
|
257
|
+
"large": 32,
|
|
258
|
+
xl: 40,
|
|
259
|
+
"extra-large": 40
|
|
260
|
+
};
|
|
261
|
+
var resolveSize = (size) => {
|
|
262
|
+
if (typeof size === "number") return size;
|
|
263
|
+
if (typeof size === "string" && SIZE_TOKENS[size] != null) return SIZE_TOKENS[size];
|
|
264
|
+
return 24;
|
|
265
|
+
};
|
|
266
|
+
var isImageUri = (s) => typeof s === "string" && /^(https?:|data:image\/)/i.test(s);
|
|
267
|
+
var escapeXmlAttr = (s) => String(s).replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
268
|
+
var pickColor = (key, palette, index) => {
|
|
269
|
+
if (!key) return palette[index % palette.length];
|
|
270
|
+
const code = String(key).charCodeAt(0) || 0;
|
|
271
|
+
return palette[(code + index) % palette.length];
|
|
272
|
+
};
|
|
273
|
+
var normalizeEntry = (entry) => {
|
|
274
|
+
if (entry == null) return null;
|
|
275
|
+
if (typeof entry === "string") {
|
|
276
|
+
if (entry.length === 0) return null;
|
|
277
|
+
if (isImageUri(entry)) return { src: entry };
|
|
278
|
+
return { letter: entry.slice(0, 2).toUpperCase() };
|
|
279
|
+
}
|
|
280
|
+
if (typeof entry === "object") {
|
|
281
|
+
if (entry.src) return { src: entry.src, letter: entry.letter };
|
|
282
|
+
if (entry.letter) return { letter: String(entry.letter).slice(0, 2).toUpperCase(), color: entry.color };
|
|
283
|
+
}
|
|
284
|
+
return null;
|
|
285
|
+
};
|
|
286
|
+
var makeAvatarStackDataUri = (rawEntries, opts = {}) => {
|
|
287
|
+
const {
|
|
288
|
+
size: sizeProp = "medium",
|
|
289
|
+
step: stepProp,
|
|
290
|
+
overlap: overlapProp,
|
|
291
|
+
maxVisible = 4,
|
|
292
|
+
colors = DEFAULT_COLORS,
|
|
293
|
+
overflowBg = HS_NEUTRAL_CHIP,
|
|
294
|
+
overflowColor = HS_TEXT_COLOR,
|
|
295
|
+
fontFamily = HS_FONT_FAMILY
|
|
296
|
+
} = opts;
|
|
297
|
+
const size = resolveSize(sizeProp);
|
|
298
|
+
let step;
|
|
299
|
+
if (stepProp != null) {
|
|
300
|
+
step = stepProp;
|
|
301
|
+
} else if (overlapProp != null) {
|
|
302
|
+
const clampedOverlap = Math.max(0, Math.min(size - 1, overlapProp));
|
|
303
|
+
step = size - clampedOverlap;
|
|
304
|
+
} else {
|
|
305
|
+
step = Math.round(size * 0.65);
|
|
306
|
+
}
|
|
307
|
+
const entries = (rawEntries || []).map(normalizeEntry).filter(Boolean);
|
|
308
|
+
if (entries.length === 0) return null;
|
|
309
|
+
const visible = entries.slice(0, maxVisible);
|
|
310
|
+
const overflowCount = entries.length - visible.length;
|
|
311
|
+
const slots = overflowCount > 0 ? [...entries.slice(0, maxVisible - 1), { overflow: overflowCount }] : visible;
|
|
312
|
+
const count = slots.length;
|
|
313
|
+
const r = size / 2;
|
|
314
|
+
const haloR = r + 1;
|
|
315
|
+
const width = size + (count - 1) * step;
|
|
316
|
+
const height = size;
|
|
317
|
+
const defs = `<defs><clipPath id="hsuixAvatarClip"><circle cx="${r}" cy="${r}" r="${r}"/></clipPath></defs>`;
|
|
318
|
+
const fontFamilyAttr = fontFamily.replace(/"/g, """);
|
|
319
|
+
const pieces = slots.map((slot, i) => {
|
|
320
|
+
const cx = r + i * step;
|
|
321
|
+
const tx = i * step;
|
|
322
|
+
const halo = i > 0 ? `<circle cx="${cx}" cy="${r}" r="${haloR}" fill="#ffffff" />` : "";
|
|
323
|
+
if (slot.overflow) {
|
|
324
|
+
return halo + `<circle cx="${cx}" cy="${r}" r="${r}" fill="${overflowBg}" /><text x="${cx}" y="${r + 1}" text-anchor="middle" dominant-baseline="central" font-family="${fontFamilyAttr}" font-size="${Math.round(size * 0.42)}" font-weight="700" fill="${overflowColor}">+${slot.overflow}</text>`;
|
|
325
|
+
}
|
|
326
|
+
if (slot.src) {
|
|
327
|
+
return halo + `<g transform="translate(${tx}, 0)"><image href="${escapeXmlAttr(slot.src)}" x="0" y="0" width="${size}" height="${size}" preserveAspectRatio="xMidYMid slice" clip-path="url(#hsuixAvatarClip)" /></g>`;
|
|
328
|
+
}
|
|
329
|
+
const letter = slot.letter || "?";
|
|
330
|
+
const bgColor = slot.color || pickColor(letter, colors, i);
|
|
331
|
+
return halo + `<circle cx="${cx}" cy="${r}" r="${r}" fill="${bgColor}" /><text x="${cx}" y="${r + 1}" text-anchor="middle" dominant-baseline="central" font-family="${fontFamilyAttr}" font-size="${Math.round(size * 0.46)}" font-weight="700" fill="#ffffff">${escapeXmlAttr(letter)}</text>`;
|
|
332
|
+
});
|
|
333
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${width}" height="${height}">` + defs + pieces.join("") + `</svg>`;
|
|
334
|
+
return {
|
|
335
|
+
src: `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`,
|
|
336
|
+
width,
|
|
337
|
+
height,
|
|
338
|
+
count
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
var AvatarStack = ({
|
|
342
|
+
items,
|
|
343
|
+
size,
|
|
344
|
+
overlap,
|
|
345
|
+
step,
|
|
346
|
+
maxVisible,
|
|
347
|
+
colors,
|
|
348
|
+
overflowBg,
|
|
349
|
+
overflowColor,
|
|
350
|
+
fontFamily,
|
|
351
|
+
alt
|
|
352
|
+
}) => {
|
|
353
|
+
const stack = makeAvatarStackDataUri(items, {
|
|
354
|
+
size,
|
|
355
|
+
overlap,
|
|
356
|
+
step,
|
|
357
|
+
maxVisible,
|
|
358
|
+
colors,
|
|
359
|
+
overflowBg,
|
|
360
|
+
overflowColor,
|
|
361
|
+
fontFamily
|
|
362
|
+
});
|
|
363
|
+
if (!stack) return null;
|
|
364
|
+
return import_react3.default.createElement(import_ui_extensions3.Image, {
|
|
365
|
+
src: stack.src,
|
|
366
|
+
width: stack.width,
|
|
367
|
+
height: stack.height,
|
|
368
|
+
alt: alt ?? `${items.length} associated records`
|
|
369
|
+
});
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
// src/common-components/datePresets.js
|
|
373
|
+
var HS_DATE_PRESETS = [
|
|
374
|
+
{ label: "Today", value: "today" },
|
|
375
|
+
{ label: "Yesterday", value: "yesterday" },
|
|
376
|
+
{ label: "Tomorrow", value: "tomorrow" },
|
|
377
|
+
{ label: "This week", value: "this_week" },
|
|
378
|
+
{ label: "Last week", value: "last_week" },
|
|
379
|
+
{ label: "Last 7 days", value: "7d" },
|
|
380
|
+
{ label: "Last 30 days", value: "30d" },
|
|
381
|
+
{ label: "Last 90 days", value: "90d" },
|
|
382
|
+
{ label: "This month", value: "this_month" },
|
|
383
|
+
{ label: "Last month", value: "last_month" },
|
|
384
|
+
{ label: "This quarter", value: "this_quarter" },
|
|
385
|
+
{ label: "Last quarter", value: "last_quarter" },
|
|
386
|
+
{ label: "This year", value: "this_year" },
|
|
387
|
+
{ label: "Last year", value: "last_year" }
|
|
388
|
+
];
|
|
389
|
+
var HS_DATE_DIRECTION_LABELS = {
|
|
390
|
+
asc: "Ascending",
|
|
391
|
+
desc: "Descending"
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
// src/common-components/KeyValueList.js
|
|
395
|
+
var import_react4 = __toESM(require("react"));
|
|
396
|
+
var import_ui_extensions4 = require("@hubspot/ui-extensions");
|
|
200
397
|
var KeyValueList = ({ items = [], direction = "row", gap = "sm" }) => {
|
|
201
398
|
const rows = items.map(
|
|
202
|
-
(item, index) =>
|
|
203
|
-
|
|
399
|
+
(item, index) => import_react4.default.createElement(
|
|
400
|
+
import_ui_extensions4.DescriptionListItem,
|
|
204
401
|
{
|
|
205
402
|
key: item.key ?? item.label ?? `kv-${index}`,
|
|
206
403
|
label: item.label
|
|
@@ -208,16 +405,16 @@ var KeyValueList = ({ items = [], direction = "row", gap = "sm" }) => {
|
|
|
208
405
|
item.value
|
|
209
406
|
)
|
|
210
407
|
);
|
|
211
|
-
return
|
|
212
|
-
|
|
408
|
+
return import_react4.default.createElement(
|
|
409
|
+
import_ui_extensions4.Flex,
|
|
213
410
|
{ direction: "column", gap },
|
|
214
|
-
|
|
411
|
+
import_react4.default.createElement(import_ui_extensions4.DescriptionList, { direction }, ...rows)
|
|
215
412
|
);
|
|
216
413
|
};
|
|
217
414
|
|
|
218
415
|
// src/common-components/SectionHeader.js
|
|
219
|
-
var
|
|
220
|
-
var
|
|
416
|
+
var import_react5 = __toESM(require("react"));
|
|
417
|
+
var import_ui_extensions5 = require("@hubspot/ui-extensions");
|
|
221
418
|
var SectionHeader = ({
|
|
222
419
|
title,
|
|
223
420
|
description,
|
|
@@ -228,12 +425,12 @@ var SectionHeader = ({
|
|
|
228
425
|
}) => {
|
|
229
426
|
const body = [];
|
|
230
427
|
if (title != null) {
|
|
231
|
-
body.push(
|
|
428
|
+
body.push(import_react5.default.createElement(import_ui_extensions5.Heading, { key: "title", as: titleAs }, title));
|
|
232
429
|
}
|
|
233
430
|
if (description != null) {
|
|
234
431
|
body.push(
|
|
235
|
-
|
|
236
|
-
|
|
432
|
+
import_react5.default.createElement(
|
|
433
|
+
import_ui_extensions5.Text,
|
|
237
434
|
{ key: "description", variant: "microcopy" },
|
|
238
435
|
description
|
|
239
436
|
)
|
|
@@ -242,19 +439,297 @@ var SectionHeader = ({
|
|
|
242
439
|
if (children != null) {
|
|
243
440
|
body.push(children);
|
|
244
441
|
}
|
|
245
|
-
const content =
|
|
442
|
+
const content = import_react5.default.createElement(import_ui_extensions5.Flex, { direction: "column", gap }, ...body);
|
|
246
443
|
if (actions == null) return content;
|
|
247
|
-
return
|
|
248
|
-
|
|
444
|
+
return import_react5.default.createElement(
|
|
445
|
+
import_ui_extensions5.Flex,
|
|
249
446
|
{ direction: "row", justify: "between", align: "start", gap: "sm" },
|
|
250
447
|
content,
|
|
251
448
|
actions
|
|
252
449
|
);
|
|
253
450
|
};
|
|
451
|
+
|
|
452
|
+
// src/common-components/StyledText.js
|
|
453
|
+
var import_react6 = __toESM(require("react"));
|
|
454
|
+
var import_ui_extensions6 = require("@hubspot/ui-extensions");
|
|
455
|
+
var VARIANT_PRESETS = {
|
|
456
|
+
bodytext: { fontSize: 14, lineHeight: 24, fontWeight: 400 },
|
|
457
|
+
microcopy: { fontSize: 12, lineHeight: 18, fontWeight: 400 }
|
|
458
|
+
};
|
|
459
|
+
var WEIGHT_ALIASES = {
|
|
460
|
+
bold: 700,
|
|
461
|
+
demibold: 600,
|
|
462
|
+
regular: 400
|
|
463
|
+
};
|
|
464
|
+
var LINE_DECORATION = {
|
|
465
|
+
strikethrough: "line-through",
|
|
466
|
+
underline: "underline"
|
|
467
|
+
};
|
|
468
|
+
var ORIENTATION_ROTATION = {
|
|
469
|
+
horizontal: 0,
|
|
470
|
+
"vertical-up": -90,
|
|
471
|
+
"vertical-down": 90
|
|
472
|
+
};
|
|
473
|
+
var BACKGROUND_PRESETS = {
|
|
474
|
+
tag: {
|
|
475
|
+
color: HS_SUBTLE_BG,
|
|
476
|
+
borderColor: HS_TAG_SUBTLE_BORDER,
|
|
477
|
+
borderWidth: HS_TAG_BORDER_WIDTH,
|
|
478
|
+
radius: HS_TAG_BORDER_RADIUS,
|
|
479
|
+
paddingX: HS_TAG_PADDING_X,
|
|
480
|
+
paddingY: HS_TAG_PADDING_Y,
|
|
481
|
+
height: HS_TAG_LINE_HEIGHT,
|
|
482
|
+
textColor: HS_TAG_TEXT_COLOR,
|
|
483
|
+
fontSize: HS_TAG_FONT_SIZE,
|
|
484
|
+
canvasPaddingX: 0,
|
|
485
|
+
canvasPaddingY: 0
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
var TAG_VARIANTS = {
|
|
489
|
+
default: {
|
|
490
|
+
color: HS_SUBTLE_BG,
|
|
491
|
+
borderColor: HS_TAG_SUBTLE_BORDER,
|
|
492
|
+
textColor: HS_TAG_TEXT_COLOR
|
|
493
|
+
},
|
|
494
|
+
success: {
|
|
495
|
+
color: "#E5F8F6",
|
|
496
|
+
borderColor: "#00BDA5",
|
|
497
|
+
textColor: "#00BDA5"
|
|
498
|
+
},
|
|
499
|
+
warning: {
|
|
500
|
+
color: "#FEF8F0",
|
|
501
|
+
borderColor: "#F5C26B",
|
|
502
|
+
textColor: "#D39913"
|
|
503
|
+
},
|
|
504
|
+
error: {
|
|
505
|
+
color: "#FDEDEE",
|
|
506
|
+
borderColor: "#F2545B",
|
|
507
|
+
textColor: "#F2545B"
|
|
508
|
+
},
|
|
509
|
+
danger: {
|
|
510
|
+
color: "#FDEDEE",
|
|
511
|
+
borderColor: "#F2545B",
|
|
512
|
+
textColor: "#F2545B"
|
|
513
|
+
},
|
|
514
|
+
info: {
|
|
515
|
+
color: "#E5F5F8",
|
|
516
|
+
borderColor: "#00A4BD",
|
|
517
|
+
textColor: "#00A4BD"
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
var NATIVE_TAG_VARIANT_ALIASES = {
|
|
521
|
+
danger: "error"
|
|
522
|
+
};
|
|
523
|
+
var escapeSvgText = (s) => String(s).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
524
|
+
var applyTextTransform = (text, transform) => {
|
|
525
|
+
if (!transform || transform === "none") return String(text);
|
|
526
|
+
const s = String(text);
|
|
527
|
+
switch (transform) {
|
|
528
|
+
case "uppercase":
|
|
529
|
+
return s.toUpperCase();
|
|
530
|
+
case "lowercase":
|
|
531
|
+
return s.toLowerCase();
|
|
532
|
+
case "capitalize":
|
|
533
|
+
return s.replace(/\b\w/g, (c) => c.toUpperCase());
|
|
534
|
+
case "sentenceCase":
|
|
535
|
+
return s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();
|
|
536
|
+
default:
|
|
537
|
+
return s;
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
var estimateTextWidth = (text, fontSize) => Math.max(fontSize, Math.round(String(text).length * fontSize * 0.58));
|
|
541
|
+
var resolveBackground = (background) => {
|
|
542
|
+
if (!background) return null;
|
|
543
|
+
const preset = background.preset ? BACKGROUND_PRESETS[background.preset] : null;
|
|
544
|
+
const variant = background.preset === "tag" && background.variant ? TAG_VARIANTS[background.variant] || null : null;
|
|
545
|
+
return {
|
|
546
|
+
...preset || {},
|
|
547
|
+
...variant || {},
|
|
548
|
+
...background
|
|
549
|
+
};
|
|
550
|
+
};
|
|
551
|
+
var buildBackgroundRect = ({ background, x, y, width, height }) => {
|
|
552
|
+
const radius = (background == null ? void 0 : background.radius) ?? 3;
|
|
553
|
+
const fill = (background == null ? void 0 : background.color) ?? "transparent";
|
|
554
|
+
const borderWidth = (background == null ? void 0 : background.borderWidth) ?? 0;
|
|
555
|
+
const borderColor = background == null ? void 0 : background.borderColor;
|
|
556
|
+
if (!borderColor || borderWidth <= 0) {
|
|
557
|
+
return `<rect x="${x}" y="${y}" width="${width}" height="${height}" rx="${radius}" fill="${fill}" />`;
|
|
558
|
+
}
|
|
559
|
+
const isTagPreset = (background == null ? void 0 : background.preset) === "tag";
|
|
560
|
+
const fillRect = `<rect x="${x}" y="${y}" width="${width}" height="${height}" rx="${radius}" fill="${fill}" />`;
|
|
561
|
+
const strokeInset = borderWidth / 2;
|
|
562
|
+
const strokeX = x + strokeInset;
|
|
563
|
+
const strokeY = y + strokeInset;
|
|
564
|
+
const strokeW = Math.max(0, width - borderWidth);
|
|
565
|
+
const strokeH = Math.max(0, height - borderWidth);
|
|
566
|
+
return fillRect + `<rect x="${strokeX}" y="${strokeY}" width="${strokeW}" height="${strokeH}" rx="${Math.max(
|
|
567
|
+
0,
|
|
568
|
+
radius - strokeInset
|
|
569
|
+
)}" fill="none" stroke="${borderColor}" stroke-width="${borderWidth}"${isTagPreset ? ` shape-rendering="crispEdges"` : ""} />`;
|
|
570
|
+
};
|
|
571
|
+
var canUseNativeTag = ({
|
|
572
|
+
background,
|
|
573
|
+
orientation,
|
|
574
|
+
color,
|
|
575
|
+
fontFamily,
|
|
576
|
+
fontSize,
|
|
577
|
+
width,
|
|
578
|
+
height,
|
|
579
|
+
paddingX,
|
|
580
|
+
paddingY,
|
|
581
|
+
format = {}
|
|
582
|
+
}) => {
|
|
583
|
+
if (!background || background.preset !== "tag") return false;
|
|
584
|
+
const resolvedOrientation = typeof orientation === "number" ? orientation : ORIENTATION_ROTATION[orientation ?? "horizontal"] ?? 0;
|
|
585
|
+
if (resolvedOrientation !== 0) return false;
|
|
586
|
+
if (color != null || fontFamily != null || fontSize != null) return false;
|
|
587
|
+
if (width != null || height != null || paddingX != null || paddingY != null) return false;
|
|
588
|
+
if (background.color != null || background.textColor != null) return false;
|
|
589
|
+
if (background.borderColor != null || background.borderWidth != null) return false;
|
|
590
|
+
if (background.radius != null || background.height != null) return false;
|
|
591
|
+
if (background.paddingX != null || background.paddingY != null) return false;
|
|
592
|
+
if (background.canvasPaddingX != null || background.canvasPaddingY != null) return false;
|
|
593
|
+
if (format.italic || format.lineDecoration) return false;
|
|
594
|
+
if (format.textTransform && format.textTransform !== "none") return false;
|
|
595
|
+
return true;
|
|
596
|
+
};
|
|
597
|
+
var makeStyledTextDataUri = (text, opts = {}) => {
|
|
598
|
+
const {
|
|
599
|
+
variant = "bodytext",
|
|
600
|
+
format = {},
|
|
601
|
+
orientation = "horizontal",
|
|
602
|
+
color: colorProp = HS_TEXT_COLOR,
|
|
603
|
+
fontFamily = HS_FONT_FAMILY,
|
|
604
|
+
background: backgroundProp = null,
|
|
605
|
+
paddingX: paddingXProp = 4,
|
|
606
|
+
paddingY: paddingYProp = 2,
|
|
607
|
+
width: widthOverride,
|
|
608
|
+
height: heightOverride,
|
|
609
|
+
fontSize: fontSizeOverride
|
|
610
|
+
} = opts;
|
|
611
|
+
const preset = VARIANT_PRESETS[variant] || VARIANT_PRESETS.bodytext;
|
|
612
|
+
const background = resolveBackground(backgroundProp);
|
|
613
|
+
const fontSize = fontSizeOverride ?? (background == null ? void 0 : background.fontSize) ?? preset.fontSize;
|
|
614
|
+
const rawWeight = format.fontWeight;
|
|
615
|
+
const fontWeight = rawWeight ? WEIGHT_ALIASES[rawWeight] ?? rawWeight : preset.fontWeight;
|
|
616
|
+
const fontStyle = format.italic ? "italic" : "normal";
|
|
617
|
+
const textDecoration = LINE_DECORATION[format.lineDecoration] || "none";
|
|
618
|
+
const transformed = applyTextTransform(text, format.textTransform);
|
|
619
|
+
const lineHeight = (background == null ? void 0 : background.height) ?? preset.lineHeight ?? fontSize;
|
|
620
|
+
const color = (background == null ? void 0 : background.textColor) ?? colorProp;
|
|
621
|
+
const paddingX = (background == null ? void 0 : background.canvasPaddingX) ?? paddingXProp;
|
|
622
|
+
const paddingY = (background == null ? void 0 : background.canvasPaddingY) ?? paddingYProp;
|
|
623
|
+
const rotate = typeof orientation === "number" ? orientation : ORIENTATION_ROTATION[orientation] ?? 0;
|
|
624
|
+
const textW = estimateTextWidth(transformed, fontSize);
|
|
625
|
+
let pillW = 0;
|
|
626
|
+
let pillH = 0;
|
|
627
|
+
if (background) {
|
|
628
|
+
const bgPadX = background.paddingX ?? 6;
|
|
629
|
+
const bgPadY = background.paddingY ?? 3;
|
|
630
|
+
pillW = textW + bgPadX * 2;
|
|
631
|
+
pillH = background.height ?? Math.max(lineHeight, fontSize + bgPadY * 2);
|
|
632
|
+
}
|
|
633
|
+
const intrinsicW = (background ? pillW : textW) + paddingX * 2;
|
|
634
|
+
const intrinsicH = (background ? pillH : lineHeight) + paddingY * 2;
|
|
635
|
+
const isOrthoRotation = rotate === 90 || rotate === -90 || rotate === 270;
|
|
636
|
+
const canvasW = widthOverride ?? (isOrthoRotation ? intrinsicH : intrinsicW);
|
|
637
|
+
const canvasH = heightOverride ?? (isOrthoRotation ? intrinsicW : intrinsicH);
|
|
638
|
+
const cx = canvasW / 2;
|
|
639
|
+
const cy = canvasH / 2;
|
|
640
|
+
const rectX = cx - pillW / 2;
|
|
641
|
+
const rectY = cy - pillH / 2;
|
|
642
|
+
const group = (background ? buildBackgroundRect({
|
|
643
|
+
background,
|
|
644
|
+
x: rectX,
|
|
645
|
+
y: rectY,
|
|
646
|
+
width: pillW,
|
|
647
|
+
height: pillH
|
|
648
|
+
}) : "") + `<text x="${cx}" y="${cy}" text-anchor="middle" dominant-baseline="central" font-family="${fontFamily.replace(/"/g, """)}" font-size="${fontSize}" font-weight="${fontWeight}" font-style="${fontStyle}" text-decoration="${textDecoration}" fill="${color}">${escapeSvgText(transformed)}</text>`;
|
|
649
|
+
const wrapped = rotate ? `<g transform="rotate(${rotate} ${cx} ${cy})">${group}</g>` : group;
|
|
650
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${canvasW}" height="${canvasH}">` + wrapped + `</svg>`;
|
|
651
|
+
return {
|
|
652
|
+
src: `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`,
|
|
653
|
+
width: canvasW,
|
|
654
|
+
height: canvasH
|
|
655
|
+
};
|
|
656
|
+
};
|
|
657
|
+
var StyledText = ({
|
|
658
|
+
children,
|
|
659
|
+
text,
|
|
660
|
+
alt,
|
|
661
|
+
variant,
|
|
662
|
+
format,
|
|
663
|
+
orientation,
|
|
664
|
+
color,
|
|
665
|
+
background,
|
|
666
|
+
fontFamily,
|
|
667
|
+
fontSize,
|
|
668
|
+
paddingX,
|
|
669
|
+
paddingY,
|
|
670
|
+
width,
|
|
671
|
+
height
|
|
672
|
+
}) => {
|
|
673
|
+
const resolvedText = text ?? (typeof children === "string" ? children : "");
|
|
674
|
+
if (canUseNativeTag({
|
|
675
|
+
background,
|
|
676
|
+
orientation,
|
|
677
|
+
color,
|
|
678
|
+
fontFamily,
|
|
679
|
+
fontSize,
|
|
680
|
+
width,
|
|
681
|
+
height,
|
|
682
|
+
paddingX,
|
|
683
|
+
paddingY,
|
|
684
|
+
format
|
|
685
|
+
})) {
|
|
686
|
+
const nativeVariant = NATIVE_TAG_VARIANT_ALIASES[background == null ? void 0 : background.variant] ?? (background == null ? void 0 : background.variant) ?? "default";
|
|
687
|
+
return import_react6.default.createElement(import_ui_extensions6.Tag, { variant: nativeVariant }, resolvedText);
|
|
688
|
+
}
|
|
689
|
+
const { src, width: w, height: h } = makeStyledTextDataUri(resolvedText, {
|
|
690
|
+
variant,
|
|
691
|
+
format,
|
|
692
|
+
orientation,
|
|
693
|
+
color,
|
|
694
|
+
background,
|
|
695
|
+
fontFamily,
|
|
696
|
+
fontSize,
|
|
697
|
+
paddingX,
|
|
698
|
+
paddingY,
|
|
699
|
+
width,
|
|
700
|
+
height
|
|
701
|
+
});
|
|
702
|
+
return import_react6.default.createElement(import_ui_extensions6.Image, {
|
|
703
|
+
src,
|
|
704
|
+
width: w,
|
|
705
|
+
height: h,
|
|
706
|
+
alt: alt ?? String(resolvedText)
|
|
707
|
+
});
|
|
708
|
+
};
|
|
254
709
|
// Annotate the CommonJS export names for ESM import in node:
|
|
255
710
|
0 && (module.exports = {
|
|
256
711
|
AutoStatusTag,
|
|
257
712
|
AutoTag,
|
|
713
|
+
AvatarStack,
|
|
714
|
+
DEFAULT_SVG_FONT_WEIGHT,
|
|
715
|
+
HS_DATE_DIRECTION_LABELS,
|
|
716
|
+
HS_DATE_PRESETS,
|
|
717
|
+
HS_FONT_FAMILY,
|
|
718
|
+
HS_MUTED_TEXT,
|
|
719
|
+
HS_NEUTRAL_CHIP,
|
|
720
|
+
HS_SUBTLE_BG,
|
|
721
|
+
HS_TAG_BORDER_RADIUS,
|
|
722
|
+
HS_TAG_BORDER_WIDTH,
|
|
723
|
+
HS_TAG_FONT_SIZE,
|
|
724
|
+
HS_TAG_LINE_HEIGHT,
|
|
725
|
+
HS_TAG_PADDING_X,
|
|
726
|
+
HS_TAG_PADDING_Y,
|
|
727
|
+
HS_TAG_SUBTLE_BORDER,
|
|
728
|
+
HS_TAG_TEXT_COLOR,
|
|
729
|
+
HS_TEXT_COLOR,
|
|
258
730
|
KeyValueList,
|
|
259
|
-
SectionHeader
|
|
731
|
+
SectionHeader,
|
|
732
|
+
StyledText,
|
|
733
|
+
makeAvatarStackDataUri,
|
|
734
|
+
makeStyledTextDataUri
|
|
260
735
|
});
|