@eqtylab/equality 3.2.3 → 3.2.4
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/code-block.module.module.css.module.css +100 -5
- package/dist/global-theme-config.css +5 -3
- package/dist/index.cjs +117 -122
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +118 -121
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React15 from 'react';
|
|
2
|
-
import { forwardRef, useState, useRef, useEffect, useMemo,
|
|
2
|
+
import { forwardRef, useState, useRef, useEffect, useMemo, useCallback, useLayoutEffect, createElement, useSyncExternalStore } from 'react';
|
|
3
3
|
import { cva } from 'class-variance-authority';
|
|
4
4
|
import styles2 from './alert.module.module.css.module.css';
|
|
5
5
|
import * as LucideIcons from 'lucide-react';
|
|
@@ -25,8 +25,6 @@ import styles12 from './card.module.module.css.module.css';
|
|
|
25
25
|
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
26
26
|
import styles13 from './checkbox.module.module.css.module.css';
|
|
27
27
|
import { Prism } from 'react-syntax-highlighter';
|
|
28
|
-
import darkStyle from 'react-syntax-highlighter/dist/esm/styles/prism/a11y-dark';
|
|
29
|
-
import lightStyle from 'react-syntax-highlighter/dist/esm/styles/prism/prism';
|
|
30
28
|
import styles15 from './code-block.module.module.css.module.css';
|
|
31
29
|
import styles14 from './icon-button.module.module.css.module.css';
|
|
32
30
|
import { Command as Command$1 } from 'cmdk';
|
|
@@ -1117,122 +1115,6 @@ function CopyButton({
|
|
|
1117
1115
|
}
|
|
1118
1116
|
);
|
|
1119
1117
|
}
|
|
1120
|
-
|
|
1121
|
-
// src/theme/lib/utils.ts
|
|
1122
|
-
var STORAGE_KEY = "equality-theme";
|
|
1123
|
-
var UPDATE_EVENT = "equality-theme-change";
|
|
1124
|
-
var FALLBACK_THEME = "light";
|
|
1125
|
-
var getFallbackTheme = (options = {}) => {
|
|
1126
|
-
const { canFallbackToBrowserSettings = false } = options;
|
|
1127
|
-
if (typeof window === "undefined" || !canFallbackToBrowserSettings) {
|
|
1128
|
-
return FALLBACK_THEME;
|
|
1129
|
-
}
|
|
1130
|
-
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
1131
|
-
};
|
|
1132
|
-
var getDefaultTheme = () => {
|
|
1133
|
-
const themeProviderRootElement = document.querySelector("[data-equality-theme]") || document.documentElement;
|
|
1134
|
-
if (themeProviderRootElement) {
|
|
1135
|
-
return themeProviderRootElement.getAttribute("data-equality-theme") || void 0;
|
|
1136
|
-
} else {
|
|
1137
|
-
return void 0;
|
|
1138
|
-
}
|
|
1139
|
-
};
|
|
1140
|
-
var getThemeFromLocalStorage = () => {
|
|
1141
|
-
const safeReadStorage = (key) => {
|
|
1142
|
-
try {
|
|
1143
|
-
return window.localStorage.getItem(key);
|
|
1144
|
-
} catch {
|
|
1145
|
-
return null;
|
|
1146
|
-
}
|
|
1147
|
-
};
|
|
1148
|
-
const themeLocalStorageValue = safeReadStorage(STORAGE_KEY);
|
|
1149
|
-
return themeLocalStorageValue;
|
|
1150
|
-
};
|
|
1151
|
-
var getThemeFromWindow = () => {
|
|
1152
|
-
return window.__equalityTheme;
|
|
1153
|
-
};
|
|
1154
|
-
var applyThemeToDom = (theme) => {
|
|
1155
|
-
const themeProviderRootElement = document.querySelector("[data-equality-theme]") || document.documentElement;
|
|
1156
|
-
if (themeProviderRootElement) {
|
|
1157
|
-
themeProviderRootElement.setAttribute("data-equality-theme", theme);
|
|
1158
|
-
}
|
|
1159
|
-
};
|
|
1160
|
-
var setThemeInLocalStorage = (theme) => {
|
|
1161
|
-
try {
|
|
1162
|
-
window.localStorage.setItem(STORAGE_KEY, theme);
|
|
1163
|
-
window.dispatchEvent(new CustomEvent(UPDATE_EVENT, { detail: theme }));
|
|
1164
|
-
} catch {
|
|
1165
|
-
console.error("Failed to set theme in localStorage");
|
|
1166
|
-
}
|
|
1167
|
-
};
|
|
1168
|
-
var setThemeOnWindow = (theme) => {
|
|
1169
|
-
window.__equalityTheme = theme;
|
|
1170
|
-
window.dispatchEvent(new CustomEvent(UPDATE_EVENT, { detail: theme }));
|
|
1171
|
-
};
|
|
1172
|
-
var setTheme = (theme) => {
|
|
1173
|
-
const isUsingLocalStorage = window.__equalityIsUsingLocalStorage;
|
|
1174
|
-
if (isUsingLocalStorage) {
|
|
1175
|
-
setThemeInLocalStorage(theme);
|
|
1176
|
-
} else {
|
|
1177
|
-
setThemeOnWindow(theme);
|
|
1178
|
-
}
|
|
1179
|
-
applyThemeToDom(theme);
|
|
1180
|
-
};
|
|
1181
|
-
var getCurrentThemeState = (options = {}) => {
|
|
1182
|
-
const { canFallbackToBrowserSettings = false } = options;
|
|
1183
|
-
if (typeof window === "undefined") {
|
|
1184
|
-
return void 0;
|
|
1185
|
-
}
|
|
1186
|
-
const isUsingLocalStorage = window.__equalityIsUsingLocalStorage;
|
|
1187
|
-
const storedTheme = isUsingLocalStorage ? getThemeFromLocalStorage() : getThemeFromWindow();
|
|
1188
|
-
const theme = storedTheme || getDefaultTheme() || getFallbackTheme({ canFallbackToBrowserSettings });
|
|
1189
|
-
if (!storedTheme) {
|
|
1190
|
-
setTheme(theme);
|
|
1191
|
-
}
|
|
1192
|
-
return theme;
|
|
1193
|
-
};
|
|
1194
|
-
var subscribeToThemeChange = (listener) => {
|
|
1195
|
-
if (typeof window === "undefined") {
|
|
1196
|
-
return () => {
|
|
1197
|
-
};
|
|
1198
|
-
}
|
|
1199
|
-
const isUsingLocalStorage = window.__equalityIsUsingLocalStorage;
|
|
1200
|
-
if (isUsingLocalStorage) {
|
|
1201
|
-
const storageListener = (event) => {
|
|
1202
|
-
if (event.key === STORAGE_KEY) listener();
|
|
1203
|
-
};
|
|
1204
|
-
const updateListener = () => listener();
|
|
1205
|
-
window.addEventListener("storage", storageListener);
|
|
1206
|
-
window.addEventListener(UPDATE_EVENT, updateListener);
|
|
1207
|
-
return () => {
|
|
1208
|
-
window.removeEventListener("storage", storageListener);
|
|
1209
|
-
window.removeEventListener(UPDATE_EVENT, updateListener);
|
|
1210
|
-
};
|
|
1211
|
-
} else {
|
|
1212
|
-
const windowListener = () => {
|
|
1213
|
-
listener();
|
|
1214
|
-
};
|
|
1215
|
-
window.addEventListener(UPDATE_EVENT, windowListener);
|
|
1216
|
-
return () => {
|
|
1217
|
-
window.removeEventListener(UPDATE_EVENT, windowListener);
|
|
1218
|
-
};
|
|
1219
|
-
}
|
|
1220
|
-
};
|
|
1221
|
-
|
|
1222
|
-
// src/theme/hooks/use-theme.ts
|
|
1223
|
-
var subscribe = (listener) => {
|
|
1224
|
-
return subscribeToThemeChange(listener);
|
|
1225
|
-
};
|
|
1226
|
-
var getSnapshot = () => {
|
|
1227
|
-
return getCurrentThemeState();
|
|
1228
|
-
};
|
|
1229
|
-
var getServerSnapshot = () => {
|
|
1230
|
-
return void 0;
|
|
1231
|
-
};
|
|
1232
|
-
var useTheme = () => {
|
|
1233
|
-
const theme = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
1234
|
-
return [theme, setTheme];
|
|
1235
|
-
};
|
|
1236
1118
|
var WRAP = true;
|
|
1237
1119
|
var CodeBlock = ({
|
|
1238
1120
|
className,
|
|
@@ -1243,7 +1125,6 @@ var CodeBlock = ({
|
|
|
1243
1125
|
codeLabel,
|
|
1244
1126
|
copy
|
|
1245
1127
|
}) => {
|
|
1246
|
-
const [theme] = useTheme();
|
|
1247
1128
|
return /* @__PURE__ */ jsxs("div", { className: cn(styles15["code-block"], styles15[variant], className), children: [
|
|
1248
1129
|
/* @__PURE__ */ jsxs("div", { className: styles15.header, children: [
|
|
1249
1130
|
/* @__PURE__ */ jsxs("div", { className: styles15["header-left"], children: [
|
|
@@ -1256,7 +1137,7 @@ var CodeBlock = ({
|
|
|
1256
1137
|
Prism,
|
|
1257
1138
|
{
|
|
1258
1139
|
language,
|
|
1259
|
-
|
|
1140
|
+
useInlineStyles: false,
|
|
1260
1141
|
wrapLines: WRAP,
|
|
1261
1142
|
wrapLongLines: WRAP,
|
|
1262
1143
|
className: styles15.pre,
|
|
@@ -4181,6 +4062,122 @@ var ThemeProvider = ({ customVars, portalContainer, children }) => {
|
|
|
4181
4062
|
) });
|
|
4182
4063
|
};
|
|
4183
4064
|
|
|
4065
|
+
// src/theme/lib/utils.ts
|
|
4066
|
+
var STORAGE_KEY = "equality-theme";
|
|
4067
|
+
var UPDATE_EVENT = "equality-theme-change";
|
|
4068
|
+
var FALLBACK_THEME = "light";
|
|
4069
|
+
var getFallbackTheme = (options = {}) => {
|
|
4070
|
+
const { canFallbackToBrowserSettings = false } = options;
|
|
4071
|
+
if (typeof window === "undefined" || !canFallbackToBrowserSettings) {
|
|
4072
|
+
return FALLBACK_THEME;
|
|
4073
|
+
}
|
|
4074
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
4075
|
+
};
|
|
4076
|
+
var getDefaultTheme = () => {
|
|
4077
|
+
const themeProviderRootElement = document.querySelector("[data-equality-theme]") || document.documentElement;
|
|
4078
|
+
if (themeProviderRootElement) {
|
|
4079
|
+
return themeProviderRootElement.getAttribute("data-equality-theme") || void 0;
|
|
4080
|
+
} else {
|
|
4081
|
+
return void 0;
|
|
4082
|
+
}
|
|
4083
|
+
};
|
|
4084
|
+
var getThemeFromLocalStorage = () => {
|
|
4085
|
+
const safeReadStorage = (key) => {
|
|
4086
|
+
try {
|
|
4087
|
+
return window.localStorage.getItem(key);
|
|
4088
|
+
} catch {
|
|
4089
|
+
return null;
|
|
4090
|
+
}
|
|
4091
|
+
};
|
|
4092
|
+
const themeLocalStorageValue = safeReadStorage(STORAGE_KEY);
|
|
4093
|
+
return themeLocalStorageValue;
|
|
4094
|
+
};
|
|
4095
|
+
var getThemeFromWindow = () => {
|
|
4096
|
+
return window.__equalityTheme;
|
|
4097
|
+
};
|
|
4098
|
+
var applyThemeToDom = (theme) => {
|
|
4099
|
+
const themeProviderRootElement = document.querySelector("[data-equality-theme]") || document.documentElement;
|
|
4100
|
+
if (themeProviderRootElement) {
|
|
4101
|
+
themeProviderRootElement.setAttribute("data-equality-theme", theme);
|
|
4102
|
+
}
|
|
4103
|
+
};
|
|
4104
|
+
var setThemeInLocalStorage = (theme) => {
|
|
4105
|
+
try {
|
|
4106
|
+
window.localStorage.setItem(STORAGE_KEY, theme);
|
|
4107
|
+
window.dispatchEvent(new CustomEvent(UPDATE_EVENT, { detail: theme }));
|
|
4108
|
+
} catch {
|
|
4109
|
+
console.error("Failed to set theme in localStorage");
|
|
4110
|
+
}
|
|
4111
|
+
};
|
|
4112
|
+
var setThemeOnWindow = (theme) => {
|
|
4113
|
+
window.__equalityTheme = theme;
|
|
4114
|
+
window.dispatchEvent(new CustomEvent(UPDATE_EVENT, { detail: theme }));
|
|
4115
|
+
};
|
|
4116
|
+
var setTheme = (theme) => {
|
|
4117
|
+
const isUsingLocalStorage = window.__equalityIsUsingLocalStorage;
|
|
4118
|
+
if (isUsingLocalStorage) {
|
|
4119
|
+
setThemeInLocalStorage(theme);
|
|
4120
|
+
} else {
|
|
4121
|
+
setThemeOnWindow(theme);
|
|
4122
|
+
}
|
|
4123
|
+
applyThemeToDom(theme);
|
|
4124
|
+
};
|
|
4125
|
+
var getCurrentThemeState = (options = {}) => {
|
|
4126
|
+
const { canFallbackToBrowserSettings = false } = options;
|
|
4127
|
+
if (typeof window === "undefined") {
|
|
4128
|
+
return void 0;
|
|
4129
|
+
}
|
|
4130
|
+
const isUsingLocalStorage = window.__equalityIsUsingLocalStorage;
|
|
4131
|
+
const storedTheme = isUsingLocalStorage ? getThemeFromLocalStorage() : getThemeFromWindow();
|
|
4132
|
+
const theme = storedTheme || getDefaultTheme() || getFallbackTheme({ canFallbackToBrowserSettings });
|
|
4133
|
+
if (!storedTheme) {
|
|
4134
|
+
setTheme(theme);
|
|
4135
|
+
}
|
|
4136
|
+
return theme;
|
|
4137
|
+
};
|
|
4138
|
+
var subscribeToThemeChange = (listener) => {
|
|
4139
|
+
if (typeof window === "undefined") {
|
|
4140
|
+
return () => {
|
|
4141
|
+
};
|
|
4142
|
+
}
|
|
4143
|
+
const isUsingLocalStorage = window.__equalityIsUsingLocalStorage;
|
|
4144
|
+
if (isUsingLocalStorage) {
|
|
4145
|
+
const storageListener = (event) => {
|
|
4146
|
+
if (event.key === STORAGE_KEY) listener();
|
|
4147
|
+
};
|
|
4148
|
+
const updateListener = () => listener();
|
|
4149
|
+
window.addEventListener("storage", storageListener);
|
|
4150
|
+
window.addEventListener(UPDATE_EVENT, updateListener);
|
|
4151
|
+
return () => {
|
|
4152
|
+
window.removeEventListener("storage", storageListener);
|
|
4153
|
+
window.removeEventListener(UPDATE_EVENT, updateListener);
|
|
4154
|
+
};
|
|
4155
|
+
} else {
|
|
4156
|
+
const windowListener = () => {
|
|
4157
|
+
listener();
|
|
4158
|
+
};
|
|
4159
|
+
window.addEventListener(UPDATE_EVENT, windowListener);
|
|
4160
|
+
return () => {
|
|
4161
|
+
window.removeEventListener(UPDATE_EVENT, windowListener);
|
|
4162
|
+
};
|
|
4163
|
+
}
|
|
4164
|
+
};
|
|
4165
|
+
|
|
4166
|
+
// src/theme/hooks/use-theme.ts
|
|
4167
|
+
var subscribe = (listener) => {
|
|
4168
|
+
return subscribeToThemeChange(listener);
|
|
4169
|
+
};
|
|
4170
|
+
var getSnapshot = () => {
|
|
4171
|
+
return getCurrentThemeState();
|
|
4172
|
+
};
|
|
4173
|
+
var getServerSnapshot = () => {
|
|
4174
|
+
return void 0;
|
|
4175
|
+
};
|
|
4176
|
+
var useTheme = () => {
|
|
4177
|
+
const theme = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
4178
|
+
return [theme, setTheme];
|
|
4179
|
+
};
|
|
4180
|
+
|
|
4184
4181
|
export { Alert, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, Avatar, AvatarFallback, AvatarImage, Badge, BarGraph, BarGraphSegment, BgGradient, Button, Card, CardContent, CardContentHeader, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CodeBlock, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ControlStatusBadge, CopyButton, DateRangePicker, Dialog, DialogClose, DialogContainer, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogHeaderIcon, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DisplayField, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerHeaderActions, DrawerInnerContent, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuEmpty, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSearch, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, ELEVATION, EmptyTableState, FilterDropdown, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, FormatDate, Heading, Icon, IconButton, InfoCard, Input, Label2 as Label, ListOrGridViewToggle, LoadingOverlay, MetricCard, MotionCollapsibleContent, NotFound, PORTAL_ROOT_ID, Pagination, PanelLabel, Popover, PopoverContent, PopoverTrigger, PortalContainerProvider, Progress, ProgressIndicator, ProgressIndicatorStep, RadialGraph, RadioDropdown, RadioGroup2 as RadioGroup, RadioGroupItem, ResourceBadge, ScrollArea, ScrollBar, SearchBar, SectionHeading, SegmentedControls, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator3 as Separator, Sheet, SheetClose, SheetContainer, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetHeaderIcon, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, Skeleton, SortButton, SortSelector, Spinner, Switch, TableBody, TableCaption, TableCell, TableContainer, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContainer, TabsContent, TabsList, TabsTrigger, Textarea, ThemeProvider, Toast, ToastAction, ToastClose, ToastContainer, ToastDescription, ToastProvider, ToastRoot, ToastTitle, ToastViewport, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TruncatedDescription, badgeVariants, buttonVariants, reducer, toast, useFormField, usePortalContainer, useTheme, useToast };
|
|
4185
4182
|
//# sourceMappingURL=index.js.map
|
|
4186
4183
|
//# sourceMappingURL=index.js.map
|