spotlibs-components 0.1.21 → 0.1.23
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 +43 -1
- package/dist/index.mjs +137 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -544,6 +544,48 @@ interface BaseChipProps {
|
|
|
544
544
|
|
|
545
545
|
declare function BaseChip(props: BaseChipProps): React.ReactElement;
|
|
546
546
|
|
|
547
|
+
interface BaseWatermarkProps {
|
|
548
|
+
/** Watermark text to display */
|
|
549
|
+
text?: string;
|
|
550
|
+
/** Show/hide watermark. Default: true */
|
|
551
|
+
show?: boolean;
|
|
552
|
+
/** Text color from DerivedColor token. Default: DerivedColor.color_text_default */
|
|
553
|
+
textColor?: string;
|
|
554
|
+
/** Typography variant from VariantStyles (fontSize + fontWeight). Default: "body1_regular" */
|
|
555
|
+
textVariant?: string;
|
|
556
|
+
/** Font family. Default: "BRIDigitalText, sans-serif" */
|
|
557
|
+
fontFamily?: string;
|
|
558
|
+
/** Text opacity (0-1). Default: 0.15 */
|
|
559
|
+
opacity?: number;
|
|
560
|
+
/** Spacing between repetitions (from SpacingToken). Default: SpacingToken.spacing5 */
|
|
561
|
+
gutter?: number;
|
|
562
|
+
/** Rotation angle in degrees. Default: -30 */
|
|
563
|
+
rotate?: number;
|
|
564
|
+
/** CSS z-index of watermark overlay. Default: 10 */
|
|
565
|
+
zIndex?: number;
|
|
566
|
+
/** Max characters before truncation. Default: 40 */
|
|
567
|
+
maxChars?: number;
|
|
568
|
+
/** Custom styles for wrapper element */
|
|
569
|
+
wrapperStyle?: React.CSSProperties;
|
|
570
|
+
/** HTML tag for wrapper element. Default: "div" */
|
|
571
|
+
wrapperElement?: keyof JSX.IntrinsicElements;
|
|
572
|
+
/** Content to render with watermark overlay */
|
|
573
|
+
children?: React.ReactNode;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* BaseWatermark — watermark overlay component.
|
|
578
|
+
*
|
|
579
|
+
* All styling from spotlibs design tokens:
|
|
580
|
+
* - Typography: VariantStyles (fontSize, fontWeight)
|
|
581
|
+
* - Color: DerivedColor tokens
|
|
582
|
+
* - Spacing: SpacingToken
|
|
583
|
+
* - Font: BRIDigitalText
|
|
584
|
+
*
|
|
585
|
+
* Renders staggered repeating pattern via canvas (not grid-aligned).
|
|
586
|
+
*/
|
|
587
|
+
declare function BaseWatermark(props: BaseWatermarkProps): React.ReactElement;
|
|
588
|
+
|
|
547
589
|
interface BaseCardProps {
|
|
548
590
|
/**
|
|
549
591
|
* Card variant type. Supports typography suffix: "with-header.header1_bold"
|
|
@@ -1497,4 +1539,4 @@ interface SubFormBuilderProps<T = any> {
|
|
|
1497
1539
|
declare function FormBuilder<T = any>(props: FormBuilderProps<T>): React.ReactElement;
|
|
1498
1540
|
declare function SubFormBuilder<T = any>(props: SubFormBuilderProps<T>): React.ReactElement;
|
|
1499
1541
|
|
|
1500
|
-
export { BaseAlert, BaseButton, BaseCard, BaseCheckbox, BaseChip, BaseDatatable, BaseDatePicker, BaseDropdown, BaseDropzone, BaseModalAlert, BaseModalAlertDialog, BaseModalAlertProvider, BaseModalLoading, BaseModalLoadingDialog, BaseModalLoadingProvider, BaseModalOTP, BaseModalPopup, BaseModalStepper, BaseRadioButton, BaseSkeleton, BaseSnackbar, BaseStepper, BaseSwitch, BaseTextArea, BaseTextField, BaseTypography, CONTENT_SPACING_TOKENS, CapsLockOn, ContentSpacing, DatatablePagination, DerivedColor, DownloadIconLarge, FORM_TYPE, FormBuilder, IconBiometricScan, IconDocumentAdd, IconEdit, IconFile, IconGradingRounded, IconListDocument, IconMoney, IconProgress, IconReset, IconSave, IconSaveOutlined, IconSendWhite, IconSendWhiteFull, IconUpload, IconUserScan, IconVerification, MoneyIcon, NumberedPagination, PrimitiveColor, Radius, RadiusToken, ServerSidePaginationActions, Shadow, ShadowToken, Spacing, SpacingToken, SubFormBuilder, TextFieldUpload, UsersIcon, VariantStyles };
|
|
1542
|
+
export { BaseAlert, BaseButton, BaseCard, BaseCheckbox, BaseChip, BaseDatatable, BaseDatePicker, BaseDropdown, BaseDropzone, BaseModalAlert, BaseModalAlertDialog, BaseModalAlertProvider, BaseModalLoading, BaseModalLoadingDialog, BaseModalLoadingProvider, BaseModalOTP, BaseModalPopup, BaseModalStepper, BaseRadioButton, BaseSkeleton, BaseSnackbar, BaseStepper, BaseSwitch, BaseTextArea, BaseTextField, BaseTypography, BaseWatermark, CONTENT_SPACING_TOKENS, CapsLockOn, ContentSpacing, DatatablePagination, DerivedColor, DownloadIconLarge, FORM_TYPE, FormBuilder, IconBiometricScan, IconDocumentAdd, IconEdit, IconFile, IconGradingRounded, IconListDocument, IconMoney, IconProgress, IconReset, IconSave, IconSaveOutlined, IconSendWhite, IconSendWhiteFull, IconUpload, IconUserScan, IconVerification, MoneyIcon, NumberedPagination, PrimitiveColor, Radius, RadiusToken, ServerSidePaginationActions, Shadow, ShadowToken, Spacing, SpacingToken, SubFormBuilder, TextFieldUpload, UsersIcon, VariantStyles };
|
package/dist/index.mjs
CHANGED
|
@@ -22,7 +22,6 @@ import CollapseRaw from '@mui/material/Collapse';
|
|
|
22
22
|
import IconButtonRaw from '@mui/material/IconButton';
|
|
23
23
|
import KeyboardArrowDownIconRaw from '@mui/icons-material/KeyboardArrowDown';
|
|
24
24
|
import KeyboardArrowUpIconRaw from '@mui/icons-material/KeyboardArrowUp';
|
|
25
|
-
import { Watermark } from '@hirohe/react-watermark';
|
|
26
25
|
import SnackbarRaw from '@mui/material/Snackbar';
|
|
27
26
|
import MuiCheckboxRaw from '@mui/material/Checkbox';
|
|
28
27
|
import FormControlLabelRaw from '@mui/material/FormControlLabel';
|
|
@@ -74,6 +73,7 @@ import UploadFileRaw from '@mui/icons-material/UploadFile';
|
|
|
74
73
|
import DialogRaw from '@mui/material/Dialog';
|
|
75
74
|
import DialogContentRaw from '@mui/material/DialogContent';
|
|
76
75
|
import DialogActionsRaw from '@mui/material/DialogActions';
|
|
76
|
+
import { Watermark } from '@hirohe/react-watermark';
|
|
77
77
|
import DialogTitleRaw from '@mui/material/DialogTitle';
|
|
78
78
|
import StepContentRaw from '@mui/material/StepContent';
|
|
79
79
|
import InfoIconRaw from '@mui/icons-material/Info';
|
|
@@ -1404,6 +1404,139 @@ var BaseChip = (_a130) => {
|
|
|
1404
1404
|
}, rest)
|
|
1405
1405
|
);
|
|
1406
1406
|
};
|
|
1407
|
+
var WATERMARK_DEFAULTS = {
|
|
1408
|
+
/** Typography variant for watermark text */
|
|
1409
|
+
textVariant: "body1_regular",
|
|
1410
|
+
/** Text color from DerivedColor */
|
|
1411
|
+
textColor: DerivedColor.color_text_default,
|
|
1412
|
+
/** Font family — BRIDigitalText brand font */
|
|
1413
|
+
fontFamily: "BRIDigitalText, sans-serif",
|
|
1414
|
+
/** Opacity — subtle enough to not distract */
|
|
1415
|
+
opacity: 0.35,
|
|
1416
|
+
/** Spacing between watermark repetitions (from SpacingToken) */
|
|
1417
|
+
gutter: parseInt(SpacingToken.spacing5, 10) || 20,
|
|
1418
|
+
/** Rotation angle */
|
|
1419
|
+
rotate: -30,
|
|
1420
|
+
/** Z-index for overlay */
|
|
1421
|
+
zIndex: 10,
|
|
1422
|
+
/** Max characters before truncation */
|
|
1423
|
+
maxChars: 40,
|
|
1424
|
+
/** Offset ratio for staggered pattern (0.33 = 1/3 shift per row) */
|
|
1425
|
+
staggerOffset: 0.33,
|
|
1426
|
+
/** Border radius from design token */
|
|
1427
|
+
borderRadius: Radius.radius_2
|
|
1428
|
+
};
|
|
1429
|
+
function getTypographyStyle(variant) {
|
|
1430
|
+
const style = VariantStyles[variant] || VariantStyles[WATERMARK_DEFAULTS.textVariant];
|
|
1431
|
+
return {
|
|
1432
|
+
fontSize: parseInt(style.fontSize, 10) || 14,
|
|
1433
|
+
fontWeight: style.fontWeight || 400
|
|
1434
|
+
};
|
|
1435
|
+
}
|
|
1436
|
+
function truncateText(text, maxChars) {
|
|
1437
|
+
if (!text) return "";
|
|
1438
|
+
return text.length > maxChars ? text.slice(0, maxChars) + "..." : text;
|
|
1439
|
+
}
|
|
1440
|
+
function getRotatedBounds(width, height, angleDeg) {
|
|
1441
|
+
const radians = Math.abs(angleDeg * Math.PI / 180);
|
|
1442
|
+
return {
|
|
1443
|
+
width: width * Math.cos(radians) + height * Math.sin(radians),
|
|
1444
|
+
height: width * Math.sin(radians) + height * Math.cos(radians)
|
|
1445
|
+
};
|
|
1446
|
+
}
|
|
1447
|
+
function generateWatermarkImage({ displayText, fontSize, fontWeight, fontFamily, textColor, opacity, rotate, gutter, staggerOffset }) {
|
|
1448
|
+
const canvas = document.createElement("canvas");
|
|
1449
|
+
const ctx = canvas.getContext("2d");
|
|
1450
|
+
if (!ctx) return null;
|
|
1451
|
+
const font = `${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
1452
|
+
ctx.font = font;
|
|
1453
|
+
const textWidth = ctx.measureText(displayText).width;
|
|
1454
|
+
const textHeight = fontSize * 1.2;
|
|
1455
|
+
const bounds = getRotatedBounds(textWidth, textHeight, rotate);
|
|
1456
|
+
const cellWidth = Math.ceil(bounds.width + gutter * 2);
|
|
1457
|
+
const cellHeight = Math.ceil(bounds.height + gutter * 2);
|
|
1458
|
+
canvas.width = cellWidth;
|
|
1459
|
+
canvas.height = cellHeight * 2;
|
|
1460
|
+
drawText(ctx, { displayText, font, textColor, opacity, rotate, x: cellWidth / 2, y: cellHeight / 2 });
|
|
1461
|
+
const offsetX = (cellWidth / 2 + cellWidth * staggerOffset) % cellWidth;
|
|
1462
|
+
drawText(ctx, { displayText, font, textColor, opacity, rotate, x: offsetX, y: cellHeight + cellHeight / 2 });
|
|
1463
|
+
return canvas.toDataURL("image/png");
|
|
1464
|
+
}
|
|
1465
|
+
function drawText(ctx, { displayText, font, textColor, opacity, rotate, x, y }) {
|
|
1466
|
+
ctx.save();
|
|
1467
|
+
ctx.translate(x, y);
|
|
1468
|
+
ctx.rotate(rotate * Math.PI / 180);
|
|
1469
|
+
ctx.font = font;
|
|
1470
|
+
ctx.fillStyle = textColor;
|
|
1471
|
+
ctx.globalAlpha = opacity;
|
|
1472
|
+
ctx.textAlign = "center";
|
|
1473
|
+
ctx.textBaseline = "middle";
|
|
1474
|
+
ctx.fillText(displayText, 0, 0);
|
|
1475
|
+
ctx.restore();
|
|
1476
|
+
}
|
|
1477
|
+
var BaseWatermark = ({
|
|
1478
|
+
text = "",
|
|
1479
|
+
show: show3 = true,
|
|
1480
|
+
textColor = WATERMARK_DEFAULTS.textColor,
|
|
1481
|
+
textVariant = WATERMARK_DEFAULTS.textVariant,
|
|
1482
|
+
fontFamily = WATERMARK_DEFAULTS.fontFamily,
|
|
1483
|
+
opacity = WATERMARK_DEFAULTS.opacity,
|
|
1484
|
+
gutter = WATERMARK_DEFAULTS.gutter,
|
|
1485
|
+
rotate = WATERMARK_DEFAULTS.rotate,
|
|
1486
|
+
zIndex = WATERMARK_DEFAULTS.zIndex,
|
|
1487
|
+
maxChars = WATERMARK_DEFAULTS.maxChars,
|
|
1488
|
+
wrapperStyle,
|
|
1489
|
+
wrapperElement: WrapperElement = "div",
|
|
1490
|
+
children
|
|
1491
|
+
}) => {
|
|
1492
|
+
const [bgUrl, setBgUrl] = useState(null);
|
|
1493
|
+
useEffect(() => {
|
|
1494
|
+
if (typeof window === "undefined" || !text || !show3) {
|
|
1495
|
+
setBgUrl(null);
|
|
1496
|
+
return;
|
|
1497
|
+
}
|
|
1498
|
+
const { fontSize, fontWeight } = getTypographyStyle(textVariant);
|
|
1499
|
+
const displayText = truncateText(text, maxChars);
|
|
1500
|
+
const url = generateWatermarkImage({
|
|
1501
|
+
displayText,
|
|
1502
|
+
fontSize,
|
|
1503
|
+
fontWeight,
|
|
1504
|
+
fontFamily,
|
|
1505
|
+
textColor,
|
|
1506
|
+
opacity,
|
|
1507
|
+
rotate,
|
|
1508
|
+
gutter,
|
|
1509
|
+
staggerOffset: WATERMARK_DEFAULTS.staggerOffset
|
|
1510
|
+
});
|
|
1511
|
+
setBgUrl(url);
|
|
1512
|
+
}, [text, show3, textColor, textVariant, fontFamily, opacity, gutter, rotate, maxChars]);
|
|
1513
|
+
return /* @__PURE__ */ jsxs(
|
|
1514
|
+
WrapperElement,
|
|
1515
|
+
{
|
|
1516
|
+
style: __spreadValues({
|
|
1517
|
+
position: "relative",
|
|
1518
|
+
overflow: "hidden"
|
|
1519
|
+
}, wrapperStyle),
|
|
1520
|
+
children: [
|
|
1521
|
+
children,
|
|
1522
|
+
show3 && bgUrl && /* @__PURE__ */ jsx(
|
|
1523
|
+
"div",
|
|
1524
|
+
{
|
|
1525
|
+
"aria-hidden": "true",
|
|
1526
|
+
style: {
|
|
1527
|
+
position: "absolute",
|
|
1528
|
+
inset: 0,
|
|
1529
|
+
backgroundImage: `url(${bgUrl})`,
|
|
1530
|
+
backgroundRepeat: "repeat",
|
|
1531
|
+
pointerEvents: "none",
|
|
1532
|
+
zIndex
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
)
|
|
1536
|
+
]
|
|
1537
|
+
}
|
|
1538
|
+
);
|
|
1539
|
+
};
|
|
1407
1540
|
var _a14, _b14;
|
|
1408
1541
|
var MuiCard = (_b14 = (_a14 = MuiCardRaw) == null ? void 0 : _a14.default) != null ? _b14 : MuiCardRaw;
|
|
1409
1542
|
var _a15, _b15;
|
|
@@ -1554,14 +1687,9 @@ var BaseCard = (_a130) => {
|
|
|
1554
1687
|
backgroundColor: cardBg
|
|
1555
1688
|
},
|
|
1556
1689
|
children: isWatermark && watermarkText ? /* @__PURE__ */ jsx(
|
|
1557
|
-
|
|
1690
|
+
BaseWatermark,
|
|
1558
1691
|
{
|
|
1559
1692
|
text: watermarkText,
|
|
1560
|
-
textColor: "#000000",
|
|
1561
|
-
textSize: 14,
|
|
1562
|
-
opacity: 0.15,
|
|
1563
|
-
gutter: 20,
|
|
1564
|
-
rotate: -30,
|
|
1565
1693
|
wrapperStyle: { minHeight: "100px", position: "relative" },
|
|
1566
1694
|
children
|
|
1567
1695
|
}
|
|
@@ -1583,14 +1711,9 @@ var BaseCard = (_a130) => {
|
|
|
1583
1711
|
}, sx)
|
|
1584
1712
|
}, rest), {
|
|
1585
1713
|
children: isWatermark && watermarkText ? /* @__PURE__ */ jsx(
|
|
1586
|
-
|
|
1714
|
+
BaseWatermark,
|
|
1587
1715
|
{
|
|
1588
1716
|
text: watermarkText,
|
|
1589
|
-
textColor: "#000000",
|
|
1590
|
-
textSize: 14,
|
|
1591
|
-
opacity: 0.15,
|
|
1592
|
-
gutter: 20,
|
|
1593
|
-
rotate: -30,
|
|
1594
1717
|
wrapperStyle: { minHeight: "100px", position: "relative" },
|
|
1595
1718
|
children
|
|
1596
1719
|
}
|
|
@@ -6627,6 +6750,6 @@ var SubFormBuilder = ({
|
|
|
6627
6750
|
)) }) });
|
|
6628
6751
|
};
|
|
6629
6752
|
|
|
6630
|
-
export { BaseAlert, BaseButton, BaseCard, BaseCheckbox, BaseChip, BaseDatatable, BaseDatePicker, BaseDropdown, BaseDropzone, BaseModalAlert, BaseModalAlertDialog, BaseModalAlertProvider, BaseModalLoading, BaseModalLoadingDialog, BaseModalLoadingProvider, BaseModalOTP, BaseModalPopup, BaseModalStepper, BaseRadioButton, BaseSkeleton, BaseSnackbar, BaseStepper, BaseSwitch, BaseTextArea, BaseTextField, BaseTypography, CapsLockOn, DatatablePagination, DownloadIconLarge, FORM_TYPE, FormBuilder, IconBiometricScan, IconDocumentAdd, IconEdit, IconFile, IconGradingRounded, IconListDocument, IconMoney, IconProgress, IconReset, IconSave, IconSaveOutlined, IconSendWhite, IconSendWhiteFull, IconUpload, IconUserScan, IconVerification, MoneyIcon, NumberedPagination, Radius, radius_default as RadiusToken, ServerSidePaginationActions, Shadow, shadow_default as ShadowToken, SubFormBuilder, TextFieldUpload, UsersIcon, VariantStyles };
|
|
6753
|
+
export { BaseAlert, BaseButton, BaseCard, BaseCheckbox, BaseChip, BaseDatatable, BaseDatePicker, BaseDropdown, BaseDropzone, BaseModalAlert, BaseModalAlertDialog, BaseModalAlertProvider, BaseModalLoading, BaseModalLoadingDialog, BaseModalLoadingProvider, BaseModalOTP, BaseModalPopup, BaseModalStepper, BaseRadioButton, BaseSkeleton, BaseSnackbar, BaseStepper, BaseSwitch, BaseTextArea, BaseTextField, BaseTypography, BaseWatermark, CapsLockOn, DatatablePagination, DownloadIconLarge, FORM_TYPE, FormBuilder, IconBiometricScan, IconDocumentAdd, IconEdit, IconFile, IconGradingRounded, IconListDocument, IconMoney, IconProgress, IconReset, IconSave, IconSaveOutlined, IconSendWhite, IconSendWhiteFull, IconUpload, IconUserScan, IconVerification, MoneyIcon, NumberedPagination, Radius, radius_default as RadiusToken, ServerSidePaginationActions, Shadow, shadow_default as ShadowToken, SubFormBuilder, TextFieldUpload, UsersIcon, VariantStyles };
|
|
6631
6754
|
//# sourceMappingURL=index.mjs.map
|
|
6632
6755
|
//# sourceMappingURL=index.mjs.map
|