pentatrion-design 1.0.2 → 1.0.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/README.md CHANGED
@@ -19,7 +19,7 @@ cd my-app
19
19
  # dépendances
20
20
  pnpm add -D tailwindcss @tailwindcss/vite prettier-plugin-tailwindcss
21
21
 
22
- pnpm add pentatrion-design
22
+ pnpm add pentatrion-design clsx class-variance-authority
23
23
  ```
24
24
  Supprimer les fichiers inutiles
25
25
 
@@ -52,7 +52,8 @@ Configuration recommandée
52
52
  /* src/index.css */
53
53
  @import "tailwindcss";
54
54
 
55
- @source "./node_modules/pentatrion-design/dist/components";
55
+ @source "../node_modules/pentatrion-design/dist/components";
56
+ @source "../node_modules/pentatrion-design/dist/hooks";
56
57
 
57
58
  @import "pentatrion-design/tailwind";
58
59
 
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useAccordion } from "./useAccordion";
2
+ import { useAccordion } from "./useAccordion.js";
3
3
  import clsx from "clsx";
4
4
  export function AccordionItem({ name, children, ...rest }) {
5
5
  const { value } = useAccordion();
@@ -1,5 +1,5 @@
1
1
  import { ComponentProps, RefObject } from "react";
2
- import { ButtonProps } from "./Button";
2
+ import { ButtonProps } from "./Button.js";
3
3
  export type HrefButtonProps = ComponentProps<"a"> & Pick<ButtonProps, "withRipple" | "variant" | "size" | "color" | "selected" | "icon" | "disabled" | "width"> & {
4
4
  ref?: RefObject<HTMLAnchorElement>;
5
5
  };
@@ -1,8 +1,8 @@
1
1
  import { jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useImperativeHandle, useRef } from "react";
3
3
  import clsx from "clsx";
4
- import { useRipple } from "../../hooks/useRipple";
5
- import { buttonVariants } from "./Button";
4
+ import { useRipple } from "../../hooks/useRipple.js";
5
+ import { buttonVariants } from "./Button.js";
6
6
  export function HrefButton({ withRipple = true, variant = "contained", color = "yellow", size = "medium", width = "fit", className, disabled, children, selected = false, icon = false, href, ref, ...props }) {
7
7
  const anchorRef = useRef(null);
8
8
  useImperativeHandle(ref, () => anchorRef.current);
@@ -3,13 +3,16 @@ import { ComponentProps, ReactNode } from "react";
3
3
  import type { ThemeColor } from "../../types";
4
4
  interface Props extends ComponentProps<"div"> {
5
5
  color?: ThemeColor;
6
+ shadow?: boolean;
7
+ rounded?: boolean;
6
8
  placement?: Placement;
7
9
  children: ReactNode;
8
10
  }
9
11
  export declare const dialogVariants: (props?: ({
10
12
  color?: "yellow" | "gray" | "red" | "orange" | "green" | "blue" | "default" | null | undefined;
11
13
  shadow?: boolean | null | undefined;
14
+ rounded?: boolean | null | undefined;
12
15
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
13
- export declare function Dialog({ placement, color, children, className, role, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
16
+ export declare function Dialog({ placement, color, rounded, shadow, children, className, role, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
14
17
  export {};
15
18
  //# sourceMappingURL=Dialog.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../src/components/dialog/Dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,UAAU,KAAM,SAAQ,cAAc,CAAC,KAAK,CAAC;IAC3C,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,cAAc;;;8EAoBzB,CAAC;AAEH,wBAAgB,MAAM,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAe,EAAE,GAAG,IAAI,EAAE,EAAE,KAAK,2CAYhG"}
1
+ {"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../src/components/dialog/Dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,UAAU,KAAM,SAAQ,cAAc,CAAC,KAAK,CAAC;IAC3C,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,cAAc;;;;8EAyBzB,CAAC;AAEH,wBAAgB,MAAM,CAAC,EACrB,SAAS,EACT,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,EACR,SAAS,EACT,IAAe,EACf,GAAG,IAAI,EACR,EAAE,KAAK,2CAYP"}
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import clsx from "clsx";
3
3
  import { cva } from "class-variance-authority";
4
- export const dialogVariants = cva("relative rounded-2xl ", {
4
+ export const dialogVariants = cva("relative", {
5
5
  variants: {
6
6
  color: {
7
7
  yellow: "border-t-4 border-t-yellow-3 bg-gray-0",
@@ -16,12 +16,17 @@ export const dialogVariants = cva("relative rounded-2xl ", {
16
16
  true: "shadow-sm dark:shadow-dark",
17
17
  false: "border border-gray-2",
18
18
  },
19
+ rounded: {
20
+ true: "rounded-2xl",
21
+ false: "",
22
+ },
19
23
  },
20
24
  defaultVariants: {
21
25
  color: "default",
22
26
  shadow: true,
27
+ rounded: true,
23
28
  },
24
29
  });
25
- export function Dialog({ placement, color, children, className, role = "dialog", ...rest }) {
26
- return (_jsx("div", { role: role, className: clsx(dialogVariants({ color }), className), "data-placement": placement, "data-color": color ?? "gray", ...rest, children: children }));
30
+ export function Dialog({ placement, color, rounded, shadow, children, className, role = "dialog", ...rest }) {
31
+ return (_jsx("div", { role: role, className: clsx(dialogVariants({ color, rounded, shadow }), className), "data-placement": placement, "data-color": color ?? "gray", ...rest, children: children }));
27
32
  }
@@ -4,9 +4,9 @@ interface ModalHeaderProps extends ComponentProps<"h2"> {
4
4
  }
5
5
  export declare function ModalHeader({ children, className, closeButton, ...props }: ModalHeaderProps): import("react/jsx-runtime").JSX.Element;
6
6
  interface ModalDescriptionProps extends ComponentProps<"div"> {
7
- height?: number;
7
+ scrollable?: boolean;
8
8
  }
9
- export declare function ModalDescription({ children, className, height, ...props }: ModalDescriptionProps): import("react/jsx-runtime").JSX.Element;
9
+ export declare function ModalDescription({ children, className, scrollable, ...props }: ModalDescriptionProps): import("react/jsx-runtime").JSX.Element;
10
10
  export declare function ModalFooter({ children, className, ...props }: ComponentProps<"footer">): import("react/jsx-runtime").JSX.Element;
11
11
  export {};
12
12
  //# sourceMappingURL=Components.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Components.d.ts","sourceRoot":"","sources":["../../../src/components/modal/Components.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAMvC,UAAU,gBAAiB,SAAQ,cAAc,CAAC,IAAI,CAAC;IACrD,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AACD,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,SAAS,EACT,WAAkB,EAClB,GAAG,KAAK,EACT,EAAE,gBAAgB,2CAiBlB;AAED,UAAU,qBAAsB,SAAQ,cAAc,CAAC,KAAK,CAAC;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AACD,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAAE,qBAAqB,2CAahG;AAED,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,CAAC,QAAQ,CAAC,2CAMtF"}
1
+ {"version":3,"file":"Components.d.ts","sourceRoot":"","sources":["../../../src/components/modal/Components.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAMvC,UAAU,gBAAiB,SAAQ,cAAc,CAAC,IAAI,CAAC;IACrD,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AACD,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,SAAS,EACT,WAAkB,EAClB,GAAG,KAAK,EACT,EAAE,gBAAgB,2CAiBlB;AAED,UAAU,qBAAsB,SAAQ,cAAc,CAAC,KAAK,CAAC;IAC3D,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AACD,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,SAAS,EACT,UAAkB,EAClB,GAAG,KAAK,EACT,EAAE,qBAAqB,2CAavB;AAED,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,CAAC,QAAQ,CAAC,2CAMtF"}
@@ -5,13 +5,13 @@ import { Button } from "../button/Button";
5
5
  import { Scroll } from "../scroll/Scroll";
6
6
  export function ModalHeader({ children, className, closeButton = true, ...props }) {
7
7
  const { setOpen } = useModalContext();
8
- return (_jsxs(_Fragment, { children: [closeButton && (_jsx("div", { className: "float-right p-1", children: _jsx(Button, { icon: true, variant: "text", color: "gray", onClick: () => setOpen(false), children: _jsx("i", { className: "fe-cancel" }) }) })), _jsx("header", { className: clsx("flex items-center px-2 pt-2", className), ...props, children: _jsx("h4", { className: "font-semibold leading-6", children: children }) })] }));
8
+ return (_jsxs(_Fragment, { children: [closeButton && (_jsx("div", { className: "float-right p-1", children: _jsx(Button, { icon: true, variant: "text", color: "gray", onClick: () => setOpen(false), children: _jsx("i", { className: "fe-cancel" }) }) })), _jsx("header", { className: clsx("flex items-center px-2 pt-2", className), ...props, children: _jsx("h4", { className: "leading-6 font-semibold", children: children }) })] }));
9
9
  }
10
- export function ModalDescription({ children, className, height, ...props }) {
11
- if (!height) {
10
+ export function ModalDescription({ children, className, scrollable = false, ...props }) {
11
+ if (!scrollable) {
12
12
  return (_jsx("div", { className: clsx("p-2", className), ...props, children: children }));
13
13
  }
14
- return (_jsx("div", { className: clsx("py-2", className), ...props, children: _jsx(Scroll, { style: { height: `${height}px` }, children: children }) }));
14
+ return (_jsx(Scroll, { className: clsx("flex flex-col", className), ...props, children: children }));
15
15
  }
16
16
  export function ModalFooter({ children, className, ...props }) {
17
17
  return (_jsx("footer", { className: clsx("relative z-10 px-2 pb-2", className), ...props, children: children }));
@@ -13,11 +13,13 @@ export type SelectProps<O extends Option = Option> = {
13
13
  variant?: "normal" | "ghost";
14
14
  showArrow?: boolean;
15
15
  selectionClassName?: string;
16
+ dialogClassName?: string;
16
17
  width?: number | string;
17
18
  floatingMinWidth?: number;
18
19
  placement?: Placement;
19
20
  options: O[];
20
21
  color?: ThemeColor;
22
+ size?: "small" | "medium" | "large" | "custom";
21
23
  placeholder?: string;
22
24
  getSearchableValue?: (matchReg: RegExp, option: O) => string;
23
25
  searchable?: boolean;
@@ -28,7 +30,7 @@ export type SelectProps<O extends Option = Option> = {
28
30
  onChange?: ((e: ChangeEventLike) => void) | null;
29
31
  zIndex?: number;
30
32
  ref?: RefObject<HTMLDivElement>;
31
- } & Omit<ComponentProps<"select">, "onChange" | "value" | "defaultValue" | "multiple">;
32
- export declare function Select<O extends Option>({ id, variant, disabled, showArrow, selectionClassName, width, floatingMinWidth, placement, searchable, required, defaultValue, name, value: controlledValue, onChange, placeholder, getSearchableValue, selectSelectionComponent: SelectSelectionCustomComponent, selectOptionComponent: SelectOptionCustomComponent, options, zIndex, color, ref, onFocus, onBlur, }: SelectProps<O>): import("react/jsx-runtime").JSX.Element;
33
+ } & Omit<ComponentProps<"select">, "onChange" | "value" | "defaultValue" | "multiple" | "size">;
34
+ export declare function Select<O extends Option>({ id, variant, disabled, showArrow, selectionClassName, dialogClassName, width, floatingMinWidth, placement, searchable, required, defaultValue, name, value: controlledValue, onChange, placeholder, getSearchableValue, selectSelectionComponent: SelectSelectionCustomComponent, selectOptionComponent: SelectOptionCustomComponent, options, zIndex, color, size, ref, onFocus, onBlur, }: SelectProps<O>): import("react/jsx-runtime").JSX.Element;
33
35
  export {};
34
36
  //# sourceMappingURL=Select.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/components/select/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EACd,SAAS,EACT,SAAS,EAMV,MAAM,OAAO,CAAC;AACf,OAAO,EAIL,SAAS,EAaV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAmB,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAG1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAM1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAKzC,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;AACrE,KAAK,eAAe,GAAG;IACrB,MAAM,EAAE;QACN,KAAK,EAAE,WAAW,CAAC;KACpB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI;IACnD,OAAO,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC7B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,OAAO,EAAE,CAAC,EAAE,CAAC;IACb,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,WA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C,KAAK,SAAS,CAAC;IACzE,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,eAAe,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;CACjC,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,cAAc,GAAG,UAAU,GAAG,MAAM,CAAC,CAAC;AAMhG,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,EACvC,EAAE,EACF,OAAkB,EAClB,QAAgB,EAChB,SAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,KAAc,EACd,gBAAsB,EACtB,SAAoB,EACpB,UAAkB,EAClB,QAAe,EACf,YAAY,EACZ,IAAS,EACT,KAAK,EAAE,eAAe,EACtB,QAAe,EACf,WAA0B,EAC1B,kBAAkB,EAClB,wBAAwB,EAAE,8BAA8B,EACxD,qBAAqB,EAAE,2BAA2B,EAClD,OAAY,EACZ,MAAM,EACN,KAAgB,EAChB,IAAe,EACf,GAAG,EACH,OAAO,EACP,MAAM,GACP,EAAE,WAAW,CAAC,CAAC,CAAC,2CAuShB"}
@@ -1,18 +1,18 @@
1
1
  import { createElement as _createElement } from "react";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useCallback, useEffect, useMemo, useRef, useState, } from "react";
4
- import { FloatingFocusManager, FloatingList, FloatingPortal, autoUpdate, flip, offset, size, useClick, useDismiss, useFloating, useInteractions, useListNavigation, useMergeRefs, useRole, useTypeahead, } from "@floating-ui/react";
4
+ import { FloatingFocusManager, FloatingList, FloatingPortal, autoUpdate, flip, offset, size as floatingUiSize, useClick, useDismiss, useFloating, useInteractions, useListNavigation, useMergeRefs, useRole, useTypeahead, } from "@floating-ui/react";
5
5
  import { SelectSelection } from "./SelectSelection";
6
6
  import { SelectContext } from "./useSelectContext";
7
7
  import clsx from "clsx";
8
- import { Input } from "../input/Input";
8
+ import { Input, sizeVariant } from "../input/Input";
9
9
  import { Button } from "../button/Button";
10
10
  import { useEffectEvent } from "../../hooks/useEffectEvent";
11
11
  import { Dialog } from "../dialog/Dialog";
12
12
  function defaultGetSearchableValue(matchReg, option) {
13
13
  return matchReg.test(option.label.toLowerCase().trim());
14
14
  }
15
- export function Select({ id, variant = "normal", disabled = false, showArrow = true, selectionClassName, width = "100%", floatingMinWidth = 130, placement = "bottom", searchable = false, required = true, defaultValue, name = "", value: controlledValue, onChange = null, placeholder = "Select ...", getSearchableValue, selectSelectionComponent: SelectSelectionCustomComponent, selectOptionComponent: SelectOptionCustomComponent, options = [], zIndex, color = "yellow", ref, onFocus, onBlur, }) {
15
+ export function Select({ id, variant = "normal", disabled = false, showArrow = true, selectionClassName, dialogClassName, width = "100%", floatingMinWidth = 130, placement = "bottom", searchable = false, required = true, defaultValue, name = "", value: controlledValue, onChange = null, placeholder = "Select ...", getSearchableValue, selectSelectionComponent: SelectSelectionCustomComponent, selectOptionComponent: SelectOptionCustomComponent, options = [], zIndex, color = "yellow", size = "medium", ref, onFocus, onBlur, }) {
16
16
  const isControlled = typeof controlledValue !== "undefined";
17
17
  const divSelectionRef = useRef(null);
18
18
  const onChangeStable = useEffectEvent(onChange);
@@ -60,7 +60,7 @@ export function Select({ id, variant = "normal", disabled = false, showArrow = t
60
60
  middleware: [
61
61
  offset(5),
62
62
  flip({ padding: 10 }),
63
- size({
63
+ floatingUiSize({
64
64
  apply({ rects, elements, availableHeight }) {
65
65
  Object.assign(elements.floating.style, {
66
66
  width: `${Math.max(floatingMinWidth, rects.reference.width)}px`,
@@ -134,17 +134,17 @@ export function Select({ id, variant = "normal", disabled = false, showArrow = t
134
134
  handleSelect,
135
135
  }), [activeIndex, selectedIndex, getItemProps, handleSelect]);
136
136
  const showCancelButton = !required && selectedIndex !== null;
137
- return (_jsxs("div", { children: [_jsx("input", { className: "hidden-focusable", tabIndex: -1, id: id, name: name, value: selectedIndex !== null ? filteredOptions[selectedIndex].value : "", onFocus: () => void divSelectionRef.current.focus(), readOnly: true }), _jsxs("div", { "data-color": color, "aria-disabled": disabled, className: clsx("p8n-input-text box-border flex cursor-pointer rounded-2xl outline-offset-[-1px]", selectionClassName, isOpen && "focus"), "data-variant": variant, ref: mergedRef, tabIndex: 0, style: {
137
+ return (_jsxs("div", { children: [_jsx("input", { className: "hidden-focusable", tabIndex: -1, id: id, name: name, value: selectedIndex !== null ? filteredOptions[selectedIndex].value : "", onFocus: () => void divSelectionRef.current.focus(), readOnly: true }), _jsxs("div", { "data-color": color, "aria-disabled": disabled, className: clsx("p8n-input-text box-border flex cursor-pointer rounded-[calc(var(--h-input)/2)] outline-offset-[-1px]", selectionClassName, sizeVariant[size], isOpen && "focus"), "data-variant": variant, ref: mergedRef, tabIndex: 0, style: {
138
138
  width: typeof width === "number" ? `${width}px` : width,
139
- }, ...getReferenceProps({ onFocus, onBlur }), children: [_jsx("span", { className: "flex h-8 flex-1 items-center truncate px-2", children: selectedIndex !== null ? (_createElement(SelectSelectionComponent, { ...filteredOptions[selectedIndex], key: selectedIndex })) : (placeholder) }), showCancelButton && (_jsx(Button, { withRipple: false, type: "button", icon: true, variant: "text", color: "gray", onMouseDown: (e) => {
139
+ }, ...getReferenceProps({ onFocus, onBlur }), children: [_jsx("span", { className: "flex flex-1 items-center truncate px-2", children: selectedIndex !== null ? (_createElement(SelectSelectionComponent, { ...filteredOptions[selectedIndex], key: selectedIndex })) : (placeholder) }), showCancelButton && (_jsx(Button, { withRipple: false, type: "button", icon: true, variant: "text", color: "gray", onMouseDown: (e) => {
140
140
  // we don't want dropdown to open
141
141
  e.stopPropagation();
142
142
  }, onClick: () => {
143
143
  handleSelect(null);
144
- }, children: _jsx("i", { className: "fe-cancel" }) })), !showCancelButton && showArrow && (_jsx(Button, { color: "gray", withRipple: false, icon: true, variant: "text", focusable: false, type: "button", children: _jsx("i", { className: isOpen ? "fe-angle-up" : "fe-angle-down" }) }))] }), _jsx(FloatingPortal, { children: _jsx(SelectContext.Provider, { value: selectContext, children: isOpen && (_jsx(FloatingFocusManager, { context: context, modal: false, children: _jsx("div", { className: "z-dialog outline-hidden", "data-testid": "select-list", ref: refs.setFloating, style: {
144
+ }, children: _jsx("i", { className: "fe-cancel" }) })), !showCancelButton && showArrow && (_jsx(Button, { color: "gray", withRipple: false, icon: true, variant: "text", focusable: false, type: "button", size: "input", children: _jsx("i", { className: isOpen ? "fe-angle-up" : "fe-angle-down" }) }))] }), _jsx(FloatingPortal, { children: _jsx(SelectContext.Provider, { value: selectContext, children: isOpen && (_jsx(FloatingFocusManager, { context: context, modal: false, children: _jsx("div", { className: "z-dialog outline-hidden", "data-testid": "select-list", ref: refs.setFloating, style: {
145
145
  ...floatingStyles,
146
146
  zIndex,
147
- }, ...getFloatingProps(), children: _jsxs(Dialog, { placement: context.placement, className: "motion-safe:animate-fade-in-list max-h-80 overflow-auto", children: [searchable && (_jsx("div", { className: "p-2", children: _jsx(Input, { color: "gray", placeholder: "Search", tabIndex: selectedIndex === null ? 0 : -1, value: search, onChange: handleSearchChange, onFocus: () => setSearchHasFocus(true), onBlur: () => setSearchHasFocus(false) }) })), SelectOptionCustomComponent ? (_jsx(FloatingList, { elementsRef: listRef, labelsRef: labelsRef, children: filteredOptions.map((option) => (_createElement(SelectOptionCustomComponent, { ...option, key: option.value }))) })) : (filteredOptions.map((option, index) => {
147
+ }, ...getFloatingProps(), children: _jsxs(Dialog, { placement: context.placement, className: clsx("motion-safe:animate-fade-in-list max-h-80 overflow-auto", dialogClassName), rounded: !dialogClassName, children: [searchable && (_jsx("div", { className: "p-2", children: _jsx(Input, { color: "gray", placeholder: "Search", tabIndex: selectedIndex === null ? 0 : -1, value: search, onChange: handleSearchChange, onFocus: () => setSearchHasFocus(true), onBlur: () => setSearchHasFocus(false) }) })), SelectOptionCustomComponent ? (_jsx(FloatingList, { elementsRef: listRef, labelsRef: labelsRef, children: filteredOptions.map((option) => (_createElement(SelectOptionCustomComponent, { ...option, key: option.value }))) })) : (filteredOptions.map((option, index) => {
148
148
  const isActive = activeIndex === index;
149
149
  const isSelected = selectedIndex === index;
150
150
  return (_jsx("button", { className: clsx("option", isSelected ? "bg-gray-2" : isActive && "bg-gray-1"), "data-presentation": "compact", role: "option", "aria-selected": isActive && isSelected, tabIndex: isActive ? 0 : -1, ref: (node) => {
@@ -1,4 +1,4 @@
1
- import { ThemeColor } from "../types";
1
+ import { ThemeColor } from "../types.js";
2
2
  type Variant = {
3
3
  border: string;
4
4
  text: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pentatrion-design",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "Hugues Tavernier",
@@ -24,6 +24,7 @@
24
24
  "@tailwindcss/vite": "^4.1.2",
25
25
  "@testing-library/jest-dom": "^6.6.3",
26
26
  "@testing-library/react": "^16.3.0",
27
+ "@testing-library/dom": "^10",
27
28
  "@testing-library/user-event": "^14.6.1",
28
29
  "@types/geojson": "^7946.0.16",
29
30
  "@types/react": "^19.1.8",
@@ -48,6 +49,7 @@
48
49
  "react-dom": "^19.1.0",
49
50
  "storybook": "^9.0.1",
50
51
  "tailwindcss": "^4.1.10",
52
+ "tsc-alias": "^1.8.16",
51
53
  "tsx": "^4.20.2",
52
54
  "typescript": "^5.8.3",
53
55
  "typescript-eslint": "^8.34.0",
@@ -6,11 +6,13 @@ import { cva } from "class-variance-authority";
6
6
 
7
7
  interface Props extends ComponentProps<"div"> {
8
8
  color?: ThemeColor;
9
+ shadow?: boolean;
10
+ rounded?: boolean;
9
11
  placement?: Placement;
10
12
  children: ReactNode;
11
13
  }
12
14
 
13
- export const dialogVariants = cva("relative rounded-2xl ", {
15
+ export const dialogVariants = cva("relative", {
14
16
  variants: {
15
17
  color: {
16
18
  yellow: "border-t-4 border-t-yellow-3 bg-gray-0",
@@ -25,18 +27,32 @@ export const dialogVariants = cva("relative rounded-2xl ", {
25
27
  true: "shadow-sm dark:shadow-dark",
26
28
  false: "border border-gray-2",
27
29
  },
30
+ rounded: {
31
+ true: "rounded-2xl",
32
+ false: "",
33
+ },
28
34
  },
29
35
  defaultVariants: {
30
36
  color: "default",
31
37
  shadow: true,
38
+ rounded: true,
32
39
  },
33
40
  });
34
41
 
35
- export function Dialog({ placement, color, children, className, role = "dialog", ...rest }: Props) {
42
+ export function Dialog({
43
+ placement,
44
+ color,
45
+ rounded,
46
+ shadow,
47
+ children,
48
+ className,
49
+ role = "dialog",
50
+ ...rest
51
+ }: Props) {
36
52
  return (
37
53
  <div
38
54
  role={role}
39
- className={clsx(dialogVariants({ color }), className)}
55
+ className={clsx(dialogVariants({ color, rounded, shadow }), className)}
40
56
  data-placement={placement}
41
57
  data-color={color ?? "gray"}
42
58
  {...rest}
@@ -25,17 +25,22 @@ export function ModalHeader({
25
25
  </div>
26
26
  )}
27
27
  <header className={clsx("flex items-center px-2 pt-2", className)} {...props}>
28
- <h4 className="font-semibold leading-6">{children}</h4>
28
+ <h4 className="leading-6 font-semibold">{children}</h4>
29
29
  </header>
30
30
  </>
31
31
  );
32
32
  }
33
33
 
34
34
  interface ModalDescriptionProps extends ComponentProps<"div"> {
35
- height?: number;
35
+ scrollable?: boolean;
36
36
  }
37
- export function ModalDescription({ children, className, height, ...props }: ModalDescriptionProps) {
38
- if (!height) {
37
+ export function ModalDescription({
38
+ children,
39
+ className,
40
+ scrollable = false,
41
+ ...props
42
+ }: ModalDescriptionProps) {
43
+ if (!scrollable) {
39
44
  return (
40
45
  <div className={clsx("p-2", className)} {...props}>
41
46
  {children}
@@ -43,9 +48,9 @@ export function ModalDescription({ children, className, height, ...props }: Moda
43
48
  );
44
49
  }
45
50
  return (
46
- <div className={clsx("py-2", className)} {...props}>
47
- <Scroll style={{ height: `${height}px` }}>{children}</Scroll>
48
- </div>
51
+ <Scroll className={clsx("flex flex-col", className)} {...props}>
52
+ {children}
53
+ </Scroll>
49
54
  );
50
55
  }
51
56
 
@@ -153,7 +153,7 @@ export const Scrollable = () => {
153
153
  <ModalTrigger>open scrollable modal</ModalTrigger>
154
154
  <ModalContent>
155
155
  <ModalHeader>Header</ModalHeader>
156
- <ModalDescription height={160}>
156
+ <ModalDescription className="max-h-[80vh]" scrollable={true}>
157
157
  <div className="px-4 text-justify">
158
158
  <p>
159
159
  Lorem ipsum dolor sit amet consectetur adipisicing elit. Praesentium unde, blanditiis
@@ -24,18 +24,49 @@ const meta = {
24
24
  export default meta;
25
25
 
26
26
  export const Basic = () => {
27
+ const [value, setValue] = useState<SelectValue>(null);
28
+ return (
29
+ <>
30
+ <div className="grid grid-cols-1 gap-2">
31
+ <div>UnControlled</div>
32
+ <Select
33
+ searchable={false}
34
+ defaultValue="aixenprovence"
35
+ placeholder="Select your town..."
36
+ options={options}
37
+ ></Select>
38
+ <div>Controlled</div>
39
+ <Select
40
+ searchable={false}
41
+ placeholder="Select your town..."
42
+ options={options}
43
+ value={value}
44
+ onChange={(o) => {
45
+ onChangeAction(o);
46
+ setValue(o.target.value);
47
+ }}
48
+ ></Select>
49
+ </div>
50
+ </>
51
+ );
52
+ };
53
+
54
+ export const Variants = () => {
27
55
  const [value, setValue] = useState<SelectValue>(null);
28
56
  return (
29
57
  <div className="grid grid-cols-1 gap-2">
30
- <div>UnControlled</div>
31
58
  <Select
32
59
  searchable={false}
33
- defaultValue="aixenprovence"
34
60
  placeholder="Select your town..."
35
61
  options={options}
62
+ value={value}
63
+ onChange={(o) => {
64
+ onChangeAction(o);
65
+ setValue(o.target.value);
66
+ }}
36
67
  ></Select>
37
- <div>Controlled</div>
38
68
  <Select
69
+ variant="ghost"
39
70
  searchable={false}
40
71
  placeholder="Select your town..."
41
72
  options={options}
@@ -45,40 +76,36 @@ export const Basic = () => {
45
76
  setValue(o.target.value);
46
77
  }}
47
78
  ></Select>
48
- </div>
49
- );
50
- };
51
-
52
- export const Variants = () => {
53
- const [value, setValue] = useState<SelectValue>(null);
54
- return (
55
- <div className="grid grid-cols-1 gap-2">
56
79
  <Select
57
- searchable={false}
58
80
  placeholder="Select your town..."
59
81
  options={options}
60
- value={value}
82
+ disabled={true}
83
+ value={"aixenprovence"}
61
84
  onChange={(o) => {
62
85
  onChangeAction(o);
63
86
  setValue(o.target.value);
64
87
  }}
65
88
  ></Select>
89
+
66
90
  <Select
67
- variant="ghost"
68
- searchable={false}
69
91
  placeholder="Select your town..."
70
92
  options={options}
93
+ size="large"
94
+ dialogClassName="[--h-input:48px] rounded-[calc(var(--h-input)/2)]"
71
95
  value={value}
72
96
  onChange={(o) => {
73
97
  onChangeAction(o);
74
98
  setValue(o.target.value);
75
99
  }}
76
100
  ></Select>
101
+
77
102
  <Select
78
103
  placeholder="Select your town..."
79
104
  options={options}
80
- disabled={true}
81
- value={"aixenprovence"}
105
+ size="custom"
106
+ selectionClassName="[--h-input:128px] h-(--h-input)"
107
+ dialogClassName="[--h-input:128px] rounded-[calc(var(--h-input)/2)]"
108
+ value={value}
82
109
  onChange={(o) => {
83
110
  onChangeAction(o);
84
111
  setValue(o.target.value);
@@ -17,7 +17,7 @@ import {
17
17
  autoUpdate,
18
18
  flip,
19
19
  offset,
20
- size,
20
+ size as floatingUiSize,
21
21
  useClick,
22
22
  useDismiss,
23
23
  useFloating,
@@ -32,7 +32,7 @@ import { SelectContext } from "./useSelectContext";
32
32
 
33
33
  import type { Option } from "./interface";
34
34
  import clsx from "clsx";
35
- import { Input } from "../input/Input";
35
+ import { Input, sizeVariant } from "../input/Input";
36
36
  import { Button } from "../button/Button";
37
37
  import { useEffectEvent } from "../../hooks/useEffectEvent";
38
38
  import { Dialog } from "../dialog/Dialog";
@@ -52,11 +52,13 @@ export type SelectProps<O extends Option = Option> = {
52
52
  variant?: "normal" | "ghost";
53
53
  showArrow?: boolean;
54
54
  selectionClassName?: string;
55
+ dialogClassName?: string;
55
56
  width?: number | string;
56
57
  floatingMinWidth?: number;
57
58
  placement?: Placement;
58
59
  options: O[];
59
60
  color?: ThemeColor;
61
+ size?: "small" | "medium" | "large" | "custom";
60
62
  placeholder?: string;
61
63
  getSearchableValue?: (matchReg: RegExp, option: O) => string;
62
64
  searchable?: boolean;
@@ -67,7 +69,7 @@ export type SelectProps<O extends Option = Option> = {
67
69
  onChange?: ((e: ChangeEventLike) => void) | null;
68
70
  zIndex?: number;
69
71
  ref?: RefObject<HTMLDivElement>;
70
- } & Omit<ComponentProps<"select">, "onChange" | "value" | "defaultValue" | "multiple">;
72
+ } & Omit<ComponentProps<"select">, "onChange" | "value" | "defaultValue" | "multiple" | "size">;
71
73
 
72
74
  function defaultGetSearchableValue(matchReg: RegExp, option: Option) {
73
75
  return matchReg.test(option.label.toLowerCase().trim());
@@ -79,6 +81,7 @@ export function Select<O extends Option>({
79
81
  disabled = false,
80
82
  showArrow = true,
81
83
  selectionClassName,
84
+ dialogClassName,
82
85
  width = "100%",
83
86
  floatingMinWidth = 130,
84
87
  placement = "bottom",
@@ -95,6 +98,7 @@ export function Select<O extends Option>({
95
98
  options = [],
96
99
  zIndex,
97
100
  color = "yellow",
101
+ size = "medium",
98
102
  ref,
99
103
  onFocus,
100
104
  onBlur,
@@ -157,7 +161,7 @@ export function Select<O extends Option>({
157
161
  middleware: [
158
162
  offset(5),
159
163
  flip({ padding: 10 }),
160
- size({
164
+ floatingUiSize({
161
165
  apply({ rects, elements, availableHeight }) {
162
166
  Object.assign(elements.floating.style, {
163
167
  width: `${Math.max(floatingMinWidth, rects.reference.width)}px`,
@@ -264,8 +268,9 @@ export function Select<O extends Option>({
264
268
  data-color={color}
265
269
  aria-disabled={disabled}
266
270
  className={clsx(
267
- "p8n-input-text box-border flex cursor-pointer rounded-2xl outline-offset-[-1px]",
271
+ "p8n-input-text box-border flex cursor-pointer rounded-[calc(var(--h-input)/2)] outline-offset-[-1px]",
268
272
  selectionClassName,
273
+ sizeVariant[size],
269
274
  isOpen && "focus",
270
275
  )}
271
276
  data-variant={variant}
@@ -276,7 +281,7 @@ export function Select<O extends Option>({
276
281
  }}
277
282
  {...getReferenceProps({ onFocus, onBlur })}
278
283
  >
279
- <span className="flex h-8 flex-1 items-center truncate px-2">
284
+ <span className="flex flex-1 items-center truncate px-2">
280
285
  {selectedIndex !== null ? (
281
286
  <SelectSelectionComponent {...filteredOptions[selectedIndex]} key={selectedIndex} />
282
287
  ) : (
@@ -309,6 +314,7 @@ export function Select<O extends Option>({
309
314
  variant="text"
310
315
  focusable={false}
311
316
  type="button"
317
+ size="input"
312
318
  >
313
319
  <i className={isOpen ? "fe-angle-up" : "fe-angle-down"}></i>
314
320
  </Button>
@@ -330,7 +336,11 @@ export function Select<O extends Option>({
330
336
  >
331
337
  <Dialog
332
338
  placement={context.placement}
333
- className="motion-safe:animate-fade-in-list max-h-80 overflow-auto"
339
+ className={clsx(
340
+ "motion-safe:animate-fade-in-list max-h-80 overflow-auto",
341
+ dialogClassName,
342
+ )}
343
+ rounded={!dialogClassName}
334
344
  >
335
345
  {searchable && (
336
346
  <div className="p-2">
@@ -4,5 +4,8 @@
4
4
  "exclude": ["**/node_modules", "**/*.stories.ts", "**/*.stories.tsx", "**/*.test.ts"],
5
5
  "compilerOptions": {
6
6
  "noEmit": false
7
+ },
8
+ "tsc-alias": {
9
+ "resolveFullPaths": true
7
10
  }
8
11
  }