@particle-academy/react-fancy 5.64.1 → 5.66.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 +67 -0
- package/dist/{PastePills.types-CDyotkUb.d.cts → PastePills.types-CpXzsuwJ.d.cts} +2 -0
- package/dist/{PastePills.types-CDyotkUb.d.ts → PastePills.types-CpXzsuwJ.d.ts} +2 -0
- package/dist/{PastedFilesInput-CrgNoEBd.d.ts → PastedFilesInput-Bt3KSTVN.d.ts} +1 -1
- package/dist/{PastedFilesInput-DQ1eZaHk.d.cts → PastedFilesInput-CUQeOeOA.d.cts} +1 -1
- package/dist/{chunk-SZH7TFME.js → chunk-4EUDW2WU.js} +3 -3
- package/dist/{chunk-SZH7TFME.js.map → chunk-4EUDW2WU.js.map} +1 -1
- package/dist/{chunk-CMC2TOEQ.cjs → chunk-6CAXLP7D.cjs} +6 -6
- package/dist/{chunk-CMC2TOEQ.cjs.map → chunk-6CAXLP7D.cjs.map} +1 -1
- package/dist/{chunk-TQGRXJ74.cjs → chunk-7FYRFNPX.cjs} +9 -9
- package/dist/{chunk-TQGRXJ74.cjs.map → chunk-7FYRFNPX.cjs.map} +1 -1
- package/dist/{chunk-4XHG6Q42.cjs → chunk-7HXFEYOV.cjs} +8 -8
- package/dist/{chunk-4XHG6Q42.cjs.map → chunk-7HXFEYOV.cjs.map} +1 -1
- package/dist/{chunk-MVVHUTXA.js → chunk-B4LVQ4QI.js} +3 -3
- package/dist/{chunk-MVVHUTXA.js.map → chunk-B4LVQ4QI.js.map} +1 -1
- package/dist/{chunk-QNQNGARW.cjs → chunk-HFK5SBNM.cjs} +27 -9
- package/dist/chunk-HFK5SBNM.cjs.map +1 -0
- package/dist/{chunk-BTNF3QBR.js → chunk-J44EV6SP.js} +366 -32
- package/dist/chunk-J44EV6SP.js.map +1 -0
- package/dist/{chunk-Z6LYBL5L.cjs → chunk-MCQWTOTV.cjs} +369 -33
- package/dist/chunk-MCQWTOTV.cjs.map +1 -0
- package/dist/{chunk-ELFTEJBT.js → chunk-QSGAFKK2.js} +3 -3
- package/dist/{chunk-ELFTEJBT.js.map → chunk-QSGAFKK2.js.map} +1 -1
- package/dist/{chunk-NILA2LZY.js → chunk-YIKXJWO4.js} +27 -9
- package/dist/chunk-YIKXJWO4.js.map +1 -0
- package/dist/composer.cjs +4 -4
- package/dist/composer.d.cts +2 -2
- package/dist/composer.d.ts +2 -2
- package/dist/composer.js +2 -2
- package/dist/{index-BZON-gXr.d.ts → index-DWtSViJ3.d.cts} +147 -4
- package/dist/{index-BF5qsQur.d.cts → index-XR5t8bTq.d.ts} +147 -4
- package/dist/index.cjs +36 -28
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -5
- package/dist/input.cjs +3 -3
- package/dist/input.d.cts +1 -1
- package/dist/input.d.ts +1 -1
- package/dist/input.js +2 -2
- package/dist/inputs.cjs +3 -3
- package/dist/inputs.d.cts +1 -1
- package/dist/inputs.d.ts +1 -1
- package/dist/inputs.js +2 -2
- package/dist/json-editor.cjs +14 -14
- package/dist/json-editor.js +3 -3
- package/dist/paste-pills.cjs +14 -14
- package/dist/paste-pills.d.cts +3 -3
- package/dist/paste-pills.d.ts +3 -3
- package/dist/paste-pills.js +1 -1
- package/dist/prompt-input.cjs +11 -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/docs/PromptInput.md +101 -1
- package/package.json +1 -1
- package/dist/chunk-BTNF3QBR.js.map +0 -1
- package/dist/chunk-NILA2LZY.js.map +0 -1
- package/dist/chunk-QNQNGARW.cjs.map +0 -1
- package/dist/chunk-Z6LYBL5L.cjs.map +0 -1
|
@@ -4,7 +4,7 @@ var chunkMRZXTL46_cjs = require('./chunk-MRZXTL46.cjs');
|
|
|
4
4
|
var chunkP53432AK_cjs = require('./chunk-P53432AK.cjs');
|
|
5
5
|
var chunkQF7CD4JH_cjs = require('./chunk-QF7CD4JH.cjs');
|
|
6
6
|
var chunkO3F6DYWR_cjs = require('./chunk-O3F6DYWR.cjs');
|
|
7
|
-
var
|
|
7
|
+
var chunkHFK5SBNM_cjs = require('./chunk-HFK5SBNM.cjs');
|
|
8
8
|
var chunkKJ22KE56_cjs = require('./chunk-KJ22KE56.cjs');
|
|
9
9
|
var chunkL3V3BYVS_cjs = require('./chunk-L3V3BYVS.cjs');
|
|
10
10
|
var chunkSNHU2AI4_cjs = require('./chunk-SNHU2AI4.cjs');
|
|
@@ -82,7 +82,7 @@ var Input = react.forwardRef(
|
|
|
82
82
|
const pasting = pasteThreshold !== void 0 || pasteImages;
|
|
83
83
|
const editorRef = react.useRef(null);
|
|
84
84
|
const hiddenRef = react.useRef(null);
|
|
85
|
-
const paste =
|
|
85
|
+
const paste = chunkHFK5SBNM_cjs.useInlinePaste({
|
|
86
86
|
pasteThreshold,
|
|
87
87
|
pasteImages,
|
|
88
88
|
previewChars,
|
|
@@ -136,7 +136,7 @@ var Input = react.forwardRef(
|
|
|
136
136
|
),
|
|
137
137
|
pasting ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
138
138
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
139
|
-
|
|
139
|
+
chunkHFK5SBNM_cjs.InlinePasteEditor,
|
|
140
140
|
{
|
|
141
141
|
ref: editorRef,
|
|
142
142
|
id: inputId,
|
|
@@ -188,7 +188,7 @@ var Input = react.forwardRef(
|
|
|
188
188
|
value: paste.expand(pasteValue)
|
|
189
189
|
}
|
|
190
190
|
),
|
|
191
|
-
pasteImages && filesName && /* @__PURE__ */ jsxRuntime.jsx(
|
|
191
|
+
pasteImages && filesName && /* @__PURE__ */ jsxRuntime.jsx(chunkHFK5SBNM_cjs.PastedFilesInput, { name: filesName, files: pastedFiles, form: props.form })
|
|
192
192
|
] }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
193
193
|
"input",
|
|
194
194
|
{
|
|
@@ -300,5 +300,5 @@ function EyeOffIcon() {
|
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
exports.Input = Input;
|
|
303
|
-
//# sourceMappingURL=chunk-
|
|
304
|
-
//# sourceMappingURL=chunk-
|
|
303
|
+
//# sourceMappingURL=chunk-6CAXLP7D.cjs.map
|
|
304
|
+
//# sourceMappingURL=chunk-6CAXLP7D.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-adornment-width.ts","../src/components/inputs/Input/Input.tsx"],"names":["useState","useCallback","useEffect","forwardRef","useId","useFieldMode","useInlineEdit","useControllableState","useRef","useInlinePaste","useMemo","jsx","DisplayValue","InputWrapper","jsxs","Fragment","InlinePasteEditor","cn","inputBaseClasses","inputSizeClasses","dirtyClasses","errorClasses","PastedFilesInput","Field"],"mappings":";;;;;;;;;;;;;;AA0BO,SAAS,iBAAA,GAAkE;AAChF,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAIA,eAAS,CAAC,CAAA;AACpC,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAIA,eAA6B,IAAI,CAAA;AAEzD,EAAA,MAAM,GAAA,GAAMC,kBAAY,CAAC,CAAA,KAA0B,QAAQ,CAAC,CAAA,EAAG,EAAE,CAAA;AAEjE,EAAAC,eAAA,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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,IAAA,EAAK,QAAO,MAAA,EAAO,cAAA,EAAe,aAAY,GAAA,EAAI,aAAA,EAAc,SAAQ,cAAA,EAAe,OAAA,EAAQ,eAAY,MAAA,EACzJ,QAAA,EAAA;AAAA,oBAAAA,cAAA,CAAC,MAAA,EAAA,EAAK,GAAE,gGAAA,EAAiG,CAAA;AAAA,oBACzGA,cAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAE,sCAAA,EAAuC,CAAA;AAAA,oBAC/CA,cAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAE,8FAAA,EAA+F,CAAA;AAAA,oBACvGA,cAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAE,YAAA,EAAa;AAAA,GAAA,EACvB,CAAA;AAEJ","file":"chunk-CMC2TOEQ.cjs","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-[color:var(--fancy-text-faint,var(--color-zinc-400))] dark:text-[color:var(--fancy-text-faint-dark,var(--color-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-[color:var(--fancy-text-faint,var(--color-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-[color:var(--fancy-text-faint-dark,var(--color-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-[color:var(--fancy-text-faint,var(--color-zinc-400))] dark:text-[color:var(--fancy-text-faint-dark,var(--color-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"]}
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-adornment-width.ts","../src/components/inputs/Input/Input.tsx"],"names":["useState","useCallback","useEffect","forwardRef","useId","useFieldMode","useInlineEdit","useControllableState","useRef","useInlinePaste","useMemo","jsx","DisplayValue","InputWrapper","jsxs","Fragment","InlinePasteEditor","cn","inputBaseClasses","inputSizeClasses","dirtyClasses","errorClasses","PastedFilesInput","Field"],"mappings":";;;;;;;;;;;;;;AA0BO,SAAS,iBAAA,GAAkE;AAChF,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAIA,eAAS,CAAC,CAAA;AACpC,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAIA,eAA6B,IAAI,CAAA;AAEzD,EAAA,MAAM,GAAA,GAAMC,kBAAY,CAAC,CAAA,KAA0B,QAAQ,CAAC,CAAA,EAAG,EAAE,CAAA;AAEjE,EAAAC,eAAA,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,GAAQC,gBAAA;AAAA,EACnB,CACE;AAAA,IACE,IAAA,GAAO,MAAA;AAAA,IAC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A,EAAA,EAAK,CAAA,EAAE,sCAAA,EAAuC,CAAA;AAAA,oBAC/CA,cAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAE,8FAAA,EAA+F,CAAA;AAAA,oBACvGA,cAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAE,YAAA,EAAa;AAAA,GAAA,EACvB,CAAA;AAEJ","file":"chunk-6CAXLP7D.cjs","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-[color:var(--fancy-text-faint,var(--color-zinc-400))] dark:text-[color:var(--fancy-text-faint-dark,var(--color-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-[color:var(--fancy-text-faint,var(--color-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-[color:var(--fancy-text-faint-dark,var(--color-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-[color:var(--fancy-text-faint,var(--color-zinc-400))] dark:text-[color:var(--fancy-text-faint-dark,var(--color-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"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkHFK5SBNM_cjs = require('./chunk-HFK5SBNM.cjs');
|
|
4
4
|
var chunkSNHU2AI4_cjs = require('./chunk-SNHU2AI4.cjs');
|
|
5
5
|
var chunkZU5Q77OT_cjs = require('./chunk-ZU5Q77OT.cjs');
|
|
6
6
|
var react = require('react');
|
|
@@ -37,7 +37,7 @@ var Composer = react.forwardRef(
|
|
|
37
37
|
);
|
|
38
38
|
const textareaRef = react.useRef(null);
|
|
39
39
|
const editorRef = react.useRef(null);
|
|
40
|
-
const paste =
|
|
40
|
+
const paste = chunkHFK5SBNM_cjs.useInlinePaste({
|
|
41
41
|
pasteThreshold,
|
|
42
42
|
pasteImages,
|
|
43
43
|
previewChars,
|
|
@@ -131,7 +131,7 @@ ${text}` : text);
|
|
|
131
131
|
"data-react-fancy-composer-paste-pill": paste2.id,
|
|
132
132
|
onClick: () => insertPaste(paste2),
|
|
133
133
|
disabled,
|
|
134
|
-
"aria-label": `Insert this pasted text, ${
|
|
134
|
+
"aria-label": `Insert this pasted text, ${chunkHFK5SBNM_cjs.withSeparators(paste2.text.length)} characters`,
|
|
135
135
|
"aria-describedby": `${paste2.id}-preview`,
|
|
136
136
|
className: chunkZU5Q77OT_cjs.cn(
|
|
137
137
|
"inline-flex items-center gap-1.5 rounded-full border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-zinc-50 py-1 pl-2.5 pr-7 text-xs text-zinc-700 transition-colors hover:bg-zinc-100 dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-zinc-800 dark:text-zinc-200 dark:hover:bg-zinc-700",
|
|
@@ -140,7 +140,7 @@ ${text}` : text);
|
|
|
140
140
|
),
|
|
141
141
|
children: /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
142
142
|
"Pasted text \xB7 ",
|
|
143
|
-
|
|
143
|
+
chunkHFK5SBNM_cjs.withSeparators(paste2.text.length),
|
|
144
144
|
" characters"
|
|
145
145
|
] })
|
|
146
146
|
}
|
|
@@ -170,7 +170,7 @@ ${text}` : text);
|
|
|
170
170
|
"pointer-events-none absolute bottom-full left-0 z-10 mb-1 hidden max-w-xs whitespace-pre-wrap break-all rounded-md bg-zinc-900 px-2 py-1 text-xs text-white group-hover:block dark:bg-zinc-100 dark:text-zinc-900",
|
|
171
171
|
classNames?.preview
|
|
172
172
|
),
|
|
173
|
-
children: renderPastePreview?.({ kind: "text", paste: paste2 }) ??
|
|
173
|
+
children: renderPastePreview?.({ kind: "text", paste: paste2 }) ?? chunkHFK5SBNM_cjs.endsOf(paste2.text, previewChars)
|
|
174
174
|
}
|
|
175
175
|
)
|
|
176
176
|
] }, paste2.id)
|
|
@@ -179,7 +179,7 @@ ${text}` : text);
|
|
|
179
179
|
),
|
|
180
180
|
inline ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
181
181
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
182
|
-
|
|
182
|
+
chunkHFK5SBNM_cjs.InlinePasteEditor,
|
|
183
183
|
{
|
|
184
184
|
ref: editorRef,
|
|
185
185
|
value,
|
|
@@ -194,7 +194,7 @@ ${text}` : text);
|
|
|
194
194
|
}
|
|
195
195
|
),
|
|
196
196
|
paste.portals,
|
|
197
|
-
pasteImages && pasteFilesName && /* @__PURE__ */ jsxRuntime.jsx(
|
|
197
|
+
pasteImages && pasteFilesName && /* @__PURE__ */ jsxRuntime.jsx(chunkHFK5SBNM_cjs.PastedFilesInput, { name: pasteFilesName, files: pastedFiles })
|
|
198
198
|
] }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
199
199
|
"textarea",
|
|
200
200
|
{
|
|
@@ -233,5 +233,5 @@ ${text}` : text);
|
|
|
233
233
|
Composer.displayName = "Composer";
|
|
234
234
|
|
|
235
235
|
exports.Composer = Composer;
|
|
236
|
-
//# sourceMappingURL=chunk-
|
|
237
|
-
//# sourceMappingURL=chunk-
|
|
236
|
+
//# sourceMappingURL=chunk-7FYRFNPX.cjs.map
|
|
237
|
+
//# sourceMappingURL=chunk-7FYRFNPX.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Composer/Composer.tsx"],"names":["forwardRef","Composer","useControllableState","useRef","useInlinePaste","useMemo","useCallback","jsxs","cn","jsx","paste","withSeparators","endsOf","Fragment","InlinePasteEditor","PastedFilesInput"],"mappings":";;;;;;;;AAeA,IAAM,aAAA,GAAgB,EAAA;AAEf,IAAM,QAAA,GAAWA,gBAAA;AAAA,EACtB,SAASC,SAAAA,CACP;AAAA,IACE,KAAA,EAAO,eAAA;AAAA,IACP,YAAA,GAAe,EAAA;AAAA,IACf,QAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA,GAAc,mBAAA;AAAA,IACd,OAAA;AAAA,IACA,QAAA,GAAW,KAAA;AAAA,IACX,SAAA;AAAA,IACA,cAAA;AAAA,IACA,cAAA,GAAiB,OAAA;AAAA,IACjB,WAAA,GAAc,KAAA;AAAA,IACd,YAAA,GAAe,aAAA;AAAA,IACf,kBAAA;AAAA,IACA,UAAA;AAAA,IACA,UAAA,EAAY,oBAAA;AAAA,IACZ,kBAAA;AAAA,IACA,UAAA,EAAY,oBAAA;AAAA,IACZ,kBAAA;AAAA,IACA;AAAA,KAEF,GAAA,EACA;AACA,IAAA,MAAM,SAAS,cAAA,KAAmB,QAAA;AAClC,IAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAIC,sCAAA;AAAA,MACxB,eAAA;AAAA,MACA,YAAA;AAAA,MACA;AAAA,KACF;AACA,IAAA,MAAM,WAAA,GAAcC,aAA4B,IAAI,CAAA;AACpD,IAAA,MAAM,SAAA,GAAYA,aAAgC,IAAI,CAAA;AAOtD,IAAA,MAAM,QAAQC,gCAAA,CAAe;AAAA,MAC3B,cAAA;AAAA,MACA,WAAA;AAAA,MACA,YAAA;AAAA,MACA,kBAAA;AAAA,MACA,UAAA;AAAA,MACA,QAAA;AAAA,MACA,UAAA,EAAY,oBAAA;AAAA,MACZ,kBAAA;AAAA,MACA,UAAA,EAAY,oBAAA;AAAA,MACZ,kBAAA;AAAA,MACA;AAAA,KACD,CAAA;A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from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { useControllableState } from \"../../hooks/use-controllable-state\";\nimport {\n endsOf,\n InlinePasteEditor,\n PastedFilesInput,\n useInlinePaste,\n withSeparators,\n type HeldPaste,\n type InlinePasteEditorHandle,\n} from \"../PastePills\";\nimport type { ComposerProps } from \"./Composer.types\";\n\n/** Characters of a held paste shown at each end of the hover preview, unless `previewChars` says otherwise. */\nconst PREVIEW_CHARS = 20;\n\nexport const Composer = forwardRef<HTMLDivElement, ComposerProps>(\n function Composer(\n {\n value: controlledValue,\n defaultValue = \"\",\n onChange,\n onSubmit,\n placeholder = \"Type a message...\",\n actions,\n disabled = false,\n className,\n pasteThreshold,\n pastePlacement = \"above\",\n pasteImages = false,\n previewChars = PREVIEW_CHARS,\n renderPastePreview,\n classNames,\n heldPastes: controlledHeldPastes,\n onHeldPastesChange,\n heldImages: controlledHeldImages,\n onHeldImagesChange,\n pasteFilesName,\n },\n ref,\n ) {\n const inline = pastePlacement === \"inline\";\n const [value, setValue] = useControllableState(\n controlledValue,\n defaultValue,\n onChange,\n );\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const editorRef = useRef<InlinePasteEditorHandle>(null);\n /*\n * The holding logic lives in `usePastePills`, wrapped by `useInlinePaste` for\n * the inline placement — which `PromptInput` shares, so the two components\n * cannot disagree about what a pill means. The rule that must not drift is\n * the one below: a send with pills still closed carries the text.\n */\n const paste = useInlinePaste({\n pasteThreshold,\n pasteImages,\n previewChars,\n renderPastePreview,\n classNames,\n disabled,\n heldPastes: controlledHeldPastes,\n onHeldPastesChange,\n heldImages: controlledHeldImages,\n onHeldImagesChange,\n editorRef,\n });\n const pills = paste.pills;\n const heldPastes = paste.heldPastes;\n const pastedFiles = useMemo(\n () => (inline && pasteImages ? paste.imagesIn(value).map((i) => i.file) : []),\n [inline, pasteImages, paste, value],\n );\n\n const handlePaste = useCallback(\n (e: React.ClipboardEvent<HTMLTextAreaElement>) => {\n // Composable by design, so this reads as a question rather than a handover.\n // Nothing else here wants the paste, so the answer is simply ignored.\n pills.handlePaste(e);\n },\n [pills],\n );\n\n const handleInlineChange = useCallback(\n (next: string) => {\n setValue(next);\n paste.prune(next);\n },\n [setValue, paste],\n );\n\n /** Everything the person believes they are sending, in the order they built it. */\n const composeOutgoing = useCallback(() => {\n if (inline) return paste.expand(value);\n\n return [value, ...heldPastes.map((p) => p.text)].filter(Boolean).join(\"\\n\\n\");\n }, [inline, value, heldPastes, paste]);\n\n const hasContent = value.trim().length > 0 || (!inline && heldPastes.length > 0);\n\n const focusInput = useCallback(() => {\n if (inline) editorRef.current?.focus();\n else textareaRef.current?.focus();\n }, [inline]);\n\n const handleSubmit = useCallback(() => {\n if (!hasContent || disabled) return;\n\n /*\n * THE DANGEROUS STATE, and the reason this feature needed a spec rather than\n * a guess. A pill reads as \"your paste is attached\" — so a send that drops it\n * means asking a question about a document without the document, and nobody\n * can tell: the sender believes it went, the receiver sees a question about\n * nothing.\n *\n * Above the input, held pastes go out in arrival order after what was typed,\n * because people type the question BEFORE pasting the thing it is about.\n * Inline, every pill goes out exactly where it sits.\n */\n const images = inline ? paste.imagesIn(value) : [];\n\n onSubmit?.(composeOutgoing(), { images });\n setValue(\"\");\n paste.clear();\n focusInput();\n }, [hasContent, disabled, value, inline, paste, onSubmit, composeOutgoing, setValue, focusInput]);\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n handleSubmit();\n }\n };\n\n /** Above the input: click a pill to dump it in, APPENDED to what is already typed. */\n const insertPaste = useCallback(\n (held: HeldPaste) => {\n // `expand` removes it and hands back the text; inserting is this\n // component's job because the hook owns no DOM.\n const text = pills.expand(held.id);\n\n if (text === undefined) return;\n\n setValue((current) => (current ? `${current}\\n\\n${text}` : text));\n textareaRef.current?.focus();\n },\n [pills, setValue],\n );\n\n return (\n <div\n data-react-fancy-composer=\"\"\n ref={ref}\n className={cn(\n \"rounded-xl border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-[color:var(--fancy-surface,var(--color-white))] dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))]\",\n disabled && \"opacity-50\",\n className,\n )}\n >\n {!inline && heldPastes.length > 0 && (\n <div\n data-react-fancy-composer-paste-pills=\"\"\n className=\"flex flex-wrap gap-1.5 px-3 pt-3\"\n >\n {heldPastes.map((paste) => (\n // `group` + `group-hover` rather than hover state: the preview is\n // presentation, and a useState for it would be one more thing an\n // agent could desynchronise.\n <span key={paste.id} className=\"group relative inline-flex\">\n <button\n type=\"button\"\n data-react-fancy-composer-paste-pill={paste.id}\n onClick={() => insertPaste(paste)}\n disabled={disabled}\n // No `title`. A native tooltip plus the hover preview below\n // renders TWO tooltips on the same hover, at different delays.\n // The label says what clicking does; the preview says what the\n // text is, and it is linked rather than merely adjacent so a\n // screen reader reaches it too.\n aria-label={`Insert this pasted text, ${withSeparators(paste.text.length)} characters`}\n aria-describedby={`${paste.id}-preview`}\n // `pr-7` leaves room for the absolutely-positioned × that sits\n // over this button's right edge. With a smaller right padding the\n // × lands on top of the label.\n className={cn(\n \"inline-flex items-center gap-1.5 rounded-full border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-zinc-50 py-1 pl-2.5 pr-7 text-xs text-zinc-700 transition-colors hover:bg-zinc-100 dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-zinc-800 dark:text-zinc-200 dark:hover:bg-zinc-700\",\n classNames?.pill,\n classNames?.textPill,\n )}\n >\n <span>\n Pasted text · {withSeparators(paste.text.length)} characters\n </span>\n </button>\n\n <button\n type=\"button\"\n data-react-fancy-composer-paste-pill-remove={paste.id}\n onClick={() => pills.remove(paste.id)}\n disabled={disabled}\n aria-label=\"Discard this pasted text\"\n className={cn(\n \"absolute right-1 top-1/2 -translate-y-1/2 rounded-full px-1 text-xs text-zinc-400 transition-colors hover:text-zinc-700 dark:hover:text-zinc-100\",\n classNames?.remove,\n )}\n >\n ×\n </button>\n\n <span\n id={`${paste.id}-preview`}\n data-react-fancy-composer-paste-pill-preview={paste.id}\n role=\"tooltip\"\n className={cn(\n \"pointer-events-none absolute bottom-full left-0 z-10 mb-1 hidden max-w-xs whitespace-pre-wrap break-all rounded-md bg-zinc-900 px-2 py-1 text-xs text-white group-hover:block dark:bg-zinc-100 dark:text-zinc-900\",\n classNames?.preview,\n )}\n >\n {renderPastePreview?.({ kind: \"text\", paste }) ??\n endsOf(paste.text, previewChars)}\n </span>\n </span>\n ))}\n </div>\n )}\n\n {inline ? (\n <>\n <InlinePasteEditor\n ref={editorRef}\n value={value}\n known={paste.known}\n onChange={handleInlineChange}\n onSubmit={handleSubmit}\n onPaste={paste.decidePaste}\n onHostsChange={paste.onHostsChange}\n placeholder={placeholder}\n disabled={disabled}\n className={classNames?.input}\n />\n {paste.portals}\n {pasteImages && pasteFilesName && (\n <PastedFilesInput name={pasteFilesName} files={pastedFiles} />\n )}\n </>\n ) : (\n <textarea\n ref={textareaRef}\n value={value}\n onChange={(e) => setValue(e.target.value)}\n onKeyDown={handleKeyDown}\n onPaste={handlePaste}\n placeholder={placeholder}\n disabled={disabled}\n rows={3}\n className={cn(\n \"w-full resize-none bg-transparent px-4 pt-3 text-sm outline-none placeholder:text-zinc-400\",\n classNames?.input,\n )}\n />\n )}\n <div className=\"flex items-center justify-between border-t border-zinc-100 px-3 py-2 dark:border-zinc-800\">\n <div className=\"flex items-center gap-1\">{actions}</div>\n <button\n type=\"button\"\n onClick={handleSubmit}\n disabled={disabled || !hasContent}\n className=\"rounded-lg bg-zinc-900 px-3 py-1.5 text-sm font-medium text-white transition-colors hover:bg-zinc-800 disabled:opacity-50 dark:bg-white dark:text-zinc-900 dark:hover:bg-zinc-100\"\n >\n Send\n </button>\n </div>\n </div>\n );\n },\n);\n\nComposer.displayName = \"Composer\";\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/Composer/Composer.tsx"],"names":["forwardRef","Composer","useControllableState","useRef","useInlinePaste","useMemo","useCallback","jsxs","cn","jsx","paste","withSeparators","endsOf","Fragment","InlinePasteEditor","PastedFilesInput"],"mappings":";;;;;;;;AAeA,IAAM,aAAA,GAAgB,EAAA;AAEf,IAAM,QAAA,GAAWA,gBAAA;AAAA,EACtB,SAASC,SAAAA,CACP;AAAA,IACE,KAAA,EAAO,eAAA;AAAA,IACP,YAAA,GAAe,EAAA;AAAA,IACf,QAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA,GAAc,mBAAA;AAAA,IACd,OAAA;AAAA,IACA,QAAA,GAAW,KAAA;AAAA,IACX,SAAA;AAAA,IACA,cAAA;AAAA,IACA,cAAA,GAAiB,OAAA;AAAA,IACjB,WAAA,GAAc,KAAA;AAAA,IACd,YAAA,GAAe,aAAA;AAAA,IACf,kBAAA;AAAA,IACA,UAAA;AAAA,IACA,UAAA,EAAY,oBAAA;AAAA,IACZ,kBAAA;AAAA,IACA,UAAA,EAAY,oBAAA;AAAA,IACZ,kBAAA;AAAA,IACA;AAAA,KAEF,GAAA,EACA;AACA,IAAA,MAAM,SAAS,cAAA,KAAmB,QAAA;AAClC,IAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAIC,sCAAA;AAAA,MACxB,eAAA;AAAA,MACA,YAAA;AAAA,MACA;AAAA,KACF;AACA,IAAA,MAAM,WAAA,GAAcC,aAA4B,IAAI,CAAA;AACpD,IAAA,MAAM,SAAA,GAAYA,aAAgC,IAAI,CAAA;AAOtD,IAAA,MAAM,QAAQC,gCAAA,CAAe;AAAA,MAC3B,cAAA;AAAA,MACA,WAAA;AAAA,MACA,YAAA;AAAA,MACA,kBAAA;AAAA,MACA,UAAA;AAAA,MACA,QAAA;AAAA,MACA,UAAA,EAAY,oBAAA;AAAA,MACZ,kBAAA;AAAA,MACA,UAAA,EAAY,oBAAA;AAAA,MACZ,kBAAA;AAAA,MACA;AAAA,KACD,CAAA;AACD,IAAA,MAAM,QAAQ,KAAA,CAAM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AAe,KAAA,CAAM,aAAA;AAAA,gBACrB,WAAA;AAAA,gBACA,QAAA;AAAA,gBACA,WAAW,UAAA,EAAY;AAAA;AAAA,aACzB;AAAA,YACC,KAAA,CAAM,OAAA;AAAA,YACN,eAAe,cAAA,oBACdL,cAAA,CAACM,sCAAiB,IAAA,EAAM,cAAA,EAAgB,OAAO,WAAA,EAAa;AAAA,WAAA,EAEhE,CAAA,mBAEAN,cAAA;AAAA,YAAC,UAAA;AAAA,YAAA;AAAA,cACC,GAAA,EAAK,WAAA;AAAA,cACL,KAAA;AAAA,cACA,UAAU,CAAC,CAAA,KAAM,QAAA,CAAS,CAAA,CAAE,OAAO,KAAK,CAAA;AAAA,cACxC,SAAA,EAAW,aAAA;AAAA,cACX,OAAA,EAAS,WAAA;AAAA,cACT,WAAA;AAAA,cACA,QAAA;AAAA,cACA,IAAA,EAAM,CAAA;AAAA,cACN,SAAA,EAAWD,oBAAA;AAAA,gBACT,4FAAA;AAAA,gBACA,UAAA,EAAY;AAAA;AACd;AAAA,WACF;AAAA,0BAEFD,eAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,2FAAA,EACb,QAAA,EAAA;AAAA,4BAAAE,cAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,yBAAA,EAA2B,QAAA,EAAA,OAAA,EAAQ,CAAA;AAAA,4BAClDA,cAAA;AAAA,cAAC,QAAA;AAAA,cAAA;AAAA,gBACC,IAAA,EAAK,QAAA;AAAA,gBACL,OAAA,EAAS,YAAA;AAAA,gBACT,QAAA,EAAU,YAAY,CAAC,UAAA;AAAA,gBACvB,SAAA,EAAU,mLAAA;AAAA,gBACX,QAAA,EAAA;AAAA;AAAA;AAED,WAAA,EACF;AAAA;AAAA;AAAA,KACF;AAAA,EAEJ;AACF;AAEA,QAAA,CAAS,WAAA,GAAc,UAAA","file":"chunk-7FYRFNPX.cjs","sourcesContent":["import { forwardRef, useCallback, useMemo, useRef } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { useControllableState } from \"../../hooks/use-controllable-state\";\nimport {\n endsOf,\n InlinePasteEditor,\n PastedFilesInput,\n useInlinePaste,\n withSeparators,\n type HeldPaste,\n type InlinePasteEditorHandle,\n} from \"../PastePills\";\nimport type { ComposerProps } from \"./Composer.types\";\n\n/** Characters of a held paste shown at each end of the hover preview, unless `previewChars` says otherwise. */\nconst PREVIEW_CHARS = 20;\n\nexport const Composer = forwardRef<HTMLDivElement, ComposerProps>(\n function Composer(\n {\n value: controlledValue,\n defaultValue = \"\",\n onChange,\n onSubmit,\n placeholder = \"Type a message...\",\n actions,\n disabled = false,\n className,\n pasteThreshold,\n pastePlacement = \"above\",\n pasteImages = false,\n previewChars = PREVIEW_CHARS,\n renderPastePreview,\n classNames,\n heldPastes: controlledHeldPastes,\n onHeldPastesChange,\n heldImages: controlledHeldImages,\n onHeldImagesChange,\n pasteFilesName,\n },\n ref,\n ) {\n const inline = pastePlacement === \"inline\";\n const [value, setValue] = useControllableState(\n controlledValue,\n defaultValue,\n onChange,\n );\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const editorRef = useRef<InlinePasteEditorHandle>(null);\n /*\n * The holding logic lives in `usePastePills`, wrapped by `useInlinePaste` for\n * the inline placement — which `PromptInput` shares, so the two components\n * cannot disagree about what a pill means. The rule that must not drift is\n * the one below: a send with pills still closed carries the text.\n */\n const paste = useInlinePaste({\n pasteThreshold,\n pasteImages,\n previewChars,\n renderPastePreview,\n classNames,\n disabled,\n heldPastes: controlledHeldPastes,\n onHeldPastesChange,\n heldImages: controlledHeldImages,\n onHeldImagesChange,\n editorRef,\n });\n const pills = paste.pills;\n const heldPastes = paste.heldPastes;\n const pastedFiles = useMemo(\n () => (inline && pasteImages ? paste.imagesIn(value).map((i) => i.file) : []),\n [inline, pasteImages, paste, value],\n );\n\n const handlePaste = useCallback(\n (e: React.ClipboardEvent<HTMLTextAreaElement>) => {\n // Composable by design, so this reads as a question rather than a handover.\n // Nothing else here wants the paste, so the answer is simply ignored.\n pills.handlePaste(e);\n },\n [pills],\n );\n\n const handleInlineChange = useCallback(\n (next: string) => {\n setValue(next);\n paste.prune(next);\n },\n [setValue, paste],\n );\n\n /** Everything the person believes they are sending, in the order they built it. */\n const composeOutgoing = useCallback(() => {\n if (inline) return paste.expand(value);\n\n return [value, ...heldPastes.map((p) => p.text)].filter(Boolean).join(\"\\n\\n\");\n }, [inline, value, heldPastes, paste]);\n\n const hasContent = value.trim().length > 0 || (!inline && heldPastes.length > 0);\n\n const focusInput = useCallback(() => {\n if (inline) editorRef.current?.focus();\n else textareaRef.current?.focus();\n }, [inline]);\n\n const handleSubmit = useCallback(() => {\n if (!hasContent || disabled) return;\n\n /*\n * THE DANGEROUS STATE, and the reason this feature needed a spec rather than\n * a guess. A pill reads as \"your paste is attached\" — so a send that drops it\n * means asking a question about a document without the document, and nobody\n * can tell: the sender believes it went, the receiver sees a question about\n * nothing.\n *\n * Above the input, held pastes go out in arrival order after what was typed,\n * because people type the question BEFORE pasting the thing it is about.\n * Inline, every pill goes out exactly where it sits.\n */\n const images = inline ? paste.imagesIn(value) : [];\n\n onSubmit?.(composeOutgoing(), { images });\n setValue(\"\");\n paste.clear();\n focusInput();\n }, [hasContent, disabled, value, inline, paste, onSubmit, composeOutgoing, setValue, focusInput]);\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n handleSubmit();\n }\n };\n\n /** Above the input: click a pill to dump it in, APPENDED to what is already typed. */\n const insertPaste = useCallback(\n (held: HeldPaste) => {\n // `expand` removes it and hands back the text; inserting is this\n // component's job because the hook owns no DOM.\n const text = pills.expand(held.id);\n\n if (text === undefined) return;\n\n setValue((current) => (current ? `${current}\\n\\n${text}` : text));\n textareaRef.current?.focus();\n },\n [pills, setValue],\n );\n\n return (\n <div\n data-react-fancy-composer=\"\"\n ref={ref}\n className={cn(\n \"rounded-xl border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-[color:var(--fancy-surface,var(--color-white))] dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))]\",\n disabled && \"opacity-50\",\n className,\n )}\n >\n {!inline && heldPastes.length > 0 && (\n <div\n data-react-fancy-composer-paste-pills=\"\"\n className=\"flex flex-wrap gap-1.5 px-3 pt-3\"\n >\n {heldPastes.map((paste) => (\n // `group` + `group-hover` rather than hover state: the preview is\n // presentation, and a useState for it would be one more thing an\n // agent could desynchronise.\n <span key={paste.id} className=\"group relative inline-flex\">\n <button\n type=\"button\"\n data-react-fancy-composer-paste-pill={paste.id}\n onClick={() => insertPaste(paste)}\n disabled={disabled}\n // No `title`. A native tooltip plus the hover preview below\n // renders TWO tooltips on the same hover, at different delays.\n // The label says what clicking does; the preview says what the\n // text is, and it is linked rather than merely adjacent so a\n // screen reader reaches it too.\n aria-label={`Insert this pasted text, ${withSeparators(paste.text.length)} characters`}\n aria-describedby={`${paste.id}-preview`}\n // `pr-7` leaves room for the absolutely-positioned × that sits\n // over this button's right edge. With a smaller right padding the\n // × lands on top of the label.\n className={cn(\n \"inline-flex items-center gap-1.5 rounded-full border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-zinc-50 py-1 pl-2.5 pr-7 text-xs text-zinc-700 transition-colors hover:bg-zinc-100 dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-zinc-800 dark:text-zinc-200 dark:hover:bg-zinc-700\",\n classNames?.pill,\n classNames?.textPill,\n )}\n >\n <span>\n Pasted text · {withSeparators(paste.text.length)} characters\n </span>\n </button>\n\n <button\n type=\"button\"\n data-react-fancy-composer-paste-pill-remove={paste.id}\n onClick={() => pills.remove(paste.id)}\n disabled={disabled}\n aria-label=\"Discard this pasted text\"\n className={cn(\n \"absolute right-1 top-1/2 -translate-y-1/2 rounded-full px-1 text-xs text-zinc-400 transition-colors hover:text-zinc-700 dark:hover:text-zinc-100\",\n classNames?.remove,\n )}\n >\n ×\n </button>\n\n <span\n id={`${paste.id}-preview`}\n data-react-fancy-composer-paste-pill-preview={paste.id}\n role=\"tooltip\"\n className={cn(\n \"pointer-events-none absolute bottom-full left-0 z-10 mb-1 hidden max-w-xs whitespace-pre-wrap break-all rounded-md bg-zinc-900 px-2 py-1 text-xs text-white group-hover:block dark:bg-zinc-100 dark:text-zinc-900\",\n classNames?.preview,\n )}\n >\n {renderPastePreview?.({ kind: \"text\", paste }) ??\n endsOf(paste.text, previewChars)}\n </span>\n </span>\n ))}\n </div>\n )}\n\n {inline ? (\n <>\n <InlinePasteEditor\n ref={editorRef}\n value={value}\n known={paste.known}\n onChange={handleInlineChange}\n onSubmit={handleSubmit}\n onPaste={paste.decidePaste}\n onHostsChange={paste.onHostsChange}\n placeholder={placeholder}\n disabled={disabled}\n className={classNames?.input}\n />\n {paste.portals}\n {pasteImages && pasteFilesName && (\n <PastedFilesInput name={pasteFilesName} files={pastedFiles} />\n )}\n </>\n ) : (\n <textarea\n ref={textareaRef}\n value={value}\n onChange={(e) => setValue(e.target.value)}\n onKeyDown={handleKeyDown}\n onPaste={handlePaste}\n placeholder={placeholder}\n disabled={disabled}\n rows={3}\n className={cn(\n \"w-full resize-none bg-transparent px-4 pt-3 text-sm outline-none placeholder:text-zinc-400\",\n classNames?.input,\n )}\n />\n )}\n <div className=\"flex items-center justify-between border-t border-zinc-100 px-3 py-2 dark:border-zinc-800\">\n <div className=\"flex items-center gap-1\">{actions}</div>\n <button\n type=\"button\"\n onClick={handleSubmit}\n disabled={disabled || !hasContent}\n className=\"rounded-lg bg-zinc-900 px-3 py-1.5 text-sm font-medium text-white transition-colors hover:bg-zinc-800 disabled:opacity-50 dark:bg-white dark:text-zinc-900 dark:hover:bg-zinc-100\"\n >\n Send\n </button>\n </div>\n </div>\n );\n },\n);\n\nComposer.displayName = \"Composer\";\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var chunk2O5UXH5R_cjs = require('./chunk-2O5UXH5R.cjs');
|
|
4
4
|
var chunkTLRFXSPA_cjs = require('./chunk-TLRFXSPA.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunk6CAXLP7D_cjs = require('./chunk-6CAXLP7D.cjs');
|
|
6
6
|
var chunkWKPBCB67_cjs = require('./chunk-WKPBCB67.cjs');
|
|
7
7
|
var chunkMAZEX4EZ_cjs = require('./chunk-MAZEX4EZ.cjs');
|
|
8
8
|
var chunkP53432AK_cjs = require('./chunk-P53432AK.cjs');
|
|
@@ -572,7 +572,7 @@ function JsonEditorValue({ node, mode, size, readOnly, id, onCommit }) {
|
|
|
572
572
|
);
|
|
573
573
|
case "secret":
|
|
574
574
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
575
|
-
|
|
575
|
+
chunk6CAXLP7D_cjs.Input,
|
|
576
576
|
{
|
|
577
577
|
...common,
|
|
578
578
|
type: "password",
|
|
@@ -587,7 +587,7 @@ function JsonEditorValue({ node, mode, size, readOnly, id, onCommit }) {
|
|
|
587
587
|
case "string":
|
|
588
588
|
default:
|
|
589
589
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
590
|
-
|
|
590
|
+
chunk6CAXLP7D_cjs.Input,
|
|
591
591
|
{
|
|
592
592
|
...common,
|
|
593
593
|
type: node.type === "url" ? "url" : node.type === "email" ? "email" : "text",
|
|
@@ -639,7 +639,7 @@ function RawValueEditor({
|
|
|
639
639
|
);
|
|
640
640
|
}
|
|
641
641
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
642
|
-
|
|
642
|
+
chunk6CAXLP7D_cjs.Input,
|
|
643
643
|
{
|
|
644
644
|
id,
|
|
645
645
|
size,
|
|
@@ -712,7 +712,7 @@ function JsonEditorRow({ node }) {
|
|
|
712
712
|
className: "w-1/3 min-w-0 shrink-0",
|
|
713
713
|
children: [
|
|
714
714
|
renameable ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
715
|
-
|
|
715
|
+
chunk6CAXLP7D_cjs.Input,
|
|
716
716
|
{
|
|
717
717
|
size: ctx.size,
|
|
718
718
|
mode: "edit",
|
|
@@ -889,7 +889,7 @@ function JsonEditorAddForm({ path, kind, depth, suggestedType }) {
|
|
|
889
889
|
style: { paddingInlineStart: depth * INDENT + 32 },
|
|
890
890
|
children: [
|
|
891
891
|
kind === "object" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
892
|
-
|
|
892
|
+
chunk6CAXLP7D_cjs.Input,
|
|
893
893
|
{
|
|
894
894
|
size: ctx.size,
|
|
895
895
|
mode: "edit",
|
|
@@ -1350,5 +1350,5 @@ exports.parsePath = parsePath;
|
|
|
1350
1350
|
exports.pathToString = pathToString;
|
|
1351
1351
|
exports.resolveKeyRule = resolveKeyRule;
|
|
1352
1352
|
exports.typeMatches = typeMatches;
|
|
1353
|
-
//# sourceMappingURL=chunk-
|
|
1354
|
-
//# sourceMappingURL=chunk-
|
|
1353
|
+
//# sourceMappingURL=chunk-7HXFEYOV.cjs.map
|
|
1354
|
+
//# sourceMappingURL=chunk-7HXFEYOV.cjs.map
|