@algenium/blocks 1.3.0 → 1.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/index.cjs +303 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +61 -1
- package/dist/index.d.ts +61 -1
- package/dist/index.js +299 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -68,6 +68,20 @@ var LanguageContext = React2.createContext(null);
|
|
|
68
68
|
function useLanguageContext() {
|
|
69
69
|
return React2.useContext(LanguageContext);
|
|
70
70
|
}
|
|
71
|
+
var BLOCKS_DATA_ENVIRONMENTS = [
|
|
72
|
+
"production",
|
|
73
|
+
"staging",
|
|
74
|
+
"development"
|
|
75
|
+
];
|
|
76
|
+
function isBlocksDataEnvironment(value) {
|
|
77
|
+
return BLOCKS_DATA_ENVIRONMENTS.includes(value);
|
|
78
|
+
}
|
|
79
|
+
var EnvironmentContext = React2.createContext(
|
|
80
|
+
null
|
|
81
|
+
);
|
|
82
|
+
function useEnvironmentContext() {
|
|
83
|
+
return React2.useContext(EnvironmentContext);
|
|
84
|
+
}
|
|
71
85
|
|
|
72
86
|
// node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
|
|
73
87
|
function r(e) {
|
|
@@ -3669,7 +3683,7 @@ function LanguageSwitcher({
|
|
|
3669
3683
|
const onLanguageChange = propOnLanguageChange ?? context?.setLanguage;
|
|
3670
3684
|
const sizes = sizeClasses2[size];
|
|
3671
3685
|
const shapeClass = shapeClasses2[shape];
|
|
3672
|
-
const
|
|
3686
|
+
const defaultLabels4 = {
|
|
3673
3687
|
language: labels.language ?? "Language"
|
|
3674
3688
|
};
|
|
3675
3689
|
if (variant === "mini") {
|
|
@@ -3680,7 +3694,7 @@ function LanguageSwitcher({
|
|
|
3680
3694
|
{
|
|
3681
3695
|
variant: "ghost",
|
|
3682
3696
|
size: "icon",
|
|
3683
|
-
"aria-label":
|
|
3697
|
+
"aria-label": defaultLabels4.language,
|
|
3684
3698
|
className: cn(sizes.buttonMini, shapeClass, className),
|
|
3685
3699
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Languages, { className: sizes.iconMini })
|
|
3686
3700
|
}
|
|
@@ -3691,7 +3705,7 @@ function LanguageSwitcher({
|
|
|
3691
3705
|
side: tooltipSide,
|
|
3692
3706
|
align: tooltipAlign,
|
|
3693
3707
|
sideOffset: tooltipSideOffset,
|
|
3694
|
-
children:
|
|
3708
|
+
children: defaultLabels4.language
|
|
3695
3709
|
}
|
|
3696
3710
|
)
|
|
3697
3711
|
] }),
|
|
@@ -3774,6 +3788,286 @@ function LanguageSwitcher({
|
|
|
3774
3788
|
}
|
|
3775
3789
|
);
|
|
3776
3790
|
}
|
|
3791
|
+
var defaultLabels2 = {
|
|
3792
|
+
environment: "Data environment",
|
|
3793
|
+
live: "Live",
|
|
3794
|
+
staging: "Staging",
|
|
3795
|
+
development: "Development"
|
|
3796
|
+
};
|
|
3797
|
+
var sizeClasses3 = {
|
|
3798
|
+
sm: {
|
|
3799
|
+
container: "h-7 p-0.5 text-xs",
|
|
3800
|
+
button: "h-6 px-2",
|
|
3801
|
+
buttonMini: "h-7 gap-1.5 px-2",
|
|
3802
|
+
dot: "size-2",
|
|
3803
|
+
iconMini: "size-3.5"
|
|
3804
|
+
},
|
|
3805
|
+
md: {
|
|
3806
|
+
container: "h-8 p-0.5 text-xs",
|
|
3807
|
+
button: "h-7 px-2.5",
|
|
3808
|
+
buttonMini: "h-8 gap-2 px-2.5",
|
|
3809
|
+
dot: "size-2.5",
|
|
3810
|
+
iconMini: "size-4"
|
|
3811
|
+
},
|
|
3812
|
+
lg: {
|
|
3813
|
+
container: "h-9 p-0.5 text-sm",
|
|
3814
|
+
button: "h-8 px-3",
|
|
3815
|
+
buttonMini: "h-9 gap-2 px-3",
|
|
3816
|
+
dot: "size-2.5",
|
|
3817
|
+
iconMini: "size-4"
|
|
3818
|
+
}
|
|
3819
|
+
};
|
|
3820
|
+
var shapeClasses3 = {
|
|
3821
|
+
rounded: "rounded-md",
|
|
3822
|
+
pill: "rounded-full"
|
|
3823
|
+
};
|
|
3824
|
+
function envDotClass(env) {
|
|
3825
|
+
switch (env) {
|
|
3826
|
+
case "production":
|
|
3827
|
+
return "bg-emerald-500";
|
|
3828
|
+
case "staging":
|
|
3829
|
+
return "bg-orange-500";
|
|
3830
|
+
case "development":
|
|
3831
|
+
return "bg-amber-400";
|
|
3832
|
+
default:
|
|
3833
|
+
return "bg-muted-foreground";
|
|
3834
|
+
}
|
|
3835
|
+
}
|
|
3836
|
+
function labelForEnv(env, labels) {
|
|
3837
|
+
switch (env) {
|
|
3838
|
+
case "production":
|
|
3839
|
+
return labels.live;
|
|
3840
|
+
case "staging":
|
|
3841
|
+
return labels.staging;
|
|
3842
|
+
case "development":
|
|
3843
|
+
return labels.development;
|
|
3844
|
+
default:
|
|
3845
|
+
return env;
|
|
3846
|
+
}
|
|
3847
|
+
}
|
|
3848
|
+
function EnvironmentSwitcher({
|
|
3849
|
+
className,
|
|
3850
|
+
environment: propEnvironment,
|
|
3851
|
+
onEnvironmentChange: propOnEnvironmentChange,
|
|
3852
|
+
environments: propEnvironments,
|
|
3853
|
+
labels: userLabels,
|
|
3854
|
+
size = "sm",
|
|
3855
|
+
shape = "rounded",
|
|
3856
|
+
variant = "mini",
|
|
3857
|
+
align = "end",
|
|
3858
|
+
side = "bottom",
|
|
3859
|
+
tooltipSide = "bottom",
|
|
3860
|
+
tooltipAlign = "center",
|
|
3861
|
+
tooltipSideOffset = 8
|
|
3862
|
+
}) {
|
|
3863
|
+
const ctx = useEnvironmentContext();
|
|
3864
|
+
const labels = { ...defaultLabels2, ...userLabels };
|
|
3865
|
+
const environments = propEnvironments ?? ctx?.environments ?? [...BLOCKS_DATA_ENVIRONMENTS];
|
|
3866
|
+
const environment = propEnvironment ?? ctx?.environment ?? "production";
|
|
3867
|
+
const setEnvironment = propOnEnvironmentChange ?? ctx?.setEnvironment ?? (() => {
|
|
3868
|
+
});
|
|
3869
|
+
const sizes = sizeClasses3[size];
|
|
3870
|
+
const shapeClass = shapeClasses3[shape];
|
|
3871
|
+
const handleSelect = (next) => {
|
|
3872
|
+
if (next === environment) return;
|
|
3873
|
+
setEnvironment(next);
|
|
3874
|
+
};
|
|
3875
|
+
if (variant === "mini") {
|
|
3876
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { modal: false, children: [
|
|
3877
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
|
|
3878
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3879
|
+
Button,
|
|
3880
|
+
{
|
|
3881
|
+
"data-testid": "environment-switcher",
|
|
3882
|
+
variant: "outline",
|
|
3883
|
+
size: "sm",
|
|
3884
|
+
"aria-label": labels.environment,
|
|
3885
|
+
className: cn(
|
|
3886
|
+
sizes.buttonMini,
|
|
3887
|
+
shapeClass,
|
|
3888
|
+
"font-medium tabular-nums border-border bg-background",
|
|
3889
|
+
className
|
|
3890
|
+
),
|
|
3891
|
+
children: [
|
|
3892
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3893
|
+
"span",
|
|
3894
|
+
{
|
|
3895
|
+
className: cn(
|
|
3896
|
+
"rounded-full shrink-0 ring-1 ring-background",
|
|
3897
|
+
sizes.dot,
|
|
3898
|
+
envDotClass(environment)
|
|
3899
|
+
),
|
|
3900
|
+
"aria-hidden": true
|
|
3901
|
+
}
|
|
3902
|
+
),
|
|
3903
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "max-w-[5.5rem] truncate", children: labelForEnv(environment, labels) })
|
|
3904
|
+
]
|
|
3905
|
+
}
|
|
3906
|
+
) }) }),
|
|
3907
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3908
|
+
TooltipContent,
|
|
3909
|
+
{
|
|
3910
|
+
side: tooltipSide,
|
|
3911
|
+
align: tooltipAlign,
|
|
3912
|
+
sideOffset: tooltipSideOffset,
|
|
3913
|
+
children: labels.environment
|
|
3914
|
+
}
|
|
3915
|
+
)
|
|
3916
|
+
] }),
|
|
3917
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuContent, { side, align, sideOffset: 8, children: environments.map((env) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3918
|
+
DropdownMenuItem,
|
|
3919
|
+
{
|
|
3920
|
+
onClick: () => handleSelect(env),
|
|
3921
|
+
className: cn(
|
|
3922
|
+
"gap-2 cursor-pointer",
|
|
3923
|
+
environment === env && "bg-accent"
|
|
3924
|
+
),
|
|
3925
|
+
children: [
|
|
3926
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3927
|
+
"span",
|
|
3928
|
+
{
|
|
3929
|
+
className: cn(
|
|
3930
|
+
"rounded-full shrink-0 ring-1 ring-background",
|
|
3931
|
+
sizes.dot,
|
|
3932
|
+
envDotClass(env)
|
|
3933
|
+
),
|
|
3934
|
+
"aria-hidden": true
|
|
3935
|
+
}
|
|
3936
|
+
),
|
|
3937
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: labelForEnv(env, labels) })
|
|
3938
|
+
]
|
|
3939
|
+
},
|
|
3940
|
+
env
|
|
3941
|
+
)) })
|
|
3942
|
+
] });
|
|
3943
|
+
}
|
|
3944
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3945
|
+
"div",
|
|
3946
|
+
{
|
|
3947
|
+
"data-testid": "environment-switcher",
|
|
3948
|
+
className: cn(
|
|
3949
|
+
"relative isolate flex items-center bg-background ring-1 ring-border",
|
|
3950
|
+
sizes.container,
|
|
3951
|
+
shapeClass,
|
|
3952
|
+
className
|
|
3953
|
+
),
|
|
3954
|
+
children: [
|
|
3955
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3956
|
+
lucideReact.FlaskConical,
|
|
3957
|
+
{
|
|
3958
|
+
className: cn(sizes.iconMini, "ml-1.5 mr-1 text-muted-foreground"),
|
|
3959
|
+
"aria-hidden": true
|
|
3960
|
+
}
|
|
3961
|
+
),
|
|
3962
|
+
environments.map((env) => {
|
|
3963
|
+
const isActive = environment === env;
|
|
3964
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3965
|
+
"button",
|
|
3966
|
+
{
|
|
3967
|
+
type: "button",
|
|
3968
|
+
"aria-label": labelForEnv(env, labels),
|
|
3969
|
+
"aria-pressed": isActive,
|
|
3970
|
+
className: cn(
|
|
3971
|
+
"relative min-w-0 font-semibold capitalize",
|
|
3972
|
+
sizes.button,
|
|
3973
|
+
shapeClass
|
|
3974
|
+
),
|
|
3975
|
+
onClick: () => handleSelect(env),
|
|
3976
|
+
children: [
|
|
3977
|
+
/* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: isActive && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3978
|
+
framerMotion.motion.div,
|
|
3979
|
+
{
|
|
3980
|
+
className: cn("absolute inset-0 bg-secondary", shapeClass),
|
|
3981
|
+
layoutId: "activeEnvironment",
|
|
3982
|
+
initial: { opacity: 0 },
|
|
3983
|
+
animate: { opacity: 1 },
|
|
3984
|
+
exit: { opacity: 0 },
|
|
3985
|
+
transition: { type: "spring", duration: 0.5 }
|
|
3986
|
+
}
|
|
3987
|
+
) }),
|
|
3988
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3989
|
+
"span",
|
|
3990
|
+
{
|
|
3991
|
+
className: cn(
|
|
3992
|
+
"relative z-10 flex max-w-[4.5rem] items-center justify-center gap-1 truncate sm:max-w-[6rem]",
|
|
3993
|
+
isActive ? "text-foreground" : "text-muted-foreground"
|
|
3994
|
+
),
|
|
3995
|
+
children: [
|
|
3996
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3997
|
+
"span",
|
|
3998
|
+
{
|
|
3999
|
+
className: cn(
|
|
4000
|
+
"rounded-full shrink-0 ring-1 ring-background",
|
|
4001
|
+
"h-1.5 w-1.5",
|
|
4002
|
+
envDotClass(env)
|
|
4003
|
+
),
|
|
4004
|
+
"aria-hidden": true
|
|
4005
|
+
}
|
|
4006
|
+
),
|
|
4007
|
+
labelForEnv(env, labels)
|
|
4008
|
+
]
|
|
4009
|
+
}
|
|
4010
|
+
)
|
|
4011
|
+
]
|
|
4012
|
+
},
|
|
4013
|
+
env
|
|
4014
|
+
);
|
|
4015
|
+
})
|
|
4016
|
+
]
|
|
4017
|
+
}
|
|
4018
|
+
);
|
|
4019
|
+
}
|
|
4020
|
+
var defaultLabels3 = {
|
|
4021
|
+
stagingMessage: "You are viewing staging data \u2014 changes do not affect live customers.",
|
|
4022
|
+
developmentMessage: "You are viewing development data \u2014 for testing only.",
|
|
4023
|
+
dismiss: "Dismiss"
|
|
4024
|
+
};
|
|
4025
|
+
function EnvironmentBanner({
|
|
4026
|
+
className,
|
|
4027
|
+
environment: propEnvironment,
|
|
4028
|
+
labels: userLabels,
|
|
4029
|
+
enabled = true
|
|
4030
|
+
}) {
|
|
4031
|
+
const ctx = useEnvironmentContext();
|
|
4032
|
+
const labels = { ...defaultLabels3, ...userLabels };
|
|
4033
|
+
const [dismissed, setDismissed] = React2.useState(false);
|
|
4034
|
+
const environment = propEnvironment ?? ctx?.environment ?? "production";
|
|
4035
|
+
const handleDismiss = React2.useCallback(() => {
|
|
4036
|
+
setDismissed(true);
|
|
4037
|
+
}, []);
|
|
4038
|
+
if (!enabled || dismissed || environment === "production") {
|
|
4039
|
+
return null;
|
|
4040
|
+
}
|
|
4041
|
+
const isStaging = environment === "staging";
|
|
4042
|
+
const message = isStaging ? labels.stagingMessage : labels.developmentMessage;
|
|
4043
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4044
|
+
"div",
|
|
4045
|
+
{
|
|
4046
|
+
role: "status",
|
|
4047
|
+
"data-testid": "environment-banner",
|
|
4048
|
+
className: cn(
|
|
4049
|
+
"flex w-full items-center justify-center gap-2 border-b px-3 py-2 text-center text-sm font-medium",
|
|
4050
|
+
isStaging ? "border-orange-500/30 bg-orange-500/15 text-orange-950 dark:text-orange-100" : "border-amber-500/30 bg-amber-500/15 text-amber-950 dark:text-amber-100",
|
|
4051
|
+
className
|
|
4052
|
+
),
|
|
4053
|
+
children: [
|
|
4054
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1", children: message }),
|
|
4055
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4056
|
+
Button,
|
|
4057
|
+
{
|
|
4058
|
+
type: "button",
|
|
4059
|
+
variant: "ghost",
|
|
4060
|
+
size: "icon",
|
|
4061
|
+
className: "h-7 w-7 shrink-0 opacity-80 hover:opacity-100",
|
|
4062
|
+
onClick: handleDismiss,
|
|
4063
|
+
"aria-label": labels.dismiss,
|
|
4064
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-4 w-4" })
|
|
4065
|
+
}
|
|
4066
|
+
)
|
|
4067
|
+
]
|
|
4068
|
+
}
|
|
4069
|
+
);
|
|
4070
|
+
}
|
|
3777
4071
|
function Slider({
|
|
3778
4072
|
className,
|
|
3779
4073
|
defaultValue,
|
|
@@ -6999,6 +7293,7 @@ function formatRelativeTime(dateStr) {
|
|
|
6999
7293
|
|
|
7000
7294
|
exports.AvatarEditor = AvatarEditor;
|
|
7001
7295
|
exports.AvatarEditorDialog = AvatarEditorDialog;
|
|
7296
|
+
exports.BLOCKS_DATA_ENVIRONMENTS = BLOCKS_DATA_ENVIRONMENTS;
|
|
7002
7297
|
exports.Button = Button;
|
|
7003
7298
|
exports.CalendarContext = CalendarContext;
|
|
7004
7299
|
exports.CalendarSubscribeButton = CalendarSubscribeButton;
|
|
@@ -7043,6 +7338,9 @@ exports.DropdownMenuSub = DropdownMenuSub;
|
|
|
7043
7338
|
exports.DropdownMenuSubContent = DropdownMenuSubContent;
|
|
7044
7339
|
exports.DropdownMenuSubTrigger = DropdownMenuSubTrigger;
|
|
7045
7340
|
exports.DropdownMenuTrigger = DropdownMenuTrigger;
|
|
7341
|
+
exports.EnvironmentBanner = EnvironmentBanner;
|
|
7342
|
+
exports.EnvironmentContext = EnvironmentContext;
|
|
7343
|
+
exports.EnvironmentSwitcher = EnvironmentSwitcher;
|
|
7046
7344
|
exports.EventDialog = EventDialog;
|
|
7047
7345
|
exports.EventRsvpBadge = EventRsvpBadge;
|
|
7048
7346
|
exports.LanguageContext = LanguageContext;
|
|
@@ -7067,10 +7365,12 @@ exports.UpcomingEvents = UpcomingEvents;
|
|
|
7067
7365
|
exports.buttonVariants = buttonVariants;
|
|
7068
7366
|
exports.cn = cn;
|
|
7069
7367
|
exports.defaultLanguages = defaultLanguages;
|
|
7368
|
+
exports.isBlocksDataEnvironment = isBlocksDataEnvironment;
|
|
7070
7369
|
exports.toggleVariants = toggleVariants;
|
|
7071
7370
|
exports.useCalendarContext = useCalendarContext;
|
|
7072
7371
|
exports.useChatRoom = useChatRoom;
|
|
7073
7372
|
exports.useChatSidebar = useChatSidebar;
|
|
7373
|
+
exports.useEnvironmentContext = useEnvironmentContext;
|
|
7074
7374
|
exports.useLanguageContext = useLanguageContext;
|
|
7075
7375
|
exports.useNotificationsContext = useNotificationsContext;
|
|
7076
7376
|
//# sourceMappingURL=index.cjs.map
|