pentatrion-design 0.0.19 → 0.1.0
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/components/autocomplete/Autocomplete.js +3 -1
- package/components/input/Input.js +2 -2
- package/components/resize-area/ResizeArea.d.ts +3 -2
- package/components/resize-area/ResizeArea.js +7 -6
- package/components/textarea/Textarea.js +2 -2
- package/package.json +1 -1
- package/tailwind/base.js +4 -1
- package/tailwind/components.js +0 -3
|
@@ -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
|
-
|
|
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,9 +9,9 @@ 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,
|
|
12
|
+
]), children: prefix })), _jsx("input", { ref: ref, className: clsx(inputConfig.input, !prefix && "pl-4", !suffix && "pr-4"), disabled: disabled, readOnly: readOnly, onClick: (e) => {
|
|
13
13
|
if (readOnly) {
|
|
14
|
-
|
|
14
|
+
e.target?.select();
|
|
15
15
|
}
|
|
16
16
|
}, ...rest }), suffix && (_jsx("div", { className: clsx([
|
|
17
17
|
"relative flex-center",
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ComponentProps } from "react";
|
|
1
|
+
import { ComponentProps, RefObject } from "react";
|
|
2
2
|
interface Props extends ComponentProps<"div"> {
|
|
3
3
|
name: string;
|
|
4
4
|
position: "top" | "bottom" | "left" | "right";
|
|
5
5
|
initialValue?: number;
|
|
6
|
+
container?: RefObject<HTMLDivElement>;
|
|
6
7
|
}
|
|
7
|
-
export declare function ResizeArea({ name, position, initialValue, className, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function ResizeArea({ name, position, initialValue, className, container, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect } from "react";
|
|
3
3
|
import clsx from "clsx";
|
|
4
|
-
export function ResizeArea({ name, position, initialValue, className, ...rest }) {
|
|
4
|
+
export function ResizeArea({ name, position, initialValue, className, container, ...rest }) {
|
|
5
5
|
useEffect(() => {
|
|
6
6
|
const cssVarName = `--sidebar-${name}-${["top", "bottom"].includes(position) ? "height" : "width"}`;
|
|
7
7
|
if (initialValue) {
|
|
@@ -20,25 +20,26 @@ export function ResizeArea({ name, position, initialValue, className, ...rest })
|
|
|
20
20
|
const handlePointerMove = useCallback((e) => {
|
|
21
21
|
const cssVarName = `--sidebar-${name}-${["top", "bottom"].includes(position) ? "height" : "width"}`;
|
|
22
22
|
let cssVarValue;
|
|
23
|
+
const containerRect = (container?.current || document.documentElement).getBoundingClientRect();
|
|
23
24
|
switch (position) {
|
|
24
25
|
case "top":
|
|
25
|
-
cssVarValue =
|
|
26
|
+
cssVarValue = containerRect.bottom - e.pageY;
|
|
26
27
|
break;
|
|
27
28
|
case "right":
|
|
28
|
-
cssVarValue = e.pageX;
|
|
29
|
+
cssVarValue = e.pageX - containerRect.left;
|
|
29
30
|
break;
|
|
30
31
|
case "left":
|
|
31
|
-
cssVarValue =
|
|
32
|
+
cssVarValue = containerRect.right - e.pageX;
|
|
32
33
|
break;
|
|
33
34
|
case "bottom":
|
|
34
|
-
cssVarValue = e.pageY;
|
|
35
|
+
cssVarValue = e.pageY - containerRect.top;
|
|
35
36
|
break;
|
|
36
37
|
}
|
|
37
38
|
document.documentElement.style.setProperty(cssVarName, `${cssVarValue}px`);
|
|
38
39
|
return () => {
|
|
39
40
|
document.documentElement.style.removeProperty(cssVarName);
|
|
40
41
|
};
|
|
41
|
-
}, [name, position]);
|
|
42
|
+
}, [name, position, container]);
|
|
42
43
|
const handlePointerUp = useCallback(() => {
|
|
43
44
|
const handler = handlePointerMove;
|
|
44
45
|
document.removeEventListener("pointermove", handler);
|
|
@@ -2,9 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import clsx from "clsx";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
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: () => {
|
|
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, onFocus: (e) => {
|
|
6
6
|
if (readOnly) {
|
|
7
|
-
|
|
7
|
+
e.target.select();
|
|
8
8
|
}
|
|
9
9
|
}, disabled: disabled, ...rest }), action && _jsx("div", { className: "absolute right-1 top-1", children: action })] }));
|
|
10
10
|
});
|
package/package.json
CHANGED
package/tailwind/base.js
CHANGED
|
@@ -15,9 +15,12 @@ export const base = {
|
|
|
15
15
|
":focus-visible": {
|
|
16
16
|
"@apply rounded outline outline-2 outline-offset-2 outline-yellow-5": {},
|
|
17
17
|
},
|
|
18
|
-
"textarea
|
|
18
|
+
"textarea[readonly],.readonly": {
|
|
19
19
|
"@apply bg-gray-1": {},
|
|
20
20
|
},
|
|
21
|
+
":is(input,textarea)[readonly]": {
|
|
22
|
+
color: "rgb(var(--color-gray-6))",
|
|
23
|
+
},
|
|
21
24
|
'input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration, input[type="search"]::-webkit-search-results-button, input[type="search"]::-webkit-search-results-decoration': {
|
|
22
25
|
display: "none",
|
|
23
26
|
},
|
package/tailwind/components.js
CHANGED
|
@@ -230,9 +230,6 @@ export const components = {
|
|
|
230
230
|
opacity: "0.5",
|
|
231
231
|
},
|
|
232
232
|
},
|
|
233
|
-
":is(input,textarea)[readonly]": {
|
|
234
|
-
color: "rgb(var(--color-gray-6))",
|
|
235
|
-
},
|
|
236
233
|
".option": {
|
|
237
234
|
"@apply flex w-full px-2 h-8 items-center text-left relative cursor-pointer first:rounded-t-2xl last:rounded-b-2xl hover:bg-gray-1 focus-full:text-gray-8 outline-none": {},
|
|
238
235
|
"&[disabled]": { color: "rgb(var(--color-gray-6))", pointerEvents: "none" },
|