@cmdniels/uikit 1.4.7 → 1.5.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/out/components/glass/Glass.d.ts +6 -0
- package/out/components/glass/Glass.js +89 -0
- package/out/components/glass/GlassDisplacementMap.d.ts +16 -0
- package/out/components/glass/GlassDisplacementMap.js +39 -0
- package/out/components/glass/GlassFilter.d.ts +15 -0
- package/out/components/glass/GlassFilter.js +11 -0
- package/out/components/input-group/{InputGroupTextarea.d.ts → InputGroupTextArea.d.ts} +1 -1
- package/out/components/input-group/{InputGroupTextarea.js → InputGroupTextArea.js} +3 -3
- package/out/components/select/Select.js +0 -1
- package/out/index.d.ts +2 -1
- package/out/index.js +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type HTMLAttributes } from "react";
|
|
2
|
+
export default function Glass({ children, className, depth, zIndex, refraction, ...props }: HTMLAttributes<HTMLDivElement> & {
|
|
3
|
+
depth?: number;
|
|
4
|
+
zIndex?: number;
|
|
5
|
+
refraction?: boolean;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
import { useId, useRef, useEffect, useState } from "react";
|
|
15
|
+
import cn from "../../cn";
|
|
16
|
+
import GlassFilter from "./GlassFilter";
|
|
17
|
+
export default function Glass(_a) {
|
|
18
|
+
var { children, className, depth = 10, zIndex = 0, refraction = false } = _a, props = __rest(_a, ["children", "className", "depth", "zIndex", "refraction"]);
|
|
19
|
+
const refractionFilterId = useId();
|
|
20
|
+
const containerRef = useRef(null);
|
|
21
|
+
const [dimensions, setDimensions] = useState({ width: 200, height: 200 });
|
|
22
|
+
const [radius, setRadius] = useState({ bottomLeft: 0, bottomRight: 0, topLeft: 0, topRight: 0 });
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const updateDimensions = () => {
|
|
25
|
+
if (containerRef.current) {
|
|
26
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
27
|
+
const computedStyle = window.getComputedStyle(containerRef.current);
|
|
28
|
+
const parseRadius = (value) => parseFloat(value) || 0;
|
|
29
|
+
const radiusValues = {
|
|
30
|
+
topLeft: parseRadius(computedStyle.borderTopLeftRadius),
|
|
31
|
+
topRight: parseRadius(computedStyle.borderTopRightRadius),
|
|
32
|
+
bottomLeft: parseRadius(computedStyle.borderBottomLeftRadius),
|
|
33
|
+
bottomRight: parseRadius(computedStyle.borderBottomRightRadius),
|
|
34
|
+
};
|
|
35
|
+
const maxRadius = Math.min(rect.width, rect.height) / 2;
|
|
36
|
+
setDimensions({
|
|
37
|
+
width: rect.width || 200,
|
|
38
|
+
height: rect.height || 200,
|
|
39
|
+
});
|
|
40
|
+
setRadius({
|
|
41
|
+
topLeft: Math.min(radiusValues.topLeft, maxRadius),
|
|
42
|
+
topRight: Math.min(radiusValues.topRight, maxRadius),
|
|
43
|
+
bottomLeft: Math.min(radiusValues.bottomLeft, maxRadius),
|
|
44
|
+
bottomRight: Math.min(radiusValues.bottomRight, maxRadius),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
updateDimensions();
|
|
49
|
+
const resizeObserver = new ResizeObserver(updateDimensions);
|
|
50
|
+
if (containerRef.current) {
|
|
51
|
+
resizeObserver.observe(containerRef.current);
|
|
52
|
+
}
|
|
53
|
+
return () => resizeObserver.disconnect();
|
|
54
|
+
}, [refraction]);
|
|
55
|
+
const { width, height } = dimensions;
|
|
56
|
+
const avarageSize = (width + height) / 2;
|
|
57
|
+
const strength = avarageSize / 3;
|
|
58
|
+
const chromaticAberration = avarageSize / 10;
|
|
59
|
+
return (_jsxs(_Fragment, { children: [refraction && (_jsx(GlassFilter, { id: refractionFilterId, depth: depth, height: height, width: width, radius: radius, strength: strength, chromaticAberration: chromaticAberration })), _jsxs("div", Object.assign({}, props, { ref: containerRef, className: cn("relative isolate overflow-hidden rounded-lg bg-card/10 shadow-xl", className), style: { zIndex }, children: [refraction && (_jsx("div", { style: {
|
|
60
|
+
content: "",
|
|
61
|
+
position: "absolute",
|
|
62
|
+
inset: 0,
|
|
63
|
+
zIndex: zIndex - 1,
|
|
64
|
+
opacity: 1,
|
|
65
|
+
borderBottomLeftRadius: radius.bottomLeft,
|
|
66
|
+
borderBottomRightRadius: radius.bottomRight,
|
|
67
|
+
borderTopLeftRadius: radius.topLeft,
|
|
68
|
+
borderTopRightRadius: radius.topRight,
|
|
69
|
+
backdropFilter: `url(#${refractionFilterId})`,
|
|
70
|
+
WebkitBackdropFilter: `url(#${refractionFilterId})`,
|
|
71
|
+
willChange: "backdrop-filter, border-radius",
|
|
72
|
+
pointerEvents: "none",
|
|
73
|
+
} })), _jsx("div", { style: {
|
|
74
|
+
content: "",
|
|
75
|
+
position: "absolute",
|
|
76
|
+
inset: 0,
|
|
77
|
+
zIndex: zIndex - 1,
|
|
78
|
+
opacity: 1,
|
|
79
|
+
borderBottomLeftRadius: radius.bottomLeft,
|
|
80
|
+
borderBottomRightRadius: radius.bottomRight,
|
|
81
|
+
borderTopLeftRadius: radius.topLeft,
|
|
82
|
+
borderTopRightRadius: radius.topRight,
|
|
83
|
+
boxShadow: `inset 0 0 8px 0px oklch(1 0 0 / 0.3)`,
|
|
84
|
+
backdropFilter: `blur(2px) brightness(1.1) saturate(1.5)`,
|
|
85
|
+
WebkitBackdropFilter: `blur(2px) brightness(1.1) saturate(1.5)`,
|
|
86
|
+
willChange: "backdrop-filter, border-radius",
|
|
87
|
+
pointerEvents: "none",
|
|
88
|
+
} }), children] }))] }));
|
|
89
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creating the displacement map that is used by feDisplacementMap filter.
|
|
3
|
+
* Gradients take into account the radius of the element.
|
|
4
|
+
* This is why they start and end in the middle of the angle curve.
|
|
5
|
+
*/
|
|
6
|
+
export default function GlassDisplacementMap({ height, width, radius, depth, }: {
|
|
7
|
+
height: number;
|
|
8
|
+
width: number;
|
|
9
|
+
radius: {
|
|
10
|
+
bottomLeft: number;
|
|
11
|
+
bottomRight: number;
|
|
12
|
+
topLeft: number;
|
|
13
|
+
topRight: number;
|
|
14
|
+
};
|
|
15
|
+
depth: number;
|
|
16
|
+
}): string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
3
|
+
/**
|
|
4
|
+
* Creating the displacement map that is used by feDisplacementMap filter.
|
|
5
|
+
* Gradients take into account the radius of the element.
|
|
6
|
+
* This is why they start and end in the middle of the angle curve.
|
|
7
|
+
*/
|
|
8
|
+
export default function GlassDisplacementMap({ height, width, radius, depth, }) {
|
|
9
|
+
const averageRadius = (radius.topLeft + radius.topRight + radius.bottomLeft + radius.bottomRight) / 4;
|
|
10
|
+
const innerWidth = width - 2 * depth;
|
|
11
|
+
const innerHeight = height - 2 * depth;
|
|
12
|
+
const innerRadius = {
|
|
13
|
+
topLeft: Math.max(0, radius.topLeft - depth),
|
|
14
|
+
topRight: Math.max(0, radius.topRight - depth),
|
|
15
|
+
bottomLeft: Math.max(0, radius.bottomLeft - depth),
|
|
16
|
+
bottomRight: Math.max(0, radius.bottomRight - depth),
|
|
17
|
+
};
|
|
18
|
+
const createRoundedRectPath = (x, y, w, h, r) => {
|
|
19
|
+
const maxRadius = Math.min(w / 2, h / 2);
|
|
20
|
+
const tl = Math.min(r.topLeft, maxRadius);
|
|
21
|
+
const tr = Math.min(r.topRight, maxRadius);
|
|
22
|
+
const bl = Math.min(r.bottomLeft, maxRadius);
|
|
23
|
+
const br = Math.min(r.bottomRight, maxRadius);
|
|
24
|
+
return `
|
|
25
|
+
M ${x + tl} ${y}
|
|
26
|
+
L ${x + w - tr} ${y}
|
|
27
|
+
Q ${x + w} ${y} ${x + w} ${y + tr}
|
|
28
|
+
L ${x + w} ${y + h - br}
|
|
29
|
+
Q ${x + w} ${y + h} ${x + w - br} ${y + h}
|
|
30
|
+
L ${x + bl} ${y + h}
|
|
31
|
+
Q ${x} ${y + h} ${x} ${y + h - bl}
|
|
32
|
+
L ${x} ${y + tl}
|
|
33
|
+
Q ${x} ${y} ${x + tl} ${y}
|
|
34
|
+
Z
|
|
35
|
+
`;
|
|
36
|
+
};
|
|
37
|
+
const svg = (_jsxs("svg", { height: height, width: width, viewBox: `0 0 ${width} ${height}`, xmlns: "http://www.w3.org/2000/svg", children: [_jsxs("defs", { children: [_jsxs("linearGradient", { id: "Y", x1: "0", x2: "0", y1: `${Math.ceil((averageRadius / height) * 15)}%`, y2: `${Math.floor(100 - (averageRadius / height) * 15)}%`, children: [_jsx("stop", { offset: "0%", stopColor: "#0F0" }), _jsx("stop", { offset: "100%", stopColor: "#000" })] }), _jsxs("linearGradient", { id: "X", x1: `${Math.ceil((averageRadius / width) * 15)}%`, x2: `${Math.floor(100 - (averageRadius / width) * 15)}%`, y1: "0", y2: "0", children: [_jsx("stop", { offset: "0%", stopColor: "#F00" }), _jsx("stop", { offset: "100%", stopColor: "#000" })] })] }), _jsx("rect", { x: "0", y: "0", height: height, width: width, fill: "#808080" }), _jsxs("g", { filter: "blur(2px)", children: [_jsx("rect", { x: "0", y: "0", height: height, width: width, fill: "#000080" }), _jsx("rect", { x: "0", y: "0", height: height, width: width, fill: "url(#Y)", style: { mixBlendMode: "screen" } }), _jsx("rect", { x: "0", y: "0", height: height, width: width, fill: "url(#X)", style: { mixBlendMode: "screen" } }), _jsx("path", { d: createRoundedRectPath(depth, depth, innerWidth, innerHeight, innerRadius), fill: "#808080", filter: `blur(${depth}px)` })] })] }));
|
|
38
|
+
return `data:image/svg+xml;utf8,${encodeURIComponent(renderToStaticMarkup(svg))}`;
|
|
39
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type HTMLAttributes } from "react";
|
|
2
|
+
export default function GlassFilter({ id, depth, height, width, radius, strength, chromaticAberration, }: HTMLAttributes<HTMLDivElement> & {
|
|
3
|
+
id: string;
|
|
4
|
+
depth?: number;
|
|
5
|
+
height: number;
|
|
6
|
+
width: number;
|
|
7
|
+
strength?: number;
|
|
8
|
+
chromaticAberration?: number;
|
|
9
|
+
radius: {
|
|
10
|
+
bottomLeft: number;
|
|
11
|
+
bottomRight: number;
|
|
12
|
+
topLeft: number;
|
|
13
|
+
topRight: number;
|
|
14
|
+
};
|
|
15
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import GlassDisplacementMap from "./GlassDisplacementMap";
|
|
4
|
+
export default function GlassFilter({ id, depth = 10, height, width, radius, strength = 20, chromaticAberration = 2, }) {
|
|
5
|
+
return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "0", height: "0", style: { position: "absolute", overflow: "hidden" }, children: _jsx("defs", { children: _jsxs("filter", { id: id, colorInterpolationFilters: "sRGB", children: [_jsx("feImage", { x: "0", y: "0", height: height, width: width, href: GlassDisplacementMap({
|
|
6
|
+
height,
|
|
7
|
+
width,
|
|
8
|
+
radius,
|
|
9
|
+
depth,
|
|
10
|
+
}), result: "displacementMap" }), _jsx("feDisplacementMap", { in: "SourceGraphic", in2: "displacementMap", scale: strength + chromaticAberration * 2, xChannelSelector: "R", yChannelSelector: "G" }), _jsx("feColorMatrix", { type: "matrix", values: "1 0 0 0 0\n\t\t\t\t\t\t\t\t\t0 0 0 0 0\n\t\t\t\t\t\t\t\t\t0 0 0 0 0\n\t\t\t\t\t\t\t\t\t0 0 0 1 0", result: "displacedR" }), _jsx("feDisplacementMap", { in: "SourceGraphic", in2: "displacementMap", scale: strength + chromaticAberration, xChannelSelector: "R", yChannelSelector: "G" }), _jsx("feColorMatrix", { type: "matrix", values: "0 0 0 0 0\n\t\t\t\t\t\t\t\t\t0 1 0 0 0\n\t\t\t\t\t\t\t\t\t0 0 0 0 0\n\t\t\t\t\t\t\t\t\t0 0 0 1 0", result: "displacedG" }), _jsx("feDisplacementMap", { in: "SourceGraphic", in2: "displacementMap", scale: strength, xChannelSelector: "R", yChannelSelector: "G" }), _jsx("feColorMatrix", { type: "matrix", values: "0 0 0 0 0\n\t\t\t\t\t\t\t\t\t0 0 0 0 0\n\t\t\t\t\t\t\t\t\t0 0 1 0 0\n\t\t\t\t\t\t\t\t\t0 0 0 1 0", result: "displacedB" }), _jsx("feBlend", { in: "displacedR", in2: "displacedG", mode: "screen" }), _jsx("feBlend", { in2: "displacedB", mode: "screen" })] }) }) }));
|
|
11
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ComponentProps } from "react";
|
|
2
|
-
export default function
|
|
2
|
+
export default function InputGroupTextArea({ className, ...props }: ComponentProps<"textarea">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -12,8 +12,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
};
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import cn from "../../cn";
|
|
15
|
-
import
|
|
16
|
-
export default function
|
|
15
|
+
import TextArea from "../../components/textarea/TextArea";
|
|
16
|
+
export default function InputGroupTextArea(_a) {
|
|
17
17
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
18
|
-
return (_jsx(
|
|
18
|
+
return (_jsx(TextArea, Object.assign({ "data-slot": "input-group-control", className: cn("flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent", className) }, props)));
|
|
19
19
|
}
|
package/out/index.d.ts
CHANGED
|
@@ -118,13 +118,14 @@ export { default as FieldSeparator } from "./components/field/FieldSeparator";
|
|
|
118
118
|
export { default as FieldSet } from "./components/field/FieldSet";
|
|
119
119
|
export { default as FieldTitle } from "./components/field/FieldTitle";
|
|
120
120
|
export { default as FileDropzone } from "./components/file-dropzone/FileDropzone";
|
|
121
|
+
export { default as Glass } from "./components/glass/Glass";
|
|
121
122
|
export { default as Input } from "./components/input/Input";
|
|
122
123
|
export { default as InputGroup } from "./components/input-group/InputGroup";
|
|
123
124
|
export { default as InputGroupAddon } from "./components/input-group/InputGroupAddon";
|
|
124
125
|
export { default as InputGroupButton } from "./components/input-group/InputGroupButton";
|
|
125
126
|
export { default as InputGroupInput } from "./components/input-group/InputGroupInput";
|
|
126
127
|
export { default as InputGroupText } from "./components/input-group/InputGroupText";
|
|
127
|
-
export { default as
|
|
128
|
+
export { default as InputGroupTextArea } from "./components/input-group/InputGroupTextArea";
|
|
128
129
|
export { default as Item } from "./components/item/Item";
|
|
129
130
|
export { default as ItemActions } from "./components/item/ItemActions";
|
|
130
131
|
export { default as ItemContent } from "./components/item/ItemContent";
|
package/out/index.js
CHANGED
|
@@ -137,6 +137,8 @@ export { default as FieldSet } from "./components/field/FieldSet";
|
|
|
137
137
|
export { default as FieldTitle } from "./components/field/FieldTitle";
|
|
138
138
|
// File Dropzone
|
|
139
139
|
export { default as FileDropzone } from "./components/file-dropzone/FileDropzone";
|
|
140
|
+
// Glass
|
|
141
|
+
export { default as Glass } from "./components/glass/Glass";
|
|
140
142
|
// Input
|
|
141
143
|
export { default as Input } from "./components/input/Input";
|
|
142
144
|
// Input Group
|
|
@@ -145,7 +147,7 @@ export { default as InputGroupAddon } from "./components/input-group/InputGroupA
|
|
|
145
147
|
export { default as InputGroupButton } from "./components/input-group/InputGroupButton";
|
|
146
148
|
export { default as InputGroupInput } from "./components/input-group/InputGroupInput";
|
|
147
149
|
export { default as InputGroupText } from "./components/input-group/InputGroupText";
|
|
148
|
-
export { default as
|
|
150
|
+
export { default as InputGroupTextArea } from "./components/input-group/InputGroupTextArea";
|
|
149
151
|
// Item
|
|
150
152
|
export { default as Item } from "./components/item/Item";
|
|
151
153
|
export { default as ItemActions } from "./components/item/ItemActions";
|