@particle-academy/react-fancy 5.43.0 → 5.45.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/CHANGELOG.md +47 -0
- package/dist/{Composer.types-CuSPnaOt.d.cts → PastePills.types-CDyotkUb.d.cts} +35 -82
- package/dist/{Composer.types-CuSPnaOt.d.ts → PastePills.types-CDyotkUb.d.ts} +35 -82
- package/dist/PastedFilesInput-CrgNoEBd.d.ts +141 -0
- package/dist/PastedFilesInput-DQ1eZaHk.d.cts +141 -0
- package/dist/{chunk-IPNJMHJ3.cjs → chunk-2QIGXSSZ.cjs} +105 -3
- package/dist/chunk-2QIGXSSZ.cjs.map +1 -0
- package/dist/chunk-4TFTLPAC.js +244 -0
- package/dist/chunk-4TFTLPAC.js.map +1 -0
- package/dist/{chunk-BZOU7VJQ.cjs → chunk-BR27AXFE.cjs} +16 -10
- package/dist/chunk-BR27AXFE.cjs.map +1 -0
- package/dist/{chunk-G4WYCWIQ.js → chunk-DMFJJ73P.js} +3 -3
- package/dist/{chunk-G4WYCWIQ.js.map → chunk-DMFJJ73P.js.map} +1 -1
- package/dist/{chunk-2VIDYJUG.js → chunk-EEWRLFTI.js} +107 -5
- package/dist/chunk-EEWRLFTI.js.map +1 -0
- package/dist/chunk-HM7SW53Z.cjs +246 -0
- package/dist/chunk-HM7SW53Z.cjs.map +1 -0
- package/dist/{chunk-SF5OAVGD.js → chunk-JZCAMPIA.js} +12 -4
- package/dist/chunk-JZCAMPIA.js.map +1 -0
- package/dist/{chunk-2JOWGYAJ.js → chunk-KYZNCVRD.js} +213 -179
- package/dist/chunk-KYZNCVRD.js.map +1 -0
- package/dist/{chunk-MXAVGOHW.js → chunk-L637KPEA.js} +12 -6
- package/dist/chunk-L637KPEA.js.map +1 -0
- package/dist/{chunk-6TZPM43Q.cjs → chunk-MSRYJETY.cjs} +219 -178
- package/dist/chunk-MSRYJETY.cjs.map +1 -0
- package/dist/{chunk-K4NHVCY6.cjs → chunk-S5ZYG5MG.cjs} +8 -8
- package/dist/{chunk-K4NHVCY6.cjs.map → chunk-S5ZYG5MG.cjs.map} +1 -1
- package/dist/{chunk-UUBHUSUP.cjs → chunk-Z3FIU77M.cjs} +14 -6
- package/dist/chunk-Z3FIU77M.cjs.map +1 -0
- package/dist/composer.cjs +4 -4
- package/dist/composer.d.cts +93 -3
- package/dist/composer.d.ts +93 -3
- package/dist/composer.js +2 -2
- package/dist/faux-client.cjs +3 -2
- package/dist/faux-client.d.cts +26 -0
- package/dist/faux-client.d.ts +26 -0
- package/dist/faux-client.js +2 -1
- package/dist/{index-S4FC1yFK.d.ts → index-BF5qsQur.d.cts} +8 -2
- package/dist/{index-BsIBOwaK.d.cts → index-BZON-gXr.d.ts} +8 -2
- package/dist/index.cjs +77 -65
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +13 -13
- package/dist/input.cjs +6 -2
- package/dist/input.d.cts +34 -0
- package/dist/input.d.ts +34 -0
- package/dist/input.js +5 -1
- package/dist/inputs.cjs +8 -6
- package/dist/inputs.d.cts +1 -0
- package/dist/inputs.d.ts +1 -0
- package/dist/inputs.js +4 -2
- package/dist/json-editor.cjs +15 -13
- package/dist/json-editor.js +4 -2
- package/dist/paste-pills.cjs +65 -0
- package/dist/paste-pills.cjs.map +1 -0
- package/dist/paste-pills.d.cts +34 -0
- package/dist/paste-pills.d.ts +34 -0
- package/dist/paste-pills.js +8 -0
- package/dist/paste-pills.js.map +1 -0
- package/dist/prompt-input.cjs +3 -3
- package/dist/prompt-input.d.cts +2 -2
- package/dist/prompt-input.d.ts +2 -2
- package/dist/prompt-input.js +2 -2
- package/package.json +11 -1
- package/dist/chunk-2JOWGYAJ.js.map +0 -1
- package/dist/chunk-2VIDYJUG.js.map +0 -1
- package/dist/chunk-6TZPM43Q.cjs.map +0 -1
- package/dist/chunk-BZOU7VJQ.cjs.map +0 -1
- package/dist/chunk-FA4IG5RB.js +0 -100
- package/dist/chunk-FA4IG5RB.js.map +0 -1
- package/dist/chunk-IPNJMHJ3.cjs.map +0 -1
- package/dist/chunk-MXAVGOHW.js.map +0 -1
- package/dist/chunk-SF5OAVGD.js.map +0 -1
- package/dist/chunk-UUBHUSUP.cjs.map +0 -1
- package/dist/chunk-WCWZADR2.cjs +0 -102
- package/dist/chunk-WCWZADR2.cjs.map +0 -1
|
@@ -2,12 +2,13 @@ import { InputWrapper } from './chunk-PWEZCMIY.js';
|
|
|
2
2
|
import { DisplayValue } from './chunk-KKWNKBKR.js';
|
|
3
3
|
import { Field } from './chunk-5MU6X3KO.js';
|
|
4
4
|
import { inputBaseClasses, inputSizeClasses, dirtyClasses, errorClasses } from './chunk-GFYSELJF.js';
|
|
5
|
+
import { useInlinePaste, InlinePasteEditor, PastedFilesInput } from './chunk-KYZNCVRD.js';
|
|
5
6
|
import { useInlineEdit } from './chunk-OL53XYHF.js';
|
|
6
7
|
import { useFieldMode } from './chunk-NRXK42LO.js';
|
|
7
8
|
import { useControllableState } from './chunk-EDYAXGUM.js';
|
|
8
9
|
import { cn } from './chunk-MMW2JGKZ.js';
|
|
9
|
-
import { forwardRef, useId, useState, useCallback, useEffect } from 'react';
|
|
10
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
10
|
+
import { forwardRef, useId, useRef, useMemo, useState, useCallback, useEffect } from 'react';
|
|
11
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
11
12
|
|
|
12
13
|
function useAdornmentWidth() {
|
|
13
14
|
const [width, setWidth] = useState(0);
|
|
@@ -54,6 +55,16 @@ var Input = forwardRef(
|
|
|
54
55
|
onRevealedChange,
|
|
55
56
|
revealLabel = "Show password",
|
|
56
57
|
hideLabel = "Hide password",
|
|
58
|
+
pasteThreshold,
|
|
59
|
+
pasteImages = false,
|
|
60
|
+
pasteFilesName,
|
|
61
|
+
previewChars = 20,
|
|
62
|
+
renderPastePreview,
|
|
63
|
+
pasteClassNames,
|
|
64
|
+
heldPastes,
|
|
65
|
+
onHeldPastesChange,
|
|
66
|
+
heldImages,
|
|
67
|
+
onHeldImagesChange,
|
|
57
68
|
...props
|
|
58
69
|
}, ref) => {
|
|
59
70
|
const autoId = useId();
|
|
@@ -66,6 +77,34 @@ var Input = forwardRef(
|
|
|
66
77
|
const [isRevealed, setRevealed] = useControllableState(revealed, false, onRevealedChange);
|
|
67
78
|
const shown = canReveal && isRevealed;
|
|
68
79
|
const renderedType = shown ? "text" : type;
|
|
80
|
+
const pasting = pasteThreshold !== void 0 || pasteImages;
|
|
81
|
+
const editorRef = useRef(null);
|
|
82
|
+
const hiddenRef = useRef(null);
|
|
83
|
+
const paste = useInlinePaste({
|
|
84
|
+
pasteThreshold,
|
|
85
|
+
pasteImages,
|
|
86
|
+
previewChars,
|
|
87
|
+
renderPastePreview,
|
|
88
|
+
classNames: pasteClassNames,
|
|
89
|
+
disabled: disabled === true,
|
|
90
|
+
heldPastes,
|
|
91
|
+
onHeldPastesChange,
|
|
92
|
+
heldImages,
|
|
93
|
+
onHeldImagesChange,
|
|
94
|
+
editorRef,
|
|
95
|
+
blockText: false
|
|
96
|
+
});
|
|
97
|
+
const [pasteValue, setPasteValue] = useControllableState(
|
|
98
|
+
props.value === void 0 ? void 0 : String(props.value),
|
|
99
|
+
props.defaultValue === void 0 ? "" : String(props.defaultValue),
|
|
100
|
+
onValueChange
|
|
101
|
+
);
|
|
102
|
+
const filesName = pasteFilesName ?? (props.name ? `${props.name}_files[]` : void 0);
|
|
103
|
+
const pastedFiles = useMemo(
|
|
104
|
+
() => pasteImages ? paste.imagesIn(pasteValue).map((i) => i.file) : [],
|
|
105
|
+
[pasteImages, paste, pasteValue]
|
|
106
|
+
);
|
|
107
|
+
const labelId = `${inputId}-label`;
|
|
69
108
|
const input = !showControl ? /* @__PURE__ */ jsx(
|
|
70
109
|
DisplayValue,
|
|
71
110
|
{
|
|
@@ -93,7 +132,62 @@ var Input = forwardRef(
|
|
|
93
132
|
children: leading
|
|
94
133
|
}
|
|
95
134
|
),
|
|
96
|
-
/* @__PURE__ */
|
|
135
|
+
pasting ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
136
|
+
/* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsx(
|
|
137
|
+
InlinePasteEditor,
|
|
138
|
+
{
|
|
139
|
+
ref: editorRef,
|
|
140
|
+
id: inputId,
|
|
141
|
+
value: pasteValue,
|
|
142
|
+
known: paste.known,
|
|
143
|
+
onChange: (next) => {
|
|
144
|
+
setPasteValue(next);
|
|
145
|
+
paste.prune(next);
|
|
146
|
+
},
|
|
147
|
+
onSubmit: () => hiddenRef.current?.form?.requestSubmit(),
|
|
148
|
+
multiline: false,
|
|
149
|
+
onPaste: paste.decidePaste,
|
|
150
|
+
onHostsChange: paste.onHostsChange,
|
|
151
|
+
placeholder: props.placeholder ?? "",
|
|
152
|
+
disabled: disabled === true,
|
|
153
|
+
ariaLabelledBy: label ? labelId : props["aria-labelledby"],
|
|
154
|
+
ariaInvalid: Boolean(error),
|
|
155
|
+
placeholderClassName: cn(pastePlaceholderClasses[size], leading ? "left-9" : void 0),
|
|
156
|
+
style: {
|
|
157
|
+
...leadingWidth ? { paddingLeft: leadingWidth + 20 } : null,
|
|
158
|
+
...trailingWidth ? { paddingRight: trailingWidth + 20 } : null
|
|
159
|
+
},
|
|
160
|
+
className: cn(
|
|
161
|
+
inputBaseClasses,
|
|
162
|
+
inputSizeClasses[size],
|
|
163
|
+
dirtyClasses(dirty),
|
|
164
|
+
errorClasses(error),
|
|
165
|
+
// One line, like the <input> it stands in for.
|
|
166
|
+
"min-h-0 max-h-none w-full overflow-x-auto overflow-y-hidden whitespace-nowrap break-normal",
|
|
167
|
+
leading && !leadingWidth && "pl-9",
|
|
168
|
+
trailing && !trailingWidth && "pr-9",
|
|
169
|
+
className,
|
|
170
|
+
pasteClassNames?.input
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
) }),
|
|
174
|
+
paste.portals,
|
|
175
|
+
/* @__PURE__ */ jsx(
|
|
176
|
+
"input",
|
|
177
|
+
{
|
|
178
|
+
ref: (el) => {
|
|
179
|
+
hiddenRef.current = el;
|
|
180
|
+
if (typeof ref === "function") ref(el);
|
|
181
|
+
else if (ref) ref.current = el;
|
|
182
|
+
},
|
|
183
|
+
type: "hidden",
|
|
184
|
+
name: props.name,
|
|
185
|
+
form: props.form,
|
|
186
|
+
value: paste.expand(pasteValue)
|
|
187
|
+
}
|
|
188
|
+
),
|
|
189
|
+
pasteImages && filesName && /* @__PURE__ */ jsx(PastedFilesInput, { name: filesName, files: pastedFiles, form: props.form })
|
|
190
|
+
] }) : /* @__PURE__ */ jsx(
|
|
97
191
|
"input",
|
|
98
192
|
{
|
|
99
193
|
ref,
|
|
@@ -166,6 +260,7 @@ var Input = forwardRef(
|
|
|
166
260
|
Field,
|
|
167
261
|
{
|
|
168
262
|
label,
|
|
263
|
+
labelId: pasting ? labelId : void 0,
|
|
169
264
|
labelHidden,
|
|
170
265
|
description,
|
|
171
266
|
error,
|
|
@@ -180,6 +275,13 @@ var Input = forwardRef(
|
|
|
180
275
|
}
|
|
181
276
|
);
|
|
182
277
|
Input.displayName = "Input";
|
|
278
|
+
var pastePlaceholderClasses = {
|
|
279
|
+
xs: "left-2 top-1 text-xs",
|
|
280
|
+
sm: "left-2.5 top-1.5 text-sm",
|
|
281
|
+
md: "left-3 top-2 text-sm",
|
|
282
|
+
lg: "left-4 top-2.5 text-base",
|
|
283
|
+
xl: "left-5 top-3 text-lg"
|
|
284
|
+
};
|
|
183
285
|
function EyeIcon() {
|
|
184
286
|
return /* @__PURE__ */ jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
185
287
|
/* @__PURE__ */ jsx("path", { d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" }),
|
|
@@ -196,5 +298,5 @@ function EyeOffIcon() {
|
|
|
196
298
|
}
|
|
197
299
|
|
|
198
300
|
export { Input };
|
|
199
|
-
//# sourceMappingURL=chunk-
|
|
200
|
-
//# sourceMappingURL=chunk-
|
|
301
|
+
//# sourceMappingURL=chunk-EEWRLFTI.js.map
|
|
302
|
+
//# sourceMappingURL=chunk-EEWRLFTI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-adornment-width.ts","../src/components/inputs/Input/Input.tsx"],"names":[],"mappings":";;;;;;;;;;;;AA0BO,SAAS,iBAAA,GAAkE;AAChF,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAAS,CAAC,CAAA;AACpC,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,SAA6B,IAAI,CAAA;AAEzD,EAAA,MAAM,GAAA,GAAM,YAAY,CAAC,CAAA,KAA0B,QAAQ,CAAC,CAAA,EAAG,EAAE,CAAA;AAEjE,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,CAAC,IAAA,EAAM;AACT,MAAA,QAAA,CAAS,CAAC,CAAA;AAEV,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,OAAO,MAAM,QAAA,CAAS,IAAA,CAAK,qBAAA,GAAwB,KAAK,CAAA;AAC9D,IAAA,IAAA,EAAK;AAEL,IAAA,IAAI,OAAO,mBAAmB,WAAA,EAAa;AAE3C,IAAA,MAAM,QAAA,GAAW,IAAI,cAAA,CAAe,IAAI,CAAA;AACxC,IAAA,QAAA,CAAS,QAAQ,IAAI,CAAA;AAErB,IAAA,OAAO,MAAM,SAAS,UAAA,EAAW;AAAA,EACnC,CAAA,EAAG,CAAC,IAAI,CAAC,CAAA;AAET,EAAA,OAAO,CAAC,KAAK,KAAK,CAAA;AACpB;AC5BO,IAAM,KAAA,GAAQ,UAAA;AAAA,EACnB,CACE;AAAA,IACE,IAAA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,CAAA;AAAA,oBAC/C,GAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAE,8FAAA,EAA+F,CAAA;AAAA,oBACvG,GAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAE,YAAA,EAAa;AAAA,GAAA,EACvB,CAAA;AAEJ","file":"chunk-EEWRLFTI.js","sourcesContent":["import { useCallback, useEffect, useState } from \"react\";\n\n/**\n * Measure an inline adornment so the input can reserve exactly its width.\n *\n * ## Why this exists\n *\n * `leading` / `trailing` render ABSOLUTELY over the input, so they take no\n * space in flow and the input must be padded by hand to keep text clear of\n * them. That padding used to be a fixed `pl-9` / `pr-9` — 36px, sized for a\n * single icon. Any wider adornment ran straight under the value: `leading =\n * \"https://\"` is roughly 50px, so `https://` and `fancy.app` rendered on top of\n * one another.\n *\n * A fixed padding cannot be right for arbitrary content, and these props accept\n * arbitrary content — a currency code, a unit, a protocol, a short label. So\n * the width is measured rather than assumed.\n *\n * Returns `0` until measured (and on the server), which is the signal to keep\n * the old fixed padding as a fallback: an unmeasured render is then no worse\n * than it was before, rather than unpadded.\n *\n * `ResizeObserver` rather than a one-shot read, because the width changes after\n * first paint for reasons the first paint cannot see — a webfont swapping in,\n * the adornment's own content changing, a container query resizing the text.\n */\nexport function useAdornmentWidth(): [(node: HTMLElement | null) => void, number] {\n const [width, setWidth] = useState(0);\n const [node, setNode] = useState<HTMLElement | null>(null);\n\n const ref = useCallback((n: HTMLElement | null) => setNode(n), []);\n\n useEffect(() => {\n if (!node) {\n setWidth(0);\n\n return;\n }\n\n const read = () => setWidth(node.getBoundingClientRect().width);\n read();\n\n if (typeof ResizeObserver === \"undefined\") return;\n\n const observer = new ResizeObserver(read);\n observer.observe(node);\n\n return () => observer.disconnect();\n }, [node]);\n\n return [ref, width];\n}\n","import { forwardRef, useId, useMemo, useRef } from \"react\";\nimport { cn } from \"../../../utils/cn\";\nimport { useControllableState } from \"../../../hooks/use-controllable-state\";\nimport { useAdornmentWidth } from \"../../../hooks/use-adornment-width\";\nimport { Field } from \"../Field\";\nimport { InputWrapper } from \"../InputWrapper\";\nimport {\n dirtyClasses,\n errorClasses,\n inputBaseClasses,\n inputSizeClasses,\n} from \"../inputs.utils\";\nimport { useFieldMode } from \"../mode/FieldMode.context\";\nimport { DisplayValue } from \"../mode/DisplayValue\";\nimport { useInlineEdit } from \"../mode/useInlineEdit\";\nimport {\n InlinePasteEditor,\n PastedFilesInput,\n useInlinePaste,\n type InlinePasteEditorHandle,\n} from \"../../PastePills\";\nimport type { InputProps } from \"./Input.types\";\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(\n (\n {\n type = \"text\",\n size = \"md\",\n dirty,\n error,\n label,\n labelHidden,\n description,\n required,\n disabled,\n className,\n id,\n leading,\n trailing,\n prefix,\n suffix,\n prefixPosition,\n suffixPosition,\n mode,\n onValueChange,\n onChange,\n reveal,\n revealed,\n onRevealedChange,\n revealLabel = \"Show password\",\n hideLabel = \"Hide password\",\n pasteThreshold,\n pasteImages = false,\n pasteFilesName,\n previewChars = 20,\n renderPastePreview,\n pasteClassNames,\n heldPastes,\n onHeldPastesChange,\n heldImages,\n onHeldImagesChange,\n ...props\n },\n ref,\n ) => {\n const autoId = useId();\n const inputId = id ?? autoId;\n const resolvedMode = useFieldMode(mode);\n const { showControl, interactive, enterEdit, exitEdit } = useInlineEdit(resolvedMode, disabled);\n\n // Measured, not assumed: `leading`/`trailing` take arbitrary content, and a\n // fixed padding can only ever be right for one width. See\n // `useAdornmentWidth` for what went wrong with the fixed version.\n const [leadingRef, leadingWidth] = useAdornmentWidth();\n const [trailingRef, trailingWidth] = useAdornmentWidth();\n\n // Only meaningful on a password field: a reveal on an already-visible input\n // is a button that does nothing.\n const canReveal = reveal === true && type === \"password\";\n const [isRevealed, setRevealed] = useControllableState(revealed, false, onRevealedChange);\n const shown = canReveal && isRevealed;\n // The rendered type, NOT the declared one — `type` stays \"password\" so the\n // display-mode masking below and any caller reading props are unaffected.\n const renderedType = shown ? \"text\" : type;\n\n /*\n * Paste pills: the same core `Composer` and `PromptInput` use, so the three\n * cannot disagree about what a pill holds or what a send carries. Hooks run\n * whether or not it is on (Rules of Hooks); nothing is rendered unless asked.\n */\n const pasting = pasteThreshold !== undefined || pasteImages;\n const editorRef = useRef<InlinePasteEditorHandle>(null);\n const hiddenRef = useRef<HTMLInputElement | null>(null);\n const paste = useInlinePaste({\n pasteThreshold,\n pasteImages,\n previewChars,\n renderPastePreview,\n classNames: pasteClassNames,\n disabled: disabled === true,\n heldPastes,\n onHeldPastesChange,\n heldImages,\n onHeldImagesChange,\n editorRef,\n blockText: false,\n });\n const [pasteValue, setPasteValue] = useControllableState<string>(\n props.value === undefined ? undefined : String(props.value),\n props.defaultValue === undefined ? \"\" : String(props.defaultValue),\n onValueChange,\n );\n const filesName = pasteFilesName ?? (props.name ? `${props.name}_files[]` : undefined);\n const pastedFiles = useMemo(\n () => (pasteImages ? paste.imagesIn(pasteValue).map((i) => i.file) : []),\n [pasteImages, paste, pasteValue],\n );\n const labelId = `${inputId}-label`;\n\n const input = !showControl ? (\n <DisplayValue\n size={size}\n interactive={interactive}\n onActivate={enterEdit}\n leading={leading ?? prefix}\n trailing={trailing ?? suffix}\n >\n {type === \"password\" ? (props.value ? \"••••••\" : \"\") : (props.value as string | undefined)}\n </DisplayValue>\n ) : (\n <InputWrapper\n prefix={prefix}\n suffix={suffix}\n prefixPosition={prefixPosition}\n suffixPosition={suffixPosition}\n size={size}\n >\n <div data-react-fancy-input=\"\" className=\"relative flex items-center\">\n {leading && (\n <span\n ref={leadingRef}\n className=\"pointer-events-none absolute left-3 text-zinc-400 dark:text-zinc-500\"\n >\n {leading}\n </span>\n )}\n {pasting ? (\n <>\n <div className=\"min-w-0 flex-1\">\n <InlinePasteEditor\n ref={editorRef}\n id={inputId}\n value={pasteValue}\n known={paste.known}\n onChange={(next) => {\n setPasteValue(next);\n paste.prune(next);\n }}\n // Enter in a text field submits its form; keep that.\n onSubmit={() => hiddenRef.current?.form?.requestSubmit()}\n multiline={false}\n onPaste={paste.decidePaste}\n onHostsChange={paste.onHostsChange}\n placeholder={props.placeholder ?? \"\"}\n disabled={disabled === true}\n ariaLabelledBy={label ? labelId : props[\"aria-labelledby\"]}\n ariaInvalid={Boolean(error)}\n placeholderClassName={cn(pastePlaceholderClasses[size], leading ? \"left-9\" : undefined)}\n style={{\n ...(leadingWidth ? { paddingLeft: leadingWidth + 20 } : null),\n ...(trailingWidth ? { paddingRight: trailingWidth + 20 } : null),\n }}\n className={cn(\n inputBaseClasses,\n inputSizeClasses[size],\n dirtyClasses(dirty),\n errorClasses(error),\n // One line, like the <input> it stands in for.\n \"min-h-0 max-h-none w-full overflow-x-auto overflow-y-hidden whitespace-nowrap break-normal\",\n leading && !leadingWidth && \"pl-9\",\n trailing && !trailingWidth && \"pr-9\",\n className,\n pasteClassNames?.input,\n )}\n />\n </div>\n {paste.portals}\n {/* What a native submit posts: the value with every pill expanded. */}\n <input\n ref={(el) => {\n hiddenRef.current = el;\n if (typeof ref === \"function\") ref(el);\n else if (ref) ref.current = el;\n }}\n type=\"hidden\"\n name={props.name}\n form={props.form}\n value={paste.expand(pasteValue)}\n />\n {pasteImages && filesName && (\n <PastedFilesInput name={filesName} files={pastedFiles} form={props.form} />\n )}\n </>\n ) : (\n <input\n ref={ref}\n id={inputId}\n type={renderedType}\n disabled={disabled}\n required={required}\n className={cn(\n inputBaseClasses,\n inputSizeClasses[size],\n dirtyClasses(dirty),\n errorClasses(error),\n \"w-full\",\n // The fixed classes are the PRE-MEASURE fallback only. Once the\n // adornment is measured, the inline style below overrides them\n // with its real width -- a fixed 36px is correct for one icon and\n // wrong for anything wider, which is how `https://` came to\n // render on top of the value.\n leading && !leadingWidth && \"pl-9\",\n (trailing || canReveal) && !trailingWidth && \"pr-9\",\n className,\n )}\n style={{\n // 12px clears `left-3`/`right-3`; 8px is the gap to the text.\n ...(leadingWidth ? { paddingLeft: leadingWidth + 20 } : null),\n ...(trailingWidth ? { paddingRight: trailingWidth + 20 } : null),\n ...props.style,\n }}\n onChange={(e) => {\n onChange?.(e);\n onValueChange?.(e.target.value);\n }}\n {...props}\n // Inline click-to-edit: focus on entering edit, return to the display\n // (and run the host's onBlur) when focus leaves.\n autoFocus={interactive || props.autoFocus}\n onBlur={(e) => {\n props.onBlur?.(e);\n if (interactive) exitEdit();\n }}\n />\n )}\n {canReveal ? (\n <button\n type=\"button\"\n // type=\"button\" is load-bearing: the default is \"submit\", so a\n // reveal inside a login form would submit it on every click.\n id={`${inputId}-reveal`}\n data-react-fancy-reveal=\"\"\n onClick={() => setRevealed((v) => !v)}\n disabled={disabled}\n aria-controls={inputId}\n aria-pressed={shown}\n aria-label={shown ? hideLabel : revealLabel}\n title={shown ? hideLabel : revealLabel}\n // Not focusable by tab: the field and the submit button are the\n // path through a login form, and a reveal in between is a stop\n // most people do not want. Still reachable by click and by\n // screen readers.\n tabIndex={-1}\n className=\"absolute right-2 inline-flex items-center justify-center rounded p-1 text-zinc-400 transition-colors hover:text-zinc-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500/40 disabled:cursor-not-allowed disabled:opacity-50 dark:text-zinc-500 dark:hover:text-zinc-300\"\n >\n {shown ? <EyeOffIcon /> : <EyeIcon />}\n </button>\n ) : (\n trailing && (\n <span\n ref={trailingRef}\n className=\"pointer-events-none absolute right-3 text-zinc-400 dark:text-zinc-500\"\n >\n {trailing}\n </span>\n )\n )}\n </div>\n </InputWrapper>\n );\n\n if (label || error || description) {\n return (\n <Field\n label={label}\n labelId={pasting ? labelId : undefined}\n labelHidden={labelHidden}\n description={description}\n error={error}\n required={required}\n htmlFor={inputId}\n size={size}\n >\n {input}\n </Field>\n );\n }\n\n return input;\n },\n);\n\nInput.displayName = \"Input\";\n\n/** Where the placeholder sits over the paste editor, matching `inputSizeClasses`. */\nconst pastePlaceholderClasses = {\n xs: \"left-2 top-1 text-xs\",\n sm: \"left-2.5 top-1.5 text-sm\",\n md: \"left-3 top-2 text-sm\",\n lg: \"left-4 top-2.5 text-base\",\n xl: \"left-5 top-3 text-lg\",\n} as const;\n\n/**\n * Inline SVGs rather than the Icon component: Input is the most-installed\n * primitive in the kit, and routing it through the icon registry would make\n * every consumer's password field depend on an icon set being configured.\n */\nfunction EyeIcon() {\n return (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n <path d=\"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0\" />\n <circle cx=\"12\" cy=\"12\" r=\"3\" />\n </svg>\n );\n}\n\nfunction EyeOffIcon() {\n return (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n <path d=\"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49\" />\n <path d=\"M14.084 14.158a3 3 0 0 1-4.242-4.242\" />\n <path d=\"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143\" />\n <path d=\"m2 2 20 20\" />\n </svg>\n );\n}\n"]}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkSNHU2AI4_cjs = require('./chunk-SNHU2AI4.cjs');
|
|
4
|
+
var chunkZU5Q77OT_cjs = require('./chunk-ZU5Q77OT.cjs');
|
|
5
|
+
var react = require('react');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
|
|
8
|
+
var DOT_COLORS = ["bg-rose-300", "bg-amber-300", "bg-green-300"];
|
|
9
|
+
var ZOOM_STEP = 1.25;
|
|
10
|
+
var clamp = (n, min, max) => Math.min(max, Math.max(min, n));
|
|
11
|
+
var FauxClient = react.forwardRef(
|
|
12
|
+
({
|
|
13
|
+
variant = "browser",
|
|
14
|
+
url,
|
|
15
|
+
meta,
|
|
16
|
+
dots = true,
|
|
17
|
+
width,
|
|
18
|
+
scale = "fit",
|
|
19
|
+
controls = false,
|
|
20
|
+
zoom: controlledZoom,
|
|
21
|
+
defaultZoom = 1,
|
|
22
|
+
onZoomChange,
|
|
23
|
+
minZoom = 0.5,
|
|
24
|
+
maxZoom = 4,
|
|
25
|
+
onFullscreenChange,
|
|
26
|
+
className,
|
|
27
|
+
barClassName,
|
|
28
|
+
bodyClassName,
|
|
29
|
+
children,
|
|
30
|
+
...rest
|
|
31
|
+
}, ref) => {
|
|
32
|
+
const scaled = typeof width === "number";
|
|
33
|
+
const rootRef = react.useRef(null);
|
|
34
|
+
const viewportRef = react.useRef(null);
|
|
35
|
+
const stageRef = react.useRef(null);
|
|
36
|
+
const [fit, setFit] = react.useState(typeof scale === "number" ? scale : 1);
|
|
37
|
+
const [naturalHeight, setNaturalHeight] = react.useState(void 0);
|
|
38
|
+
const showZoom = controls === true || typeof controls === "object" && controls.zoom !== false;
|
|
39
|
+
const showFullscreen = controls === true || typeof controls === "object" && controls.fullscreen !== false;
|
|
40
|
+
const [zoom, setZoom] = chunkSNHU2AI4_cjs.useControllableState(controlledZoom, defaultZoom, onZoomChange);
|
|
41
|
+
const [fullscreen, setFullscreen] = react.useState(false);
|
|
42
|
+
react.useLayoutEffect(() => {
|
|
43
|
+
if (!scaled) return;
|
|
44
|
+
const viewport = viewportRef.current;
|
|
45
|
+
const stage = stageRef.current;
|
|
46
|
+
if (!viewport || !stage) return;
|
|
47
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
48
|
+
const measure = () => {
|
|
49
|
+
const avail = viewport.clientWidth;
|
|
50
|
+
setFit(scale === "fit" ? width && width > 0 ? avail / width : 1 : scale);
|
|
51
|
+
setNaturalHeight(stage.offsetHeight);
|
|
52
|
+
};
|
|
53
|
+
measure();
|
|
54
|
+
const ro = new ResizeObserver(measure);
|
|
55
|
+
ro.observe(viewport);
|
|
56
|
+
ro.observe(stage);
|
|
57
|
+
return () => ro.disconnect();
|
|
58
|
+
}, [scaled, scale, width]);
|
|
59
|
+
react.useEffect(() => {
|
|
60
|
+
if (!showFullscreen || typeof document === "undefined") return;
|
|
61
|
+
const sync = () => {
|
|
62
|
+
const on = document.fullscreenElement != null && document.fullscreenElement === rootRef.current;
|
|
63
|
+
setFullscreen(on);
|
|
64
|
+
onFullscreenChange?.(on);
|
|
65
|
+
};
|
|
66
|
+
document.addEventListener("fullscreenchange", sync);
|
|
67
|
+
return () => document.removeEventListener("fullscreenchange", sync);
|
|
68
|
+
}, [showFullscreen, onFullscreenChange]);
|
|
69
|
+
const toggleFullscreen = react.useCallback(() => {
|
|
70
|
+
const el = rootRef.current;
|
|
71
|
+
if (!el || typeof document === "undefined") return;
|
|
72
|
+
if (document.fullscreenElement === el) void document.exitFullscreen?.();
|
|
73
|
+
else void el.requestFullscreen?.();
|
|
74
|
+
}, []);
|
|
75
|
+
const zoomBy = (factor) => {
|
|
76
|
+
setZoom(clamp(Math.round(zoom * factor * 100) / 100, minZoom, maxZoom));
|
|
77
|
+
};
|
|
78
|
+
const setRefs = (el) => {
|
|
79
|
+
rootRef.current = el;
|
|
80
|
+
if (typeof ref === "function") ref(el);
|
|
81
|
+
else if (ref) ref.current = el;
|
|
82
|
+
};
|
|
83
|
+
const isBrowser = variant === "browser";
|
|
84
|
+
const isDevice = variant === "device";
|
|
85
|
+
const effective = fit * zoom;
|
|
86
|
+
const zoomed = zoom !== 1;
|
|
87
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
88
|
+
"div",
|
|
89
|
+
{
|
|
90
|
+
ref: setRefs,
|
|
91
|
+
"data-react-fancy-faux-client": "",
|
|
92
|
+
"data-fullscreen": showFullscreen ? String(fullscreen) : void 0,
|
|
93
|
+
className: chunkZU5Q77OT_cjs.cn(
|
|
94
|
+
"relative overflow-hidden bg-white dark:bg-zinc-900",
|
|
95
|
+
isBrowser && "rounded-2xl border border-zinc-200 shadow-xl dark:border-zinc-800",
|
|
96
|
+
isDevice && "rounded-[2rem] border-[10px] border-zinc-800 shadow-2xl dark:border-zinc-700",
|
|
97
|
+
variant === "bare" && "rounded-lg border border-zinc-200 dark:border-zinc-800",
|
|
98
|
+
// Full screen: the frame fills the screen and its body takes the room.
|
|
99
|
+
fullscreen && "flex flex-col rounded-none",
|
|
100
|
+
className
|
|
101
|
+
),
|
|
102
|
+
...rest,
|
|
103
|
+
children: [
|
|
104
|
+
isBrowser && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
105
|
+
"div",
|
|
106
|
+
{
|
|
107
|
+
className: chunkZU5Q77OT_cjs.cn(
|
|
108
|
+
"flex items-center gap-2 border-b border-zinc-200 bg-zinc-50 px-3.5 py-2.5 font-mono text-[11.5px] text-zinc-500 dark:border-zinc-800 dark:bg-zinc-950 dark:text-zinc-400",
|
|
109
|
+
barClassName
|
|
110
|
+
),
|
|
111
|
+
children: [
|
|
112
|
+
dots && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mr-1.5 flex gap-[5px]", children: DOT_COLORS.map((color, i) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: chunkZU5Q77OT_cjs.cn("h-[9px] w-[9px] rounded-full", color) }, i)) }),
|
|
113
|
+
url != null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children: url }),
|
|
114
|
+
meta != null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0 text-zinc-400 dark:text-zinc-500", children: meta })
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
119
|
+
"div",
|
|
120
|
+
{
|
|
121
|
+
ref: viewportRef,
|
|
122
|
+
className: chunkZU5Q77OT_cjs.cn(
|
|
123
|
+
"relative",
|
|
124
|
+
// Zoomed in, the content is bigger than the frame: scroll to it.
|
|
125
|
+
zoomed ? "overflow-auto" : "overflow-hidden",
|
|
126
|
+
fullscreen && "min-h-0 flex-1",
|
|
127
|
+
bodyClassName
|
|
128
|
+
),
|
|
129
|
+
style: scaled && !fullscreen && naturalHeight !== void 0 ? { height: naturalHeight * fit } : void 0,
|
|
130
|
+
children: scaled ? (
|
|
131
|
+
// A sizer the size of the zoomed content, so the scrollbars are right.
|
|
132
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
133
|
+
"div",
|
|
134
|
+
{
|
|
135
|
+
style: naturalHeight !== void 0 && width !== void 0 ? { width: width * effective, height: naturalHeight * effective, position: "relative" } : void 0,
|
|
136
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
137
|
+
"div",
|
|
138
|
+
{
|
|
139
|
+
ref: stageRef,
|
|
140
|
+
"data-react-fancy-faux-client-content": "",
|
|
141
|
+
className: "absolute left-0 top-0 origin-top-left",
|
|
142
|
+
style: { width, transform: `scale(${effective})` },
|
|
143
|
+
children
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
149
|
+
"div",
|
|
150
|
+
{
|
|
151
|
+
"data-react-fancy-faux-client-content": "",
|
|
152
|
+
className: chunkZU5Q77OT_cjs.cn(fullscreen && "h-full"),
|
|
153
|
+
style: zoomed ? { zoom: String(zoom) } : void 0,
|
|
154
|
+
children
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
),
|
|
159
|
+
(showZoom || showFullscreen) && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
160
|
+
"div",
|
|
161
|
+
{
|
|
162
|
+
"data-react-fancy-faux-client-controls": "",
|
|
163
|
+
className: "absolute bottom-2 right-2 z-10 flex items-center gap-0.5 rounded-md border border-zinc-200 bg-white/90 p-0.5 text-zinc-700 shadow-sm backdrop-blur dark:border-zinc-700 dark:bg-zinc-900/90 dark:text-zinc-200",
|
|
164
|
+
children: [
|
|
165
|
+
showZoom && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
166
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
167
|
+
"button",
|
|
168
|
+
{
|
|
169
|
+
type: "button",
|
|
170
|
+
"data-react-fancy-faux-client-zoom-out": "",
|
|
171
|
+
"aria-label": "Zoom out",
|
|
172
|
+
disabled: zoom <= minZoom,
|
|
173
|
+
onClick: () => zoomBy(1 / ZOOM_STEP),
|
|
174
|
+
className: "flex h-6 w-6 items-center justify-center rounded text-base leading-none hover:bg-zinc-100 disabled:opacity-40 dark:hover:bg-zinc-800",
|
|
175
|
+
children: "\u2212"
|
|
176
|
+
}
|
|
177
|
+
),
|
|
178
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
179
|
+
"button",
|
|
180
|
+
{
|
|
181
|
+
type: "button",
|
|
182
|
+
"data-react-fancy-faux-client-zoom-reset": "",
|
|
183
|
+
"aria-label": "Reset zoom",
|
|
184
|
+
onClick: () => setZoom(1),
|
|
185
|
+
className: "min-w-[3rem] rounded px-1 text-center text-xs tabular-nums hover:bg-zinc-100 dark:hover:bg-zinc-800",
|
|
186
|
+
children: [
|
|
187
|
+
Math.round(zoom * 100),
|
|
188
|
+
"%"
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
),
|
|
192
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
193
|
+
"button",
|
|
194
|
+
{
|
|
195
|
+
type: "button",
|
|
196
|
+
"data-react-fancy-faux-client-zoom-in": "",
|
|
197
|
+
"aria-label": "Zoom in",
|
|
198
|
+
disabled: zoom >= maxZoom,
|
|
199
|
+
onClick: () => zoomBy(ZOOM_STEP),
|
|
200
|
+
className: "flex h-6 w-6 items-center justify-center rounded text-base leading-none hover:bg-zinc-100 disabled:opacity-40 dark:hover:bg-zinc-800",
|
|
201
|
+
children: "+"
|
|
202
|
+
}
|
|
203
|
+
)
|
|
204
|
+
] }),
|
|
205
|
+
showFullscreen && /* @__PURE__ */ jsxRuntime.jsx(
|
|
206
|
+
"button",
|
|
207
|
+
{
|
|
208
|
+
type: "button",
|
|
209
|
+
"data-react-fancy-faux-client-fullscreen": "",
|
|
210
|
+
"aria-label": fullscreen ? "Exit full screen" : "Full screen",
|
|
211
|
+
"aria-pressed": fullscreen,
|
|
212
|
+
title: fullscreen ? "Exit full screen" : "Full screen",
|
|
213
|
+
onClick: toggleFullscreen,
|
|
214
|
+
className: "flex h-6 w-6 items-center justify-center rounded hover:bg-zinc-100 dark:hover:bg-zinc-800",
|
|
215
|
+
children: fullscreen ? /* @__PURE__ */ jsxRuntime.jsx(ExitFullscreenIcon, {}) : /* @__PURE__ */ jsxRuntime.jsx(FullscreenIcon, {})
|
|
216
|
+
}
|
|
217
|
+
)
|
|
218
|
+
]
|
|
219
|
+
}
|
|
220
|
+
)
|
|
221
|
+
]
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
);
|
|
226
|
+
FauxClient.displayName = "FauxClient";
|
|
227
|
+
function FullscreenIcon() {
|
|
228
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
229
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8 3H5a2 2 0 0 0-2 2v3" }),
|
|
230
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M21 8V5a2 2 0 0 0-2-2h-3" }),
|
|
231
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3 16v3a2 2 0 0 0 2 2h3" }),
|
|
232
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M16 21h3a2 2 0 0 0 2-2v-3" })
|
|
233
|
+
] });
|
|
234
|
+
}
|
|
235
|
+
function ExitFullscreenIcon() {
|
|
236
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
237
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8 3v3a2 2 0 0 1-2 2H3" }),
|
|
238
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M21 8h-3a2 2 0 0 1-2-2V3" }),
|
|
239
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3 16h3a2 2 0 0 1 2 2v3" }),
|
|
240
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M16 21v-3a2 2 0 0 1 2-2h3" })
|
|
241
|
+
] });
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
exports.FauxClient = FauxClient;
|
|
245
|
+
//# sourceMappingURL=chunk-HM7SW53Z.cjs.map
|
|
246
|
+
//# sourceMappingURL=chunk-HM7SW53Z.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/FauxClient/FauxClient.tsx"],"names":["forwardRef","useRef","useState","useControllableState","useLayoutEffect","useEffect","useCallback","jsxs","cn","jsx","Fragment"],"mappings":";;;;;;;AAKA,IAAM,UAAA,GAAa,CAAC,aAAA,EAAe,cAAA,EAAgB,cAAc,CAAA;AAGjE,IAAM,SAAA,GAAY,IAAA;AAElB,IAAM,KAAA,GAAQ,CAAC,CAAA,EAAW,GAAA,EAAa,GAAA,KAAgB,IAAA,CAAK,GAAA,CAAI,GAAA,EAAK,IAAA,CAAK,GAAA,CAAI,GAAA,EAAK,CAAC,CAAC,CAAA;AAa9E,IAAM,UAAA,GAAaA,gBAAA;AAAA,EACxB,CACE;AAAA,IACE,OAAA,GAAU,SAAA;AAAA,IACV,GAAA;AAAA,IACA,IAAA;AAAA,IACA,IAAA,GAAO,IAAA;AAAA,IACP,KAAA;AAAA,IACA,KAAA,GAAQ,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useEffect, useLayoutEffect, useRef, useState } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { useControllableState } from \"../../hooks/use-controllable-state\";\nimport type { FauxClientProps } from \"./FauxClient.types\";\n\nconst DOT_COLORS = [\"bg-rose-300\", \"bg-amber-300\", \"bg-green-300\"];\n\n/** One click of the zoom bar. Matches `ImageViewer`, so the kit zooms one way. */\nconst ZOOM_STEP = 1.25;\n\nconst clamp = (n: number, min: number, max: number) => Math.min(max, Math.max(min, n));\n\n/**\n * A frame that mimics a browser window or device, rendering **real UI** inside.\n * With a logical `width` + `scale=\"fit\"` it renders a full-size page/app and\n * scales it down to fit any container (live thumbnails, device mockups) — the\n * content is real and interactive, just zoomed.\n *\n * Omit `width` for chrome around natural-size content (e.g. a code/preview card).\n *\n * `controls` adds a zoom bar and a full-screen button, for content that has to be\n * READ rather than glanced at: a slide or a sheet shrunk to fit a panel.\n */\nexport const FauxClient = forwardRef<HTMLDivElement, FauxClientProps>(\n (\n {\n variant = \"browser\",\n url,\n meta,\n dots = true,\n width,\n scale = \"fit\",\n controls = false,\n zoom: controlledZoom,\n defaultZoom = 1,\n onZoomChange,\n minZoom = 0.5,\n maxZoom = 4,\n onFullscreenChange,\n className,\n barClassName,\n bodyClassName,\n children,\n ...rest\n },\n ref,\n ) => {\n const scaled = typeof width === \"number\";\n const rootRef = useRef<HTMLDivElement | null>(null);\n const viewportRef = useRef<HTMLDivElement>(null);\n const stageRef = useRef<HTMLDivElement>(null);\n const [fit, setFit] = useState(typeof scale === \"number\" ? scale : 1);\n const [naturalHeight, setNaturalHeight] = useState<number | undefined>(undefined);\n\n const showZoom = controls === true || (typeof controls === \"object\" && controls.zoom !== false);\n const showFullscreen = controls === true || (typeof controls === \"object\" && controls.fullscreen !== false);\n const [zoom, setZoom] = useControllableState(controlledZoom, defaultZoom, onZoomChange);\n const [fullscreen, setFullscreen] = useState(false);\n\n useLayoutEffect(() => {\n if (!scaled) return;\n const viewport = viewportRef.current;\n const stage = stageRef.current;\n if (!viewport || !stage) return;\n if (typeof ResizeObserver === \"undefined\") return;\n\n const measure = () => {\n const avail = viewport.clientWidth;\n setFit(scale === \"fit\" ? (width && width > 0 ? avail / width : 1) : scale);\n // offsetHeight is the pre-transform layout height (CSS transforms don't affect it).\n setNaturalHeight(stage.offsetHeight);\n };\n\n measure();\n const ro = new ResizeObserver(measure);\n ro.observe(viewport);\n ro.observe(stage);\n return () => ro.disconnect();\n }, [scaled, scale, width]);\n\n // Full screen is the browser's state, not ours: follow it, so Esc and the\n // browser's own exit leave the button telling the truth.\n useEffect(() => {\n if (!showFullscreen || typeof document === \"undefined\") return;\n const sync = () => {\n const on = document.fullscreenElement != null && document.fullscreenElement === rootRef.current;\n setFullscreen(on);\n onFullscreenChange?.(on);\n };\n document.addEventListener(\"fullscreenchange\", sync);\n return () => document.removeEventListener(\"fullscreenchange\", sync);\n }, [showFullscreen, onFullscreenChange]);\n\n const toggleFullscreen = useCallback(() => {\n const el = rootRef.current;\n if (!el || typeof document === \"undefined\") return;\n if (document.fullscreenElement === el) void document.exitFullscreen?.();\n else void el.requestFullscreen?.();\n }, []);\n\n const zoomBy = (factor: number) => {\n // Rounded so ten clicks in and ten out land back on 100%, not 99.99%.\n setZoom(clamp(Math.round(zoom * factor * 100) / 100, minZoom, maxZoom));\n };\n\n const setRefs = (el: HTMLDivElement | null) => {\n rootRef.current = el;\n if (typeof ref === \"function\") ref(el);\n else if (ref) ref.current = el;\n };\n\n const isBrowser = variant === \"browser\";\n const isDevice = variant === \"device\";\n const effective = fit * zoom;\n const zoomed = zoom !== 1;\n\n return (\n <div\n ref={setRefs}\n data-react-fancy-faux-client=\"\"\n data-fullscreen={showFullscreen ? String(fullscreen) : undefined}\n className={cn(\n \"relative overflow-hidden bg-white dark:bg-zinc-900\",\n isBrowser && \"rounded-2xl border border-zinc-200 shadow-xl dark:border-zinc-800\",\n isDevice && \"rounded-[2rem] border-[10px] border-zinc-800 shadow-2xl dark:border-zinc-700\",\n variant === \"bare\" && \"rounded-lg border border-zinc-200 dark:border-zinc-800\",\n // Full screen: the frame fills the screen and its body takes the room.\n fullscreen && \"flex flex-col rounded-none\",\n className,\n )}\n {...rest}\n >\n {isBrowser && (\n <div\n className={cn(\n \"flex items-center gap-2 border-b border-zinc-200 bg-zinc-50 px-3.5 py-2.5 font-mono text-[11.5px] text-zinc-500 dark:border-zinc-800 dark:bg-zinc-950 dark:text-zinc-400\",\n barClassName,\n )}\n >\n {dots && (\n <div className=\"mr-1.5 flex gap-[5px]\">\n {DOT_COLORS.map((color, i) => (\n <span key={i} className={cn(\"h-[9px] w-[9px] rounded-full\", color)} />\n ))}\n </div>\n )}\n {url != null && <span className=\"min-w-0 flex-1 truncate\">{url}</span>}\n {meta != null && <span className=\"shrink-0 text-zinc-400 dark:text-zinc-500\">{meta}</span>}\n </div>\n )}\n\n <div\n ref={viewportRef}\n className={cn(\n \"relative\",\n // Zoomed in, the content is bigger than the frame: scroll to it.\n zoomed ? \"overflow-auto\" : \"overflow-hidden\",\n fullscreen && \"min-h-0 flex-1\",\n bodyClassName,\n )}\n // The frame keeps its FIT height whatever the zoom; zooming scrolls.\n style={scaled && !fullscreen && naturalHeight !== undefined ? { height: naturalHeight * fit } : undefined}\n >\n {scaled ? (\n // A sizer the size of the zoomed content, so the scrollbars are right.\n <div\n style={\n naturalHeight !== undefined && width !== undefined\n ? { width: width * effective, height: naturalHeight * effective, position: \"relative\" }\n : undefined\n }\n >\n <div\n ref={stageRef}\n data-react-fancy-faux-client-content=\"\"\n className=\"absolute left-0 top-0 origin-top-left\"\n style={{ width, transform: `scale(${effective})` }}\n >\n {children}\n </div>\n </div>\n ) : (\n <div\n data-react-fancy-faux-client-content=\"\"\n className={cn(fullscreen && \"h-full\")}\n // CSS `zoom` rather than a transform: it changes layout size, so the\n // content reflows and the viewport scrolls to all of it.\n style={zoomed ? { zoom: String(zoom) } : undefined}\n >\n {children}\n </div>\n )}\n </div>\n\n {(showZoom || showFullscreen) && (\n <div\n data-react-fancy-faux-client-controls=\"\"\n className=\"absolute bottom-2 right-2 z-10 flex items-center gap-0.5 rounded-md border border-zinc-200 bg-white/90 p-0.5 text-zinc-700 shadow-sm backdrop-blur dark:border-zinc-700 dark:bg-zinc-900/90 dark:text-zinc-200\"\n >\n {showZoom && (\n <>\n <button\n type=\"button\"\n data-react-fancy-faux-client-zoom-out=\"\"\n aria-label=\"Zoom out\"\n disabled={zoom <= minZoom}\n onClick={() => zoomBy(1 / ZOOM_STEP)}\n className=\"flex h-6 w-6 items-center justify-center rounded text-base leading-none hover:bg-zinc-100 disabled:opacity-40 dark:hover:bg-zinc-800\"\n >\n −\n </button>\n <button\n type=\"button\"\n data-react-fancy-faux-client-zoom-reset=\"\"\n aria-label=\"Reset zoom\"\n onClick={() => setZoom(1)}\n className=\"min-w-[3rem] rounded px-1 text-center text-xs tabular-nums hover:bg-zinc-100 dark:hover:bg-zinc-800\"\n >\n {Math.round(zoom * 100)}%\n </button>\n <button\n type=\"button\"\n data-react-fancy-faux-client-zoom-in=\"\"\n aria-label=\"Zoom in\"\n disabled={zoom >= maxZoom}\n onClick={() => zoomBy(ZOOM_STEP)}\n className=\"flex h-6 w-6 items-center justify-center rounded text-base leading-none hover:bg-zinc-100 disabled:opacity-40 dark:hover:bg-zinc-800\"\n >\n +\n </button>\n </>\n )}\n {showFullscreen && (\n <button\n type=\"button\"\n data-react-fancy-faux-client-fullscreen=\"\"\n aria-label={fullscreen ? \"Exit full screen\" : \"Full screen\"}\n aria-pressed={fullscreen}\n title={fullscreen ? \"Exit full screen\" : \"Full screen\"}\n onClick={toggleFullscreen}\n className=\"flex h-6 w-6 items-center justify-center rounded hover:bg-zinc-100 dark:hover:bg-zinc-800\"\n >\n {fullscreen ? <ExitFullscreenIcon /> : <FullscreenIcon />}\n </button>\n )}\n </div>\n )}\n </div>\n );\n },\n);\n\nFauxClient.displayName = \"FauxClient\";\n\n/** Inline, like `Input`'s reveal icons: a frame should not need an icon set configured. */\nfunction FullscreenIcon() {\n return (\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n <path d=\"M8 3H5a2 2 0 0 0-2 2v3\" />\n <path d=\"M21 8V5a2 2 0 0 0-2-2h-3\" />\n <path d=\"M3 16v3a2 2 0 0 0 2 2h3\" />\n <path d=\"M16 21h3a2 2 0 0 0 2-2v-3\" />\n </svg>\n );\n}\n\nfunction ExitFullscreenIcon() {\n return (\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n <path d=\"M8 3v3a2 2 0 0 1-2 2H3\" />\n <path d=\"M21 8h-3a2 2 0 0 1-2-2V3\" />\n <path d=\"M3 16h3a2 2 0 0 1 2 2v3\" />\n <path d=\"M16 21v-3a2 2 0 0 1 2-2h3\" />\n </svg>\n );\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useInlinePaste, InlinePasteEditor } from './chunk-
|
|
1
|
+
import { useInlinePaste, InlinePasteEditor, PastedFilesInput } from './chunk-KYZNCVRD.js';
|
|
2
2
|
import { Tooltip } from './chunk-CF5KRDN4.js';
|
|
3
3
|
import { Button } from './chunk-JJRD3WX3.js';
|
|
4
4
|
import { Icon } from './chunk-IVRYSSM7.js';
|
|
@@ -50,6 +50,7 @@ function PromptInput({
|
|
|
50
50
|
previewChars = 20,
|
|
51
51
|
renderPastePreview,
|
|
52
52
|
pasteClassNames,
|
|
53
|
+
pasteFilesName,
|
|
53
54
|
attachButton = "label",
|
|
54
55
|
sendButton = "label",
|
|
55
56
|
usedTokens,
|
|
@@ -298,7 +299,14 @@ function PromptInput({
|
|
|
298
299
|
)
|
|
299
300
|
}
|
|
300
301
|
),
|
|
301
|
-
paste.portals
|
|
302
|
+
paste.portals,
|
|
303
|
+
pasteImages && pasteFilesName && /* @__PURE__ */ jsx(
|
|
304
|
+
PastedFilesInput,
|
|
305
|
+
{
|
|
306
|
+
name: pasteFilesName,
|
|
307
|
+
files: paste.imagesIn(text).map((i) => i.file)
|
|
308
|
+
}
|
|
309
|
+
)
|
|
302
310
|
] }) : /* @__PURE__ */ jsx(
|
|
303
311
|
"textarea",
|
|
304
312
|
{
|
|
@@ -473,5 +481,5 @@ function fmtSize(b) {
|
|
|
473
481
|
}
|
|
474
482
|
|
|
475
483
|
export { PromptInput, browserPlatformHints, detectPlatform, modifierKeyLabel };
|
|
476
|
-
//# sourceMappingURL=chunk-
|
|
477
|
-
//# sourceMappingURL=chunk-
|
|
484
|
+
//# sourceMappingURL=chunk-JZCAMPIA.js.map
|
|
485
|
+
//# sourceMappingURL=chunk-JZCAMPIA.js.map
|