pentatrion-design 0.0.17 → 0.0.19

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.
@@ -7,15 +7,11 @@ export interface AutocompleteProps<O extends OptionLike = Option> {
7
7
  className?: string;
8
8
  icon?: boolean | ReactNode;
9
9
  color?: ThemeColor;
10
- /**
11
- * render suffix only if selection
12
- * ex: add contextuel buttons associated to selection
13
- */
14
- selectionSuffix?: ReactNode;
15
10
  /**
16
11
  * render suffix only if selection and searchValue is empty
17
12
  */
18
13
  noSearchSuffix?: ReactNode;
14
+ suffix?: ReactNode;
19
15
  placement?: Placement;
20
16
  placeholder?: string;
21
17
  /**
@@ -11,7 +11,7 @@ import { Button } from "../button";
11
11
  import { Dialog } from "../dialog";
12
12
  import { Loader } from "../loader";
13
13
  import { inputConfig } from "../input/Input";
14
- export const Autocomplete = forwardRef(function Autocomplete({ className, icon = true, color = "yellow", selectionSuffix, noSearchSuffix, placement = "bottom", placeholder = "Search...", selection = null, onChangeSelection, autocompleteOptionComponent, loading = false, clearSearchButton = false, searchValue, onChangeSearchValue, options, selectOnFocus = true, readOnly = false, }, inputRef) {
14
+ export const Autocomplete = forwardRef(function Autocomplete({ className, icon = true, color = "yellow", noSearchSuffix, suffix, placement = "bottom", placeholder = "Search...", selection = null, onChangeSelection, autocompleteOptionComponent, loading = false, clearSearchButton = false, searchValue, onChangeSearchValue, options, selectOnFocus = true, readOnly = false, }, inputRef) {
15
15
  const [isOpen, setIsOpen] = useState(false);
16
16
  const [activeIndex, setActiveIndex] = useState(null);
17
17
  const onChangeSearchValueStable = useEventCallback(onChangeSearchValue);
@@ -121,7 +121,7 @@ export const Autocomplete = forwardRef(function Autocomplete({ className, icon =
121
121
  handleSelect(activeIndex);
122
122
  }
123
123
  },
124
- }) }), _jsxs("div", { className: "relative flex-center", children: [selection && selectionSuffix, showClearSearchButton && (_jsx(Button, { withRipple: false, icon: true, color: "gray", variant: "text", onClick: () => {
124
+ }) }), _jsxs("div", { className: "relative flex-center", children: [suffix, showClearSearchButton && (_jsx(Button, { withRipple: false, icon: true, color: "gray", variant: "text", onClick: () => {
125
125
  setIsOpen(false);
126
126
  onChangeSelectionStable(null);
127
127
  setActiveIndex(null);
@@ -1,6 +1,6 @@
1
1
  import { AutocompleteProps } from "./Autocomplete";
2
2
  import { OptionLike, Option } from "../select";
3
- interface Props<O extends OptionLike = Option> extends Pick<AutocompleteProps<O>, "className" | "icon" | "color" | "selectionSuffix" | "noSearchSuffix" | "placement" | "placeholder" | "selection" | "onChangeSelection" | "autocompleteOptionComponent" | "loading" | "clearSearchButton" | "readOnly"> {
3
+ interface Props<O extends OptionLike = Option> extends Pick<AutocompleteProps<O>, "className" | "icon" | "color" | "suffix" | "noSearchSuffix" | "placement" | "placeholder" | "selection" | "onChangeSelection" | "autocompleteOptionComponent" | "loading" | "clearSearchButton" | "readOnly"> {
4
4
  onChangeSearchValueCallback: (searchValue: string) => Promise<O[]>;
5
5
  debounce?: number;
6
6
  }
@@ -1,6 +1,6 @@
1
1
  import { AutocompleteProps } from "./Autocomplete";
2
2
  import { Option, OptionLike } from "../select";
3
- interface Props<O extends OptionLike = Option> extends Pick<AutocompleteProps<O>, "className" | "icon" | "color" | "placement" | "placeholder" | "selection" | "onChangeSelection" | "autocompleteOptionComponent" | "options" | "selection" | "readOnly"> {
3
+ interface Props<O extends OptionLike = Option> extends Pick<AutocompleteProps<O>, "className" | "icon" | "color" | "suffix" | "noSearchSuffix" | "placement" | "placeholder" | "selection" | "onChangeSelection" | "autocompleteOptionComponent" | "options" | "selection" | "readOnly"> {
4
4
  }
5
5
  export declare function SimpleAutocomplete<O extends OptionLike = Option>({ options, selection, onChangeSelection, ...rest }: Props<O>): import("react/jsx-runtime").JSX.Element;
6
6
  export {};
@@ -1,7 +1,8 @@
1
- import { ComponentProps } from "react";
1
+ import { ComponentProps, ReactNode } from "react";
2
2
  import type { ThemeColor } from "../../types";
3
3
  export interface TextareaProps extends ComponentProps<"textarea"> {
4
4
  variant?: "normal" | "ghost";
5
5
  color?: ThemeColor;
6
+ action?: ReactNode;
6
7
  }
7
8
  export declare const Textarea: (props: TextareaProps & import("react").RefAttributes<HTMLTextAreaElement>) => React.ReactElement | null;
@@ -1,6 +1,10 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import clsx from "clsx";
3
3
  import { forwardRef } from "react";
4
- export const Textarea = forwardRef(function Textarea({ variant = "normal", color = "yellow", disabled = false, className, ...rest }, ref) {
5
- return (_jsx("textarea", { "data-color": color, "data-variant": variant, ref: ref, className: clsx("p8n-textarea min-w-0 appearance-none rounded-2xl bg-transparent p-2 outline-offset-[-1px] filter-none", disabled && "disabled", className), disabled: disabled, ...rest }));
4
+ export const Textarea = forwardRef(function Textarea({ variant = "normal", color = "yellow", disabled = false, className, readOnly, action, ...rest }, ref) {
5
+ return (_jsxs("div", { className: clsx("relative block", className), children: [_jsx("textarea", { "data-color": color, "data-variant": variant, ref: ref, className: clsx("p8n-textarea w-full min-w-0 appearance-none rounded-2xl bg-transparent p-2 outline-offset-[-1px] filter-none", disabled && "disabled", readOnly && "readonly"), readOnly: readOnly, onFocus: () => {
6
+ if (readOnly) {
7
+ document.activeElement?.select();
8
+ }
9
+ }, disabled: disabled, ...rest }), action && _jsx("div", { className: "absolute right-1 top-1", children: action })] }));
6
10
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pentatrion-design",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "Hugues Tavernier",
@@ -230,7 +230,7 @@ export const components = {
230
230
  opacity: "0.5",
231
231
  },
232
232
  },
233
- "input[readonly]": {
233
+ ":is(input,textarea)[readonly]": {
234
234
  color: "rgb(var(--color-gray-6))",
235
235
  },
236
236
  ".option": {
@@ -42,16 +42,14 @@ export const pentatrionTw = plugin.withOptions(function (options = {}) {
42
42
  options.vars !== false && addBase(vars);
43
43
  options.base !== false && addBase(base);
44
44
  options.components !== false && addComponents(components);
45
- options.componentsInputOutline !== false &&
46
- addComponents(componentsInputOutline);
47
- options.componentsResizeArea !== false &&
48
- addComponents(componentsResizeArea);
45
+ options.componentsInputOutline !== false && addComponents(componentsInputOutline);
46
+ options.componentsResizeArea !== false && addComponents(componentsResizeArea);
49
47
  options.componentsStep !== false && addComponents(componentsStep);
50
48
  options.utilities !== false && addUtilities(utilities);
51
49
  options.utilitiesDialog !== false && addUtilities(utilitiesDialog);
52
50
  addVariant("active-full", ["&:active", "&.active"]);
53
- // addVariant("focus-full", ["&:focus-within", "&.focus", "&:focus"]);
54
- addVariant("focus-full", ["&:has(input:focus)", "&.focus", "&:focus"]);
51
+ // dbl :focus:focus else :hover will have priority to focus-full variant.
52
+ addVariant("focus-full", ["&:has(input:focus)", "&.focus", "&:focus:focus"]);
55
53
  };
56
54
  }, function () {
57
55
  return {