pentatrion-design 0.0.5 → 0.0.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.
@@ -182,7 +182,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
182
182
  className,
183
183
  buttonVariants.size(icon, size),
184
184
  buttonVariants.variant[variant](color),
185
- icon && "justify-center [&_:last-child:not(i,img)]:pr-4",
185
+ icon && "justify-center [&_:last-child:not(i,img,svg)]:pr-4",
186
186
  fullWidth && "w-full",
187
187
  selected && "active",
188
188
  notClickable && "disabled",
@@ -0,0 +1,89 @@
1
+ import {
2
+ ComponentPropsWithRef,
3
+ forwardRef,
4
+ useImperativeHandle,
5
+ useRef,
6
+ } from "react";
7
+ import clsx from "clsx";
8
+ import { ThemeColor } from "../../types.d";
9
+ import { useRipple } from "../../hooks";
10
+ import { buttonVariants } from "./Button";
11
+
12
+ export interface LinkButtonProps extends ComponentPropsWithRef<"a"> {
13
+ href: string;
14
+
15
+ withRipple?: boolean;
16
+
17
+ variant?: "contained" | "light" | "outlined" | "text" | "ghost";
18
+
19
+ size?: "small" | "medium" | "large" | "custom";
20
+
21
+ color?: ThemeColor;
22
+
23
+ children?: React.ReactNode;
24
+
25
+ fullWidth?: boolean;
26
+
27
+ focusable?: boolean;
28
+
29
+ /**
30
+ * For a selected item inside a group.
31
+ */
32
+ selected?: boolean;
33
+
34
+ icon?: boolean;
35
+ }
36
+
37
+ export const LinkButton = forwardRef<HTMLAnchorElement, LinkButtonProps>(
38
+ function LinkButton(
39
+ {
40
+ withRipple = true,
41
+ variant = "contained",
42
+ color = "yellow",
43
+ size = "medium",
44
+ focusable = true,
45
+ fullWidth,
46
+ className,
47
+ children,
48
+ selected = false,
49
+ icon = false,
50
+ href,
51
+ ...props
52
+ },
53
+ ref,
54
+ ) {
55
+ const anchorRef = useRef<HTMLAnchorElement>(null);
56
+
57
+ useImperativeHandle<HTMLAnchorElement | null, HTMLAnchorElement | null>(
58
+ ref,
59
+ () => anchorRef.current,
60
+ );
61
+
62
+ const ripples = useRipple(anchorRef);
63
+
64
+ // check if overflow-clip-margin: 1px; is needed ?
65
+ return (
66
+ <a
67
+ tabIndex={focusable ? 0 : -1}
68
+ role="button"
69
+ href={href}
70
+ ref={anchorRef}
71
+ className={clsx(
72
+ "relative inline-flex cursor-pointer items-center overflow-clip border-0 text-center leading-5 no-underline duration-300 focus-visible:outline focus-visible:outline-2 motion-safe:transition-color-shadow",
73
+ icon ? "rounded-full" : "rounded-2xl",
74
+ className,
75
+ buttonVariants.size(icon, size),
76
+ buttonVariants.variant[variant](color),
77
+ icon && "justify-center [&_:last-child:not(i,img)]:pr-4",
78
+ fullWidth && "w-full",
79
+ selected && "active",
80
+ )}
81
+ data-variant={variant}
82
+ {...props}
83
+ >
84
+ {withRipple && ripples}
85
+ {children}
86
+ </a>
87
+ );
88
+ },
89
+ );
@@ -1,2 +1,3 @@
1
1
  export { Button, type ButtonProps, buttonVariants } from "./Button";
2
2
  export { ButtonGroup } from "./ButtonGroup";
3
+ export { LinkButton } from "./LinkButton";
@@ -35,7 +35,7 @@ export const Toggle = forwardRef<HTMLInputElement, ToggleProps>(
35
35
  disabled={disabled}
36
36
  type="checkbox"
37
37
  className={clsx(
38
- "p8n-input-toggle ll-toggle p8n-input-checkbox relative mr-1 box-border inline-block h-[18px] w-[30px] appearance-none rounded-xl bg-gray-1 after:absolute after:left-[3px] after:top-[3px] after:h-[12px] after:w-[12px] after:rounded-full after:bg-gray-2 after:outline after:outline-1 after:outline-gray-3 after:transition-all after:duration-100 checked:bg-gray-2 checked:after:translate-x-[12px] checked:after:bg-current checked:after:outline-current",
38
+ "p8n-input-toggle ll-toggle p8n-input-checkbox relative mr-1 box-border inline-block h-[18px] w-[30px] cursor-pointer appearance-none rounded-xl bg-gray-1 after:absolute after:left-[3px] after:top-[3px] after:h-[12px] after:w-[12px] after:rounded-full after:bg-gray-2 after:outline after:outline-1 after:outline-gray-3 after:transition-all after:duration-100 checked:bg-gray-2 checked:after:translate-x-[12px] checked:after:bg-current checked:after:outline-current",
39
39
  className,
40
40
  )}
41
41
  checked={checked}
@@ -1,17 +1,26 @@
1
- import { useCallback, useEffect } from "react";
1
+ import { ComponentProps, useCallback, useEffect } from "react";
2
2
  import clsx from "clsx";
3
3
 
4
- interface Props {
4
+ interface Props extends ComponentProps<"div"> {
5
5
  name: string;
6
6
  position: "top" | "bottom" | "left" | "right";
7
7
  initialValue?: number;
8
8
  }
9
9
 
10
- export function ResizeArea({ name, position, initialValue }: Props) {
10
+ export function ResizeArea({
11
+ name,
12
+ position,
13
+ initialValue,
14
+ className,
15
+ ...rest
16
+ }: Props) {
11
17
  useEffect(() => {
12
18
  const cssVarName = `--sidebar-${name}-${["top", "bottom"].includes(position) ? "height" : "width"}`;
13
19
  if (initialValue) {
14
- document.documentElement.style.setProperty(cssVarName, `${initialValue}px`);
20
+ document.documentElement.style.setProperty(
21
+ cssVarName,
22
+ `${initialValue}px`,
23
+ );
15
24
  }
16
25
  // we want to set the initial value, we don't want this value to be updated after
17
26
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -43,7 +52,10 @@ export function ResizeArea({ name, position, initialValue }: Props) {
43
52
  cssVarValue = e.pageY;
44
53
  break;
45
54
  }
46
- document.documentElement.style.setProperty(cssVarName, `${cssVarValue}px`);
55
+ document.documentElement.style.setProperty(
56
+ cssVarName,
57
+ `${cssVarValue}px`,
58
+ );
47
59
  return () => {
48
60
  document.documentElement.style.removeProperty(cssVarName);
49
61
  };
@@ -54,7 +66,10 @@ export function ResizeArea({ name, position, initialValue }: Props) {
54
66
  const handlePointerUp = useCallback(() => {
55
67
  const handler = handlePointerMove;
56
68
  document.removeEventListener("pointermove", handler);
57
- document.documentElement.classList.remove("cursor-row-resize", "cursor-col-resize");
69
+ document.documentElement.classList.remove(
70
+ "cursor-row-resize",
71
+ "cursor-col-resize",
72
+ );
58
73
 
59
74
  return () => {
60
75
  document.removeEventListener("pointermove", handler);
@@ -72,8 +87,12 @@ export function ResizeArea({ name, position, initialValue }: Props) {
72
87
  }
73
88
 
74
89
  return (
75
- <div className={clsx(["p8n-resize-area", position])}>
76
- <button className="area-button" type="button" onPointerDown={handlePointerDown}></button>
90
+ <div className={clsx(["p8n-resize-area", position, className])} {...rest}>
91
+ <button
92
+ className="area-button"
93
+ type="button"
94
+ onPointerDown={handlePointerDown}
95
+ ></button>
77
96
  </div>
78
97
  );
79
98
  }
package/dist/index.d.ts CHANGED
@@ -217,6 +217,23 @@ interface Props$A extends ComponentProps<"div"> {
217
217
  }
218
218
  declare function ButtonGroup({ children, className, direction }: Props$A): react_jsx_runtime.JSX.Element;
219
219
 
220
+ interface LinkButtonProps extends ComponentPropsWithRef<"a"> {
221
+ href: string;
222
+ withRipple?: boolean;
223
+ variant?: "contained" | "light" | "outlined" | "text" | "ghost";
224
+ size?: "small" | "medium" | "large" | "custom";
225
+ color?: ThemeColor;
226
+ children?: React.ReactNode;
227
+ fullWidth?: boolean;
228
+ focusable?: boolean;
229
+ /**
230
+ * For a selected item inside a group.
231
+ */
232
+ selected?: boolean;
233
+ icon?: boolean;
234
+ }
235
+ declare const LinkButton: (props: LinkButtonProps & react.RefAttributes<HTMLAnchorElement>) => react.ReactElement<any, string | react.JSXElementConstructor<any>> | null;
236
+
220
237
  declare const cardConfig: {
221
238
  item: string;
222
239
  group: string;
@@ -862,12 +879,12 @@ interface Props$f {
862
879
  }
863
880
  declare const Portal: ({ children }: Props$f) => react.ReactPortal;
864
881
 
865
- interface Props$e {
882
+ interface Props$e extends ComponentProps<"div"> {
866
883
  name: string;
867
884
  position: "top" | "bottom" | "left" | "right";
868
885
  initialValue?: number;
869
886
  }
870
- declare function ResizeArea({ name, position, initialValue }: Props$e): react_jsx_runtime.JSX.Element;
887
+ declare function ResizeArea({ name, position, initialValue, className, ...rest }: Props$e): react_jsx_runtime.JSX.Element;
871
888
 
872
889
  interface Props$d extends ComponentPropsWithoutRef<"div"> {
873
890
  horizontal?: boolean;
@@ -1166,4 +1183,4 @@ declare const pentatrionTw: {
1166
1183
  __isOptionsFunction: true;
1167
1184
  };
1168
1185
 
1169
- export { _default as Autocomplete, _default$1 as AutocompleteOption, type AutocompleteProps, Badge, Button, ButtonGroup, type ButtonProps, Checkbox, Code, ContextMenu, ContextMenuItem, type ContextMenuItemMouseEvent, type CustomFetchOptions, Dialog, DropdownMenu, DropdownMenuContent, DropdownMenuContext, DropdownMenuItem, DropdownMenuNested, type DropdownMenuOptions, DropdownMenuTrigger, FetchError, Flash, Highlight, Href, Input, InputField, LazyAutocomplete, Loader, MenuItem, MenuItemWithChildren, Modal, ModalContent, ModalContext, ModalDescription, ModalFooter, ModalHeader, type ModalOptions, ModalTrigger, type NoDataOption, NotificationsContext, NotificationsProvider, type Option, type OptionLike, Popover, PopoverContent, PopoverContext, PopoverDescription, PopoverFooter, PopoverHeader, type PopoverOptions, PopoverTrigger, Portal, Radio, RadioGroup, Range, ResizeArea, Scroll, Select, SelectContext, SelectOption, SelectSelection, type SelectSelectionProps, SimpleAutocomplete, SimpleTooltip, Snack, Sortable, type SortableItem, Step, Steps, Table, TableBody, TableCell, TableFooter, TableHeader, TableHeaderCell, TableRow, Tabs, type ThemeColor, Toggle, Tooltip, TooltipContent, TooltipContext, TooltipTrigger, arrayEquals, buttonVariants, cardConfig, colorVariants, createNotificationsManager, dialogVariants, fetchAPI, getIndexLetter, getOptionLabel, getOptionValue, inputConfig, isErrorLike, parseError, pentatrionTw, useAutocomplete, useCombinedRefs, useContextNotifications, useCopyToClipboard, useDebounce, useDropdownMenu, useDropdownMenuContext, useEventCallback, useEventListener, useFetch, useIsClosing, useIsMounted, useIsomorphicLayoutEffect, useModal, useModalContext, useOnClickOutside, usePopover, usePopoverContext, usePrevious, useRefDebounce, useRipple, useSelect, useStateDebounce, useTooltip, useTooltipContext };
1186
+ export { _default as Autocomplete, _default$1 as AutocompleteOption, type AutocompleteProps, Badge, Button, ButtonGroup, type ButtonProps, Checkbox, Code, ContextMenu, ContextMenuItem, type ContextMenuItemMouseEvent, type CustomFetchOptions, Dialog, DropdownMenu, DropdownMenuContent, DropdownMenuContext, DropdownMenuItem, DropdownMenuNested, type DropdownMenuOptions, DropdownMenuTrigger, FetchError, Flash, Highlight, Href, Input, InputField, LazyAutocomplete, LinkButton, Loader, MenuItem, MenuItemWithChildren, Modal, ModalContent, ModalContext, ModalDescription, ModalFooter, ModalHeader, type ModalOptions, ModalTrigger, type NoDataOption, NotificationsContext, NotificationsProvider, type Option, type OptionLike, Popover, PopoverContent, PopoverContext, PopoverDescription, PopoverFooter, PopoverHeader, type PopoverOptions, PopoverTrigger, Portal, Radio, RadioGroup, Range, ResizeArea, Scroll, Select, SelectContext, SelectOption, SelectSelection, type SelectSelectionProps, SimpleAutocomplete, SimpleTooltip, Snack, Sortable, type SortableItem, Step, Steps, Table, TableBody, TableCell, TableFooter, TableHeader, TableHeaderCell, TableRow, Tabs, type ThemeColor, Toggle, Tooltip, TooltipContent, TooltipContext, TooltipTrigger, arrayEquals, buttonVariants, cardConfig, colorVariants, createNotificationsManager, dialogVariants, fetchAPI, getIndexLetter, getOptionLabel, getOptionValue, inputConfig, isErrorLike, parseError, pentatrionTw, useAutocomplete, useCombinedRefs, useContextNotifications, useCopyToClipboard, useDebounce, useDropdownMenu, useDropdownMenuContext, useEventCallback, useEventListener, useFetch, useIsClosing, useIsMounted, useIsomorphicLayoutEffect, useModal, useModalContext, useOnClickOutside, usePopover, usePopoverContext, usePrevious, useRefDebounce, useRipple, useSelect, useStateDebounce, useTooltip, useTooltipContext };