@epilot/spark-ui 0.32.0 → 0.32.2
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/{button-B_RNHEc7.d.ts → button-4QGaO78M.d.ts} +3 -3
- package/dist/{button-DBcEcIMk.d.cts → button-C-KeUy2j.d.cts} +3 -3
- package/dist/components/alert-dialog.d.cts +1 -1
- package/dist/components/alert-dialog.d.ts +1 -1
- package/dist/components/attachment.d.cts +2 -2
- package/dist/components/attachment.d.ts +2 -2
- package/dist/components/autocomplete.cjs +2 -9
- package/dist/components/autocomplete.cjs.map +1 -1
- package/dist/components/autocomplete.js +3 -10
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/avatar.js +1 -1
- package/dist/components/badge.js +1 -1
- package/dist/components/bar-chart.cjs +1 -1
- package/dist/components/bar-chart.js +2 -2
- package/dist/components/bubble.d.cts +1 -1
- package/dist/components/bubble.d.ts +1 -1
- package/dist/components/button-group.js +1 -1
- package/dist/components/button.d.cts +1 -1
- package/dist/components/button.d.ts +1 -1
- package/dist/components/button.js +1 -1
- package/dist/components/calendar.js +1 -1
- package/dist/components/callout.d.cts +1 -1
- package/dist/components/callout.d.ts +1 -1
- package/dist/components/checkbox-card.cjs +9 -4
- package/dist/components/checkbox-card.cjs.map +1 -1
- package/dist/components/checkbox-card.js +9 -4
- package/dist/components/checkbox-card.js.map +1 -1
- package/dist/components/checkbox-group.js +1 -1
- package/dist/components/checkbox.js +1 -1
- package/dist/components/combobox.cjs +3 -2
- package/dist/components/combobox.cjs.map +1 -1
- package/dist/components/combobox.js +4 -3
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/dropzone.d.cts +1 -1
- package/dist/components/dropzone.d.ts +1 -1
- package/dist/components/empty-state.d.cts +1 -1
- package/dist/components/empty-state.d.ts +1 -1
- package/dist/components/field.js +1 -1
- package/dist/components/icon.js +1 -1
- package/dist/components/image-carousel.d.cts +1 -1
- package/dist/components/image-carousel.d.ts +1 -1
- package/dist/components/image-carousel.js +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 +2 -2
- package/dist/components/input-group.cjs.map +1 -1
- package/dist/components/input-group.js +3 -3
- package/dist/components/input-group.js.map +1 -1
- package/dist/components/line-chart.cjs +3 -3
- package/dist/components/line-chart.js +4 -4
- package/dist/components/marker.d.cts +1 -1
- package/dist/components/marker.d.ts +1 -1
- package/dist/components/message-scroller.d.cts +1 -1
- package/dist/components/message-scroller.d.ts +1 -1
- package/dist/components/message-scroller.js +1 -1
- package/dist/components/page-header.d.cts +1 -1
- package/dist/components/page-header.d.ts +1 -1
- package/dist/components/pagination.d.cts +1 -1
- package/dist/components/pagination.d.ts +1 -1
- package/dist/components/period-tabs.d.cts +1 -1
- package/dist/components/period-tabs.d.ts +1 -1
- package/dist/components/pill.cjs +9 -27
- package/dist/components/pill.cjs.map +1 -1
- package/dist/components/pill.d.cts +9 -12
- package/dist/components/pill.d.ts +9 -12
- package/dist/components/pill.js +11 -29
- package/dist/components/pill.js.map +1 -1
- package/dist/components/power-history-chart.cjs +3 -3
- package/dist/components/power-history-chart.js +4 -4
- package/dist/components/power-network.js +1 -1
- package/dist/components/radio-card-group.cjs +9 -4
- package/dist/components/radio-card-group.cjs.map +1 -1
- package/dist/components/radio-card-group.js +9 -4
- package/dist/components/radio-card-group.js.map +1 -1
- package/dist/components/radio.js +1 -1
- package/dist/components/select.cjs +4 -3
- package/dist/components/select.cjs.map +1 -1
- package/dist/components/select.js +5 -4
- package/dist/components/select.js.map +1 -1
- package/dist/components/solar-forecast-chart.js +1 -1
- package/dist/components/spark-home.js +1 -1
- package/dist/components/switch-group.js +1 -1
- package/dist/components/switch.js +1 -1
- package/dist/components/tabs.js +1 -1
- package/dist/components/textarea.cjs +1 -1
- package/dist/components/textarea.cjs.map +1 -1
- package/dist/components/textarea.js +1 -1
- package/dist/components/textarea.js.map +1 -1
- package/dist/components/theme.js +1 -1
- package/dist/components/toggle-group.js +1 -1
- package/dist/components/toggle.d.cts +1 -1
- package/dist/components/toggle.d.ts +1 -1
- package/dist/components/toggle.js +1 -1
- package/dist/lib/date-field.cjs +6 -5
- package/dist/lib/date-field.cjs.map +1 -1
- package/dist/lib/date-field.d.cts +7 -1
- package/dist/lib/date-field.d.ts +7 -1
- package/dist/lib/date-field.js +7 -6
- package/dist/lib/date-field.js.map +1 -1
- package/dist/lib/input-box-variants.cjs +3 -1
- package/dist/lib/input-box-variants.cjs.map +1 -1
- package/dist/lib/input-box-variants.d.cts +2 -1
- package/dist/lib/input-box-variants.d.ts +2 -1
- package/dist/lib/input-box-variants.js +3 -2
- package/dist/lib/input-box-variants.js.map +1 -1
- package/dist/lib/mask-hint.cjs +1 -1
- package/dist/lib/mask-hint.cjs.map +1 -1
- package/dist/lib/mask-hint.js +1 -1
- package/dist/lib/mask-hint.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/theme.css +7 -1
- package/package.json +1 -1
|
@@ -81,7 +81,7 @@ const inputGroupVariants = (0, class_variance_authority.cva)("group/input-group
|
|
|
81
81
|
{
|
|
82
82
|
chrome: "box",
|
|
83
83
|
inputStyle: "ghost",
|
|
84
|
-
class: GHOST
|
|
84
|
+
class: (0, cn.cn)(GHOST, "h-10")
|
|
85
85
|
},
|
|
86
86
|
{
|
|
87
87
|
chrome: "box",
|
|
@@ -122,7 +122,7 @@ function InputGroup({ className, ...props }) {
|
|
|
122
122
|
chrome,
|
|
123
123
|
inputStyle,
|
|
124
124
|
inputColor
|
|
125
|
-
}), 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),
|
|
125
|
+
}), 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 field-unlabeled:[&_[data-slot=input]]:py-0", inputStyle === "surface" && "has-[input:focus-visible]:outline-offset-[-2px]!")), className),
|
|
126
126
|
...props
|
|
127
127
|
});
|
|
128
128
|
}
|
|
@@ -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 { useIsomorphicLayoutEffect } from '../hooks/use-isomorphic-layout-effect'\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 data-floating-control={floating || undefined}\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 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":";;;;;;;;;;;;;;;AAWA,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;CACp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;EACvB,aAAa;GACX,MAAM,oBAAoB,SAAS,KAAK;GACxC,UAAU,WAAW;EACvB;CACF,CAAC;CAED,OACE,iBAAA,GAAA,kBAAA,KAAC,QAAD;EACO;EACL,aAAU;EACV,cAAW;EACX,YAAA,GAAA,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"}
|
|
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 { useIsomorphicLayoutEffect } from '../hooks/use-isomorphic-layout-effect'\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: cn(GHOST, 'h-10') },\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 data-floating-control={floating || undefined}\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 field-unlabeled:[&_[data-slot=input]]:py-0',\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 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":";;;;;;;;;;;;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cAAgC,wBAAwB;EAC5D,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO;EAC3C,MAAM,cAAc,YAAY,QAAQ,QAAQ,MAAM,KAAK;EAC3D,MAAM;EACN,MAAM,iBAAiB,SAAS,KAAK;EACrC,MAAM,WACJ,OAAO,mBAAmB,cAAc,OAAO,IAAI,eAAe,KAAK;EACzE,UAAU,QAAQ,KAAK;EACvB,aAAa;GACX,MAAM,oBAAoB,SAAS,KAAK;GACxC,UAAU,WAAW;EACvB;CACF,CAAC;CAED,OACE,iBAAA,GAAA,kBAAA,KAAC,QAAD;EACO;EACL,aAAU;EACV,cAAW;EACX,YAAA,GAAA,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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
|
-
import { cn } from "../utils/cn.js";
|
|
4
3
|
import { useIsomorphicLayoutEffect } from "../hooks/use-isomorphic-layout-effect.js";
|
|
4
|
+
import { cn } from "../utils/cn.js";
|
|
5
5
|
import { useTheme } from "./theme.js";
|
|
6
6
|
import "../lib/input-box-variants.js";
|
|
7
7
|
import { useFieldContext } from "./field.js";
|
|
@@ -78,7 +78,7 @@ const inputGroupVariants = cva("group/input-group relative flex h-10 w-full min-
|
|
|
78
78
|
{
|
|
79
79
|
chrome: "box",
|
|
80
80
|
inputStyle: "ghost",
|
|
81
|
-
class: GHOST
|
|
81
|
+
class: cn(GHOST, "h-10")
|
|
82
82
|
},
|
|
83
83
|
{
|
|
84
84
|
chrome: "box",
|
|
@@ -119,7 +119,7 @@ function InputGroup({ className, ...props }) {
|
|
|
119
119
|
chrome,
|
|
120
120
|
inputStyle,
|
|
121
121
|
inputColor
|
|
122
|
-
}), 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),
|
|
122
|
+
}), 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 field-unlabeled:[&_[data-slot=input]]:py-0", inputStyle === "surface" && "has-[input:focus-visible]:outline-offset-[-2px]!")), className),
|
|
123
123
|
...props
|
|
124
124
|
});
|
|
125
125
|
}
|
|
@@ -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 { useIsomorphicLayoutEffect } from '../hooks/use-isomorphic-layout-effect'\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 data-floating-control={floating || undefined}\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 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 In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ACrC,MAAM,WACJ,OAAO,mBAAmB,cAAc,OAAO,IAAI,eAAe,KAAK;EACzE,UAAU,QAAQ,KAAK;EACvB,aAAa;GACX,MAAM,oBAAoB,SAAS,KAAK;GACxC,UAAU,WAAW;EACvB;CACF,CAAC;CAED,OACE,oBAAC,QAAD;EACO;EACL,aAAU;EACV,cAAW;EACX,WAAW,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"}
|
|
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 { useIsomorphicLayoutEffect } from '../hooks/use-isomorphic-layout-effect'\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: cn(GHOST, 'h-10') },\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 data-floating-control={floating || undefined}\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 field-unlabeled:[&_[data-slot=input]]:py-0',\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 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":";;;;;;;;;;;;AAWA,MAAM,QACJ;AAEF,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UAAU,QAAQ,KAAK;EACvB,aAAa;GACX,MAAM,oBAAoB,SAAS,KAAK;GACxC,UAAU,WAAW;EACvB;CACF,CAAC;CAED,OACE,oBAAC,QAAD;EACO;EACL,aAAU;EACV,cAAW;EACX,WAAW,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"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
4
|
-
const require_utils_format = require("../utils/format.cjs");
|
|
5
|
-
const require_utils_chart_scale = require("../utils/chart-scale.cjs");
|
|
6
|
-
const require_utils_chart_time_ticks = require("../utils/chart-time-ticks.cjs");
|
|
7
4
|
const require_hooks_use_chart_zoom = require("../hooks/use-chart-zoom.cjs");
|
|
8
5
|
const require_hooks_use_reduced_motion = require("../hooks/use-reduced-motion.cjs");
|
|
6
|
+
const require_utils_format = require("../utils/format.cjs");
|
|
7
|
+
const require_utils_chart_scale = require("../utils/chart-scale.cjs");
|
|
9
8
|
const require_components_chart = require("./chart.cjs");
|
|
9
|
+
const require_utils_chart_time_ticks = require("../utils/chart-time-ticks.cjs");
|
|
10
10
|
let react = require("react");
|
|
11
11
|
react = require_chunk.__toESM(react);
|
|
12
12
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { getDocumentLang, localeNumberFormat } from "../utils/format.js";
|
|
3
|
-
import { buildYAxisScale, formatYAxisTick } from "../utils/chart-scale.js";
|
|
4
|
-
import { buildTimeTicks } from "../utils/chart-time-ticks.js";
|
|
5
|
-
import { cn } from "../utils/cn.js";
|
|
6
2
|
import { useAnimatedChartDomain, useChartZoom } from "../hooks/use-chart-zoom.js";
|
|
7
3
|
import { useReducedMotion } from "../hooks/use-reduced-motion.js";
|
|
4
|
+
import { cn } from "../utils/cn.js";
|
|
5
|
+
import { getDocumentLang, localeNumberFormat } from "../utils/format.js";
|
|
6
|
+
import { buildYAxisScale, formatYAxisTick } from "../utils/chart-scale.js";
|
|
8
7
|
import { ChartTooltipCard, ChartZoomResetButton, clampTooltipPosition, useMeasuredSize } from "./chart.js";
|
|
8
|
+
import { buildTimeTicks } from "../utils/chart-time-ticks.js";
|
|
9
9
|
import * as React$1 from "react";
|
|
10
10
|
import { useCallback, useMemo } from "react";
|
|
11
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -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?: "separator" | "default" | "border" | 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?: "separator" | "default" | "border" | 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 { r as ButtonProps } from "../button-
|
|
3
|
+
import { r as ButtonProps } from "../button-C-KeUy2j.cjs";
|
|
4
4
|
import * as React$1 from "react";
|
|
5
5
|
import { MessageScroller as MessageScroller$1, useMessageScroller, useMessageScrollerScrollable, useMessageScrollerVisibility } from "@shadcn/react/message-scroller";
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { r as ButtonProps } from "../button-
|
|
3
|
+
import { r as ButtonProps } from "../button-4QGaO78M.js";
|
|
4
4
|
import * as React$1 from "react";
|
|
5
5
|
import { MessageScroller as MessageScroller$1, useMessageScroller, useMessageScrollerScrollable, useMessageScrollerVisibility } from "@shadcn/react/message-scroller";
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { cn } from "../utils/cn.js";
|
|
3
2
|
import { useReducedMotion } from "../hooks/use-reduced-motion.js";
|
|
3
|
+
import { cn } from "../utils/cn.js";
|
|
4
4
|
import { Button } from "./button.js";
|
|
5
5
|
import { MESSAGE_ANIMATIONS } from "../lib/message-animations.js";
|
|
6
6
|
import * as React$1 from "react";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { r as ButtonProps } from "../button-
|
|
3
|
+
import { r as ButtonProps } from "../button-C-KeUy2j.cjs";
|
|
4
4
|
|
|
5
5
|
//#region src/components/period-tabs.d.ts
|
|
6
6
|
type PeriodStepperButtonProps = Omit<ButtonProps, 'styleVariant' | 'color' | 'size' | 'children' | 'aria-label'> & {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { r as ButtonProps } from "../button-
|
|
3
|
+
import { r as ButtonProps } from "../button-4QGaO78M.js";
|
|
4
4
|
|
|
5
5
|
//#region src/components/period-tabs.d.ts
|
|
6
6
|
type PeriodStepperButtonProps = Omit<ButtonProps, 'styleVariant' | 'color' | 'size' | 'children' | 'aria-label'> & {
|
package/dist/components/pill.cjs
CHANGED
|
@@ -5,7 +5,6 @@ const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
|
5
5
|
const require_lib_accent_colors = require("../lib/accent-colors.cjs");
|
|
6
6
|
let react = require("react");
|
|
7
7
|
react = require_chunk.__toESM(react);
|
|
8
|
-
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
9
8
|
let _base_ui_react_button = require("@base-ui/react/button");
|
|
10
9
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
10
|
let cn = require("cn");
|
|
@@ -13,13 +12,10 @@ let cn = require("cn");
|
|
|
13
12
|
const PillDisabledContext = react.createContext(false);
|
|
14
13
|
/**
|
|
15
14
|
* Like Badge, but interactive: `onClick` makes the whole pill a button
|
|
16
|
-
* (Enter/Space),
|
|
17
|
-
* Both are optional -- with neither, it's a static label.
|
|
15
|
+
* (Enter/Space). Without it, it's a static label.
|
|
18
16
|
*/
|
|
19
|
-
const Pill = react.forwardRef(function Pill({ className, children, styleVariant, color, disabled = false, onClick,
|
|
17
|
+
const Pill = react.forwardRef(function Pill({ className, children, styleVariant, color, disabled = false, onClick, onKeyDown, ...props }, ref) {
|
|
20
18
|
const clickable = !disabled && onClick !== void 0;
|
|
21
|
-
const removable = !disabled && onRemove !== void 0;
|
|
22
|
-
const focusable = clickable || removable;
|
|
23
19
|
const hasLook = styleVariant !== void 0 || color !== void 0;
|
|
24
20
|
const handleKeyDown = (event) => {
|
|
25
21
|
onKeyDown?.(event);
|
|
@@ -27,46 +23,32 @@ const Pill = react.forwardRef(function Pill({ className, children, styleVariant,
|
|
|
27
23
|
if (event.key === " ") event.preventDefault();
|
|
28
24
|
onClick?.(event);
|
|
29
25
|
}
|
|
30
|
-
if (removable && (event.key === "Delete" || event.key === "Backspace")) onRemove?.(event);
|
|
31
26
|
};
|
|
32
27
|
const interaction = {
|
|
33
28
|
onKeyDown: handleKeyDown,
|
|
34
29
|
...clickable && {
|
|
35
30
|
role: "button",
|
|
36
|
-
onClick
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
onClick,
|
|
32
|
+
tabIndex: 0
|
|
33
|
+
}
|
|
39
34
|
};
|
|
40
35
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PillDisabledContext.Provider, {
|
|
41
36
|
value: disabled,
|
|
42
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.
|
|
37
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
43
38
|
"aria-disabled": disabled || void 0,
|
|
44
|
-
"aria-keyshortcuts": removable ? "Delete" : void 0,
|
|
45
39
|
"data-slot": "pill",
|
|
46
40
|
"data-style": hasLook ? styleVariant ?? "soft" : void 0,
|
|
47
41
|
"data-accent-color": color ? require_lib_accent_colors.accentByColor[color] : void 0,
|
|
48
42
|
...interaction,
|
|
49
43
|
ref,
|
|
50
|
-
className: (0, cn.cn)("inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-xs font-medium select-none", "bg-(--spark-style-bg,var(--neutral-a3)) text-(--spark-style-fg,var(--spark-badge-fg,var(--neutral-a11)))", "shadow-[inset_0_0_0_var(--spark-style-border-width,1px)_var(--spark-style-border,transparent)]",
|
|
44
|
+
className: (0, cn.cn)("inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-xs font-medium select-none", "bg-(--spark-style-bg,var(--neutral-a3)) text-(--spark-style-fg,var(--spark-badge-fg,var(--neutral-a11)))", "shadow-[inset_0_0_0_var(--spark-style-border-width,1px)_var(--spark-style-border,transparent)]", clickable && "transition-colors motion-reduce:transition-none", clickable && "cursor-pointer hover:bg-(--spark-style-bg-hover,var(--neutral-a4))", disabled && "pointer-events-none opacity-50", className),
|
|
51
45
|
...props,
|
|
52
|
-
children
|
|
53
|
-
className: "sr-only",
|
|
54
|
-
children: removeLabel
|
|
55
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
56
|
-
"aria-hidden": "true",
|
|
57
|
-
"data-slot": "pill-remove",
|
|
58
|
-
onClick: (event) => {
|
|
59
|
-
event.stopPropagation();
|
|
60
|
-
onRemove?.(event);
|
|
61
|
-
},
|
|
62
|
-
className: "-mr-1 inline-flex size-4 shrink-0 items-center justify-center rounded-full transition-colors hover:bg-(--spark-style-bg-hover,var(--neutral-a4)) motion-reduce:transition-none",
|
|
63
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_epilot_spark_icons.Close, { className: "[--spark-icon-size:14px]" })
|
|
64
|
-
})] }) : null]
|
|
46
|
+
children
|
|
65
47
|
})
|
|
66
48
|
});
|
|
67
49
|
});
|
|
68
50
|
Pill.displayName = "Pill";
|
|
69
|
-
/** A button inside a static `Pill` (no `onClick
|
|
51
|
+
/** A button inside a static `Pill` (no `onClick`); it is disabled with the pill. */
|
|
70
52
|
const PillButton = react.forwardRef(function PillButton({ className, disabled, ...props }, ref) {
|
|
71
53
|
const pillDisabled = react.useContext(PillDisabledContext);
|
|
72
54
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_button.Button, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pill.cjs","names":["React","accentByColor","
|
|
1
|
+
{"version":3,"file":"pill.cjs","names":["React","accentByColor","ButtonPrimitive"],"sources":["../../src/components/pill.tsx"],"sourcesContent":["'use client'\n\nimport { Button as ButtonPrimitive } from '@base-ui/react/button'\nimport * as React from 'react'\nimport { accentByColor } from '../lib/accent-colors'\nimport type { SparkAccentColor } from '../lib/accent-colors'\nimport type { SparkStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\n\ntype PillProps = Omit<React.HTMLAttributes<HTMLSpanElement>, 'onClick'> & {\n styleVariant?: SparkStyle\n color?: SparkAccentColor\n disabled?: boolean\n onClick?: (event: React.SyntheticEvent<HTMLSpanElement>) => void\n}\n\nconst PillDisabledContext = React.createContext(false)\n\n/**\n * Like Badge, but interactive: `onClick` makes the whole pill a button\n * (Enter/Space). Without it, it's a static label.\n */\nconst Pill = React.forwardRef<HTMLSpanElement, PillProps>(function Pill(\n {\n className,\n children,\n styleVariant,\n color,\n disabled = false,\n onClick,\n onKeyDown,\n ...props\n },\n ref,\n) {\n const clickable = !disabled && onClick !== undefined\n const hasLook = styleVariant !== undefined || color !== undefined\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLSpanElement>) => {\n onKeyDown?.(event)\n if (clickable && (event.key === 'Enter' || event.key === ' ')) {\n if (event.key === ' ') event.preventDefault()\n onClick?.(event)\n }\n }\n\n const interaction = {\n onKeyDown: handleKeyDown,\n ...(clickable && { role: 'button' as const, onClick, tabIndex: 0 }),\n }\n\n return (\n <PillDisabledContext.Provider value={disabled}>\n <span\n aria-disabled={disabled || undefined}\n data-slot=\"pill\"\n data-style={hasLook ? (styleVariant ?? 'soft') : undefined}\n data-accent-color={color ? accentByColor[color] : undefined}\n {...interaction}\n ref={ref}\n className={cn(\n 'inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-xs font-medium select-none',\n 'bg-(--spark-style-bg,var(--neutral-a3)) text-(--spark-style-fg,var(--spark-badge-fg,var(--neutral-a11)))',\n 'shadow-[inset_0_0_0_var(--spark-style-border-width,1px)_var(--spark-style-border,transparent)]',\n clickable && 'transition-colors motion-reduce:transition-none',\n clickable &&\n 'cursor-pointer hover:bg-(--spark-style-bg-hover,var(--neutral-a4))',\n disabled && 'pointer-events-none opacity-50',\n className,\n )}\n {...props}\n >\n {children}\n </span>\n </PillDisabledContext.Provider>\n )\n})\n\nPill.displayName = 'Pill'\n\ntype PillButtonProps = Omit<\n React.ComponentProps<typeof ButtonPrimitive>,\n 'ref' | 'className' | 'aria-label'\n> & {\n className?: string\n /** Names the button; the icon inside is decorative. */\n 'aria-label': string\n}\n\n/** A button inside a static `Pill` (no `onClick`); it is disabled with the pill. */\nconst PillButton = React.forwardRef<HTMLButtonElement, PillButtonProps>(\n function PillButton({ className, disabled, ...props }, ref) {\n const pillDisabled = React.useContext(PillDisabledContext)\n return (\n <ButtonPrimitive\n ref={ref}\n data-slot=\"pill-button\"\n disabled={disabled ?? pillDisabled}\n // fixed 24px target at any scaling; the ring takes the pill's ink, which reads on its fill\n className={cn(\n '-mr-2 inline-flex size-[24px] shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors hover:bg-(--spark-style-bg-hover,var(--neutral-a4)) focus-visible:outline-current motion-reduce:transition-none',\n className,\n )}\n {...props}\n />\n )\n },\n)\n\nPillButton.displayName = 'PillButton'\n\nexport { Pill, PillButton }\nexport type { PillButtonProps, PillProps }\n"],"mappings":";;;;;;;;;;;AAgBA,MAAM,sBAAsBA,MAAM,cAAc,KAAK;;;;;AAMrD,MAAM,OAAOA,MAAM,WAAuC,SAAS,KACjE,EACE,WACA,UACA,cACA,OACA,WAAW,OACX,SACA,WACA,GAAG,SAEL,KACA;CACA,MAAM,YAAY,CAAC,YAAY,YAAY,KAAA;CAC3C,MAAM,UAAU,iBAAiB,KAAA,KAAa,UAAU,KAAA;CAExD,MAAM,iBAAiB,UAAgD;EACrE,YAAY,KAAK;EACjB,IAAI,cAAc,MAAM,QAAQ,WAAW,MAAM,QAAQ,MAAM;GAC7D,IAAI,MAAM,QAAQ,KAAK,MAAM,eAAe;GAC5C,UAAU,KAAK;EACjB;CACF;CAEA,MAAM,cAAc;EAClB,WAAW;EACX,GAAI,aAAa;GAAE,MAAM;GAAmB;GAAS,UAAU;EAAE;CACnE;CAEA,OACE,iBAAA,GAAA,kBAAA,KAAC,oBAAoB,UAArB;EAA8B,OAAO;YACnC,iBAAA,GAAA,kBAAA,KAAC,QAAD;GACE,iBAAe,YAAY,KAAA;GAC3B,aAAU;GACV,cAAY,UAAW,gBAAgB,SAAU,KAAA;GACjD,qBAAmB,QAAQC,0BAAAA,cAAc,SAAS,KAAA;GAClD,GAAI;GACC;GACL,YAAA,GAAA,GAAA,IACE,0FACA,4GACA,kGACA,aAAa,mDACb,aACE,sEACF,YAAY,kCACZ,SACF;GACA,GAAI;GAEH;EACG,CAAA;CACsB,CAAA;AAElC,CAAC;AAED,KAAK,cAAc;;AAYnB,MAAM,aAAaD,MAAM,WACvB,SAAS,WAAW,EAAE,WAAW,UAAU,GAAG,SAAS,KAAK;CAC1D,MAAM,eAAeA,MAAM,WAAW,mBAAmB;CACzD,OACE,iBAAA,GAAA,kBAAA,KAACE,sBAAAA,QAAD;EACO;EACL,aAAU;EACV,UAAU,YAAY;EAEtB,YAAA,GAAA,GAAA,IACE,oOACA,SACF;EACA,GAAI;CACL,CAAA;AAEL,CACF;AAEA,WAAW,cAAc"}
|
|
@@ -6,14 +6,7 @@ import * as React$1 from "react";
|
|
|
6
6
|
import { Button } from "@base-ui/react/button";
|
|
7
7
|
|
|
8
8
|
//#region src/components/pill.d.ts
|
|
9
|
-
type
|
|
10
|
-
onRemove?: undefined;
|
|
11
|
-
removeLabel?: string;
|
|
12
|
-
} | {
|
|
13
|
-
/** Fires on a pointer click of the (decorative) glyph, or Delete/Backspace while the pill has focus. */onRemove: (event: React$1.SyntheticEvent) => void; /** Visually-hidden text folded into the pill's accessible name -- the glyph itself is `aria-hidden`. */
|
|
14
|
-
removeLabel: string;
|
|
15
|
-
};
|
|
16
|
-
type PillProps = Omit<React$1.HTMLAttributes<HTMLSpanElement>, 'onClick'> & PillOnRemoveProps & {
|
|
9
|
+
type PillProps = Omit<React$1.HTMLAttributes<HTMLSpanElement>, 'onClick'> & {
|
|
17
10
|
styleVariant?: SparkStyle;
|
|
18
11
|
color?: SparkAccentColor;
|
|
19
12
|
disabled?: boolean;
|
|
@@ -21,15 +14,19 @@ type PillProps = Omit<React$1.HTMLAttributes<HTMLSpanElement>, 'onClick'> & Pill
|
|
|
21
14
|
};
|
|
22
15
|
/**
|
|
23
16
|
* Like Badge, but interactive: `onClick` makes the whole pill a button
|
|
24
|
-
* (Enter/Space),
|
|
25
|
-
* Both are optional -- with neither, it's a static label.
|
|
17
|
+
* (Enter/Space). Without it, it's a static label.
|
|
26
18
|
*/
|
|
27
|
-
declare const Pill: React$1.ForwardRefExoticComponent<
|
|
19
|
+
declare const Pill: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLSpanElement>, "onClick"> & {
|
|
20
|
+
styleVariant?: SparkStyle;
|
|
21
|
+
color?: SparkAccentColor;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
onClick?: (event: React$1.SyntheticEvent<HTMLSpanElement>) => void;
|
|
24
|
+
} & React$1.RefAttributes<HTMLSpanElement>>;
|
|
28
25
|
type PillButtonProps = Omit<React$1.ComponentProps<typeof Button>, 'ref' | 'className' | 'aria-label'> & {
|
|
29
26
|
className?: string; /** Names the button; the icon inside is decorative. */
|
|
30
27
|
'aria-label': string;
|
|
31
28
|
};
|
|
32
|
-
/** A button inside a static `Pill` (no `onClick
|
|
29
|
+
/** A button inside a static `Pill` (no `onClick`); it is disabled with the pill. */
|
|
33
30
|
declare const PillButton: React$1.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ButtonProps, "ref"> & React$1.RefAttributes<HTMLElement>, "className" | "ref" | "aria-label"> & {
|
|
34
31
|
className?: string; /** Names the button; the icon inside is decorative. */
|
|
35
32
|
'aria-label': string;
|
|
@@ -6,14 +6,7 @@ import * as React$1 from "react";
|
|
|
6
6
|
import { Button } from "@base-ui/react/button";
|
|
7
7
|
|
|
8
8
|
//#region src/components/pill.d.ts
|
|
9
|
-
type
|
|
10
|
-
onRemove?: undefined;
|
|
11
|
-
removeLabel?: string;
|
|
12
|
-
} | {
|
|
13
|
-
/** Fires on a pointer click of the (decorative) glyph, or Delete/Backspace while the pill has focus. */onRemove: (event: React$1.SyntheticEvent) => void; /** Visually-hidden text folded into the pill's accessible name -- the glyph itself is `aria-hidden`. */
|
|
14
|
-
removeLabel: string;
|
|
15
|
-
};
|
|
16
|
-
type PillProps = Omit<React$1.HTMLAttributes<HTMLSpanElement>, 'onClick'> & PillOnRemoveProps & {
|
|
9
|
+
type PillProps = Omit<React$1.HTMLAttributes<HTMLSpanElement>, 'onClick'> & {
|
|
17
10
|
styleVariant?: SparkStyle;
|
|
18
11
|
color?: SparkAccentColor;
|
|
19
12
|
disabled?: boolean;
|
|
@@ -21,15 +14,19 @@ type PillProps = Omit<React$1.HTMLAttributes<HTMLSpanElement>, 'onClick'> & Pill
|
|
|
21
14
|
};
|
|
22
15
|
/**
|
|
23
16
|
* Like Badge, but interactive: `onClick` makes the whole pill a button
|
|
24
|
-
* (Enter/Space),
|
|
25
|
-
* Both are optional -- with neither, it's a static label.
|
|
17
|
+
* (Enter/Space). Without it, it's a static label.
|
|
26
18
|
*/
|
|
27
|
-
declare const Pill: React$1.ForwardRefExoticComponent<
|
|
19
|
+
declare const Pill: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLSpanElement>, "onClick"> & {
|
|
20
|
+
styleVariant?: SparkStyle;
|
|
21
|
+
color?: SparkAccentColor;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
onClick?: (event: React$1.SyntheticEvent<HTMLSpanElement>) => void;
|
|
24
|
+
} & React$1.RefAttributes<HTMLSpanElement>>;
|
|
28
25
|
type PillButtonProps = Omit<React$1.ComponentProps<typeof Button>, 'ref' | 'className' | 'aria-label'> & {
|
|
29
26
|
className?: string; /** Names the button; the icon inside is decorative. */
|
|
30
27
|
'aria-label': string;
|
|
31
28
|
};
|
|
32
|
-
/** A button inside a static `Pill` (no `onClick
|
|
29
|
+
/** A button inside a static `Pill` (no `onClick`); it is disabled with the pill. */
|
|
33
30
|
declare const PillButton: React$1.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ButtonProps, "ref"> & React$1.RefAttributes<HTMLElement>, "className" | "ref" | "aria-label"> & {
|
|
34
31
|
className?: string; /** Names the button; the icon inside is decorative. */
|
|
35
32
|
'aria-label': string;
|