ruler-components 0.1.4 → 0.1.6
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 +14 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.js +63 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import React__default from 'react';
|
|
2
|
+
import React__default, { ReactNode } from 'react';
|
|
3
3
|
import { LucideIcon } from 'lucide-react';
|
|
4
4
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
5
5
|
import { VariantProps } from 'class-variance-authority';
|
|
@@ -455,4 +455,16 @@ interface TooltipProps extends VariantProps<typeof tooltipVariants> {
|
|
|
455
455
|
}
|
|
456
456
|
declare function Tooltip({ content, children, side, align, sideOffset, delayDuration, disabled, className, }: TooltipProps): React.JSX.Element;
|
|
457
457
|
|
|
458
|
-
|
|
458
|
+
type Theme = "light" | "dark";
|
|
459
|
+
|
|
460
|
+
type ThemeContextValue = {
|
|
461
|
+
theme: Theme;
|
|
462
|
+
setTheme: (theme: Theme) => void;
|
|
463
|
+
};
|
|
464
|
+
declare function ThemeProvider({ children, defaultTheme, }: {
|
|
465
|
+
children: ReactNode;
|
|
466
|
+
defaultTheme?: Theme;
|
|
467
|
+
}): React.JSX.Element;
|
|
468
|
+
declare function useTheme(): ThemeContextValue;
|
|
469
|
+
|
|
470
|
+
export { AILoader, Accordion, AccordionItem, AccordionLink, AccordionNested, AccordionSkeletonChevron, AccordionSkeletonPlus, Alert, type AlertProps, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, Badge, type BadgeProps, BlurReveal, BreadcrumbStepper, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, type CardProps, CardSkeletonGrid, CardTitle, Checkbox, type CheckboxProps, CodeBlock, DataTable, type DataTableColumn, type DataTableProps, Dialog, DialogAction, DialogContent, DialogFooter, DialogHeader, DialogItem, DialogTrigger, DotStepper, DotWave, Dropdown, DropdownContent, DropdownDivider, DropdownItem, DropdownLabel, DropdownTrigger, ExpandableRow, FeatureCard, Field, type FieldProps, HalfCircles, HorizontalStepper, Input, InputAddon, InputAutocomplete, InputFilled, InputFloating, InputIcon, InputOTP, InputPassword, type InputProps, InputSearch, InputStandard, InputUnderline, InteractiveStepper, Label, type LabelProps, ListSkeleton, LoadBar, Menu, MenuDivider, MenuItem, type MenuItemProps, MenuLabel, type MenuProps, Modal, ModalBody, ModalClose, type ModalCloseProps, ModalContent, type ModalContentProps, ModalDescription, ModalFooter, ModalHeader, ModalOption, type ModalProps, ModalTitle, ModalTrigger, type ModalTriggerProps, MorphingLoader, OrbitLoader, Pagination, type PaginationProps, Progress, ProgressBar, type ProgressProps, ProgressRing, ProgressStepper, PulseLoader, Radio, RadioGroup, type RadioGroupProps, type RadioProps, SegmentedStepper, SkeletonShimmer, SpinnerDots, SpinnerGradient, SquaresLoader, type Step, Switch, type SwitchProps, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, TableSkeleton, Tabs, TabsContent, TabsList, TabsTrigger, type Theme, ThemeProvider, ThreeDots, TimelineStepper, Tooltip, type TooltipProps, TypingIndicator, VerticalStepper, avatarVariants, badgeVariants, buttonVariants, checkboxControlVariants, getGradientFromName, getInitials, inputVariants, labelVariants, menuItemVariants, menuVariants, modalContentVariants, overlayVariants, radioControlVariants, useTheme };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import React__default from 'react';
|
|
2
|
+
import React__default, { ReactNode } from 'react';
|
|
3
3
|
import { LucideIcon } from 'lucide-react';
|
|
4
4
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
5
5
|
import { VariantProps } from 'class-variance-authority';
|
|
@@ -455,4 +455,16 @@ interface TooltipProps extends VariantProps<typeof tooltipVariants> {
|
|
|
455
455
|
}
|
|
456
456
|
declare function Tooltip({ content, children, side, align, sideOffset, delayDuration, disabled, className, }: TooltipProps): React.JSX.Element;
|
|
457
457
|
|
|
458
|
-
|
|
458
|
+
type Theme = "light" | "dark";
|
|
459
|
+
|
|
460
|
+
type ThemeContextValue = {
|
|
461
|
+
theme: Theme;
|
|
462
|
+
setTheme: (theme: Theme) => void;
|
|
463
|
+
};
|
|
464
|
+
declare function ThemeProvider({ children, defaultTheme, }: {
|
|
465
|
+
children: ReactNode;
|
|
466
|
+
defaultTheme?: Theme;
|
|
467
|
+
}): React.JSX.Element;
|
|
468
|
+
declare function useTheme(): ThemeContextValue;
|
|
469
|
+
|
|
470
|
+
export { AILoader, Accordion, AccordionItem, AccordionLink, AccordionNested, AccordionSkeletonChevron, AccordionSkeletonPlus, Alert, type AlertProps, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, Badge, type BadgeProps, BlurReveal, BreadcrumbStepper, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, type CardProps, CardSkeletonGrid, CardTitle, Checkbox, type CheckboxProps, CodeBlock, DataTable, type DataTableColumn, type DataTableProps, Dialog, DialogAction, DialogContent, DialogFooter, DialogHeader, DialogItem, DialogTrigger, DotStepper, DotWave, Dropdown, DropdownContent, DropdownDivider, DropdownItem, DropdownLabel, DropdownTrigger, ExpandableRow, FeatureCard, Field, type FieldProps, HalfCircles, HorizontalStepper, Input, InputAddon, InputAutocomplete, InputFilled, InputFloating, InputIcon, InputOTP, InputPassword, type InputProps, InputSearch, InputStandard, InputUnderline, InteractiveStepper, Label, type LabelProps, ListSkeleton, LoadBar, Menu, MenuDivider, MenuItem, type MenuItemProps, MenuLabel, type MenuProps, Modal, ModalBody, ModalClose, type ModalCloseProps, ModalContent, type ModalContentProps, ModalDescription, ModalFooter, ModalHeader, ModalOption, type ModalProps, ModalTitle, ModalTrigger, type ModalTriggerProps, MorphingLoader, OrbitLoader, Pagination, type PaginationProps, Progress, ProgressBar, type ProgressProps, ProgressRing, ProgressStepper, PulseLoader, Radio, RadioGroup, type RadioGroupProps, type RadioProps, SegmentedStepper, SkeletonShimmer, SpinnerDots, SpinnerGradient, SquaresLoader, type Step, Switch, type SwitchProps, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, TableSkeleton, Tabs, TabsContent, TabsList, TabsTrigger, type Theme, ThemeProvider, ThreeDots, TimelineStepper, Tooltip, type TooltipProps, TypingIndicator, VerticalStepper, avatarVariants, badgeVariants, buttonVariants, checkboxControlVariants, getGradientFromName, getInitials, inputVariants, labelVariants, menuItemVariants, menuVariants, modalContentVariants, overlayVariants, radioControlVariants, useTheme };
|
package/dist/index.js
CHANGED
|
@@ -160,6 +160,7 @@ __export(index_exports, {
|
|
|
160
160
|
TabsContent: () => TabsContent,
|
|
161
161
|
TabsList: () => TabsList,
|
|
162
162
|
TabsTrigger: () => TabsTrigger,
|
|
163
|
+
ThemeProvider: () => ThemeProvider,
|
|
163
164
|
ThreeDots: () => ThreeDots,
|
|
164
165
|
TimelineStepper: () => TimelineStepper,
|
|
165
166
|
Tooltip: () => Tooltip,
|
|
@@ -177,7 +178,8 @@ __export(index_exports, {
|
|
|
177
178
|
menuVariants: () => menuVariants,
|
|
178
179
|
modalContentVariants: () => modalContentVariants,
|
|
179
180
|
overlayVariants: () => overlayVariants,
|
|
180
|
-
radioControlVariants: () => radioControlVariants
|
|
181
|
+
radioControlVariants: () => radioControlVariants,
|
|
182
|
+
useTheme: () => useTheme
|
|
181
183
|
});
|
|
182
184
|
module.exports = __toCommonJS(index_exports);
|
|
183
185
|
|
|
@@ -3494,6 +3496,63 @@ function Tooltip({
|
|
|
3494
3496
|
mounted && tooltipNode ? (0, import_react_dom3.createPortal)(tooltipNode, document.body) : null
|
|
3495
3497
|
] });
|
|
3496
3498
|
}
|
|
3499
|
+
|
|
3500
|
+
// components/theme-provider.tsx
|
|
3501
|
+
var import_react11 = require("react");
|
|
3502
|
+
|
|
3503
|
+
// lib/theme.ts
|
|
3504
|
+
var THEME_COOKIE_KEY = "ruler-ui-theme";
|
|
3505
|
+
var THEME_STORAGE_KEY = "ruler-ui-theme";
|
|
3506
|
+
function applyTheme(theme) {
|
|
3507
|
+
document.documentElement.classList.toggle("dark", theme === "dark");
|
|
3508
|
+
}
|
|
3509
|
+
function persistTheme(theme) {
|
|
3510
|
+
localStorage.setItem(THEME_STORAGE_KEY, theme);
|
|
3511
|
+
document.cookie = `${THEME_COOKIE_KEY}=${theme};path=/;max-age=31536000;SameSite=Lax`;
|
|
3512
|
+
}
|
|
3513
|
+
function readStoredTheme() {
|
|
3514
|
+
const fromStorage = localStorage.getItem(THEME_STORAGE_KEY);
|
|
3515
|
+
if (fromStorage === "light" || fromStorage === "dark") {
|
|
3516
|
+
return fromStorage;
|
|
3517
|
+
}
|
|
3518
|
+
const match = document.cookie.match(
|
|
3519
|
+
new RegExp(`(?:^|; )${THEME_COOKIE_KEY}=([^;]*)`)
|
|
3520
|
+
);
|
|
3521
|
+
if ((match == null ? void 0 : match[1]) === "light" || (match == null ? void 0 : match[1]) === "dark") {
|
|
3522
|
+
return match[1];
|
|
3523
|
+
}
|
|
3524
|
+
return null;
|
|
3525
|
+
}
|
|
3526
|
+
|
|
3527
|
+
// components/theme-provider.tsx
|
|
3528
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3529
|
+
var ThemeContext = (0, import_react11.createContext)(null);
|
|
3530
|
+
function ThemeProvider({
|
|
3531
|
+
children,
|
|
3532
|
+
defaultTheme = "light"
|
|
3533
|
+
}) {
|
|
3534
|
+
const [theme, setThemeState] = (0, import_react11.useState)(defaultTheme);
|
|
3535
|
+
(0, import_react11.useEffect)(() => {
|
|
3536
|
+
const stored = readStoredTheme();
|
|
3537
|
+
const resolved = stored != null ? stored : defaultTheme;
|
|
3538
|
+
setThemeState(resolved);
|
|
3539
|
+
applyTheme(resolved);
|
|
3540
|
+
}, [defaultTheme]);
|
|
3541
|
+
const setTheme = (0, import_react11.useCallback)((nextTheme) => {
|
|
3542
|
+
setThemeState(nextTheme);
|
|
3543
|
+
persistTheme(nextTheme);
|
|
3544
|
+
applyTheme(nextTheme);
|
|
3545
|
+
}, []);
|
|
3546
|
+
const value = (0, import_react11.useMemo)(() => ({ theme, setTheme }), [theme, setTheme]);
|
|
3547
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ThemeContext.Provider, { value, children });
|
|
3548
|
+
}
|
|
3549
|
+
function useTheme() {
|
|
3550
|
+
const context = (0, import_react11.useContext)(ThemeContext);
|
|
3551
|
+
if (!context) {
|
|
3552
|
+
throw new Error("useTheme must be used within ThemeProvider");
|
|
3553
|
+
}
|
|
3554
|
+
return context;
|
|
3555
|
+
}
|
|
3497
3556
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3498
3557
|
0 && (module.exports = {
|
|
3499
3558
|
AILoader,
|
|
@@ -3596,6 +3655,7 @@ function Tooltip({
|
|
|
3596
3655
|
TabsContent,
|
|
3597
3656
|
TabsList,
|
|
3598
3657
|
TabsTrigger,
|
|
3658
|
+
ThemeProvider,
|
|
3599
3659
|
ThreeDots,
|
|
3600
3660
|
TimelineStepper,
|
|
3601
3661
|
Tooltip,
|
|
@@ -3613,6 +3673,7 @@ function Tooltip({
|
|
|
3613
3673
|
menuVariants,
|
|
3614
3674
|
modalContentVariants,
|
|
3615
3675
|
overlayVariants,
|
|
3616
|
-
radioControlVariants
|
|
3676
|
+
radioControlVariants,
|
|
3677
|
+
useTheme
|
|
3617
3678
|
});
|
|
3618
3679
|
//# sourceMappingURL=index.js.map
|