@epilot/spark-ui 0.28.2 → 0.29.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/dist/components/attachment.d.cts +1 -1
- package/dist/components/attachment.d.ts +1 -1
- package/dist/components/avatar.d.cts +1 -1
- package/dist/components/avatar.d.ts +1 -1
- package/dist/components/badge.d.cts +1 -1
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/banner.d.cts +1 -1
- package/dist/components/box.d.cts +1 -1
- package/dist/components/box.d.ts +1 -1
- package/dist/components/bubble.d.cts +1 -1
- package/dist/components/bubble.d.ts +1 -1
- package/dist/components/button-group.d.cts +1 -1
- package/dist/components/button-group.d.ts +1 -1
- package/dist/components/button.cjs +16 -16
- package/dist/components/button.cjs.map +1 -1
- package/dist/components/button.d.cts +4 -4
- package/dist/components/button.d.ts +4 -4
- package/dist/components/button.js +16 -16
- package/dist/components/button.js.map +1 -1
- package/dist/components/callout.d.cts +1 -1
- package/dist/components/callout.d.ts +1 -1
- package/dist/components/card.d.cts +1 -1
- package/dist/components/card.d.ts +1 -1
- package/dist/components/checkbox-group.d.cts +1 -1
- package/dist/components/checkbox-group.d.ts +1 -1
- package/dist/components/checkbox.d.cts +1 -1
- package/dist/components/checkbox.d.ts +1 -1
- package/dist/components/combobox.d.cts +1 -1
- package/dist/components/combobox.d.ts +1 -1
- package/dist/components/field.cjs +57 -16
- package/dist/components/field.cjs.map +1 -1
- package/dist/components/field.d.cts +8 -4
- package/dist/components/field.d.ts +8 -4
- package/dist/components/field.js +57 -16
- package/dist/components/field.js.map +1 -1
- package/dist/components/info-block.d.cts +1 -1
- package/dist/components/info-block.d.ts +1 -1
- package/dist/components/input-group.cjs +71 -3
- package/dist/components/input-group.cjs.map +1 -1
- package/dist/components/input-group.d.cts +6 -1
- package/dist/components/input-group.d.ts +6 -1
- package/dist/components/input-group.js +72 -5
- package/dist/components/input-group.js.map +1 -1
- package/dist/components/input.cjs +6 -3
- package/dist/components/input.cjs.map +1 -1
- package/dist/components/input.d.cts +1 -1
- package/dist/components/input.d.ts +1 -1
- package/dist/components/input.js +7 -4
- package/dist/components/input.js.map +1 -1
- package/dist/components/list.d.cts +1 -1
- package/dist/components/list.d.ts +1 -1
- package/dist/components/marker.d.cts +1 -1
- package/dist/components/marker.d.ts +1 -1
- package/dist/components/pill.d.cts +1 -1
- package/dist/components/pill.d.ts +1 -1
- package/dist/components/radio.d.cts +1 -1
- package/dist/components/radio.d.ts +1 -1
- package/dist/components/segmented-control.d.cts +1 -1
- package/dist/components/segmented-control.d.ts +1 -1
- package/dist/components/select.cjs +2 -1
- package/dist/components/select.cjs.map +1 -1
- package/dist/components/select.d.cts +1 -1
- package/dist/components/select.d.ts +1 -1
- package/dist/components/select.js +3 -2
- package/dist/components/select.js.map +1 -1
- package/dist/components/separator.cjs +15 -18
- package/dist/components/separator.cjs.map +1 -1
- package/dist/components/separator.d.cts +3 -0
- package/dist/components/separator.d.ts +3 -0
- package/dist/components/separator.js +16 -19
- package/dist/components/separator.js.map +1 -1
- package/dist/components/skeleton.cjs +20 -5
- package/dist/components/skeleton.cjs.map +1 -1
- package/dist/components/skeleton.d.cts +9 -5
- package/dist/components/skeleton.d.ts +9 -5
- package/dist/components/skeleton.js +19 -6
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/spinner.cjs +8 -81
- package/dist/components/spinner.cjs.map +1 -1
- package/dist/components/spinner.js +8 -81
- package/dist/components/spinner.js.map +1 -1
- package/dist/components/switch-group.d.cts +1 -1
- package/dist/components/switch-group.d.ts +1 -1
- package/dist/components/switch.d.cts +1 -1
- package/dist/components/switch.d.ts +1 -1
- package/dist/components/textarea.cjs +6 -3
- package/dist/components/textarea.cjs.map +1 -1
- package/dist/components/textarea.d.cts +1 -1
- package/dist/components/textarea.d.ts +1 -1
- package/dist/components/textarea.js +6 -3
- package/dist/components/textarea.js.map +1 -1
- package/dist/components/theme.d.cts +1 -1
- package/dist/components/theme.d.ts +1 -1
- package/dist/components/toggle-group.d.cts +1 -1
- package/dist/components/toggle-group.d.ts +1 -1
- package/dist/components/toggle.d.cts +1 -1
- package/dist/components/toggle.d.ts +1 -1
- package/dist/components/tooltip.cjs +29 -25
- package/dist/components/tooltip.cjs.map +1 -1
- package/dist/components/tooltip.d.cts +4 -2
- package/dist/components/tooltip.d.ts +4 -2
- package/dist/components/tooltip.js +29 -25
- package/dist/components/tooltip.js.map +1 -1
- package/dist/lib/accent-theme.d.cts +1 -1
- package/dist/lib/accent-theme.d.ts +1 -1
- package/dist/lib/container-chrome.d.cts +1 -1
- package/dist/lib/container-chrome.d.ts +1 -1
- package/dist/lib/input-box-variants.cjs +11 -0
- package/dist/lib/input-box-variants.cjs.map +1 -1
- package/dist/lib/input-box-variants.d.cts +6 -2
- package/dist/lib/input-box-variants.d.ts +6 -2
- package/dist/lib/input-box-variants.js +8 -1
- package/dist/lib/input-box-variants.js.map +1 -1
- package/dist/lib/selection-list.d.cts +1 -1
- package/dist/lib/selection-list.d.ts +1 -1
- package/dist/lib/theme-types.cjs.map +1 -1
- package/dist/lib/theme-types.d.cts +1 -1
- package/dist/lib/theme-types.d.ts +1 -1
- package/dist/lib/theme-types.js.map +1 -1
- package/dist/lib/toggle-group-context.d.cts +1 -1
- package/dist/lib/toggle-group-context.d.ts +1 -1
- package/dist/styles/spark-default.css +3 -1
- package/dist/styles/theme.css +18 -98
- package/dist/{theme-types-Dlge0s3s.d.ts → theme-types-CHl-L2F-.d.cts} +2 -2
- package/dist/{theme-types-Dlge0s3s.d.cts → theme-types-CHl-L2F-.d.ts} +2 -2
- package/package.json +3 -2
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
4
|
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
5
|
+
require("../lib/input-box-variants.cjs");
|
|
5
6
|
const require_components_theme = require("./theme.cjs");
|
|
6
7
|
const require_components_field = require("./field.cjs");
|
|
7
8
|
const require_components_input = require("./input.cjs");
|
|
@@ -110,14 +111,16 @@ function InputGroup({ className, ...props }) {
|
|
|
110
111
|
const theme = require_components_theme.useTheme();
|
|
111
112
|
const inputStyle = field?.inputStyle ?? theme.inputStyle ?? "soft";
|
|
112
113
|
const inputColor = field?.inputColor ?? theme.inputColor ?? "brand";
|
|
114
|
+
const chrome = field?.labelPosition === "inset" ? "inset" : "box";
|
|
115
|
+
const floating = field?.labelPosition === "floating";
|
|
113
116
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
114
117
|
"data-slot": "input-group",
|
|
115
118
|
role: "group",
|
|
116
119
|
className: (0, cn.cn)(inputGroupVariants({
|
|
117
|
-
chrome
|
|
120
|
+
chrome,
|
|
118
121
|
inputStyle,
|
|
119
122
|
inputColor
|
|
120
|
-
}), className),
|
|
123
|
+
}), floating && (inputStyle === "outlined" ? "h-12 border-0! has-[input:focus-visible]:outline-hidden!" : (0, cn.cn)("h-12 [&_[data-slot=input]]:h-full [&_[data-slot=input]]:pt-5 [&_[data-slot=input]]:pb-1", inputStyle === "surface" && "has-[input:focus-visible]:outline-offset-[-2px]!")), className),
|
|
121
124
|
...props
|
|
122
125
|
});
|
|
123
126
|
}
|
|
@@ -129,11 +132,13 @@ const inputGroupAddonVariants = (0, class_variance_authority.cva)("flex h-auto c
|
|
|
129
132
|
defaultVariants: { align: "inline-start" }
|
|
130
133
|
});
|
|
131
134
|
function InputGroupAddon({ className, align = "inline-start", ...props }) {
|
|
135
|
+
const field = require_components_field.useFieldContext();
|
|
136
|
+
const shiftWithValue = field?.labelPosition === "floating" && field.inputStyle !== "outlined";
|
|
132
137
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
133
138
|
role: "presentation",
|
|
134
139
|
"data-slot": "input-group-addon",
|
|
135
140
|
"data-align": align,
|
|
136
|
-
className: (0, cn.cn)(inputGroupAddonVariants({ align }), className),
|
|
141
|
+
className: (0, cn.cn)(inputGroupAddonVariants({ align }), shiftWithValue && "transition-[translate] duration-200 ease-[cubic-bezier(0,0,0.2,1)] field-floated:translate-y-2 motion-reduce:transition-none", className),
|
|
137
142
|
onClick: (event) => {
|
|
138
143
|
if (event.target.closest("button")) return;
|
|
139
144
|
event.currentTarget.parentElement?.querySelector("input")?.focus();
|
|
@@ -156,10 +161,73 @@ const InputGroupInput = react.forwardRef(function InputGroupInput({ className, .
|
|
|
156
161
|
...props
|
|
157
162
|
});
|
|
158
163
|
});
|
|
164
|
+
const useIsomorphicLayoutEffect = typeof window === "undefined" ? react.useEffect : react.useLayoutEffect;
|
|
165
|
+
const SUFFIX_GAP = 4;
|
|
166
|
+
function placeSuffix(suffix, mirror, unit, input) {
|
|
167
|
+
const style = getComputedStyle(input);
|
|
168
|
+
const basePaddingRight = input.dataset.suffixPaddingRight ?? style.paddingRight;
|
|
169
|
+
input.dataset.suffixPaddingRight = basePaddingRight;
|
|
170
|
+
const paddingLeft = parseFloat(style.paddingLeft);
|
|
171
|
+
const paddingRight = parseFloat(basePaddingRight);
|
|
172
|
+
mirror.textContent = input.value;
|
|
173
|
+
suffix.toggleAttribute("data-empty", input.value === "");
|
|
174
|
+
suffix.style.font = style.font;
|
|
175
|
+
suffix.style.lineHeight = "normal";
|
|
176
|
+
suffix.style.letterSpacing = style.letterSpacing;
|
|
177
|
+
suffix.style.top = `${input.offsetTop}px`;
|
|
178
|
+
suffix.style.height = `${input.offsetHeight}px`;
|
|
179
|
+
suffix.style.paddingTop = style.paddingTop;
|
|
180
|
+
suffix.style.paddingBottom = style.paddingBottom;
|
|
181
|
+
const textLeft = input.offsetLeft + paddingLeft;
|
|
182
|
+
const available = input.clientWidth - paddingLeft - paddingRight;
|
|
183
|
+
const pinned = mirror.offsetWidth + SUFFIX_GAP + unit.offsetWidth > available;
|
|
184
|
+
suffix.toggleAttribute("data-pinned", pinned);
|
|
185
|
+
suffix.style.left = `${textLeft}px`;
|
|
186
|
+
suffix.style.width = `${input.clientWidth - paddingLeft - paddingRight}px`;
|
|
187
|
+
input.style.paddingRight = pinned ? `${paddingRight + unit.offsetWidth + SUFFIX_GAP}px` : "";
|
|
188
|
+
}
|
|
189
|
+
function InputGroupSuffix({ className, children, ...props }) {
|
|
190
|
+
const ref = react.useRef(null);
|
|
191
|
+
const mirrorRef = react.useRef(null);
|
|
192
|
+
const unitRef = react.useRef(null);
|
|
193
|
+
useIsomorphicLayoutEffect(() => {
|
|
194
|
+
const suffix = ref.current;
|
|
195
|
+
const mirror = mirrorRef.current;
|
|
196
|
+
const unit = unitRef.current;
|
|
197
|
+
const input = suffix?.closest("[data-slot=input-group]")?.querySelector("input[data-slot=input]");
|
|
198
|
+
if (!suffix || !mirror || !unit || !input) return;
|
|
199
|
+
const place = () => placeSuffix(suffix, mirror, unit, input);
|
|
200
|
+
place();
|
|
201
|
+
input.addEventListener("input", place);
|
|
202
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(place);
|
|
203
|
+
observer?.observe(input);
|
|
204
|
+
return () => {
|
|
205
|
+
input.removeEventListener("input", place);
|
|
206
|
+
observer?.disconnect();
|
|
207
|
+
};
|
|
208
|
+
});
|
|
209
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
210
|
+
ref,
|
|
211
|
+
"data-slot": "input-group-suffix",
|
|
212
|
+
"data-empty": "",
|
|
213
|
+
className: (0, cn.cn)("pointer-events-none absolute flex items-center overflow-hidden whitespace-pre text-gray group-has-[[aria-invalid=true]]/input-group:text-error group-has-[input:disabled]/input-group:text-gray-disabled group-data-[invalid=true]/field:text-error data-empty:invisible data-pinned:justify-end", className),
|
|
214
|
+
...props,
|
|
215
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
216
|
+
ref: mirrorRef,
|
|
217
|
+
"aria-hidden": "true",
|
|
218
|
+
className: "invisible"
|
|
219
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
220
|
+
ref: unitRef,
|
|
221
|
+
className: "ml-1 font-semibold",
|
|
222
|
+
children
|
|
223
|
+
})] })
|
|
224
|
+
});
|
|
225
|
+
}
|
|
159
226
|
//#endregion
|
|
160
227
|
exports.InputGroup = InputGroup;
|
|
161
228
|
exports.InputGroupAddon = InputGroupAddon;
|
|
162
229
|
exports.InputGroupInput = InputGroupInput;
|
|
230
|
+
exports.InputGroupSuffix = InputGroupSuffix;
|
|
163
231
|
exports.InputGroupText = InputGroupText;
|
|
164
232
|
|
|
165
233
|
//# sourceMappingURL=input-group.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-group.cjs","names":["useFieldContext","useTheme","React","Input"],"sources":["../../src/components/input-group.tsx"],"sourcesContent":["'use client'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\nimport { cn } from '../utils/cn'\nimport { useFieldContext } from './field'\nimport { Input, type InputProps } from './input'\nimport { useTheme } from './theme'\n\nconst GHOST =\n 'rounded-none border-0 border-b-2 px-0 has-[:focus-visible]:border-b-input-active has-[[data-slot=input][aria-invalid=true]]:border-b-input-invalid has-[[data-slot=input][aria-invalid=true]]:has-[:focus-visible]:border-b-(--color-error-active)! group-data-[invalid=true]/field:border-b-input-invalid! group-data-[invalid=true]/field:has-[:focus-visible]:border-b-(--color-error-active)!'\n\nconst inputGroupVariants = cva(\n 'group/input-group relative flex h-10 w-full min-w-0 items-center gap-2 bg-transparent transition-[color,border-color] motion-reduce:transition-none',\n {\n variants: {\n chrome: {\n // inside an inset field the shell is the box; the group keeps the\n // classic underline (inputs inside stay chrome-less)\n inset: GHOST,\n // h-11 matches the standalone Input box; inside an inset field the shell draws the outline\n box: 'h-11 rounded-md px-3 transition-[color,background-color,border-color] has-[input:focus-visible]:focus-outline group-data-[invalid=true]/field:has-[input:focus-visible]:outline-(--color-error-active) has-[[data-slot=input][aria-invalid=true]]:has-[input:focus-visible]:outline-(--color-error-active) motion-reduce:transition-none',\n },\n inputStyle: { soft: '', surface: '', outlined: '', ghost: '' },\n inputColor: { brand: '', gray: '' },\n },\n compoundVariants: [\n {\n chrome: 'box',\n inputStyle: 'soft',\n // invalid hover deepens the error tint instead of the accent hover\n class:\n 'group-data-[invalid=true]/field:bg-base-error-soft has-[[data-slot=input][aria-invalid=true]]:bg-base-error-soft has-[[data-slot=input][aria-invalid=true]:not(:disabled)]:hover:bg-red-a4 group-data-[invalid=true]/field:has-[input:not(:disabled)]:hover:bg-red-a4',\n },\n {\n chrome: 'box',\n inputStyle: 'soft',\n inputColor: 'brand',\n class:\n 'bg-input-base has-[input:not(:disabled)]:hover:bg-input-base-hover',\n },\n {\n chrome: 'box',\n inputStyle: 'soft',\n inputColor: 'gray',\n class: 'bg-base-gray-soft has-[input:not(:disabled)]:hover:bg-gray-a4',\n },\n {\n chrome: 'box',\n inputStyle: ['surface', 'outlined'],\n class:\n 'border group-data-[invalid=true]/field:border-input-invalid group-data-[invalid=true]/field:has-[:focus-visible]:border-input-invalid! has-[[data-slot=input][aria-invalid=true]]:border-input-invalid has-[[data-slot=input][aria-invalid=true]]:has-[:focus-visible]:border-input-invalid!',\n },\n {\n chrome: 'box',\n inputStyle: 'surface',\n inputColor: 'brand',\n class:\n 'border-input bg-base-accent-surface has-[:focus-visible]:border-input-active',\n },\n {\n chrome: 'box',\n inputStyle: 'surface',\n inputColor: 'gray',\n class:\n 'border-input-gray bg-base-gray-surface has-[:focus-visible]:border-gray-a8',\n },\n {\n chrome: 'box',\n inputStyle: 'outlined',\n inputColor: 'brand',\n class: 'border-input has-[:focus-visible]:border-input-active',\n },\n {\n chrome: 'box',\n inputStyle: 'outlined',\n inputColor: 'gray',\n class: 'border-input-gray has-[:focus-visible]:border-gray-a8',\n },\n { chrome: 'box', inputStyle: 'ghost', class: GHOST },\n {\n chrome: 'box',\n inputStyle: 'ghost',\n inputColor: 'brand',\n class: 'border-b-input',\n },\n {\n chrome: 'box',\n inputStyle: 'ghost',\n inputColor: 'gray',\n class: 'border-b-input-gray',\n },\n { chrome: 'inset', inputColor: 'brand', class: 'border-b-input' },\n { chrome: 'inset', inputColor: 'gray', class: 'border-b-input-gray' },\n ],\n },\n)\n\n// The group carries the box + focus/invalid states; inputs inside are\n// chrome-less (variant=\"none\"). Style follows the enclosing Field's knobs,\n// else the <Theme> input-style/input-color knobs.\nfunction InputGroup({ className, ...props }: React.ComponentProps<'div'>) {\n const field = useFieldContext()\n const theme = useTheme()\n const inputStyle = field?.inputStyle ?? theme.inputStyle ?? 'soft'\n const inputColor = field?.inputColor ?? theme.inputColor ?? 'brand'\n const chrome = field?.labelPosition === 'inset' ? 'inset' : 'box'\n return (\n <div\n data-slot=\"input-group\"\n role=\"group\"\n className={cn(\n inputGroupVariants({ chrome, inputStyle, inputColor }),\n className,\n )}\n {...props}\n />\n )\n}\n\nconst inputGroupAddonVariants = cva(\n 'flex h-auto cursor-text items-center justify-center gap-2 py-2 text-sm font-medium text-gray-light select-none [&_svg:not([class*=size-])]:size-4',\n {\n variants: {\n align: {\n // button addons bring their own inner padding — pull them halfway\n // into the group's px so the visual gap matches the text side\n 'inline-start': 'order-first has-[>button]:-ml-2',\n 'inline-end': 'order-last has-[>button]:-mr-2',\n },\n },\n defaultVariants: {\n align: 'inline-start',\n },\n },\n)\n\nfunction InputGroupAddon({\n className,\n align = 'inline-start',\n ...props\n}: React.ComponentProps<'div'> & VariantProps<typeof inputGroupAddonVariants>) {\n return (\n <div\n // chrome, not a control: the click only forwards focus to the input the\n // way a label would, and Tab already reaches that input directly\n role=\"presentation\"\n data-slot=\"input-group-addon\"\n data-align={align}\n className={cn(inputGroupAddonVariants({ align }), className)}\n onClick={(event) => {\n if ((event.target as HTMLElement).closest('button')) return\n event.currentTarget.parentElement?.querySelector('input')?.focus()\n }}\n {...props}\n />\n )\n}\n\nfunction InputGroupText({ className, ...props }: React.ComponentProps<'span'>) {\n return (\n <span\n className={cn(\n 'flex items-center gap-2 text-xs text-gray-light [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4',\n className,\n )}\n {...props}\n />\n )\n}\n\nconst InputGroupInput = React.forwardRef<HTMLInputElement, InputProps>(\n function InputGroupInput({ className, ...props }, ref) {\n return (\n <Input\n data-slot=\"input\"\n variant=\"none\"\n className={cn('flex-1', className)}\n ref={ref}\n {...props}\n />\n )\n },\n)\n\nexport { InputGroup, InputGroupAddon, InputGroupInput, InputGroupText }\n"],"mappings":";;;;;;;;;;;;;AASA,MAAM,QACJ;AAEF,MAAM,sBAAA,GAAA,yBAAA,KACJ,uJACA;CACE,UAAU;EACR,QAAQ;GAGN,OAAO;GAEP,KAAK;EACP;EACA,YAAY;GAAE,MAAM;GAAI,SAAS;GAAI,UAAU;GAAI,OAAO;EAAG;EAC7D,YAAY;GAAE,OAAO;GAAI,MAAM;EAAG;CACpC;CACA,kBAAkB;EAChB;GACE,QAAQ;GACR,YAAY;GAEZ,OACE;EACJ;EACA;GACE,QAAQ;GACR,YAAY;GACZ,YAAY;GACZ,OACE;EACJ;EACA;GACE,QAAQ;GACR,YAAY;GACZ,YAAY;GACZ,OAAO;EACT;EACA;GACE,QAAQ;GACR,YAAY,CAAC,WAAW,UAAU;GAClC,OACE;EACJ;EACA;GACE,QAAQ;GACR,YAAY;GACZ,YAAY;GACZ,OACE;EACJ;EACA;GACE,QAAQ;GACR,YAAY;GACZ,YAAY;GACZ,OACE;EACJ;EACA;GACE,QAAQ;GACR,YAAY;GACZ,YAAY;GACZ,OAAO;EACT;EACA;GACE,QAAQ;GACR,YAAY;GACZ,YAAY;GACZ,OAAO;EACT;EACA;GAAE,QAAQ;GAAO,YAAY;GAAS,OAAO;EAAM;EACnD;GACE,QAAQ;GACR,YAAY;GACZ,YAAY;GACZ,OAAO;EACT;EACA;GACE,QAAQ;GACR,YAAY;GACZ,YAAY;GACZ,OAAO;EACT;EACA;GAAE,QAAQ;GAAS,YAAY;GAAS,OAAO;EAAiB;EAChE;GAAE,QAAQ;GAAS,YAAY;GAAQ,OAAO;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,YAAA,GAAA,GAAA,IAAc,UAAU,SAAS;EAC5B;EACL,GAAI;CACL,CAAA;AAEL,CACF"}
|
|
1
|
+
{"version":3,"file":"input-group.cjs","names":["useFieldContext","useTheme","React","Input"],"sources":["../../src/components/input-group.tsx"],"sourcesContent":["'use client'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\nimport { FLOATING_ADORNMENT_SHIFT } from '../lib/input-box-variants'\nimport { cn } from '../utils/cn'\nimport { useFieldContext } from './field'\nimport { Input, type InputProps } from './input'\nimport { useTheme } from './theme'\n\nconst GHOST =\n 'rounded-none border-0 border-b-2 px-0 has-[:focus-visible]:border-b-input-active has-[[data-slot=input][aria-invalid=true]]:border-b-input-invalid has-[[data-slot=input][aria-invalid=true]]:has-[:focus-visible]:border-b-(--color-error-active)! group-data-[invalid=true]/field:border-b-input-invalid! group-data-[invalid=true]/field:has-[:focus-visible]:border-b-(--color-error-active)!'\n\nconst inputGroupVariants = cva(\n 'group/input-group relative flex h-10 w-full min-w-0 items-center gap-2 bg-transparent transition-[color,border-color] motion-reduce:transition-none',\n {\n variants: {\n chrome: {\n // inside an inset field the shell is the box; the group keeps the\n // classic underline (inputs inside stay chrome-less)\n inset: GHOST,\n // h-11 matches the standalone Input box; inside an inset field the shell draws the outline\n box: 'h-11 rounded-md px-3 transition-[color,background-color,border-color] has-[input:focus-visible]:focus-outline group-data-[invalid=true]/field:has-[input:focus-visible]:outline-(--color-error-active) has-[[data-slot=input][aria-invalid=true]]:has-[input:focus-visible]:outline-(--color-error-active) motion-reduce:transition-none',\n },\n inputStyle: { soft: '', surface: '', outlined: '', ghost: '' },\n inputColor: { brand: '', gray: '' },\n },\n compoundVariants: [\n {\n chrome: 'box',\n inputStyle: 'soft',\n // invalid hover deepens the error tint instead of the accent hover\n class:\n 'group-data-[invalid=true]/field:bg-base-error-soft has-[[data-slot=input][aria-invalid=true]]:bg-base-error-soft has-[[data-slot=input][aria-invalid=true]:not(:disabled)]:hover:bg-red-a4 group-data-[invalid=true]/field:has-[input:not(:disabled)]:hover:bg-red-a4',\n },\n {\n chrome: 'box',\n inputStyle: 'soft',\n inputColor: 'brand',\n class:\n 'bg-input-base has-[input:not(:disabled)]:hover:bg-input-base-hover',\n },\n {\n chrome: 'box',\n inputStyle: 'soft',\n inputColor: 'gray',\n class: 'bg-base-gray-soft has-[input:not(:disabled)]:hover:bg-gray-a4',\n },\n {\n chrome: 'box',\n inputStyle: ['surface', 'outlined'],\n class:\n 'border group-data-[invalid=true]/field:border-input-invalid group-data-[invalid=true]/field:has-[:focus-visible]:border-input-invalid! has-[[data-slot=input][aria-invalid=true]]:border-input-invalid has-[[data-slot=input][aria-invalid=true]]:has-[:focus-visible]:border-input-invalid!',\n },\n {\n chrome: 'box',\n inputStyle: 'surface',\n inputColor: 'brand',\n class:\n 'border-input bg-base-accent-surface has-[:focus-visible]:border-input-active',\n },\n {\n chrome: 'box',\n inputStyle: 'surface',\n inputColor: 'gray',\n class:\n 'border-input-gray bg-base-gray-surface has-[:focus-visible]:border-gray-a8',\n },\n {\n chrome: 'box',\n inputStyle: 'outlined',\n inputColor: 'brand',\n class: 'border-input has-[:focus-visible]:border-input-active',\n },\n {\n chrome: 'box',\n inputStyle: 'outlined',\n inputColor: 'gray',\n class: 'border-input-gray has-[:focus-visible]:border-gray-a8',\n },\n { chrome: 'box', inputStyle: 'ghost', class: GHOST },\n {\n chrome: 'box',\n inputStyle: 'ghost',\n inputColor: 'brand',\n class: 'border-b-input',\n },\n {\n chrome: 'box',\n inputStyle: 'ghost',\n inputColor: 'gray',\n class: 'border-b-input-gray',\n },\n { chrome: 'inset', inputColor: 'brand', class: 'border-b-input' },\n { chrome: 'inset', inputColor: 'gray', class: 'border-b-input-gray' },\n ],\n },\n)\n\n// The group carries the box + focus/invalid states; inputs inside are\n// chrome-less (variant=\"none\"). Style follows the enclosing Field's knobs,\n// else the <Theme> input-style/input-color knobs.\nfunction InputGroup({ className, ...props }: React.ComponentProps<'div'>) {\n const field = useFieldContext()\n const theme = useTheme()\n const inputStyle = field?.inputStyle ?? theme.inputStyle ?? 'soft'\n const inputColor = field?.inputColor ?? theme.inputColor ?? 'brand'\n const chrome = field?.labelPosition === 'inset' ? 'inset' : 'box'\n const floating = field?.labelPosition === 'floating'\n return (\n <div\n data-slot=\"input-group\"\n role=\"group\"\n className={cn(\n inputGroupVariants({ chrome, inputStyle, inputColor }),\n floating &&\n (inputStyle === 'outlined'\n ? 'h-12 border-0! has-[input:focus-visible]:outline-hidden!'\n : cn(\n 'h-12 [&_[data-slot=input]]:h-full [&_[data-slot=input]]:pt-5 [&_[data-slot=input]]:pb-1',\n inputStyle === 'surface' &&\n 'has-[input:focus-visible]:outline-offset-[-2px]!',\n )),\n className,\n )}\n {...props}\n />\n )\n}\n\nconst inputGroupAddonVariants = cva(\n 'flex h-auto cursor-text items-center justify-center gap-2 py-2 text-sm font-medium text-gray-light select-none [&_svg:not([class*=size-])]:size-4',\n {\n variants: {\n align: {\n // button addons bring their own inner padding — pull them halfway\n // into the group's px so the visual gap matches the text side\n 'inline-start': 'order-first has-[>button]:-ml-2',\n 'inline-end': 'order-last has-[>button]:-mr-2',\n },\n },\n defaultVariants: {\n align: 'inline-start',\n },\n },\n)\n\nfunction InputGroupAddon({\n className,\n align = 'inline-start',\n ...props\n}: React.ComponentProps<'div'> & VariantProps<typeof inputGroupAddonVariants>) {\n const field = useFieldContext()\n const shiftWithValue =\n field?.labelPosition === 'floating' && field.inputStyle !== 'outlined'\n return (\n <div\n // chrome, not a control: the click only forwards focus to the input the\n // way a label would, and Tab already reaches that input directly\n role=\"presentation\"\n data-slot=\"input-group-addon\"\n data-align={align}\n className={cn(\n inputGroupAddonVariants({ align }),\n shiftWithValue && FLOATING_ADORNMENT_SHIFT,\n className,\n )}\n onClick={(event) => {\n if ((event.target as HTMLElement).closest('button')) return\n event.currentTarget.parentElement?.querySelector('input')?.focus()\n }}\n {...props}\n />\n )\n}\n\nfunction InputGroupText({ className, ...props }: React.ComponentProps<'span'>) {\n return (\n <span\n className={cn(\n 'flex items-center gap-2 text-xs text-gray-light [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4',\n className,\n )}\n {...props}\n />\n )\n}\n\nconst InputGroupInput = React.forwardRef<HTMLInputElement, InputProps>(\n function InputGroupInput({ className, ...props }, ref) {\n return (\n <Input\n data-slot=\"input\"\n variant=\"none\"\n className={cn('flex-1', className)}\n ref={ref}\n {...props}\n />\n )\n },\n)\n\nconst useIsomorphicLayoutEffect =\n typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect\n\nconst SUFFIX_GAP = 4\n\nfunction placeSuffix(\n suffix: HTMLSpanElement,\n mirror: HTMLSpanElement,\n unit: HTMLSpanElement,\n input: HTMLInputElement,\n) {\n const style = getComputedStyle(input)\n const basePaddingRight =\n input.dataset.suffixPaddingRight ?? style.paddingRight\n input.dataset.suffixPaddingRight = basePaddingRight\n const paddingLeft = parseFloat(style.paddingLeft)\n const paddingRight = parseFloat(basePaddingRight)\n\n mirror.textContent = input.value\n suffix.toggleAttribute('data-empty', input.value === '')\n suffix.style.font = style.font\n suffix.style.lineHeight = 'normal'\n suffix.style.letterSpacing = style.letterSpacing\n suffix.style.top = `${input.offsetTop}px`\n suffix.style.height = `${input.offsetHeight}px`\n suffix.style.paddingTop = style.paddingTop\n suffix.style.paddingBottom = style.paddingBottom\n\n const textLeft = input.offsetLeft + paddingLeft\n const available = input.clientWidth - paddingLeft - paddingRight\n const needed = mirror.offsetWidth + SUFFIX_GAP + unit.offsetWidth\n const pinned = needed > available\n suffix.toggleAttribute('data-pinned', pinned)\n suffix.style.left = `${textLeft}px`\n suffix.style.width = `${input.clientWidth - paddingLeft - paddingRight}px`\n input.style.paddingRight = pinned\n ? `${paddingRight + unit.offsetWidth + SUFFIX_GAP}px`\n : ''\n}\n\nfunction InputGroupSuffix({\n className,\n children,\n ...props\n}: React.ComponentProps<'span'>) {\n const ref = React.useRef<HTMLSpanElement>(null)\n const mirrorRef = React.useRef<HTMLSpanElement>(null)\n const unitRef = React.useRef<HTMLSpanElement>(null)\n\n useIsomorphicLayoutEffect(() => {\n const suffix = ref.current\n const mirror = mirrorRef.current\n const unit = unitRef.current\n const input = suffix\n ?.closest('[data-slot=input-group]')\n ?.querySelector<HTMLInputElement>('input[data-slot=input]')\n if (!suffix || !mirror || !unit || !input) return\n const place = () => placeSuffix(suffix, mirror, unit, input)\n place()\n input.addEventListener('input', place)\n const observer =\n typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(place)\n observer?.observe(input)\n return () => {\n input.removeEventListener('input', place)\n observer?.disconnect()\n }\n })\n\n return (\n <span\n ref={ref}\n data-slot=\"input-group-suffix\"\n data-empty=\"\"\n className={cn(\n 'pointer-events-none absolute flex items-center overflow-hidden whitespace-pre text-gray group-has-[[aria-invalid=true]]/input-group:text-error group-has-[input:disabled]/input-group:text-gray-disabled group-data-[invalid=true]/field:text-error data-empty:invisible data-pinned:justify-end',\n className,\n )}\n {...props}\n >\n <span>\n <span ref={mirrorRef} aria-hidden=\"true\" className=\"invisible\" />\n <span ref={unitRef} className=\"ml-1 font-semibold\">\n {children}\n </span>\n </span>\n </span>\n )\n}\n\nexport {\n InputGroup,\n InputGroupAddon,\n InputGroupInput,\n InputGroupSuffix,\n InputGroupText,\n}\n"],"mappings":";;;;;;;;;;;;;;AAUA,MAAM,QACJ;AAEF,MAAM,sBAAA,GAAA,yBAAA,KACJ,uJACA;CACE,UAAU;EACR,QAAQ;GAGN,OAAO;GAEP,KAAK;EACP;EACA,YAAY;GAAE,MAAM;GAAI,SAAS;GAAI,UAAU;GAAI,OAAO;EAAG;EAC7D,YAAY;GAAE,OAAO;GAAI,MAAM;EAAG;CACpC;CACA,kBAAkB;EAChB;GACE,QAAQ;GACR,YAAY;GAEZ,OACE;EACJ;EACA;GACE,QAAQ;GACR,YAAY;GACZ,YAAY;GACZ,OACE;EACJ;EACA;GACE,QAAQ;GACR,YAAY;GACZ,YAAY;GACZ,OAAO;EACT;EACA;GACE,QAAQ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GAAA,IACE,oSACA,SACF;EACA,GAAI;YAEJ,iBAAA,GAAA,kBAAA,MAAC,QAAD,EAAA,UAAA,CACE,iBAAA,GAAA,kBAAA,KAAC,QAAD;GAAM,KAAK;GAAW,eAAY;GAAO,WAAU;EAAa,CAAA,GAChE,iBAAA,GAAA,kBAAA,KAAC,QAAD;GAAM,KAAK;GAAS,WAAU;GAC3B;EACG,CAAA,CACF,EAAA,CAAA;CACF,CAAA;AAEV"}
|
|
@@ -22,6 +22,11 @@ declare function InputGroupText({
|
|
|
22
22
|
...props
|
|
23
23
|
}: React$1.ComponentProps<'span'>): import("react/jsx-runtime").JSX.Element;
|
|
24
24
|
declare const InputGroupInput: React$1.ForwardRefExoticComponent<Omit<InputProps, "ref"> & React$1.RefAttributes<HTMLInputElement>>;
|
|
25
|
+
declare function InputGroupSuffix({
|
|
26
|
+
className,
|
|
27
|
+
children,
|
|
28
|
+
...props
|
|
29
|
+
}: React$1.ComponentProps<'span'>): import("react/jsx-runtime").JSX.Element;
|
|
25
30
|
//#endregion
|
|
26
|
-
export { InputGroup, InputGroupAddon, InputGroupInput, InputGroupText };
|
|
31
|
+
export { InputGroup, InputGroupAddon, InputGroupInput, InputGroupSuffix, InputGroupText };
|
|
27
32
|
//# sourceMappingURL=input-group.d.cts.map
|
|
@@ -22,6 +22,11 @@ declare function InputGroupText({
|
|
|
22
22
|
...props
|
|
23
23
|
}: React$1.ComponentProps<'span'>): import("react/jsx-runtime").JSX.Element;
|
|
24
24
|
declare const InputGroupInput: React$1.ForwardRefExoticComponent<Omit<InputProps, "ref"> & React$1.RefAttributes<HTMLInputElement>>;
|
|
25
|
+
declare function InputGroupSuffix({
|
|
26
|
+
className,
|
|
27
|
+
children,
|
|
28
|
+
...props
|
|
29
|
+
}: React$1.ComponentProps<'span'>): import("react/jsx-runtime").JSX.Element;
|
|
25
30
|
//#endregion
|
|
26
|
-
export { InputGroup, InputGroupAddon, InputGroupInput, InputGroupText };
|
|
31
|
+
export { InputGroup, InputGroupAddon, InputGroupInput, InputGroupSuffix, InputGroupText };
|
|
27
32
|
//# sourceMappingURL=input-group.d.ts.map
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
3
|
import { cn } from "../utils/cn.js";
|
|
4
|
+
import "../lib/input-box-variants.js";
|
|
4
5
|
import { useTheme } from "./theme.js";
|
|
5
6
|
import { useFieldContext } from "./field.js";
|
|
6
7
|
import { Input } from "./input.js";
|
|
7
8
|
import * as React$1 from "react";
|
|
8
|
-
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
import { cva } from "class-variance-authority";
|
|
10
11
|
//#region src/components/input-group.tsx
|
|
11
12
|
const GHOST = "rounded-none border-0 border-b-2 px-0 has-[:focus-visible]:border-b-input-active has-[[data-slot=input][aria-invalid=true]]:border-b-input-invalid has-[[data-slot=input][aria-invalid=true]]:has-[:focus-visible]:border-b-(--color-error-active)! group-data-[invalid=true]/field:border-b-input-invalid! group-data-[invalid=true]/field:has-[:focus-visible]:border-b-(--color-error-active)!";
|
|
@@ -107,14 +108,16 @@ function InputGroup({ className, ...props }) {
|
|
|
107
108
|
const theme = useTheme();
|
|
108
109
|
const inputStyle = field?.inputStyle ?? theme.inputStyle ?? "soft";
|
|
109
110
|
const inputColor = field?.inputColor ?? theme.inputColor ?? "brand";
|
|
111
|
+
const chrome = field?.labelPosition === "inset" ? "inset" : "box";
|
|
112
|
+
const floating = field?.labelPosition === "floating";
|
|
110
113
|
return /* @__PURE__ */ jsx("div", {
|
|
111
114
|
"data-slot": "input-group",
|
|
112
115
|
role: "group",
|
|
113
116
|
className: cn(inputGroupVariants({
|
|
114
|
-
chrome
|
|
117
|
+
chrome,
|
|
115
118
|
inputStyle,
|
|
116
119
|
inputColor
|
|
117
|
-
}), className),
|
|
120
|
+
}), floating && (inputStyle === "outlined" ? "h-12 border-0! has-[input:focus-visible]:outline-hidden!" : cn("h-12 [&_[data-slot=input]]:h-full [&_[data-slot=input]]:pt-5 [&_[data-slot=input]]:pb-1", inputStyle === "surface" && "has-[input:focus-visible]:outline-offset-[-2px]!")), className),
|
|
118
121
|
...props
|
|
119
122
|
});
|
|
120
123
|
}
|
|
@@ -126,11 +129,13 @@ const inputGroupAddonVariants = cva("flex h-auto cursor-text items-center justif
|
|
|
126
129
|
defaultVariants: { align: "inline-start" }
|
|
127
130
|
});
|
|
128
131
|
function InputGroupAddon({ className, align = "inline-start", ...props }) {
|
|
132
|
+
const field = useFieldContext();
|
|
133
|
+
const shiftWithValue = field?.labelPosition === "floating" && field.inputStyle !== "outlined";
|
|
129
134
|
return /* @__PURE__ */ jsx("div", {
|
|
130
135
|
role: "presentation",
|
|
131
136
|
"data-slot": "input-group-addon",
|
|
132
137
|
"data-align": align,
|
|
133
|
-
className: cn(inputGroupAddonVariants({ align }), className),
|
|
138
|
+
className: cn(inputGroupAddonVariants({ align }), shiftWithValue && "transition-[translate] duration-200 ease-[cubic-bezier(0,0,0.2,1)] field-floated:translate-y-2 motion-reduce:transition-none", className),
|
|
134
139
|
onClick: (event) => {
|
|
135
140
|
if (event.target.closest("button")) return;
|
|
136
141
|
event.currentTarget.parentElement?.querySelector("input")?.focus();
|
|
@@ -153,7 +158,69 @@ const InputGroupInput = React$1.forwardRef(function InputGroupInput({ className,
|
|
|
153
158
|
...props
|
|
154
159
|
});
|
|
155
160
|
});
|
|
161
|
+
const useIsomorphicLayoutEffect = typeof window === "undefined" ? React$1.useEffect : React$1.useLayoutEffect;
|
|
162
|
+
const SUFFIX_GAP = 4;
|
|
163
|
+
function placeSuffix(suffix, mirror, unit, input) {
|
|
164
|
+
const style = getComputedStyle(input);
|
|
165
|
+
const basePaddingRight = input.dataset.suffixPaddingRight ?? style.paddingRight;
|
|
166
|
+
input.dataset.suffixPaddingRight = basePaddingRight;
|
|
167
|
+
const paddingLeft = parseFloat(style.paddingLeft);
|
|
168
|
+
const paddingRight = parseFloat(basePaddingRight);
|
|
169
|
+
mirror.textContent = input.value;
|
|
170
|
+
suffix.toggleAttribute("data-empty", input.value === "");
|
|
171
|
+
suffix.style.font = style.font;
|
|
172
|
+
suffix.style.lineHeight = "normal";
|
|
173
|
+
suffix.style.letterSpacing = style.letterSpacing;
|
|
174
|
+
suffix.style.top = `${input.offsetTop}px`;
|
|
175
|
+
suffix.style.height = `${input.offsetHeight}px`;
|
|
176
|
+
suffix.style.paddingTop = style.paddingTop;
|
|
177
|
+
suffix.style.paddingBottom = style.paddingBottom;
|
|
178
|
+
const textLeft = input.offsetLeft + paddingLeft;
|
|
179
|
+
const available = input.clientWidth - paddingLeft - paddingRight;
|
|
180
|
+
const pinned = mirror.offsetWidth + SUFFIX_GAP + unit.offsetWidth > available;
|
|
181
|
+
suffix.toggleAttribute("data-pinned", pinned);
|
|
182
|
+
suffix.style.left = `${textLeft}px`;
|
|
183
|
+
suffix.style.width = `${input.clientWidth - paddingLeft - paddingRight}px`;
|
|
184
|
+
input.style.paddingRight = pinned ? `${paddingRight + unit.offsetWidth + SUFFIX_GAP}px` : "";
|
|
185
|
+
}
|
|
186
|
+
function InputGroupSuffix({ className, children, ...props }) {
|
|
187
|
+
const ref = React$1.useRef(null);
|
|
188
|
+
const mirrorRef = React$1.useRef(null);
|
|
189
|
+
const unitRef = React$1.useRef(null);
|
|
190
|
+
useIsomorphicLayoutEffect(() => {
|
|
191
|
+
const suffix = ref.current;
|
|
192
|
+
const mirror = mirrorRef.current;
|
|
193
|
+
const unit = unitRef.current;
|
|
194
|
+
const input = suffix?.closest("[data-slot=input-group]")?.querySelector("input[data-slot=input]");
|
|
195
|
+
if (!suffix || !mirror || !unit || !input) return;
|
|
196
|
+
const place = () => placeSuffix(suffix, mirror, unit, input);
|
|
197
|
+
place();
|
|
198
|
+
input.addEventListener("input", place);
|
|
199
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(place);
|
|
200
|
+
observer?.observe(input);
|
|
201
|
+
return () => {
|
|
202
|
+
input.removeEventListener("input", place);
|
|
203
|
+
observer?.disconnect();
|
|
204
|
+
};
|
|
205
|
+
});
|
|
206
|
+
return /* @__PURE__ */ jsx("span", {
|
|
207
|
+
ref,
|
|
208
|
+
"data-slot": "input-group-suffix",
|
|
209
|
+
"data-empty": "",
|
|
210
|
+
className: cn("pointer-events-none absolute flex items-center overflow-hidden whitespace-pre text-gray group-has-[[aria-invalid=true]]/input-group:text-error group-has-[input:disabled]/input-group:text-gray-disabled group-data-[invalid=true]/field:text-error data-empty:invisible data-pinned:justify-end", className),
|
|
211
|
+
...props,
|
|
212
|
+
children: /* @__PURE__ */ jsxs("span", { children: [/* @__PURE__ */ jsx("span", {
|
|
213
|
+
ref: mirrorRef,
|
|
214
|
+
"aria-hidden": "true",
|
|
215
|
+
className: "invisible"
|
|
216
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
217
|
+
ref: unitRef,
|
|
218
|
+
className: "ml-1 font-semibold",
|
|
219
|
+
children
|
|
220
|
+
})] })
|
|
221
|
+
});
|
|
222
|
+
}
|
|
156
223
|
//#endregion
|
|
157
|
-
export { InputGroup, InputGroupAddon, InputGroupInput, InputGroupText };
|
|
224
|
+
export { InputGroup, InputGroupAddon, InputGroupInput, InputGroupSuffix, InputGroupText };
|
|
158
225
|
|
|
159
226
|
//# sourceMappingURL=input-group.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-group.js","names":["React"],"sources":["../../src/components/input-group.tsx"],"sourcesContent":["'use client'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\nimport { cn } from '../utils/cn'\nimport { useFieldContext } from './field'\nimport { Input, type InputProps } from './input'\nimport { useTheme } from './theme'\n\nconst GHOST =\n 'rounded-none border-0 border-b-2 px-0 has-[:focus-visible]:border-b-input-active has-[[data-slot=input][aria-invalid=true]]:border-b-input-invalid has-[[data-slot=input][aria-invalid=true]]:has-[:focus-visible]:border-b-(--color-error-active)! group-data-[invalid=true]/field:border-b-input-invalid! group-data-[invalid=true]/field:has-[:focus-visible]:border-b-(--color-error-active)!'\n\nconst inputGroupVariants = cva(\n 'group/input-group relative flex h-10 w-full min-w-0 items-center gap-2 bg-transparent transition-[color,border-color] motion-reduce:transition-none',\n {\n variants: {\n chrome: {\n // inside an inset field the shell is the box; the group keeps the\n // classic underline (inputs inside stay chrome-less)\n inset: GHOST,\n // h-11 matches the standalone Input box; inside an inset field the shell draws the outline\n box: 'h-11 rounded-md px-3 transition-[color,background-color,border-color] has-[input:focus-visible]:focus-outline group-data-[invalid=true]/field:has-[input:focus-visible]:outline-(--color-error-active) has-[[data-slot=input][aria-invalid=true]]:has-[input:focus-visible]:outline-(--color-error-active) motion-reduce:transition-none',\n },\n inputStyle: { soft: '', surface: '', outlined: '', ghost: '' },\n inputColor: { brand: '', gray: '' },\n },\n compoundVariants: [\n {\n chrome: 'box',\n inputStyle: 'soft',\n // invalid hover deepens the error tint instead of the accent hover\n class:\n 'group-data-[invalid=true]/field:bg-base-error-soft has-[[data-slot=input][aria-invalid=true]]:bg-base-error-soft has-[[data-slot=input][aria-invalid=true]:not(:disabled)]:hover:bg-red-a4 group-data-[invalid=true]/field:has-[input:not(:disabled)]:hover:bg-red-a4',\n },\n {\n chrome: 'box',\n inputStyle: 'soft',\n inputColor: 'brand',\n class:\n 'bg-input-base has-[input:not(:disabled)]:hover:bg-input-base-hover',\n },\n {\n chrome: 'box',\n inputStyle: 'soft',\n inputColor: 'gray',\n class: 'bg-base-gray-soft has-[input:not(:disabled)]:hover:bg-gray-a4',\n },\n {\n chrome: 'box',\n inputStyle: ['surface', 'outlined'],\n class:\n 'border group-data-[invalid=true]/field:border-input-invalid group-data-[invalid=true]/field:has-[:focus-visible]:border-input-invalid! has-[[data-slot=input][aria-invalid=true]]:border-input-invalid has-[[data-slot=input][aria-invalid=true]]:has-[:focus-visible]:border-input-invalid!',\n },\n {\n chrome: 'box',\n inputStyle: 'surface',\n inputColor: 'brand',\n class:\n 'border-input bg-base-accent-surface has-[:focus-visible]:border-input-active',\n },\n {\n chrome: 'box',\n inputStyle: 'surface',\n inputColor: 'gray',\n class:\n 'border-input-gray bg-base-gray-surface has-[:focus-visible]:border-gray-a8',\n },\n {\n chrome: 'box',\n inputStyle: 'outlined',\n inputColor: 'brand',\n class: 'border-input has-[:focus-visible]:border-input-active',\n },\n {\n chrome: 'box',\n inputStyle: 'outlined',\n inputColor: 'gray',\n class: 'border-input-gray has-[:focus-visible]:border-gray-a8',\n },\n { chrome: 'box', inputStyle: 'ghost', class: GHOST },\n {\n chrome: 'box',\n inputStyle: 'ghost',\n inputColor: 'brand',\n class: 'border-b-input',\n },\n {\n chrome: 'box',\n inputStyle: 'ghost',\n inputColor: 'gray',\n class: 'border-b-input-gray',\n },\n { chrome: 'inset', inputColor: 'brand', class: 'border-b-input' },\n { chrome: 'inset', inputColor: 'gray', class: 'border-b-input-gray' },\n ],\n },\n)\n\n// The group carries the box + focus/invalid states; inputs inside are\n// chrome-less (variant=\"none\"). Style follows the enclosing Field's knobs,\n// else the <Theme> input-style/input-color knobs.\nfunction InputGroup({ className, ...props }: React.ComponentProps<'div'>) {\n const field = useFieldContext()\n const theme = useTheme()\n const inputStyle = field?.inputStyle ?? theme.inputStyle ?? 'soft'\n const inputColor = field?.inputColor ?? theme.inputColor ?? 'brand'\n const chrome = field?.labelPosition === 'inset' ? 'inset' : 'box'\n return (\n <div\n data-slot=\"input-group\"\n role=\"group\"\n className={cn(\n inputGroupVariants({ chrome, inputStyle, inputColor }),\n className,\n )}\n {...props}\n />\n )\n}\n\nconst inputGroupAddonVariants = cva(\n 'flex h-auto cursor-text items-center justify-center gap-2 py-2 text-sm font-medium text-gray-light select-none [&_svg:not([class*=size-])]:size-4',\n {\n variants: {\n align: {\n // button addons bring their own inner padding — pull them halfway\n // into the group's px so the visual gap matches the text side\n 'inline-start': 'order-first has-[>button]:-ml-2',\n 'inline-end': 'order-last has-[>button]:-mr-2',\n },\n },\n defaultVariants: {\n align: 'inline-start',\n },\n },\n)\n\nfunction InputGroupAddon({\n className,\n align = 'inline-start',\n ...props\n}: React.ComponentProps<'div'> & VariantProps<typeof inputGroupAddonVariants>) {\n return (\n <div\n // chrome, not a control: the click only forwards focus to the input the\n // way a label would, and Tab already reaches that input directly\n role=\"presentation\"\n data-slot=\"input-group-addon\"\n data-align={align}\n className={cn(inputGroupAddonVariants({ align }), className)}\n onClick={(event) => {\n if ((event.target as HTMLElement).closest('button')) return\n event.currentTarget.parentElement?.querySelector('input')?.focus()\n }}\n {...props}\n />\n )\n}\n\nfunction InputGroupText({ className, ...props }: React.ComponentProps<'span'>) {\n return (\n <span\n className={cn(\n 'flex items-center gap-2 text-xs text-gray-light [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4',\n className,\n )}\n {...props}\n />\n )\n}\n\nconst InputGroupInput = React.forwardRef<HTMLInputElement, InputProps>(\n function InputGroupInput({ className, ...props }, ref) {\n return (\n <Input\n data-slot=\"input\"\n variant=\"none\"\n className={cn('flex-1', className)}\n ref={ref}\n {...props}\n />\n )\n },\n)\n\nexport { InputGroup, InputGroupAddon, InputGroupInput, InputGroupText }\n"],"mappings":";;;;;;;;;;AASA,MAAM,QACJ;AAEF,MAAM,qBAAqB,IACzB,uJACA;CACE,UAAU;EACR,QAAQ;GAGN,OAAO;GAEP,KAAK;EACP;EACA,YAAY;GAAE,MAAM;GAAI,SAAS;GAAI,UAAU;GAAI,OAAO;EAAG;EAC7D,YAAY;GAAE,OAAO;GAAI,MAAM;EAAG;CACpC;CACA,kBAAkB;EAChB;GACE,QAAQ;GACR,YAAY;GAEZ,OACE;EACJ;EACA;GACE,QAAQ;GACR,YAAY;GACZ,YAAY;GACZ,OACE;EACJ;EACA;GACE,QAAQ;GACR,YAAY;GACZ,YAAY;GACZ,OAAO;EACT;EACA;GACE,QAAQ;GACR,YAAY,CAAC,WAAW,UAAU;GAClC,OACE;EACJ;EACA;GACE,QAAQ;GACR,YAAY;GACZ,YAAY;GACZ,OACE;EACJ;EACA;GACE,QAAQ;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;AAEL;AAEA,SAAS,eAAe,EAAE,WAAW,GAAG,SAAuC;CAC7E,OACE,oBAAC,QAAD;EACE,WAAW,GACT,kHACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,MAAM,kBAAkBA,QAAM,WAC5B,SAAS,gBAAgB,EAAE,WAAW,GAAG,SAAS,KAAK;CACrD,OACE,oBAAC,OAAD;EACE,aAAU;EACV,SAAQ;EACR,WAAW,GAAG,UAAU,SAAS;EAC5B;EACL,GAAI;CACL,CAAA;AAEL,CACF"}
|
|
1
|
+
{"version":3,"file":"input-group.js","names":["React"],"sources":["../../src/components/input-group.tsx"],"sourcesContent":["'use client'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\nimport { FLOATING_ADORNMENT_SHIFT } from '../lib/input-box-variants'\nimport { cn } from '../utils/cn'\nimport { useFieldContext } from './field'\nimport { Input, type InputProps } from './input'\nimport { useTheme } from './theme'\n\nconst GHOST =\n 'rounded-none border-0 border-b-2 px-0 has-[:focus-visible]:border-b-input-active has-[[data-slot=input][aria-invalid=true]]:border-b-input-invalid has-[[data-slot=input][aria-invalid=true]]:has-[:focus-visible]:border-b-(--color-error-active)! group-data-[invalid=true]/field:border-b-input-invalid! group-data-[invalid=true]/field:has-[:focus-visible]:border-b-(--color-error-active)!'\n\nconst inputGroupVariants = cva(\n 'group/input-group relative flex h-10 w-full min-w-0 items-center gap-2 bg-transparent transition-[color,border-color] motion-reduce:transition-none',\n {\n variants: {\n chrome: {\n // inside an inset field the shell is the box; the group keeps the\n // classic underline (inputs inside stay chrome-less)\n inset: GHOST,\n // h-11 matches the standalone Input box; inside an inset field the shell draws the outline\n box: 'h-11 rounded-md px-3 transition-[color,background-color,border-color] has-[input:focus-visible]:focus-outline group-data-[invalid=true]/field:has-[input:focus-visible]:outline-(--color-error-active) has-[[data-slot=input][aria-invalid=true]]:has-[input:focus-visible]:outline-(--color-error-active) motion-reduce:transition-none',\n },\n inputStyle: { soft: '', surface: '', outlined: '', ghost: '' },\n inputColor: { brand: '', gray: '' },\n },\n compoundVariants: [\n {\n chrome: 'box',\n inputStyle: 'soft',\n // invalid hover deepens the error tint instead of the accent hover\n class:\n 'group-data-[invalid=true]/field:bg-base-error-soft has-[[data-slot=input][aria-invalid=true]]:bg-base-error-soft has-[[data-slot=input][aria-invalid=true]:not(:disabled)]:hover:bg-red-a4 group-data-[invalid=true]/field:has-[input:not(:disabled)]:hover:bg-red-a4',\n },\n {\n chrome: 'box',\n inputStyle: 'soft',\n inputColor: 'brand',\n class:\n 'bg-input-base has-[input:not(:disabled)]:hover:bg-input-base-hover',\n },\n {\n chrome: 'box',\n inputStyle: 'soft',\n inputColor: 'gray',\n class: 'bg-base-gray-soft has-[input:not(:disabled)]:hover:bg-gray-a4',\n },\n {\n chrome: 'box',\n inputStyle: ['surface', 'outlined'],\n class:\n 'border group-data-[invalid=true]/field:border-input-invalid group-data-[invalid=true]/field:has-[:focus-visible]:border-input-invalid! has-[[data-slot=input][aria-invalid=true]]:border-input-invalid has-[[data-slot=input][aria-invalid=true]]:has-[:focus-visible]:border-input-invalid!',\n },\n {\n chrome: 'box',\n inputStyle: 'surface',\n inputColor: 'brand',\n class:\n 'border-input bg-base-accent-surface has-[:focus-visible]:border-input-active',\n },\n {\n chrome: 'box',\n inputStyle: 'surface',\n inputColor: 'gray',\n class:\n 'border-input-gray bg-base-gray-surface has-[:focus-visible]:border-gray-a8',\n },\n {\n chrome: 'box',\n inputStyle: 'outlined',\n inputColor: 'brand',\n class: 'border-input has-[:focus-visible]:border-input-active',\n },\n {\n chrome: 'box',\n inputStyle: 'outlined',\n inputColor: 'gray',\n class: 'border-input-gray has-[:focus-visible]:border-gray-a8',\n },\n { chrome: 'box', inputStyle: 'ghost', class: GHOST },\n {\n chrome: 'box',\n inputStyle: 'ghost',\n inputColor: 'brand',\n class: 'border-b-input',\n },\n {\n chrome: 'box',\n inputStyle: 'ghost',\n inputColor: 'gray',\n class: 'border-b-input-gray',\n },\n { chrome: 'inset', inputColor: 'brand', class: 'border-b-input' },\n { chrome: 'inset', inputColor: 'gray', class: 'border-b-input-gray' },\n ],\n },\n)\n\n// The group carries the box + focus/invalid states; inputs inside are\n// chrome-less (variant=\"none\"). Style follows the enclosing Field's knobs,\n// else the <Theme> input-style/input-color knobs.\nfunction InputGroup({ className, ...props }: React.ComponentProps<'div'>) {\n const field = useFieldContext()\n const theme = useTheme()\n const inputStyle = field?.inputStyle ?? theme.inputStyle ?? 'soft'\n const inputColor = field?.inputColor ?? theme.inputColor ?? 'brand'\n const chrome = field?.labelPosition === 'inset' ? 'inset' : 'box'\n const floating = field?.labelPosition === 'floating'\n return (\n <div\n data-slot=\"input-group\"\n role=\"group\"\n className={cn(\n inputGroupVariants({ chrome, inputStyle, inputColor }),\n floating &&\n (inputStyle === 'outlined'\n ? 'h-12 border-0! has-[input:focus-visible]:outline-hidden!'\n : cn(\n 'h-12 [&_[data-slot=input]]:h-full [&_[data-slot=input]]:pt-5 [&_[data-slot=input]]:pb-1',\n inputStyle === 'surface' &&\n 'has-[input:focus-visible]:outline-offset-[-2px]!',\n )),\n className,\n )}\n {...props}\n />\n )\n}\n\nconst inputGroupAddonVariants = cva(\n 'flex h-auto cursor-text items-center justify-center gap-2 py-2 text-sm font-medium text-gray-light select-none [&_svg:not([class*=size-])]:size-4',\n {\n variants: {\n align: {\n // button addons bring their own inner padding — pull them halfway\n // into the group's px so the visual gap matches the text side\n 'inline-start': 'order-first has-[>button]:-ml-2',\n 'inline-end': 'order-last has-[>button]:-mr-2',\n },\n },\n defaultVariants: {\n align: 'inline-start',\n },\n },\n)\n\nfunction InputGroupAddon({\n className,\n align = 'inline-start',\n ...props\n}: React.ComponentProps<'div'> & VariantProps<typeof inputGroupAddonVariants>) {\n const field = useFieldContext()\n const shiftWithValue =\n field?.labelPosition === 'floating' && field.inputStyle !== 'outlined'\n return (\n <div\n // chrome, not a control: the click only forwards focus to the input the\n // way a label would, and Tab already reaches that input directly\n role=\"presentation\"\n data-slot=\"input-group-addon\"\n data-align={align}\n className={cn(\n inputGroupAddonVariants({ align }),\n shiftWithValue && FLOATING_ADORNMENT_SHIFT,\n className,\n )}\n onClick={(event) => {\n if ((event.target as HTMLElement).closest('button')) return\n event.currentTarget.parentElement?.querySelector('input')?.focus()\n }}\n {...props}\n />\n )\n}\n\nfunction InputGroupText({ className, ...props }: React.ComponentProps<'span'>) {\n return (\n <span\n className={cn(\n 'flex items-center gap-2 text-xs text-gray-light [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4',\n className,\n )}\n {...props}\n />\n )\n}\n\nconst InputGroupInput = React.forwardRef<HTMLInputElement, InputProps>(\n function InputGroupInput({ className, ...props }, ref) {\n return (\n <Input\n data-slot=\"input\"\n variant=\"none\"\n className={cn('flex-1', className)}\n ref={ref}\n {...props}\n />\n )\n },\n)\n\nconst useIsomorphicLayoutEffect =\n typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect\n\nconst SUFFIX_GAP = 4\n\nfunction placeSuffix(\n suffix: HTMLSpanElement,\n mirror: HTMLSpanElement,\n unit: HTMLSpanElement,\n input: HTMLInputElement,\n) {\n const style = getComputedStyle(input)\n const basePaddingRight =\n input.dataset.suffixPaddingRight ?? style.paddingRight\n input.dataset.suffixPaddingRight = basePaddingRight\n const paddingLeft = parseFloat(style.paddingLeft)\n const paddingRight = parseFloat(basePaddingRight)\n\n mirror.textContent = input.value\n suffix.toggleAttribute('data-empty', input.value === '')\n suffix.style.font = style.font\n suffix.style.lineHeight = 'normal'\n suffix.style.letterSpacing = style.letterSpacing\n suffix.style.top = `${input.offsetTop}px`\n suffix.style.height = `${input.offsetHeight}px`\n suffix.style.paddingTop = style.paddingTop\n suffix.style.paddingBottom = style.paddingBottom\n\n const textLeft = input.offsetLeft + paddingLeft\n const available = input.clientWidth - paddingLeft - paddingRight\n const needed = mirror.offsetWidth + SUFFIX_GAP + unit.offsetWidth\n const pinned = needed > available\n suffix.toggleAttribute('data-pinned', pinned)\n suffix.style.left = `${textLeft}px`\n suffix.style.width = `${input.clientWidth - paddingLeft - paddingRight}px`\n input.style.paddingRight = pinned\n ? `${paddingRight + unit.offsetWidth + SUFFIX_GAP}px`\n : ''\n}\n\nfunction InputGroupSuffix({\n className,\n children,\n ...props\n}: React.ComponentProps<'span'>) {\n const ref = React.useRef<HTMLSpanElement>(null)\n const mirrorRef = React.useRef<HTMLSpanElement>(null)\n const unitRef = React.useRef<HTMLSpanElement>(null)\n\n useIsomorphicLayoutEffect(() => {\n const suffix = ref.current\n const mirror = mirrorRef.current\n const unit = unitRef.current\n const input = suffix\n ?.closest('[data-slot=input-group]')\n ?.querySelector<HTMLInputElement>('input[data-slot=input]')\n if (!suffix || !mirror || !unit || !input) return\n const place = () => placeSuffix(suffix, mirror, unit, input)\n place()\n input.addEventListener('input', place)\n const observer =\n typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(place)\n observer?.observe(input)\n return () => {\n input.removeEventListener('input', place)\n observer?.disconnect()\n }\n })\n\n return (\n <span\n ref={ref}\n data-slot=\"input-group-suffix\"\n data-empty=\"\"\n className={cn(\n 'pointer-events-none absolute flex items-center overflow-hidden whitespace-pre text-gray group-has-[[aria-invalid=true]]/input-group:text-error group-has-[input:disabled]/input-group:text-gray-disabled group-data-[invalid=true]/field:text-error data-empty:invisible data-pinned:justify-end',\n className,\n )}\n {...props}\n >\n <span>\n <span ref={mirrorRef} aria-hidden=\"true\" className=\"invisible\" />\n <span ref={unitRef} className=\"ml-1 font-semibold\">\n {children}\n </span>\n </span>\n </span>\n )\n}\n\nexport {\n InputGroup,\n InputGroupAddon,\n InputGroupInput,\n InputGroupSuffix,\n InputGroupText,\n}\n"],"mappings":";;;;;;;;;;;AAUA,MAAM,QACJ;AAEF,MAAM,qBAAqB,IACzB,uJACA;CACE,UAAU;EACR,QAAQ;GAGN,OAAO;GAEP,KAAK;EACP;EACA,YAAY;GAAE,MAAM;GAAI,SAAS;GAAI,UAAU;GAAI,OAAO;EAAG;EAC7D,YAAY;GAAE,OAAO;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W,GACT,oSACA,SACF;EACA,GAAI;YAEJ,qBAAC,QAAD,EAAA,UAAA,CACE,oBAAC,QAAD;GAAM,KAAK;GAAW,eAAY;GAAO,WAAU;EAAa,CAAA,GAChE,oBAAC,QAAD;GAAM,KAAK;GAAS,WAAU;GAC3B;EACG,CAAA,CACF,EAAA,CAAA;CACF,CAAA;AAEV"}
|
|
@@ -88,20 +88,23 @@ const inputVariants = (0, class_variance_authority.cva)("flex h-10 w-full min-w-
|
|
|
88
88
|
}
|
|
89
89
|
]
|
|
90
90
|
});
|
|
91
|
-
const Input = react.forwardRef(function Input({ variant, className, id: idProp, "aria-describedby": ariaDescribedByProp, ...props }, ref) {
|
|
91
|
+
const Input = react.forwardRef(function Input({ variant, className, placeholder, id: idProp, "aria-describedby": ariaDescribedByProp, ...props }, ref) {
|
|
92
92
|
const { field, id, ariaDescribedBy, ariaInvalid, inputStyle, inputColor } = require_components_field.useFieldControl({
|
|
93
93
|
id: idProp,
|
|
94
94
|
ariaDescribedBy: ariaDescribedByProp,
|
|
95
95
|
variant: variant !== "none" ? variant : void 0
|
|
96
96
|
});
|
|
97
|
+
const chrome = variant === "none" ? "none" : !variant && field?.labelPosition === "inset" ? "inset" : "box";
|
|
98
|
+
const floating = field?.labelPosition === "floating";
|
|
97
99
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
98
100
|
"data-slot": "input",
|
|
99
101
|
className: (0, cn.cn)(inputVariants({
|
|
100
|
-
chrome
|
|
102
|
+
chrome,
|
|
101
103
|
inputStyle,
|
|
102
104
|
inputColor
|
|
103
|
-
}), className),
|
|
105
|
+
}), floating && chrome === "box" && require_lib_input_box_variants.floatingChrome(inputStyle), className),
|
|
104
106
|
id,
|
|
107
|
+
placeholder: placeholder ?? (floating ? " " : void 0),
|
|
105
108
|
ref,
|
|
106
109
|
"aria-invalid": ariaInvalid,
|
|
107
110
|
...props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.cjs","names":["INSET_UNDERLINE","boxChrome","React","useFieldControl"],"sources":["../../src/components/input.tsx"],"sourcesContent":["import { cva } from 'class-variance-authority'\nimport * as React from 'react'\nimport {
|
|
1
|
+
{"version":3,"file":"input.cjs","names":["INSET_UNDERLINE","boxChrome","React","useFieldControl","floatingChrome"],"sources":["../../src/components/input.tsx"],"sourcesContent":["import { cva } from 'class-variance-authority'\nimport * as React from 'react'\nimport {\n boxChrome,\n FLOATING_PLACEHOLDER,\n floatingChrome,\n INSET_UNDERLINE,\n} from '../lib/input-box-variants'\nimport type { SparkInputStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\nimport { useFieldControl } from './field'\n\ntype InputVariant = SparkInputStyle | 'none'\n\nconst inputVariants = cva(\n 'flex h-10 w-full min-w-0 [appearance:textfield] bg-transparent text-gray transition-[color,background-color,border-color] group-data-[invalid=true]/field:text-error placeholder:text-gray-placeholder disabled:cursor-not-allowed disabled:text-gray-disabled disabled:placeholder:text-gray-disabled aria-invalid:text-error motion-reduce:transition-none [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none',\n {\n variants: {\n chrome: {\n none: 'border-0 px-0 focus-visible:outline-hidden',\n // inside an inset field the shell is the box; the input keeps the\n // classic underline (the pre-knob default look)\n inset: INSET_UNDERLINE,\n box: 'h-11 rounded-md px-3 py-1 text-base transition-[color,background-color,border-color] motion-reduce:transition-none',\n },\n inputStyle: { soft: '', surface: '', outlined: '', ghost: '' },\n inputColor: { brand: '', gray: '' },\n },\n compoundVariants: [\n {\n chrome: 'box',\n inputStyle: 'soft',\n inputColor: 'brand',\n class: boxChrome.soft.brand,\n },\n {\n chrome: 'box',\n inputStyle: 'soft',\n inputColor: 'gray',\n class: boxChrome.soft.gray,\n },\n {\n chrome: 'box',\n inputStyle: 'surface',\n inputColor: 'brand',\n class: boxChrome.surface.brand,\n },\n {\n chrome: 'box',\n inputStyle: 'surface',\n inputColor: 'gray',\n class: boxChrome.surface.gray,\n },\n {\n chrome: 'box',\n inputStyle: 'outlined',\n inputColor: 'brand',\n class: boxChrome.outlined.brand,\n },\n {\n chrome: 'box',\n inputStyle: 'outlined',\n inputColor: 'gray',\n class: boxChrome.outlined.gray,\n },\n {\n chrome: 'box',\n inputStyle: 'ghost',\n inputColor: 'brand',\n class: boxChrome.ghost.brand,\n },\n {\n chrome: 'box',\n inputStyle: 'ghost',\n inputColor: 'gray',\n class: boxChrome.ghost.gray,\n },\n { chrome: 'inset', inputColor: 'brand', class: 'border-b-input' },\n { chrome: 'inset', inputColor: 'gray', class: 'border-b-input-gray' },\n ],\n },\n)\n\ninterface InputProps extends React.ComponentProps<'input'> {\n variant?: InputVariant\n}\n\n// forwardRef keeps refs working for React 18 consumers (ref-as-prop is 19-only)\nconst Input = React.forwardRef<HTMLInputElement, InputProps>(function Input(\n {\n variant,\n className,\n placeholder,\n id: idProp,\n 'aria-describedby': ariaDescribedByProp,\n ...props\n },\n ref,\n) {\n const { field, id, ariaDescribedBy, ariaInvalid, inputStyle, inputColor } =\n useFieldControl({\n id: idProp,\n ariaDescribedBy: ariaDescribedByProp,\n variant: variant !== 'none' ? variant : undefined,\n })\n // an explicit variant prop keeps the box even inside an inset field\n const chrome =\n variant === 'none'\n ? 'none'\n : !variant && field?.labelPosition === 'inset'\n ? 'inset'\n : 'box'\n const floating = field?.labelPosition === 'floating'\n\n return (\n <input\n data-slot=\"input\"\n className={cn(\n inputVariants({ chrome, inputStyle, inputColor }),\n floating && chrome === 'box' && floatingChrome(inputStyle),\n className,\n )}\n id={id}\n placeholder={placeholder ?? (floating ? FLOATING_PLACEHOLDER : undefined)}\n ref={ref}\n aria-invalid={ariaInvalid}\n {...props}\n aria-describedby={ariaDescribedBy}\n />\n )\n})\n\nexport { Input }\nexport type { InputProps, InputVariant }\n"],"mappings":";;;;;;;;;;;AAcA,MAAM,iBAAA,GAAA,yBAAA,KACJ,8bACA;CACE,UAAU;EACR,QAAQ;GACN,MAAM;GAGN,OAAOA,+BAAAA;GACP,KAAK;E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AAW,OAAO,kBAAkB;CAE1C,OACE,iBAAA,GAAA,kBAAA,KAAC,SAAD;EACE,aAAU;EACV,YAAA,GAAA,GAAA,IACE,cAAc;GAAE;GAAQ;GAAY;EAAW,CAAC,GAChD,YAAY,WAAW,SAASC,+BAAAA,eAAe,UAAU,GACzD,SACF;EACI;EACJ,aAAa,gBAAgB,WAAA,MAAkC,KAAA;EAC1D;EACL,gBAAc;EACd,GAAI;EACJ,oBAAkB;CACnB,CAAA;AAEL,CAAC"}
|
package/dist/components/input.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
|
-
import { INSET_UNDERLINE, boxChrome } from "../lib/input-box-variants.js";
|
|
3
|
+
import { INSET_UNDERLINE, boxChrome, floatingChrome } from "../lib/input-box-variants.js";
|
|
4
4
|
import { useFieldControl } from "./field.js";
|
|
5
5
|
import * as React$1 from "react";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -85,20 +85,23 @@ const inputVariants = cva("flex h-10 w-full min-w-0 [appearance:textfield] bg-tr
|
|
|
85
85
|
}
|
|
86
86
|
]
|
|
87
87
|
});
|
|
88
|
-
const Input = React$1.forwardRef(function Input({ variant, className, id: idProp, "aria-describedby": ariaDescribedByProp, ...props }, ref) {
|
|
88
|
+
const Input = React$1.forwardRef(function Input({ variant, className, placeholder, id: idProp, "aria-describedby": ariaDescribedByProp, ...props }, ref) {
|
|
89
89
|
const { field, id, ariaDescribedBy, ariaInvalid, inputStyle, inputColor } = useFieldControl({
|
|
90
90
|
id: idProp,
|
|
91
91
|
ariaDescribedBy: ariaDescribedByProp,
|
|
92
92
|
variant: variant !== "none" ? variant : void 0
|
|
93
93
|
});
|
|
94
|
+
const chrome = variant === "none" ? "none" : !variant && field?.labelPosition === "inset" ? "inset" : "box";
|
|
95
|
+
const floating = field?.labelPosition === "floating";
|
|
94
96
|
return /* @__PURE__ */ jsx("input", {
|
|
95
97
|
"data-slot": "input",
|
|
96
98
|
className: cn(inputVariants({
|
|
97
|
-
chrome
|
|
99
|
+
chrome,
|
|
98
100
|
inputStyle,
|
|
99
101
|
inputColor
|
|
100
|
-
}), className),
|
|
102
|
+
}), floating && chrome === "box" && floatingChrome(inputStyle), className),
|
|
101
103
|
id,
|
|
104
|
+
placeholder: placeholder ?? (floating ? " " : void 0),
|
|
102
105
|
ref,
|
|
103
106
|
"aria-invalid": ariaInvalid,
|
|
104
107
|
...props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","names":["React"],"sources":["../../src/components/input.tsx"],"sourcesContent":["import { cva } from 'class-variance-authority'\nimport * as React from 'react'\nimport {
|
|
1
|
+
{"version":3,"file":"input.js","names":["React"],"sources":["../../src/components/input.tsx"],"sourcesContent":["import { cva } from 'class-variance-authority'\nimport * as React from 'react'\nimport {\n boxChrome,\n FLOATING_PLACEHOLDER,\n floatingChrome,\n INSET_UNDERLINE,\n} from '../lib/input-box-variants'\nimport type { SparkInputStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\nimport { useFieldControl } from './field'\n\ntype InputVariant = SparkInputStyle | 'none'\n\nconst inputVariants = cva(\n 'flex h-10 w-full min-w-0 [appearance:textfield] bg-transparent text-gray transition-[color,background-color,border-color] group-data-[invalid=true]/field:text-error placeholder:text-gray-placeholder disabled:cursor-not-allowed disabled:text-gray-disabled disabled:placeholder:text-gray-disabled aria-invalid:text-error motion-reduce:transition-none [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none',\n {\n variants: {\n chrome: {\n none: 'border-0 px-0 focus-visible:outline-hidden',\n // inside an inset field the shell is the box; the input keeps the\n // classic underline (the pre-knob default look)\n inset: INSET_UNDERLINE,\n box: 'h-11 rounded-md px-3 py-1 text-base transition-[color,background-color,border-color] motion-reduce:transition-none',\n },\n inputStyle: { soft: '', surface: '', outlined: '', ghost: '' },\n inputColor: { brand: '', gray: '' },\n },\n compoundVariants: [\n {\n chrome: 'box',\n inputStyle: 'soft',\n inputColor: 'brand',\n class: boxChrome.soft.brand,\n },\n {\n chrome: 'box',\n inputStyle: 'soft',\n inputColor: 'gray',\n class: boxChrome.soft.gray,\n },\n {\n chrome: 'box',\n inputStyle: 'surface',\n inputColor: 'brand',\n class: boxChrome.surface.brand,\n },\n {\n chrome: 'box',\n inputStyle: 'surface',\n inputColor: 'gray',\n class: boxChrome.surface.gray,\n },\n {\n chrome: 'box',\n inputStyle: 'outlined',\n inputColor: 'brand',\n class: boxChrome.outlined.brand,\n },\n {\n chrome: 'box',\n inputStyle: 'outlined',\n inputColor: 'gray',\n class: boxChrome.outlined.gray,\n },\n {\n chrome: 'box',\n inputStyle: 'ghost',\n inputColor: 'brand',\n class: boxChrome.ghost.brand,\n },\n {\n chrome: 'box',\n inputStyle: 'ghost',\n inputColor: 'gray',\n class: boxChrome.ghost.gray,\n },\n { chrome: 'inset', inputColor: 'brand', class: 'border-b-input' },\n { chrome: 'inset', inputColor: 'gray', class: 'border-b-input-gray' },\n ],\n },\n)\n\ninterface InputProps extends React.ComponentProps<'input'> {\n variant?: InputVariant\n}\n\n// forwardRef keeps refs working for React 18 consumers (ref-as-prop is 19-only)\nconst Input = React.forwardRef<HTMLInputElement, InputProps>(function Input(\n {\n variant,\n className,\n placeholder,\n id: idProp,\n 'aria-describedby': ariaDescribedByProp,\n ...props\n },\n ref,\n) {\n const { field, id, ariaDescribedBy, ariaInvalid, inputStyle, inputColor } =\n useFieldControl({\n id: idProp,\n ariaDescribedBy: ariaDescribedByProp,\n variant: variant !== 'none' ? variant : undefined,\n })\n // an explicit variant prop keeps the box even inside an inset field\n const chrome =\n variant === 'none'\n ? 'none'\n : !variant && field?.labelPosition === 'inset'\n ? 'inset'\n : 'box'\n const floating = field?.labelPosition === 'floating'\n\n return (\n <input\n data-slot=\"input\"\n className={cn(\n inputVariants({ chrome, inputStyle, inputColor }),\n floating && chrome === 'box' && floatingChrome(inputStyle),\n className,\n )}\n id={id}\n placeholder={placeholder ?? (floating ? FLOATING_PLACEHOLDER : undefined)}\n ref={ref}\n aria-invalid={ariaInvalid}\n {...props}\n aria-describedby={ariaDescribedBy}\n />\n )\n})\n\nexport { Input }\nexport type { InputProps, InputVariant }\n"],"mappings":";;;;;;;;AAcA,MAAM,gBAAgB,IACpB,8bACA;CACE,UAAU;EACR,QAAQ;GACN,MAAM;GAGN,OAAO;GACP,KAAK;EACP;EACA,YAAY;GAAE,MAAM;GAAI,SAAS;GAAI,UAAU;GAAI,OAAO;EAAG;EAC7D,YAAY;GAAE,OAAO;GAAI,MAAM;EAAG;CACpC;CACA,kBAAkB;EAChB;GACE,QAAQ;GACR,YAAY;GACZ,YAAY;GACZ,OAAO,UAAU,KAAK;EACxB;EACA;GACE,QAAQ;GACR,YAAY;GACZ,YAAY;GACZ,OAAO,UAAU,KAAK;EACxB;EACA;GACE,QAAQ;GACR,YAAY;GACZ,YAAY;GACZ,OAAO,UAAU,QAAQ;EAC3B;EACA;GACE,QAAQ;GACR,YAAY;GACZ,YAAY;GACZ,OAAO,UAAU,QAAQ;EAC3B;EACA;GACE,QAAQ;GACR,YAAY;GACZ,YAAY;GACZ,OAAO,UAAU,SAAS;EAC5B;EACA;GACE,QAAQ;GACR,YAAY;GACZ,YAAY;GACZ,OAAO,UAAU,SAAS;EAC5B;EACA;GACE,QAAQ;GACR,YAAY;GACZ,YAAY;GACZ,OAAO,UAAU,MAAM;EACzB;EACA;GACE,QAAQ;GACR,YAAY;GACZ,YAAY;GACZ,OAAO,UAAU,MAAM;EACzB;EACA;GAAE,QAAQ;GAAS,YAAY;GAAS,OAAO;EAAiB;EAChE;GAAE,QAAQ;GAAS,YAAY;GAAQ,OAAO;EAAsB;CACtE;AACF,CACF;AAOA,MAAM,QAAQA,QAAM,WAAyC,SAAS,MACpE,EACE,SACA,WACA,aACA,IAAI,QACJ,oBAAoB,qBACpB,GAAG,SAEL,KACA;CACA,MAAM,EAAE,OAAO,IAAI,iBAAiB,aAAa,YAAY,eAC3D,gBAAgB;EACd,IAAI;EACJ,iBAAiB;EACjB,SAAS,YAAY,SAAS,UAAU,KAAA;CAC1C,CAAC;CAEH,MAAM,SACJ,YAAY,SACR,SACA,CAAC,WAAW,OAAO,kBAAkB,UACnC,UACA;CACR,MAAM,WAAW,OAAO,kBAAkB;CAE1C,OACE,oBAAC,SAAD;EACE,aAAU;EACV,WAAW,GACT,cAAc;GAAE;GAAQ;GAAY;EAAW,CAAC,GAChD,YAAY,WAAW,SAAS,eAAe,UAAU,GACzD,SACF;EACI;EACJ,aAAa,gBAAgB,WAAA,MAAkC,KAAA;EAC1D;EACL,gBAAc;EACd,GAAI;EACJ,oBAAkB;CACnB,CAAA;AAEL,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { c as SparkCardColor, l as SparkCardVariant } from "../theme-types-
|
|
3
|
+
import { c as SparkCardColor, l as SparkCardVariant } from "../theme-types-CHl-L2F-.cjs";
|
|
4
4
|
import { ContainerRadius } from "../lib/container-chrome.cjs";
|
|
5
5
|
import { Tone } from "../lib/tones.cjs";
|
|
6
6
|
import * as React$1 from "react";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { c as SparkCardColor, l as SparkCardVariant } from "../theme-types-
|
|
3
|
+
import { c as SparkCardColor, l as SparkCardVariant } from "../theme-types-CHl-L2F-.js";
|
|
4
4
|
import { ContainerRadius } from "../lib/container-chrome.js";
|
|
5
5
|
import { Tone } from "../lib/tones.js";
|
|
6
6
|
import * as React$1 from "react";
|
|
@@ -6,7 +6,7 @@ import { useRender } from "@base-ui/react/use-render";
|
|
|
6
6
|
|
|
7
7
|
//#region src/components/marker.d.ts
|
|
8
8
|
declare const markerVariants: (props?: ({
|
|
9
|
-
variant?: "
|
|
9
|
+
variant?: "border" | "default" | "separator" | null | undefined;
|
|
10
10
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
11
11
|
declare function Marker({
|
|
12
12
|
className,
|
|
@@ -6,7 +6,7 @@ import { useRender } from "@base-ui/react/use-render";
|
|
|
6
6
|
|
|
7
7
|
//#region src/components/marker.d.ts
|
|
8
8
|
declare const markerVariants: (props?: ({
|
|
9
|
-
variant?: "
|
|
9
|
+
variant?: "border" | "default" | "separator" | null | undefined;
|
|
10
10
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
11
11
|
declare function Marker({
|
|
12
12
|
className,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { d as SparkInputStyle, v as SparkStyle } from "../theme-types-
|
|
3
|
+
import { d as SparkInputStyle, v as SparkStyle } from "../theme-types-CHl-L2F-.cjs";
|
|
4
4
|
import * as React$1 from "react";
|
|
5
5
|
import { Radio as Radio$1 } from "@base-ui/react/radio";
|
|
6
6
|
import { RadioGroup as RadioGroup$1 } from "@base-ui/react/radio-group";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { d as SparkInputStyle, v as SparkStyle } from "../theme-types-
|
|
3
|
+
import { d as SparkInputStyle, v as SparkStyle } from "../theme-types-CHl-L2F-.js";
|
|
4
4
|
import * as React$1 from "react";
|
|
5
5
|
import { Radio as Radio$1 } from "@base-ui/react/radio";
|
|
6
6
|
import { RadioGroup as RadioGroup$1 } from "@base-ui/react/radio-group";
|