pentatrion-design 0.0.18 → 0.0.20

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.
@@ -96,8 +96,10 @@ export const Autocomplete = forwardRef(function Autocomplete({ className, icon =
96
96
  }), [activeIndex, selection, getItemProps, handleSelect]);
97
97
  const showClearSearchButton = clearSearchButton && (searchValue.trim() !== "" || selection !== null);
98
98
  return (_jsxs("div", { className: className, children: [_jsxs("div", { className: clsx(inputConfig.container, readOnly && "readonly"), ref: refs.setReference, "data-color": color, children: [icon !== false && (_jsxs("div", { className: "relative flex-center", children: [loading && _jsx(Loader, { size: "medium", color: "gray", className: "absolute left-0 top-0" }), icon === true ? (_jsx("span", { className: "h-8 w-8 flex-center", children: _jsx("i", { className: "fe-search" }) })) : (icon)] })), _jsx("input", { spellCheck: "false", className: clsx(inputConfig.input, icon === false && "pl-4"), ref: inputRef, type: "search", readOnly: readOnly, value: searchValue, placeholder: placeholder, "aria-autocomplete": "list", ...getReferenceProps({
99
- onFocus() {
99
+ onClick() {
100
100
  if (selectOnFocus) {
101
+ // it's better to listen onClick instead of onFocus. the event is triggered later and there
102
+ // was an issue if we listen on onFocus and user click on the text of the textarea with Firefox
101
103
  document.activeElement?.select();
102
104
  }
103
105
  },
@@ -9,7 +9,7 @@ export const Input = forwardRef(({ variant = "normal", color = "yellow", disable
9
9
  return (_jsxs("div", { "data-color": color, "data-variant": variant, className: clsx(inputConfig.container, disabled && "disabled", readOnly && "readonly", className), children: [prefix && (_jsx("div", { className: clsx([
10
10
  "relative flex-center",
11
11
  typeof prefix === "string" && "mx-2 select-none text-gray-6",
12
- ]), children: prefix })), _jsx("input", { ref: ref, className: clsx(inputConfig.input, !prefix && "pl-4", !suffix && "pr-4"), disabled: disabled, readOnly: readOnly, onFocus: () => {
12
+ ]), children: prefix })), _jsx("input", { ref: ref, className: clsx(inputConfig.input, !prefix && "pl-4", !suffix && "pr-4"), disabled: disabled, readOnly: readOnly, onClick: () => {
13
13
  if (readOnly) {
14
14
  document.activeElement?.select();
15
15
  }
@@ -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,12 @@
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 h-full w-full min-w-0 appearance-none rounded-2xl bg-transparent p-2 outline-offset-[-1px] filter-none", disabled && "disabled", readOnly && "readonly"), readOnly: readOnly, onClick: () => {
6
+ if (readOnly) {
7
+ // it's better to listen onClick instead of onFocus. the event is triggered later and there
8
+ // was an issue if we listen on onFocus and user click on the text of the textarea with Firefox
9
+ document.activeElement?.select();
10
+ }
11
+ }, disabled: disabled, ...rest }), action && _jsx("div", { className: "absolute right-1 top-1", children: action })] }));
6
12
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pentatrion-design",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
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 {