pentatrion-design 0.0.20 → 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.
|
@@ -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, onClick: () => {
|
|
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,11 +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 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,
|
|
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
|
-
|
|
8
|
-
// was an issue if we listen on onFocus and user click on the text of the textarea with Firefox
|
|
9
|
-
document.activeElement?.select();
|
|
7
|
+
e.target.select();
|
|
10
8
|
}
|
|
11
9
|
}, disabled: disabled, ...rest }), action && _jsx("div", { className: "absolute right-1 top-1", children: action })] }));
|
|
12
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" },
|