@hanzo/ui 5.3.31 → 5.3.33

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.
@@ -0,0 +1,211 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var Spline = require('@splinetool/react-spline');
5
+ var clsx = require('clsx');
6
+ var tailwindMerge = require('tailwind-merge');
7
+ var NextImage = require('next/image');
8
+ var jsxRuntime = require('react/jsx-runtime');
9
+ var React = require('react');
10
+
11
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
+
13
+ var Spline__default = /*#__PURE__*/_interopDefault(Spline);
14
+ var NextImage__default = /*#__PURE__*/_interopDefault(NextImage);
15
+ var React__default = /*#__PURE__*/_interopDefault(React);
16
+
17
+ var __defProp = Object.defineProperty;
18
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
19
+
20
+ // util/spread-to-transform.ts
21
+ function spreadToTransform(t) {
22
+ let transformStrings = [];
23
+ const scaleVal = "scale" in t ? t.scale : void 0;
24
+ if (scaleVal) {
25
+ if (typeof scaleVal === "number") {
26
+ transformStrings.push(`scale(${scaleVal})`);
27
+ } else if (Array.isArray(scaleVal) && scaleVal.length == 2 && typeof scaleVal[0] === "number") {
28
+ transformStrings.push(`scale(${scaleVal[0]}, ${scaleVal[1]})`);
29
+ } else {
30
+ throw new Error("parsing MediaTransform: Unrecognized value for 'scale'!");
31
+ }
32
+ }
33
+ return transformStrings.length > 0 ? { transform: transformStrings.join(" ") } : {};
34
+ }
35
+ __name(spreadToTransform, "spreadToTransform");
36
+ var spread_to_transform_default = spreadToTransform;
37
+ function cn(...inputs) {
38
+ return tailwindMerge.twMerge(clsx.clsx(inputs));
39
+ }
40
+ __name(cn, "cn");
41
+
42
+ // util/index.ts
43
+ function constrain(value, minOrConstrainTo, max) {
44
+ if (typeof value === "number" && typeof minOrConstrainTo === "number" && typeof max === "number") {
45
+ return Math.min(Math.max(value, minOrConstrainTo), max);
46
+ }
47
+ if (typeof value === "object" && typeof minOrConstrainTo === "object") {
48
+ const dim = value;
49
+ const constrainTo = minOrConstrainTo;
50
+ const aspectRatio = dim.w / dim.h;
51
+ const constrainAspectRatio = constrainTo.w / constrainTo.h;
52
+ if (aspectRatio > constrainAspectRatio) {
53
+ return {
54
+ w: constrainTo.w,
55
+ h: constrainTo.w / aspectRatio
56
+ };
57
+ } else {
58
+ return {
59
+ w: constrainTo.h * aspectRatio,
60
+ h: constrainTo.h
61
+ };
62
+ }
63
+ }
64
+ throw new Error("Invalid parameters for constrain function");
65
+ }
66
+ __name(constrain, "constrain");
67
+ var Image = /* @__PURE__ */ __name(({
68
+ def,
69
+ constrainTo,
70
+ transform = {},
71
+ fullWidth = false,
72
+ className = "",
73
+ preload = false
74
+ }) => {
75
+ const {
76
+ src,
77
+ alt: _alt,
78
+ dim,
79
+ sizes,
80
+ svgFillClass: _svgFillClass
81
+ } = def;
82
+ const toSpread = {};
83
+ if (fullWidth) {
84
+ toSpread.style = {
85
+ width: "100%",
86
+ height: "auto",
87
+ ...spread_to_transform_default(transform)
88
+ };
89
+ if (constrainTo) {
90
+ toSpread.style.maxWidth = constrainTo.w;
91
+ toSpread.style.maxHeight = constrainTo.h;
92
+ }
93
+ } else {
94
+ const resolved = constrainTo ? constrain(dim, constrainTo) : dim;
95
+ toSpread.width = resolved.w;
96
+ toSpread.height = resolved.h;
97
+ toSpread.style = { ...spread_to_transform_default(transform) };
98
+ }
99
+ if (sizes) {
100
+ toSpread.sizes = sizes;
101
+ }
102
+ let alt;
103
+ if (_alt) {
104
+ alt = _alt;
105
+ } else {
106
+ const tokens = src.split("/");
107
+ alt = tokens.length > 0 ? tokens[tokens.length - 1] : src;
108
+ }
109
+ const svgFillClass = _svgFillClass ?? "";
110
+ return fullWidth ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative flex flex-col items-center justify-center w-full", children: /* @__PURE__ */ jsxRuntime.jsx(
111
+ NextImage__default.default,
112
+ {
113
+ src,
114
+ alt,
115
+ ...toSpread,
116
+ priority: preload,
117
+ loading: preload ? "eager" : "lazy",
118
+ className: cn(svgFillClass, className)
119
+ }
120
+ ) }) : /* @__PURE__ */ jsxRuntime.jsx(
121
+ NextImage__default.default,
122
+ {
123
+ src,
124
+ alt,
125
+ ...toSpread,
126
+ priority: preload,
127
+ loading: preload ? "eager" : "lazy",
128
+ className: cn(svgFillClass, className)
129
+ }
130
+ );
131
+ }, "Image");
132
+ var image_default = Image;
133
+ var VideoPlayer = React__default.default.forwardRef(
134
+ ({
135
+ sources,
136
+ ...rest
137
+ }, ref) => {
138
+ return /* @__PURE__ */ jsxRuntime.jsx("video", { ref, ...rest, children: sources.map((source, index) => /* @__PURE__ */ jsxRuntime.jsx("source", { src: source }, index)) });
139
+ }
140
+ );
141
+ var video_player_default = VideoPlayer;
142
+ var MediaStack = /* @__PURE__ */ __name(({
143
+ media,
144
+ constrainTo: cnst = { w: 250, h: 250 },
145
+ clx = ""
146
+ }) => {
147
+ const { img, video, animation, mediaTransform } = media;
148
+ const transform = mediaTransform ?? {};
149
+ if (animation) {
150
+ return /* @__PURE__ */ jsxRuntime.jsx(
151
+ Spline__default.default,
152
+ {
153
+ scene: animation,
154
+ className: cn(clx, "pointer-events-none"),
155
+ "data-vaul-no-drag": true,
156
+ style: {
157
+ width: 6 / 5 * (typeof cnst.h === "number" ? cnst.h : parseInt(cnst.h)),
158
+ height: cnst.h,
159
+ ...spread_to_transform_default(transform)
160
+ }
161
+ }
162
+ );
163
+ }
164
+ if (video) {
165
+ const dim = constrain(video.dim.md, cnst);
166
+ return /* @__PURE__ */ jsxRuntime.jsx(
167
+ video_player_default,
168
+ {
169
+ className: clx,
170
+ sources: video.sources,
171
+ width: dim.w,
172
+ height: dim.h,
173
+ style: {
174
+ minHeight: dim.h,
175
+ ...spread_to_transform_default(transform)
176
+ },
177
+ ...video.videoProps
178
+ }
179
+ );
180
+ }
181
+ return img ? /* @__PURE__ */ jsxRuntime.jsx(
182
+ image_default,
183
+ {
184
+ def: img,
185
+ constrainTo: cnst,
186
+ className: clx,
187
+ transform
188
+ }
189
+ ) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: { width: cnst.w, height: cnst.h }, className: cn("bg-level-2", clx) });
190
+ }, "MediaStack");
191
+ var media_stack_default = MediaStack;
192
+ var SplinePlayer = /* @__PURE__ */ __name(({
193
+ scene,
194
+ className,
195
+ style,
196
+ onLoad
197
+ }) => {
198
+ return /* @__PURE__ */ jsxRuntime.jsx(
199
+ Spline__default.default,
200
+ {
201
+ scene,
202
+ className: cn("pointer-events-none", className),
203
+ style,
204
+ onLoad
205
+ }
206
+ );
207
+ }, "SplinePlayer");
208
+ var player_default = SplinePlayer;
209
+
210
+ exports.MediaStack = media_stack_default;
211
+ exports.SplinePlayer = player_default;
@@ -0,0 +1,202 @@
1
+ "use client";
2
+ import Spline from '@splinetool/react-spline';
3
+ import { clsx } from 'clsx';
4
+ import { twMerge } from 'tailwind-merge';
5
+ import NextImage from 'next/image';
6
+ import { jsx } from 'react/jsx-runtime';
7
+ import React from 'react';
8
+
9
+ var __defProp = Object.defineProperty;
10
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
+
12
+ // util/spread-to-transform.ts
13
+ function spreadToTransform(t) {
14
+ let transformStrings = [];
15
+ const scaleVal = "scale" in t ? t.scale : void 0;
16
+ if (scaleVal) {
17
+ if (typeof scaleVal === "number") {
18
+ transformStrings.push(`scale(${scaleVal})`);
19
+ } else if (Array.isArray(scaleVal) && scaleVal.length == 2 && typeof scaleVal[0] === "number") {
20
+ transformStrings.push(`scale(${scaleVal[0]}, ${scaleVal[1]})`);
21
+ } else {
22
+ throw new Error("parsing MediaTransform: Unrecognized value for 'scale'!");
23
+ }
24
+ }
25
+ return transformStrings.length > 0 ? { transform: transformStrings.join(" ") } : {};
26
+ }
27
+ __name(spreadToTransform, "spreadToTransform");
28
+ var spread_to_transform_default = spreadToTransform;
29
+ function cn(...inputs) {
30
+ return twMerge(clsx(inputs));
31
+ }
32
+ __name(cn, "cn");
33
+
34
+ // util/index.ts
35
+ function constrain(value, minOrConstrainTo, max) {
36
+ if (typeof value === "number" && typeof minOrConstrainTo === "number" && typeof max === "number") {
37
+ return Math.min(Math.max(value, minOrConstrainTo), max);
38
+ }
39
+ if (typeof value === "object" && typeof minOrConstrainTo === "object") {
40
+ const dim = value;
41
+ const constrainTo = minOrConstrainTo;
42
+ const aspectRatio = dim.w / dim.h;
43
+ const constrainAspectRatio = constrainTo.w / constrainTo.h;
44
+ if (aspectRatio > constrainAspectRatio) {
45
+ return {
46
+ w: constrainTo.w,
47
+ h: constrainTo.w / aspectRatio
48
+ };
49
+ } else {
50
+ return {
51
+ w: constrainTo.h * aspectRatio,
52
+ h: constrainTo.h
53
+ };
54
+ }
55
+ }
56
+ throw new Error("Invalid parameters for constrain function");
57
+ }
58
+ __name(constrain, "constrain");
59
+ var Image = /* @__PURE__ */ __name(({
60
+ def,
61
+ constrainTo,
62
+ transform = {},
63
+ fullWidth = false,
64
+ className = "",
65
+ preload = false
66
+ }) => {
67
+ const {
68
+ src,
69
+ alt: _alt,
70
+ dim,
71
+ sizes,
72
+ svgFillClass: _svgFillClass
73
+ } = def;
74
+ const toSpread = {};
75
+ if (fullWidth) {
76
+ toSpread.style = {
77
+ width: "100%",
78
+ height: "auto",
79
+ ...spread_to_transform_default(transform)
80
+ };
81
+ if (constrainTo) {
82
+ toSpread.style.maxWidth = constrainTo.w;
83
+ toSpread.style.maxHeight = constrainTo.h;
84
+ }
85
+ } else {
86
+ const resolved = constrainTo ? constrain(dim, constrainTo) : dim;
87
+ toSpread.width = resolved.w;
88
+ toSpread.height = resolved.h;
89
+ toSpread.style = { ...spread_to_transform_default(transform) };
90
+ }
91
+ if (sizes) {
92
+ toSpread.sizes = sizes;
93
+ }
94
+ let alt;
95
+ if (_alt) {
96
+ alt = _alt;
97
+ } else {
98
+ const tokens = src.split("/");
99
+ alt = tokens.length > 0 ? tokens[tokens.length - 1] : src;
100
+ }
101
+ const svgFillClass = _svgFillClass ?? "";
102
+ return fullWidth ? /* @__PURE__ */ jsx("div", { className: "relative flex flex-col items-center justify-center w-full", children: /* @__PURE__ */ jsx(
103
+ NextImage,
104
+ {
105
+ src,
106
+ alt,
107
+ ...toSpread,
108
+ priority: preload,
109
+ loading: preload ? "eager" : "lazy",
110
+ className: cn(svgFillClass, className)
111
+ }
112
+ ) }) : /* @__PURE__ */ jsx(
113
+ NextImage,
114
+ {
115
+ src,
116
+ alt,
117
+ ...toSpread,
118
+ priority: preload,
119
+ loading: preload ? "eager" : "lazy",
120
+ className: cn(svgFillClass, className)
121
+ }
122
+ );
123
+ }, "Image");
124
+ var image_default = Image;
125
+ var VideoPlayer = React.forwardRef(
126
+ ({
127
+ sources,
128
+ ...rest
129
+ }, ref) => {
130
+ return /* @__PURE__ */ jsx("video", { ref, ...rest, children: sources.map((source, index) => /* @__PURE__ */ jsx("source", { src: source }, index)) });
131
+ }
132
+ );
133
+ var video_player_default = VideoPlayer;
134
+ var MediaStack = /* @__PURE__ */ __name(({
135
+ media,
136
+ constrainTo: cnst = { w: 250, h: 250 },
137
+ clx = ""
138
+ }) => {
139
+ const { img, video, animation, mediaTransform } = media;
140
+ const transform = mediaTransform ?? {};
141
+ if (animation) {
142
+ return /* @__PURE__ */ jsx(
143
+ Spline,
144
+ {
145
+ scene: animation,
146
+ className: cn(clx, "pointer-events-none"),
147
+ "data-vaul-no-drag": true,
148
+ style: {
149
+ width: 6 / 5 * (typeof cnst.h === "number" ? cnst.h : parseInt(cnst.h)),
150
+ height: cnst.h,
151
+ ...spread_to_transform_default(transform)
152
+ }
153
+ }
154
+ );
155
+ }
156
+ if (video) {
157
+ const dim = constrain(video.dim.md, cnst);
158
+ return /* @__PURE__ */ jsx(
159
+ video_player_default,
160
+ {
161
+ className: clx,
162
+ sources: video.sources,
163
+ width: dim.w,
164
+ height: dim.h,
165
+ style: {
166
+ minHeight: dim.h,
167
+ ...spread_to_transform_default(transform)
168
+ },
169
+ ...video.videoProps
170
+ }
171
+ );
172
+ }
173
+ return img ? /* @__PURE__ */ jsx(
174
+ image_default,
175
+ {
176
+ def: img,
177
+ constrainTo: cnst,
178
+ className: clx,
179
+ transform
180
+ }
181
+ ) : /* @__PURE__ */ jsx("div", { style: { width: cnst.w, height: cnst.h }, className: cn("bg-level-2", clx) });
182
+ }, "MediaStack");
183
+ var media_stack_default = MediaStack;
184
+ var SplinePlayer = /* @__PURE__ */ __name(({
185
+ scene,
186
+ className,
187
+ style,
188
+ onLoad
189
+ }) => {
190
+ return /* @__PURE__ */ jsx(
191
+ Spline,
192
+ {
193
+ scene,
194
+ className: cn("pointer-events-none", className),
195
+ style,
196
+ onLoad
197
+ }
198
+ );
199
+ }, "SplinePlayer");
200
+ var player_default = SplinePlayer;
201
+
202
+ export { media_stack_default as MediaStack, player_default as SplinePlayer };
@@ -0,0 +1,193 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var Spline = require('@splinetool/react-spline');
5
+ var clsx = require('clsx');
6
+ var tailwindMerge = require('tailwind-merge');
7
+ var NextImage = require('next/image');
8
+ var jsxRuntime = require('react/jsx-runtime');
9
+ var React = require('react');
10
+
11
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
+
13
+ var Spline__default = /*#__PURE__*/_interopDefault(Spline);
14
+ var NextImage__default = /*#__PURE__*/_interopDefault(NextImage);
15
+ var React__default = /*#__PURE__*/_interopDefault(React);
16
+
17
+ var __defProp = Object.defineProperty;
18
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
19
+
20
+ // util/spread-to-transform.ts
21
+ function spreadToTransform(t) {
22
+ let transformStrings = [];
23
+ const scaleVal = "scale" in t ? t.scale : void 0;
24
+ if (scaleVal) {
25
+ if (typeof scaleVal === "number") {
26
+ transformStrings.push(`scale(${scaleVal})`);
27
+ } else if (Array.isArray(scaleVal) && scaleVal.length == 2 && typeof scaleVal[0] === "number") {
28
+ transformStrings.push(`scale(${scaleVal[0]}, ${scaleVal[1]})`);
29
+ } else {
30
+ throw new Error("parsing MediaTransform: Unrecognized value for 'scale'!");
31
+ }
32
+ }
33
+ return transformStrings.length > 0 ? { transform: transformStrings.join(" ") } : {};
34
+ }
35
+ __name(spreadToTransform, "spreadToTransform");
36
+ var spread_to_transform_default = spreadToTransform;
37
+ function cn(...inputs) {
38
+ return tailwindMerge.twMerge(clsx.clsx(inputs));
39
+ }
40
+ __name(cn, "cn");
41
+
42
+ // util/index.ts
43
+ function constrain(value, minOrConstrainTo, max) {
44
+ if (typeof value === "number" && typeof minOrConstrainTo === "number" && typeof max === "number") {
45
+ return Math.min(Math.max(value, minOrConstrainTo), max);
46
+ }
47
+ if (typeof value === "object" && typeof minOrConstrainTo === "object") {
48
+ const dim = value;
49
+ const constrainTo = minOrConstrainTo;
50
+ const aspectRatio = dim.w / dim.h;
51
+ const constrainAspectRatio = constrainTo.w / constrainTo.h;
52
+ if (aspectRatio > constrainAspectRatio) {
53
+ return {
54
+ w: constrainTo.w,
55
+ h: constrainTo.w / aspectRatio
56
+ };
57
+ } else {
58
+ return {
59
+ w: constrainTo.h * aspectRatio,
60
+ h: constrainTo.h
61
+ };
62
+ }
63
+ }
64
+ throw new Error("Invalid parameters for constrain function");
65
+ }
66
+ __name(constrain, "constrain");
67
+ var Image = /* @__PURE__ */ __name(({
68
+ def,
69
+ constrainTo,
70
+ transform = {},
71
+ fullWidth = false,
72
+ className = "",
73
+ preload = false
74
+ }) => {
75
+ const {
76
+ src,
77
+ alt: _alt,
78
+ dim,
79
+ sizes,
80
+ svgFillClass: _svgFillClass
81
+ } = def;
82
+ const toSpread = {};
83
+ if (fullWidth) {
84
+ toSpread.style = {
85
+ width: "100%",
86
+ height: "auto",
87
+ ...spread_to_transform_default(transform)
88
+ };
89
+ if (constrainTo) {
90
+ toSpread.style.maxWidth = constrainTo.w;
91
+ toSpread.style.maxHeight = constrainTo.h;
92
+ }
93
+ } else {
94
+ const resolved = constrainTo ? constrain(dim, constrainTo) : dim;
95
+ toSpread.width = resolved.w;
96
+ toSpread.height = resolved.h;
97
+ toSpread.style = { ...spread_to_transform_default(transform) };
98
+ }
99
+ if (sizes) {
100
+ toSpread.sizes = sizes;
101
+ }
102
+ let alt;
103
+ if (_alt) {
104
+ alt = _alt;
105
+ } else {
106
+ const tokens = src.split("/");
107
+ alt = tokens.length > 0 ? tokens[tokens.length - 1] : src;
108
+ }
109
+ const svgFillClass = _svgFillClass ?? "";
110
+ return fullWidth ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative flex flex-col items-center justify-center w-full", children: /* @__PURE__ */ jsxRuntime.jsx(
111
+ NextImage__default.default,
112
+ {
113
+ src,
114
+ alt,
115
+ ...toSpread,
116
+ priority: preload,
117
+ loading: preload ? "eager" : "lazy",
118
+ className: cn(svgFillClass, className)
119
+ }
120
+ ) }) : /* @__PURE__ */ jsxRuntime.jsx(
121
+ NextImage__default.default,
122
+ {
123
+ src,
124
+ alt,
125
+ ...toSpread,
126
+ priority: preload,
127
+ loading: preload ? "eager" : "lazy",
128
+ className: cn(svgFillClass, className)
129
+ }
130
+ );
131
+ }, "Image");
132
+ var image_default = Image;
133
+ var VideoPlayer = React__default.default.forwardRef(
134
+ ({
135
+ sources,
136
+ ...rest
137
+ }, ref) => {
138
+ return /* @__PURE__ */ jsxRuntime.jsx("video", { ref, ...rest, children: sources.map((source, index) => /* @__PURE__ */ jsxRuntime.jsx("source", { src: source }, index)) });
139
+ }
140
+ );
141
+ var video_player_default = VideoPlayer;
142
+ var MediaStack = /* @__PURE__ */ __name(({
143
+ media,
144
+ constrainTo: cnst = { w: 250, h: 250 },
145
+ clx = ""
146
+ }) => {
147
+ const { img, video, animation, mediaTransform } = media;
148
+ const transform = mediaTransform ?? {};
149
+ if (animation) {
150
+ return /* @__PURE__ */ jsxRuntime.jsx(
151
+ Spline__default.default,
152
+ {
153
+ scene: animation,
154
+ className: cn(clx, "pointer-events-none"),
155
+ "data-vaul-no-drag": true,
156
+ style: {
157
+ width: 6 / 5 * (typeof cnst.h === "number" ? cnst.h : parseInt(cnst.h)),
158
+ height: cnst.h,
159
+ ...spread_to_transform_default(transform)
160
+ }
161
+ }
162
+ );
163
+ }
164
+ if (video) {
165
+ const dim = constrain(video.dim.md, cnst);
166
+ return /* @__PURE__ */ jsxRuntime.jsx(
167
+ video_player_default,
168
+ {
169
+ className: clx,
170
+ sources: video.sources,
171
+ width: dim.w,
172
+ height: dim.h,
173
+ style: {
174
+ minHeight: dim.h,
175
+ ...spread_to_transform_default(transform)
176
+ },
177
+ ...video.videoProps
178
+ }
179
+ );
180
+ }
181
+ return img ? /* @__PURE__ */ jsxRuntime.jsx(
182
+ image_default,
183
+ {
184
+ def: img,
185
+ constrainTo: cnst,
186
+ className: clx,
187
+ transform
188
+ }
189
+ ) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: { width: cnst.w, height: cnst.h }, className: cn("bg-level-2", clx) });
190
+ }, "MediaStack");
191
+ var media_stack_default = MediaStack;
192
+
193
+ module.exports = media_stack_default;