@epilot/spark-ui 0.26.0 → 0.27.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/accordion.cjs.map +1 -1
- package/dist/components/accordion.d.cts +1 -1
- package/dist/components/accordion.d.ts +1 -1
- package/dist/components/accordion.js.map +1 -1
- package/dist/components/alert-dialog.cjs +2 -2
- package/dist/components/alert-dialog.cjs.map +1 -1
- package/dist/components/alert-dialog.js +2 -2
- package/dist/components/alert-dialog.js.map +1 -1
- 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.cjs +10 -2
- package/dist/components/badge.cjs.map +1 -1
- package/dist/components/badge.d.cts +2 -1
- package/dist/components/badge.d.ts +2 -1
- package/dist/components/badge.js +10 -2
- package/dist/components/badge.js.map +1 -1
- package/dist/components/banner.d.cts +1 -1
- package/dist/components/banner.d.ts +1 -1
- package/dist/components/box.d.cts +1 -1
- package/dist/components/box.d.ts +1 -1
- package/dist/components/bubble.cjs +1 -1
- package/dist/components/bubble.cjs.map +1 -1
- package/dist/components/bubble.d.cts +1 -1
- package/dist/components/bubble.d.ts +1 -1
- package/dist/components/bubble.js +1 -1
- package/dist/components/bubble.js.map +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 +27 -6
- package/dist/components/button.cjs.map +1 -1
- package/dist/components/button.d.cts +9 -8
- package/dist/components/button.d.ts +9 -8
- package/dist/components/button.js +27 -6
- package/dist/components/button.js.map +1 -1
- package/dist/components/callout.cjs +1 -1
- package/dist/components/callout.cjs.map +1 -1
- package/dist/components/callout.d.cts +1 -1
- package/dist/components/callout.d.ts +1 -1
- package/dist/components/callout.js +1 -1
- package/dist/components/callout.js.map +1 -1
- package/dist/components/card.cjs +8 -4
- package/dist/components/card.cjs.map +1 -1
- package/dist/components/card.d.cts +6 -2
- package/dist/components/card.d.ts +6 -2
- package/dist/components/card.js +8 -4
- package/dist/components/card.js.map +1 -1
- package/dist/components/checkbox-group.cjs +31 -0
- package/dist/components/checkbox-group.cjs.map +1 -0
- package/dist/components/checkbox-group.d.cts +27 -0
- package/dist/components/checkbox-group.d.ts +27 -0
- package/dist/components/checkbox-group.js +28 -0
- package/dist/components/checkbox-group.js.map +1 -0
- package/dist/components/checkbox.d.cts +1 -1
- package/dist/components/checkbox.d.ts +1 -1
- package/dist/components/dialog.cjs +2 -2
- package/dist/components/dialog.cjs.map +1 -1
- package/dist/components/dialog.js +2 -2
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/drawer.cjs +1 -1
- package/dist/components/drawer.cjs.map +1 -1
- package/dist/components/drawer.js +1 -1
- package/dist/components/drawer.js.map +1 -1
- package/dist/components/empty-state.cjs +3 -13
- package/dist/components/empty-state.cjs.map +1 -1
- package/dist/components/empty-state.js +3 -13
- package/dist/components/empty-state.js.map +1 -1
- package/dist/components/energy-breakdown.cjs +1 -1
- package/dist/components/energy-breakdown.cjs.map +1 -1
- package/dist/components/energy-breakdown.js +1 -1
- package/dist/components/energy-breakdown.js.map +1 -1
- package/dist/components/entity-card.cjs +1 -1
- package/dist/components/entity-card.cjs.map +1 -1
- package/dist/components/entity-card.js +1 -1
- package/dist/components/entity-card.js.map +1 -1
- package/dist/components/field.cjs +113 -18
- package/dist/components/field.cjs.map +1 -1
- package/dist/components/field.d.cts +16 -3
- package/dist/components/field.d.ts +16 -3
- package/dist/components/field.js +114 -20
- package/dist/components/field.js.map +1 -1
- package/dist/components/input-group.cjs +9 -9
- package/dist/components/input-group.cjs.map +1 -1
- package/dist/components/input-group.d.cts +1 -1
- package/dist/components/input-group.d.ts +1 -1
- package/dist/components/input-group.js +9 -9
- package/dist/components/input-group.js.map +1 -1
- package/dist/components/input.d.cts +1 -1
- package/dist/components/input.d.ts +1 -1
- package/dist/components/list.cjs +21 -5
- package/dist/components/list.cjs.map +1 -1
- package/dist/components/list.d.cts +13 -5
- package/dist/components/list.d.ts +13 -5
- package/dist/components/list.js +21 -5
- package/dist/components/list.js.map +1 -1
- package/dist/components/marker.cjs +1 -1
- package/dist/components/marker.cjs.map +1 -1
- package/dist/components/marker.js +1 -1
- package/dist/components/marker.js.map +1 -1
- package/dist/components/message-scroller.cjs +1 -1
- package/dist/components/message-scroller.cjs.map +1 -1
- package/dist/components/message-scroller.js +1 -1
- package/dist/components/message-scroller.js.map +1 -1
- package/dist/components/page-header.d.cts +1 -1
- package/dist/components/page-header.d.ts +1 -1
- package/dist/components/pill.d.cts +1 -1
- package/dist/components/pill.d.ts +1 -1
- package/dist/components/radio.cjs +6 -2
- package/dist/components/radio.cjs.map +1 -1
- package/dist/components/radio.d.cts +4 -2
- package/dist/components/radio.d.ts +4 -2
- package/dist/components/radio.js +6 -2
- package/dist/components/radio.js.map +1 -1
- package/dist/components/rating.cjs +167 -0
- package/dist/components/rating.cjs.map +1 -0
- package/dist/components/rating.d.cts +50 -0
- package/dist/components/rating.d.ts +50 -0
- package/dist/components/rating.js +162 -0
- package/dist/components/rating.js.map +1 -0
- package/dist/components/schedule-list.cjs +1 -1
- package/dist/components/schedule-list.cjs.map +1 -1
- package/dist/components/schedule-list.js +1 -1
- package/dist/components/schedule-list.js.map +1 -1
- package/dist/components/scroll-area.cjs +9 -2
- package/dist/components/scroll-area.cjs.map +1 -1
- package/dist/components/scroll-area.d.cts +1 -1
- package/dist/components/scroll-area.d.ts +1 -1
- package/dist/components/scroll-area.js +10 -3
- package/dist/components/scroll-area.js.map +1 -1
- package/dist/components/segmented-control.d.cts +1 -1
- package/dist/components/segmented-control.d.ts +1 -1
- package/dist/components/select.d.cts +1 -1
- package/dist/components/select.d.ts +1 -1
- package/dist/components/selection-item.cjs +42 -0
- package/dist/components/selection-item.cjs.map +1 -0
- package/dist/components/selection-item.d.cts +25 -0
- package/dist/components/selection-item.d.ts +25 -0
- package/dist/components/selection-item.js +39 -0
- package/dist/components/selection-item.js.map +1 -0
- package/dist/components/sheet.cjs +1 -1
- package/dist/components/sheet.js +1 -1
- package/dist/components/skeleton.cjs +1 -1
- package/dist/components/skeleton.cjs.map +1 -1
- package/dist/components/skeleton.js +1 -1
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/slider.cjs +1 -1
- package/dist/components/slider.cjs.map +1 -1
- package/dist/components/slider.js +1 -1
- package/dist/components/slider.js.map +1 -1
- package/dist/components/spinner.cjs +81 -8
- package/dist/components/spinner.cjs.map +1 -1
- package/dist/components/spinner.js +81 -8
- package/dist/components/spinner.js.map +1 -1
- package/dist/components/stat-card.cjs +1 -1
- package/dist/components/stat-card.cjs.map +1 -1
- package/dist/components/stat-card.js +1 -1
- package/dist/components/stat-card.js.map +1 -1
- package/dist/components/stepper.cjs +3 -2
- package/dist/components/stepper.cjs.map +1 -1
- package/dist/components/stepper.js +3 -2
- package/dist/components/stepper.js.map +1 -1
- package/dist/components/switch-group.cjs +32 -0
- package/dist/components/switch-group.cjs.map +1 -0
- package/dist/components/switch-group.d.cts +26 -0
- package/dist/components/switch-group.d.ts +26 -0
- package/dist/components/switch-group.js +29 -0
- package/dist/components/switch-group.js.map +1 -0
- package/dist/components/switch.d.cts +1 -1
- package/dist/components/switch.d.ts +1 -1
- package/dist/components/tabs.cjs +32 -23
- package/dist/components/tabs.cjs.map +1 -1
- package/dist/components/tabs.d.cts +5 -5
- package/dist/components/tabs.d.ts +5 -5
- package/dist/components/tabs.js +32 -23
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/textarea.d.cts +1 -1
- package/dist/components/textarea.d.ts +1 -1
- package/dist/components/theme.cjs +44 -2
- package/dist/components/theme.cjs.map +1 -1
- package/dist/components/theme.d.cts +4 -2
- package/dist/components/theme.d.ts +4 -2
- package/dist/components/theme.js +44 -2
- package/dist/components/theme.js.map +1 -1
- package/dist/components/toast.cjs +2 -2
- package/dist/components/toast.cjs.map +1 -1
- package/dist/components/toast.js +2 -2
- package/dist/components/toast.js.map +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 +2 -2
- package/dist/components/toggle.d.ts +2 -2
- package/dist/lib/accent-theme.d.cts +1 -1
- package/dist/lib/accent-theme.d.ts +1 -1
- package/dist/lib/container-chrome.cjs +4 -4
- package/dist/lib/container-chrome.cjs.map +1 -1
- package/dist/lib/container-chrome.d.cts +1 -1
- package/dist/lib/container-chrome.d.ts +1 -1
- package/dist/lib/container-chrome.js +4 -4
- package/dist/lib/container-chrome.js.map +1 -1
- package/dist/lib/input-box-variants.cjs +8 -8
- package/dist/lib/input-box-variants.cjs.map +1 -1
- package/dist/lib/input-box-variants.d.cts +1 -1
- package/dist/lib/input-box-variants.d.ts +1 -1
- package/dist/lib/input-box-variants.js +8 -8
- package/dist/lib/input-box-variants.js.map +1 -1
- package/dist/lib/selection-list.cjs +17 -0
- package/dist/lib/selection-list.cjs.map +1 -0
- package/dist/lib/selection-list.d.cts +11 -0
- package/dist/lib/selection-list.d.ts +11 -0
- package/dist/lib/selection-list.js +15 -0
- package/dist/lib/selection-list.js.map +1 -0
- package/dist/lib/theme-types.cjs.map +1 -1
- package/dist/lib/theme-types.d.cts +2 -2
- package/dist/lib/theme-types.d.ts +2 -2
- package/dist/lib/theme-types.js.map +1 -1
- package/dist/lib/toggle-group-context.d.cts +2 -1
- package/dist/lib/toggle-group-context.d.ts +2 -1
- package/dist/styles/spark-default.css +12 -1
- package/dist/styles/theme.css +98 -0
- package/dist/{theme-types-Bn5E15-P.d.ts → theme-types-CKZzOmSa.d.cts} +11 -2
- package/dist/{theme-types-Bn5E15-P.d.cts → theme-types-CKZzOmSa.d.ts} +11 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-card.cjs","names":[],"sources":["../../src/components/entity-card.tsx"],"sourcesContent":["import type { SparkIcon } from '@epilot/spark-icons'\nimport { cva } from 'class-variance-authority'\nimport * as React from 'react'\nimport type { Tone } from '../lib/tones'\nimport { cn } from '../utils/cn'\n\nconst EntityCard = ({ className, ...rest }: React.ComponentProps<'div'>) => (\n <div\n className={cn(\n 'flex flex-col overflow-hidden rounded-lg border border-gray bg-(--spark-background)',\n className,\n )}\n {...rest}\n />\n)\n\nconst EntityCardBody = ({\n className,\n active,\n ...rest\n}: React.ComponentProps<'button'> & { active?: boolean }) => (\n <button\n type=\"button\"\n className={cn(\n 'flex w-full cursor-pointer flex-col gap-3 p-4 text-left transition-colors hover:bg-gray-a2 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent-focus',\n active && 'bg-linear-to-br from-spark-9/10 to-spark-1/5 to-20%',\n className,\n )}\n {...rest}\n />\n)\n\nconst EntityCardHeader = ({\n className,\n ...rest\n}: React.ComponentProps<'div'>) => (\n <div className={cn('flex w-full items-center gap-3', className)} {...rest} />\n)\n\nconst EntityCardMeters = ({\n className,\n ...rest\n}: React.ComponentProps<'div'>) => (\n <div\n className={cn('flex flex-col gap-2 border-t border-gray pt-3', className)}\n {...rest}\n />\n)\n\nconst iconToneVariants = cva(\n // max() pill escape (matches Icon): a tile stays rounded-md at low Roundness but\n // becomes a circle at large/full, same as it did pre-harmonization via clamping.\n 'flex size-11 shrink-0 items-center justify-center rounded-[max(var(--spark-rounded-md),var(--spark-rounded-full))]',\n {\n variants: {\n tone: {\n success: 'bg-success-soft text-success-soft-foreground',\n warning: 'bg-warning-soft text-warning-soft-foreground',\n error: 'bg-error-soft text-error-soft-foreground',\n accent: 'bg-primary-soft text-primary-soft-foreground',\n neutral: 'bg-base-gray-soft text-gray',\n },\n },\n defaultVariants: { tone: 'neutral' },\n },\n)\n\nconst EntityCardIcon = ({\n className,\n icon: Glyph,\n tone,\n ...rest\n}: React.ComponentProps<'span'> & {\n icon: SparkIcon\n tone?: Tone\n}) => (\n <span className={iconToneVariants({ tone, className })} {...rest}>\n <Glyph className=\"[--spark-icon-size:18px]\" />\n </span>\n)\n\nconst EntityCardTitleColumn = ({\n className,\n ...rest\n}: React.ComponentProps<'div'>) => (\n <div\n className={cn('flex min-w-0 flex-1 flex-col gap-
|
|
1
|
+
{"version":3,"file":"entity-card.cjs","names":[],"sources":["../../src/components/entity-card.tsx"],"sourcesContent":["import type { SparkIcon } from '@epilot/spark-icons'\nimport { cva } from 'class-variance-authority'\nimport * as React from 'react'\nimport type { Tone } from '../lib/tones'\nimport { cn } from '../utils/cn'\n\nconst EntityCard = ({ className, ...rest }: React.ComponentProps<'div'>) => (\n <div\n className={cn(\n 'flex flex-col overflow-hidden rounded-lg border border-gray bg-(--spark-background)',\n className,\n )}\n {...rest}\n />\n)\n\nconst EntityCardBody = ({\n className,\n active,\n ...rest\n}: React.ComponentProps<'button'> & { active?: boolean }) => (\n <button\n type=\"button\"\n className={cn(\n 'flex w-full cursor-pointer flex-col gap-3 p-4 text-left transition-colors hover:bg-gray-a2 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent-focus',\n active && 'bg-linear-to-br from-spark-9/10 to-spark-1/5 to-20%',\n className,\n )}\n {...rest}\n />\n)\n\nconst EntityCardHeader = ({\n className,\n ...rest\n}: React.ComponentProps<'div'>) => (\n <div className={cn('flex w-full items-center gap-3', className)} {...rest} />\n)\n\nconst EntityCardMeters = ({\n className,\n ...rest\n}: React.ComponentProps<'div'>) => (\n <div\n className={cn('flex flex-col gap-2 border-t border-gray pt-3', className)}\n {...rest}\n />\n)\n\nconst iconToneVariants = cva(\n // max() pill escape (matches Icon): a tile stays rounded-md at low Roundness but\n // becomes a circle at large/full, same as it did pre-harmonization via clamping.\n 'flex size-11 shrink-0 items-center justify-center rounded-[max(var(--spark-rounded-md),var(--spark-rounded-full))]',\n {\n variants: {\n tone: {\n success: 'bg-success-soft text-success-soft-foreground',\n warning: 'bg-warning-soft text-warning-soft-foreground',\n error: 'bg-error-soft text-error-soft-foreground',\n accent: 'bg-primary-soft text-primary-soft-foreground',\n neutral: 'bg-base-gray-soft text-gray',\n },\n },\n defaultVariants: { tone: 'neutral' },\n },\n)\n\nconst EntityCardIcon = ({\n className,\n icon: Glyph,\n tone,\n ...rest\n}: React.ComponentProps<'span'> & {\n icon: SparkIcon\n tone?: Tone\n}) => (\n <span className={iconToneVariants({ tone, className })} {...rest}>\n <Glyph className=\"[--spark-icon-size:18px]\" />\n </span>\n)\n\nconst EntityCardTitleColumn = ({\n className,\n ...rest\n}: React.ComponentProps<'div'>) => (\n <div\n className={cn('flex min-w-0 flex-1 flex-col gap-1', className)}\n {...rest}\n />\n)\n\nconst EntityCardTitle = ({\n className,\n ...rest\n}: React.ComponentProps<'span'>) => (\n <span\n className={cn('truncate text-sm font-bold text-gray', className)}\n {...rest}\n />\n)\n\nconst stateToneVariants = cva(\n 'inline-flex items-center gap-1.5 text-xs font-medium',\n {\n variants: {\n tone: {\n success: 'text-success',\n warning: 'text-warning',\n error: 'text-error',\n accent: 'text-accent',\n neutral: 'text-gray-light',\n },\n },\n defaultVariants: { tone: 'neutral' },\n },\n)\n\nconst dotToneVariants = cva('size-1.5 shrink-0 rounded-full', {\n variants: {\n tone: {\n success: 'bg-base-success-solid',\n warning: 'bg-base-warning-solid',\n error: 'bg-base-error-solid',\n accent: 'bg-primary',\n neutral: 'bg-base-gray-solid',\n },\n },\n defaultVariants: { tone: 'neutral' },\n})\n\nconst EntityCardState = ({\n className,\n tone,\n children,\n ...rest\n}: React.ComponentProps<'span'> & { tone?: Tone }) => (\n <span className={stateToneVariants({ tone, className })} {...rest}>\n <span className={dotToneVariants({ tone })} />\n <span className=\"truncate\">{children}</span>\n </span>\n)\n\nconst EntityCardDetail = ({\n className,\n ...rest\n}: React.ComponentProps<'span'>) => (\n <span\n className={cn('truncate text-xs text-gray-light tabular-nums', className)}\n {...rest}\n />\n)\n\nconst EntityCardValue = ({\n className,\n ...rest\n}: React.ComponentProps<'span'>) => (\n <span\n className={cn(\n 'ms-2 shrink-0 self-center text-lg leading-tight font-bold text-gray tabular-nums',\n className,\n )}\n {...rest}\n />\n)\n\nconst EntityCardControls = ({\n className,\n ...rest\n}: React.ComponentProps<'div'>) => (\n <div\n className={cn(\n 'flex items-center gap-3 border-t border-gray bg-base-gray-surface px-4 py-3',\n className,\n )}\n {...rest}\n />\n)\n\nconst EntityCardFooter = ({\n className,\n ...rest\n}: React.ComponentProps<'div'>) => (\n <div\n className={cn(\n 'flex items-center justify-center gap-1.5 border-t border-gray bg-base-gray-surface px-4 py-2 text-xs text-gray-light',\n className,\n )}\n {...rest}\n />\n)\n\nexport {\n EntityCard,\n EntityCardBody,\n EntityCardControls,\n EntityCardDetail,\n EntityCardFooter,\n EntityCardHeader,\n EntityCardIcon,\n EntityCardMeters,\n EntityCardState,\n EntityCardTitle,\n EntityCardTitleColumn,\n EntityCardValue,\n}\n"],"mappings":";;;;;;;;;AAMA,MAAM,cAAc,EAAE,WAAW,GAAG,WAClC,iBAAA,GAAA,kBAAA,KAAC,OAAD;CACE,YAAA,GAAA,GAAA,IACE,uFACA,SACF;CACA,GAAI;AACL,CAAA;AAGH,MAAM,kBAAkB,EACtB,WACA,QACA,GAAG,WAEH,iBAAA,GAAA,kBAAA,KAAC,UAAD;CACE,MAAK;CACL,YAAA,GAAA,GAAA,IACE,yLACA,UAAU,uDACV,SACF;CACA,GAAI;AACL,CAAA;AAGH,MAAM,oBAAoB,EACxB,WACA,GAAG,WAEH,iBAAA,GAAA,kBAAA,KAAC,OAAD;CAAK,YAAA,GAAA,GAAA,IAAc,kCAAkC,SAAS;CAAG,GAAI;AAAO,CAAA;AAG9E,MAAM,oBAAoB,EACxB,WACA,GAAG,WAEH,iBAAA,GAAA,kBAAA,KAAC,OAAD;CACE,YAAA,GAAA,GAAA,IAAc,iDAAiD,SAAS;CACxE,GAAI;AACL,CAAA;AAGH,MAAM,oBAAA,GAAA,yBAAA,KAGJ,sHACA;CACE,UAAU,EACR,MAAM;EACJ,SAAS;EACT,SAAS;EACT,OAAO;EACP,QAAQ;EACR,SAAS;CACX,EACF;CACA,iBAAiB,EAAE,MAAM,UAA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,WAEH,iBAAA,GAAA,kBAAA,KAAC,QAAD;CACE,YAAA,GAAA,GAAA,IAAc,iDAAiD,SAAS;CACxE,GAAI;AACL,CAAA;AAGH,MAAM,mBAAmB,EACvB,WACA,GAAG,WAEH,iBAAA,GAAA,kBAAA,KAAC,QAAD;CACE,YAAA,GAAA,GAAA,IACE,oFACA,SACF;CACA,GAAI;AACL,CAAA;AAGH,MAAM,sBAAsB,EAC1B,WACA,GAAG,WAEH,iBAAA,GAAA,kBAAA,KAAC,OAAD;CACE,YAAA,GAAA,GAAA,IACE,+EACA,SACF;CACA,GAAI;AACL,CAAA;AAGH,MAAM,oBAAoB,EACxB,WACA,GAAG,WAEH,iBAAA,GAAA,kBAAA,KAAC,OAAD;CACE,YAAA,GAAA,GAAA,IACE,wHACA,SACF;CACA,GAAI;AACL,CAAA"}
|
|
@@ -40,7 +40,7 @@ const EntityCardIcon = ({ className, icon: Glyph, tone, ...rest }) => /* @__PURE
|
|
|
40
40
|
children: /* @__PURE__ */ jsx(Glyph, { className: "[--spark-icon-size:18px]" })
|
|
41
41
|
});
|
|
42
42
|
const EntityCardTitleColumn = ({ className, ...rest }) => /* @__PURE__ */ jsx("div", {
|
|
43
|
-
className: cn("flex min-w-0 flex-1 flex-col gap-
|
|
43
|
+
className: cn("flex min-w-0 flex-1 flex-col gap-1", className),
|
|
44
44
|
...rest
|
|
45
45
|
});
|
|
46
46
|
const EntityCardTitle = ({ className, ...rest }) => /* @__PURE__ */ jsx("span", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-card.js","names":[],"sources":["../../src/components/entity-card.tsx"],"sourcesContent":["import type { SparkIcon } from '@epilot/spark-icons'\nimport { cva } from 'class-variance-authority'\nimport * as React from 'react'\nimport type { Tone } from '../lib/tones'\nimport { cn } from '../utils/cn'\n\nconst EntityCard = ({ className, ...rest }: React.ComponentProps<'div'>) => (\n <div\n className={cn(\n 'flex flex-col overflow-hidden rounded-lg border border-gray bg-(--spark-background)',\n className,\n )}\n {...rest}\n />\n)\n\nconst EntityCardBody = ({\n className,\n active,\n ...rest\n}: React.ComponentProps<'button'> & { active?: boolean }) => (\n <button\n type=\"button\"\n className={cn(\n 'flex w-full cursor-pointer flex-col gap-3 p-4 text-left transition-colors hover:bg-gray-a2 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent-focus',\n active && 'bg-linear-to-br from-spark-9/10 to-spark-1/5 to-20%',\n className,\n )}\n {...rest}\n />\n)\n\nconst EntityCardHeader = ({\n className,\n ...rest\n}: React.ComponentProps<'div'>) => (\n <div className={cn('flex w-full items-center gap-3', className)} {...rest} />\n)\n\nconst EntityCardMeters = ({\n className,\n ...rest\n}: React.ComponentProps<'div'>) => (\n <div\n className={cn('flex flex-col gap-2 border-t border-gray pt-3', className)}\n {...rest}\n />\n)\n\nconst iconToneVariants = cva(\n // max() pill escape (matches Icon): a tile stays rounded-md at low Roundness but\n // becomes a circle at large/full, same as it did pre-harmonization via clamping.\n 'flex size-11 shrink-0 items-center justify-center rounded-[max(var(--spark-rounded-md),var(--spark-rounded-full))]',\n {\n variants: {\n tone: {\n success: 'bg-success-soft text-success-soft-foreground',\n warning: 'bg-warning-soft text-warning-soft-foreground',\n error: 'bg-error-soft text-error-soft-foreground',\n accent: 'bg-primary-soft text-primary-soft-foreground',\n neutral: 'bg-base-gray-soft text-gray',\n },\n },\n defaultVariants: { tone: 'neutral' },\n },\n)\n\nconst EntityCardIcon = ({\n className,\n icon: Glyph,\n tone,\n ...rest\n}: React.ComponentProps<'span'> & {\n icon: SparkIcon\n tone?: Tone\n}) => (\n <span className={iconToneVariants({ tone, className })} {...rest}>\n <Glyph className=\"[--spark-icon-size:18px]\" />\n </span>\n)\n\nconst EntityCardTitleColumn = ({\n className,\n ...rest\n}: React.ComponentProps<'div'>) => (\n <div\n className={cn('flex min-w-0 flex-1 flex-col gap-
|
|
1
|
+
{"version":3,"file":"entity-card.js","names":[],"sources":["../../src/components/entity-card.tsx"],"sourcesContent":["import type { SparkIcon } from '@epilot/spark-icons'\nimport { cva } from 'class-variance-authority'\nimport * as React from 'react'\nimport type { Tone } from '../lib/tones'\nimport { cn } from '../utils/cn'\n\nconst EntityCard = ({ className, ...rest }: React.ComponentProps<'div'>) => (\n <div\n className={cn(\n 'flex flex-col overflow-hidden rounded-lg border border-gray bg-(--spark-background)',\n className,\n )}\n {...rest}\n />\n)\n\nconst EntityCardBody = ({\n className,\n active,\n ...rest\n}: React.ComponentProps<'button'> & { active?: boolean }) => (\n <button\n type=\"button\"\n className={cn(\n 'flex w-full cursor-pointer flex-col gap-3 p-4 text-left transition-colors hover:bg-gray-a2 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent-focus',\n active && 'bg-linear-to-br from-spark-9/10 to-spark-1/5 to-20%',\n className,\n )}\n {...rest}\n />\n)\n\nconst EntityCardHeader = ({\n className,\n ...rest\n}: React.ComponentProps<'div'>) => (\n <div className={cn('flex w-full items-center gap-3', className)} {...rest} />\n)\n\nconst EntityCardMeters = ({\n className,\n ...rest\n}: React.ComponentProps<'div'>) => (\n <div\n className={cn('flex flex-col gap-2 border-t border-gray pt-3', className)}\n {...rest}\n />\n)\n\nconst iconToneVariants = cva(\n // max() pill escape (matches Icon): a tile stays rounded-md at low Roundness but\n // becomes a circle at large/full, same as it did pre-harmonization via clamping.\n 'flex size-11 shrink-0 items-center justify-center rounded-[max(var(--spark-rounded-md),var(--spark-rounded-full))]',\n {\n variants: {\n tone: {\n success: 'bg-success-soft text-success-soft-foreground',\n warning: 'bg-warning-soft text-warning-soft-foreground',\n error: 'bg-error-soft text-error-soft-foreground',\n accent: 'bg-primary-soft text-primary-soft-foreground',\n neutral: 'bg-base-gray-soft text-gray',\n },\n },\n defaultVariants: { tone: 'neutral' },\n },\n)\n\nconst EntityCardIcon = ({\n className,\n icon: Glyph,\n tone,\n ...rest\n}: React.ComponentProps<'span'> & {\n icon: SparkIcon\n tone?: Tone\n}) => (\n <span className={iconToneVariants({ tone, className })} {...rest}>\n <Glyph className=\"[--spark-icon-size:18px]\" />\n </span>\n)\n\nconst EntityCardTitleColumn = ({\n className,\n ...rest\n}: React.ComponentProps<'div'>) => (\n <div\n className={cn('flex min-w-0 flex-1 flex-col gap-1', className)}\n {...rest}\n />\n)\n\nconst EntityCardTitle = ({\n className,\n ...rest\n}: React.ComponentProps<'span'>) => (\n <span\n className={cn('truncate text-sm font-bold text-gray', className)}\n {...rest}\n />\n)\n\nconst stateToneVariants = cva(\n 'inline-flex items-center gap-1.5 text-xs font-medium',\n {\n variants: {\n tone: {\n success: 'text-success',\n warning: 'text-warning',\n error: 'text-error',\n accent: 'text-accent',\n neutral: 'text-gray-light',\n },\n },\n defaultVariants: { tone: 'neutral' },\n },\n)\n\nconst dotToneVariants = cva('size-1.5 shrink-0 rounded-full', {\n variants: {\n tone: {\n success: 'bg-base-success-solid',\n warning: 'bg-base-warning-solid',\n error: 'bg-base-error-solid',\n accent: 'bg-primary',\n neutral: 'bg-base-gray-solid',\n },\n },\n defaultVariants: { tone: 'neutral' },\n})\n\nconst EntityCardState = ({\n className,\n tone,\n children,\n ...rest\n}: React.ComponentProps<'span'> & { tone?: Tone }) => (\n <span className={stateToneVariants({ tone, className })} {...rest}>\n <span className={dotToneVariants({ tone })} />\n <span className=\"truncate\">{children}</span>\n </span>\n)\n\nconst EntityCardDetail = ({\n className,\n ...rest\n}: React.ComponentProps<'span'>) => (\n <span\n className={cn('truncate text-xs text-gray-light tabular-nums', className)}\n {...rest}\n />\n)\n\nconst EntityCardValue = ({\n className,\n ...rest\n}: React.ComponentProps<'span'>) => (\n <span\n className={cn(\n 'ms-2 shrink-0 self-center text-lg leading-tight font-bold text-gray tabular-nums',\n className,\n )}\n {...rest}\n />\n)\n\nconst EntityCardControls = ({\n className,\n ...rest\n}: React.ComponentProps<'div'>) => (\n <div\n className={cn(\n 'flex items-center gap-3 border-t border-gray bg-base-gray-surface px-4 py-3',\n className,\n )}\n {...rest}\n />\n)\n\nconst EntityCardFooter = ({\n className,\n ...rest\n}: React.ComponentProps<'div'>) => (\n <div\n className={cn(\n 'flex items-center justify-center gap-1.5 border-t border-gray bg-base-gray-surface px-4 py-2 text-xs text-gray-light',\n className,\n )}\n {...rest}\n />\n)\n\nexport {\n EntityCard,\n EntityCardBody,\n EntityCardControls,\n EntityCardDetail,\n EntityCardFooter,\n EntityCardHeader,\n EntityCardIcon,\n EntityCardMeters,\n EntityCardState,\n EntityCardTitle,\n EntityCardTitleColumn,\n EntityCardValue,\n}\n"],"mappings":";;;;;;AAMA,MAAM,cAAc,EAAE,WAAW,GAAG,WAClC,oBAAC,OAAD;CACE,WAAW,GACT,uFACA,SACF;CACA,GAAI;AACL,CAAA;AAGH,MAAM,kBAAkB,EACtB,WACA,QACA,GAAG,WAEH,oBAAC,UAAD;CACE,MAAK;CACL,WAAW,GACT,yLACA,UAAU,uDACV,SACF;CACA,GAAI;AACL,CAAA;AAGH,MAAM,oBAAoB,EACxB,WACA,GAAG,WAEH,oBAAC,OAAD;CAAK,WAAW,GAAG,kCAAkC,SAAS;CAAG,GAAI;AAAO,CAAA;AAG9E,MAAM,oBAAoB,EACxB,WACA,GAAG,WAEH,oBAAC,OAAD;CACE,WAAW,GAAG,iDAAiD,SAAS;CACxE,GAAI;AACL,CAAA;AAGH,MAAM,mBAAmB,IAGvB,sHACA;CACE,UAAU,EACR,MAAM;EACJ,SAAS;EACT,SAAS;EACT,OAAO;EACP,QAAQ;EACR,SAAS;CACX,EACF;CACA,iBAAiB,EAAE,MAAM,UAAU;AACrC,CACF;AAEA,MAAM,kBAAkB,EACtB,WACA,MAAM,OACN,MACA,GAAG,WAKH,oBAAC,QAAD;CAAM,WAAW,iBAAiB;EAAE;EAAM;CAAU,CAAC;CAAG,GAAI;WAC1D,oBAAC,OAAD,EAAO,WAAU,2BAA4B,CAAA;AACzC,CAAA;AAGR,MAAM,yBAAyB,EAC7B,WACA,GAAG,WAEH,oBAAC,OAAD;CACE,WAAW,GAAG,sCAAsC,SAAS;CAC7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|
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
5
5
|
const require_components_theme = require("./theme.cjs");
|
|
6
|
+
const require_components_callout = require("./callout.cjs");
|
|
6
7
|
const require_components_separator = require("./separator.cjs");
|
|
7
8
|
const require_components_skeleton = require("./skeleton.cjs");
|
|
8
9
|
let react = require("react");
|
|
@@ -35,19 +36,96 @@ function useFieldControl(options) {
|
|
|
35
36
|
inputColor
|
|
36
37
|
};
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
const FieldSetContext = react.createContext(null);
|
|
40
|
+
/** True when the nearest enclosing FieldSet has an error; ignores outer sets. */
|
|
41
|
+
function useFieldSetInvalid() {
|
|
42
|
+
return react.useContext(FieldSetContext)?.invalid || void 0;
|
|
43
|
+
}
|
|
44
|
+
function useSlotCount() {
|
|
45
|
+
const [count, setCount] = react.useState(0);
|
|
46
|
+
const setHas = react.useCallback((has) => setCount((n) => n + (has ? 1 : -1)), []);
|
|
47
|
+
return [count > 0, setHas];
|
|
48
|
+
}
|
|
49
|
+
function FieldSet({ className, indicator, indicatorLabel, "aria-describedby": ariaDescribedByProp, ...props }) {
|
|
50
|
+
const id = (0, react.useId)();
|
|
51
|
+
const [hasDescription, setHasDescription] = useSlotCount();
|
|
52
|
+
const [hasError, setHasError] = useSlotCount();
|
|
53
|
+
const [hasUnlinkedError, setHasUnlinkedError] = useSlotCount();
|
|
54
|
+
const invalid = hasError || hasUnlinkedError;
|
|
55
|
+
const fieldSetId = `field-set-${id}`;
|
|
56
|
+
const descriptionId = `${fieldSetId}-description`;
|
|
57
|
+
const errorId = `${fieldSetId}-error`;
|
|
58
|
+
const value = react.useMemo(() => ({
|
|
59
|
+
descriptionId,
|
|
60
|
+
hasDescription,
|
|
61
|
+
setHasDescription,
|
|
62
|
+
errorId,
|
|
63
|
+
hasError,
|
|
64
|
+
setHasError,
|
|
65
|
+
setHasUnlinkedError,
|
|
66
|
+
invalid,
|
|
67
|
+
indicator,
|
|
68
|
+
indicatorLabel
|
|
69
|
+
}), [
|
|
70
|
+
descriptionId,
|
|
71
|
+
hasDescription,
|
|
72
|
+
setHasDescription,
|
|
73
|
+
errorId,
|
|
74
|
+
hasError,
|
|
75
|
+
setHasError,
|
|
76
|
+
setHasUnlinkedError,
|
|
77
|
+
invalid,
|
|
78
|
+
indicator,
|
|
79
|
+
indicatorLabel
|
|
80
|
+
]);
|
|
81
|
+
const ariaDescribedBy = [
|
|
82
|
+
hasError && errorId,
|
|
83
|
+
hasDescription && descriptionId,
|
|
84
|
+
ariaDescribedByProp
|
|
85
|
+
].filter(Boolean).join(" ") || void 0;
|
|
86
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FieldSetContext.Provider, {
|
|
87
|
+
value,
|
|
88
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("fieldset", {
|
|
89
|
+
"data-slot": "field-set",
|
|
90
|
+
"data-invalid": invalid || void 0,
|
|
91
|
+
"aria-describedby": ariaDescribedBy,
|
|
92
|
+
className: (0, cn.cn)("group/field-set flex flex-col gap-[calc(var(--spark-layout-gap)*4)]", className),
|
|
93
|
+
...props
|
|
94
|
+
})
|
|
43
95
|
});
|
|
44
96
|
}
|
|
45
|
-
function FieldLegend({ className, variant = "legend", ...props }) {
|
|
46
|
-
|
|
97
|
+
function FieldLegend({ className, variant = "legend", children, ...props }) {
|
|
98
|
+
const fieldSet = react.useContext(FieldSetContext);
|
|
99
|
+
const indicator = fieldSet?.indicator;
|
|
100
|
+
const indicatorLabel = fieldSet?.indicatorLabel ?? indicator;
|
|
101
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("legend", {
|
|
102
|
+
"data-invalid": fieldSet?.invalid || void 0,
|
|
47
103
|
"data-slot": "field-legend",
|
|
48
104
|
"data-variant": variant,
|
|
49
|
-
className: (0, cn.cn)("mb-1.5 font-medium text-gray data-[variant=label]:text-sm data-[variant=legend]:text-base", className),
|
|
50
|
-
...props
|
|
105
|
+
className: (0, cn.cn)("mb-1.5 font-medium text-gray data-[invalid=true]:text-error-active! data-[variant=label]:text-sm data-[variant=legend]:text-base", className),
|
|
106
|
+
...props,
|
|
107
|
+
children: [
|
|
108
|
+
children,
|
|
109
|
+
indicator === "required" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
110
|
+
" ",
|
|
111
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
112
|
+
"aria-hidden": "true",
|
|
113
|
+
children: "*"
|
|
114
|
+
}),
|
|
115
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
116
|
+
className: "sr-only",
|
|
117
|
+
children: indicatorLabel
|
|
118
|
+
})
|
|
119
|
+
] }),
|
|
120
|
+
indicator === "optional" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [" ", /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
121
|
+
className: "font-normal text-gray-light",
|
|
122
|
+
children: [
|
|
123
|
+
"(",
|
|
124
|
+
indicatorLabel,
|
|
125
|
+
")"
|
|
126
|
+
]
|
|
127
|
+
})] })
|
|
128
|
+
]
|
|
51
129
|
});
|
|
52
130
|
}
|
|
53
131
|
function FieldGroup({ className, ...props }) {
|
|
@@ -190,7 +268,7 @@ function Field({ className, children, labelPosition: labelPositionProp, inputSty
|
|
|
190
268
|
function FieldContent({ className, ...props }) {
|
|
191
269
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
192
270
|
"data-slot": "field-content",
|
|
193
|
-
className: (0, cn.cn)("flex min-w-0 flex-1 flex-col gap-
|
|
271
|
+
className: (0, cn.cn)("flex min-w-0 flex-1 flex-col gap-1 leading-snug", className),
|
|
194
272
|
...props
|
|
195
273
|
});
|
|
196
274
|
}
|
|
@@ -246,7 +324,9 @@ function FieldTitle({ className, ...props }) {
|
|
|
246
324
|
}
|
|
247
325
|
function FieldDescription({ className, id, ...props }) {
|
|
248
326
|
const field = useFieldContext();
|
|
249
|
-
const
|
|
327
|
+
const fieldSet = react.useContext(FieldSetContext);
|
|
328
|
+
const owner = field ?? fieldSet;
|
|
329
|
+
const setHasDescription = owner?.setHasDescription;
|
|
250
330
|
react.useEffect(() => {
|
|
251
331
|
if (!setHasDescription) return;
|
|
252
332
|
setHasDescription(true);
|
|
@@ -254,8 +334,8 @@ function FieldDescription({ className, id, ...props }) {
|
|
|
254
334
|
}, [setHasDescription]);
|
|
255
335
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
256
336
|
"data-slot": "field-description",
|
|
257
|
-
id: id ??
|
|
258
|
-
className: (0, cn.cn)("
|
|
337
|
+
id: id ?? owner?.descriptionId,
|
|
338
|
+
className: (0, cn.cn)("text-sm leading-normal text-gray-light", className),
|
|
259
339
|
...props
|
|
260
340
|
});
|
|
261
341
|
}
|
|
@@ -274,7 +354,8 @@ function FieldSeparator({ children, className, ...props }) {
|
|
|
274
354
|
}
|
|
275
355
|
function FieldError({ className, children, errors, id, ...props }) {
|
|
276
356
|
const field = useFieldContext();
|
|
277
|
-
const
|
|
357
|
+
const fieldSet = react.useContext(FieldSetContext);
|
|
358
|
+
const setHasError = (field ?? fieldSet)?.setHasError;
|
|
278
359
|
const content = react.useMemo(() => {
|
|
279
360
|
if (children) return children;
|
|
280
361
|
if (!errors?.length) return null;
|
|
@@ -287,21 +368,34 @@ function FieldError({ className, children, errors, id, ...props }) {
|
|
|
287
368
|
}, [children, errors]);
|
|
288
369
|
const hasContent = Boolean(content);
|
|
289
370
|
const hasCustomId = id != null;
|
|
371
|
+
const setSetUnlinked = !field ? fieldSet?.setHasUnlinkedError : void 0;
|
|
290
372
|
react.useEffect(() => {
|
|
291
|
-
if (!
|
|
292
|
-
setHasError
|
|
293
|
-
|
|
373
|
+
if (!hasContent) return;
|
|
374
|
+
const set = hasCustomId ? setSetUnlinked : setHasError;
|
|
375
|
+
if (!set) return;
|
|
376
|
+
set(true);
|
|
377
|
+
return () => set(false);
|
|
294
378
|
}, [
|
|
295
379
|
setHasError,
|
|
380
|
+
setSetUnlinked,
|
|
296
381
|
hasContent,
|
|
297
382
|
hasCustomId
|
|
298
383
|
]);
|
|
299
384
|
if (!content) return null;
|
|
385
|
+
if (!field && fieldSet) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_callout.Callout, {
|
|
386
|
+
variant: "error",
|
|
387
|
+
role: "alert",
|
|
388
|
+
"data-slot": "field-error",
|
|
389
|
+
id: id ?? fieldSet.errorId,
|
|
390
|
+
className,
|
|
391
|
+
...props,
|
|
392
|
+
children: content
|
|
393
|
+
});
|
|
300
394
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
301
395
|
role: "alert",
|
|
302
396
|
"data-slot": "field-error",
|
|
303
397
|
id: id ?? field?.errorId,
|
|
304
|
-
className: (0, cn.cn)("
|
|
398
|
+
className: (0, cn.cn)("text-sm font-normal text-error", className),
|
|
305
399
|
...props,
|
|
306
400
|
children: content
|
|
307
401
|
});
|
|
@@ -321,5 +415,6 @@ exports.FieldTitle = FieldTitle;
|
|
|
321
415
|
exports.FieldValue = FieldValue;
|
|
322
416
|
exports.useFieldContext = useFieldContext;
|
|
323
417
|
exports.useFieldControl = useFieldControl;
|
|
418
|
+
exports.useFieldSetInvalid = useFieldSetInvalid;
|
|
324
419
|
|
|
325
420
|
//# sourceMappingURL=field.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.cjs","names":["React","useTheme","Skeleton","Separator"],"sources":["../../src/components/field.tsx"],"sourcesContent":["'use client'\n\nimport { cva } from 'class-variance-authority'\nimport * as React from 'react'\nimport { useId } from 'react'\nimport type {\n SparkInputColor,\n SparkInputStyle,\n SparkLabelPosition,\n} from '../lib/theme-types'\nimport { cn } from '../utils/cn'\nimport { Separator } from './separator'\nimport { Skeleton } from './skeleton'\nimport { useTheme } from './theme'\n\ntype FieldContextValue = {\n id: string\n labelId: string\n descriptionId: string\n hasDescription: boolean\n setHasDescription: (has: boolean) => void\n errorId: string\n hasError: boolean\n setHasError: (has: boolean) => void\n readOnly: boolean\n labelPosition: SparkLabelPosition\n inputStyle: SparkInputStyle\n inputColor: SparkInputColor\n}\n\nconst FieldContext = React.createContext<FieldContextValue | null>(null)\n\nexport function useFieldContext() {\n return React.useContext(FieldContext)\n}\n\n// Field→Theme→default resolution + id/aria-describedby wiring, shared by every\n// control that can sit inside a Field (Input, SelectTrigger, …) so they can't\n// drift on how a style/color/id resolves. `variant` is the control's own\n// per-instance override (already normalized — e.g. Input maps its 'none' to\n// undefined before calling this).\nexport function useFieldControl(options?: {\n id?: string\n ariaDescribedBy?: string\n variant?: SparkInputStyle\n}) {\n const field = useFieldContext()\n const theme = useTheme()\n const id = options?.id ?? field?.id\n const errorId = field?.hasError ? field.errorId : undefined\n const descriptionId = field?.hasDescription ? field.descriptionId : undefined\n // error before hint: the actionable message should be announced first\n const ariaDescribedBy =\n [errorId, descriptionId, options?.ariaDescribedBy]\n .filter(Boolean)\n .join(' ') || undefined\n const inputStyle =\n options?.variant ?? field?.inputStyle ?? theme.inputStyle ?? 'soft'\n const inputColor = field?.inputColor ?? theme.inputColor ?? 'brand'\n const ariaInvalid = field?.hasError || undefined\n return { field, id, ariaDescribedBy, ariaInvalid, inputStyle, inputColor }\n}\n\nfunction FieldSet({ className, ...props }: React.ComponentProps<'fieldset'>) {\n return (\n <fieldset\n data-slot=\"field-set\"\n className={cn(\n 'flex flex-col gap-[calc(var(--spark-layout-gap)*4)]',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction FieldLegend({\n className,\n variant = 'legend',\n ...props\n}: React.ComponentProps<'legend'> & { variant?: 'legend' | 'label' }) {\n return (\n <legend\n data-slot=\"field-legend\"\n data-variant={variant}\n className={cn(\n 'mb-1.5 font-medium text-gray data-[variant=label]:text-sm data-[variant=legend]:text-base',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction FieldGroup({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"field-group\"\n className={cn(\n 'group/field-group flex w-full flex-col gap-[calc(var(--spark-layout-gap)*4)]',\n className,\n )}\n {...props}\n />\n )\n}\n\nconst fieldVariants = cva(\n 'group/field relative flex w-full flex-col data-[invalid=true]:text-error-active',\n {\n variants: {\n labelPosition: {\n // inset puts label + input inside one shell, so the shell IS the input's box —\n // rounded-md tracks Input/Select/etc.'s own control radius, not the container one.\n // focus inside inset is the classic underline cue, not a shell ring\n inset: 'gap-y-1 rounded-md px-4 py-3',\n outset: 'gap-y-2',\n },\n inputStyle: { soft: '', surface: '', outlined: '', ghost: '' },\n inputColor: { brand: '', gray: '' },\n },\n compoundVariants: [\n {\n labelPosition: 'inset',\n inputStyle: 'soft',\n inputColor: 'brand',\n class:\n 'bg-input-base has-[:is(input,textarea,[data-slot=select-trigger]):not(:disabled)]:hover:bg-input-base-hover',\n },\n {\n labelPosition: 'inset',\n inputStyle: 'soft',\n inputColor: 'gray',\n class:\n 'bg-base-gray-soft has-[:is(input,textarea,[data-slot=select-trigger]):not(:disabled)]:hover:bg-gray-a4',\n },\n {\n labelPosition: 'inset',\n inputStyle: 'surface',\n inputColor: 'brand',\n class: 'border border-input bg-base-accent-surface',\n },\n {\n labelPosition: 'inset',\n inputStyle: 'surface',\n inputColor: 'gray',\n class: 'border border-input-gray bg-base-gray-surface',\n },\n {\n labelPosition: 'inset',\n inputStyle: 'outlined',\n inputColor: 'brand',\n class: 'border border-input',\n },\n {\n labelPosition: 'inset',\n inputStyle: 'outlined',\n inputColor: 'gray',\n class: 'border border-input-gray',\n },\n // ghost inset = bare label + underlined input; the input carries the line\n {\n labelPosition: 'inset',\n inputStyle: 'ghost',\n class: 'rounded-none px-0',\n },\n // shared inset states: filled shells swap bg, bordered shells swap border\n // invalid hover deepens the error tint instead of falling back to accent\n {\n labelPosition: 'inset',\n inputStyle: ['soft', 'surface'],\n class:\n 'data-[disabled=true]:bg-base-gray-soft data-[invalid=true]:bg-base-error-soft data-[invalid=true]:has-[:is(input,textarea,[data-slot=select-trigger]):not(:disabled)]:hover:bg-red-a4',\n },\n {\n labelPosition: 'inset',\n inputStyle: ['surface', 'outlined'],\n class:\n 'data-[disabled=true]:border-input-disabled data-[invalid=true]:border-input-invalid',\n },\n ],\n },\n)\n\ninterface FieldProps extends React.ComponentProps<'div'> {\n labelPosition?: SparkLabelPosition\n inputStyle?: SparkInputStyle\n inputColor?: SparkInputColor\n readOnly?: boolean\n 'data-invalid'?: boolean | 'true' | 'false'\n}\n\nfunction Field({\n className,\n children,\n labelPosition: labelPositionProp,\n inputStyle: inputStyleProp,\n inputColor: inputColorProp,\n readOnly = false,\n 'data-invalid': dataInvalid,\n ...props\n}: FieldProps) {\n const id = useId()\n const [descriptionCount, setDescriptionCount] = React.useState(0)\n const [errorCount, setErrorCount] = React.useState(0)\n // counts, not flags: one slot unmounting must not clear what siblings still need\n const setHasDescription = React.useCallback(\n (has: boolean) => setDescriptionCount((n) => n + (has ? 1 : -1)),\n [],\n )\n const setHasError = React.useCallback(\n (has: boolean) => setErrorCount((n) => n + (has ? 1 : -1)),\n [],\n )\n const hasDescription = descriptionCount > 0\n const hasError = errorCount > 0\n // knobs are structural (they move the label / pick the box carrier), so they\n // resolve here via the <Theme> context; props override per instance\n const theme = useTheme()\n const labelPosition = labelPositionProp ?? theme.labelPosition ?? 'inset'\n const inputStyle = inputStyleProp ?? theme.inputStyle ?? 'soft'\n const inputColor = inputColorProp ?? theme.inputColor ?? 'brand'\n const fieldId = `field-${id}`\n const labelId = `${fieldId}-label`\n const value = React.useMemo<FieldContextValue>(\n () => ({\n id: fieldId,\n labelId,\n descriptionId: `${fieldId}-description`,\n hasDescription,\n setHasDescription,\n errorId: `${fieldId}-error`,\n hasError,\n setHasError,\n readOnly,\n labelPosition,\n inputStyle,\n inputColor,\n }),\n [\n fieldId,\n labelId,\n hasDescription,\n setHasDescription,\n hasError,\n setHasError,\n readOnly,\n labelPosition,\n inputStyle,\n inputColor,\n ],\n )\n\n return (\n <FieldContext.Provider value={value}>\n <div\n role=\"group\"\n data-slot=\"field\"\n data-label-position={labelPosition}\n data-input-style={inputStyle}\n data-input-color={inputColor}\n data-invalid={dataInvalid ?? (hasError || undefined)}\n aria-labelledby={readOnly ? labelId : undefined}\n className={cn(\n fieldVariants({ labelPosition, inputStyle, inputColor }),\n className,\n )}\n {...props}\n >\n {children}\n </div>\n </FieldContext.Provider>\n )\n}\n\nfunction FieldContent({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"field-content\"\n className={cn(\n 'flex min-w-0 flex-1 flex-col gap-0.5 leading-snug',\n className,\n )}\n {...props}\n />\n )\n}\n\nconst fieldLabelClassName =\n 'text-sm leading-5 font-normal text-gray transition-all group-data-[invalid=true]/field:text-error-active! motion-reduce:transition-none'\n\nfunction FieldLabel({\n className,\n htmlFor,\n srOnly,\n children,\n ...props\n}: React.ComponentProps<'label'> & { srOnly?: boolean }) {\n const field = useFieldContext()\n const classNames = cn(\n // labels stay full-contrast even when disabled — the control itself\n // (dimmed text, gray shell) signals the state\n fieldLabelClassName,\n // visually hidden but kept in the a11y tree (still names + focuses the control)\n srOnly && 'sr-only',\n className,\n )\n\n if (field?.readOnly) {\n return (\n <div data-slot=\"field-label\" id={field.labelId} className={classNames}>\n {children}\n </div>\n )\n }\n\n return (\n <label\n data-slot=\"field-label\"\n className={classNames}\n htmlFor={htmlFor ?? field?.id}\n {...props}\n >\n {children}\n </label>\n )\n}\n\nfunction FieldValue({\n className,\n id,\n title,\n truncate,\n children,\n ...props\n}: React.ComponentProps<'div'> & { truncate?: boolean }) {\n return (\n <div\n data-slot=\"field-value\"\n id={id}\n // truncated string values keep the full text reachable on hover\n title={\n title ??\n (truncate && typeof children === 'string' ? children : undefined)\n }\n className={cn(\n // values are content, not controls — disabled dims but stays ≥4.5:1\n 'min-h-8 w-full text-base text-gray tabular-nums group-data-[disabled=true]/field:opacity-70',\n truncate\n ? 'block truncate leading-8'\n : 'inline-flex items-center wrap-anywhere whitespace-pre-wrap',\n className,\n )}\n {...props}\n >\n {children}\n </div>\n )\n}\n\nfunction FieldSkeleton({\n className,\n labelClassName,\n valueClassName,\n truncate,\n ...props\n}: React.ComponentProps<'div'> & {\n truncate?: boolean\n labelClassName?: string\n valueClassName?: string\n}) {\n return (\n <div\n data-slot=\"field-skeleton\"\n aria-hidden=\"true\"\n className={cn('flex w-full flex-col gap-y-1', className)}\n {...props}\n >\n <Skeleton\n data-slot=\"field-skeleton-label\"\n className={cn('h-5 w-24', labelClassName)}\n />\n <Skeleton\n data-slot=\"field-skeleton-value\"\n className={cn(\n 'h-8 min-h-8 w-full',\n truncate && 'max-w-full truncate',\n valueClassName,\n )}\n />\n </div>\n )\n}\n\nfunction FieldTitle({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"field-title\"\n className={cn(\n 'flex w-fit items-center gap-2 text-sm font-medium text-gray',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction FieldDescription({\n className,\n id,\n ...props\n}: React.ComponentProps<'div'>) {\n const field = useFieldContext()\n const setHasDescription = field?.setHasDescription\n\n React.useEffect(() => {\n if (!setHasDescription) return\n setHasDescription(true)\n return () => setHasDescription(false)\n }, [setHasDescription])\n\n return (\n <div\n data-slot=\"field-description\"\n id={id ?? field?.descriptionId}\n className={cn('mt-0.5 text-sm leading-normal text-gray-light', className)}\n {...props}\n />\n )\n}\n\nfunction FieldSeparator({\n children,\n className,\n ...props\n}: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"field-separator\"\n data-content={!!children}\n className={cn('relative -my-2 h-5 text-sm', className)}\n {...props}\n >\n <Separator className=\"absolute inset-0 top-1/2\" />\n {children && (\n <span\n className=\"relative mx-auto block w-fit bg-(--spark-background) px-2 text-gray-light\"\n data-slot=\"field-separator-content\"\n >\n {children}\n </span>\n )}\n </div>\n )\n}\n\nfunction FieldError({\n className,\n children,\n errors,\n id,\n ...props\n}: React.ComponentProps<'div'> & {\n errors?: Array<{ message?: string } | undefined>\n}) {\n const field = useFieldContext()\n const setHasError = field?.setHasError\n const content = React.useMemo(() => {\n if (children) return children\n if (!errors?.length) return null\n const unique = [\n ...new Map(errors.map((error) => [error?.message, error])).values(),\n ]\n if (unique.length === 1) return unique[0]?.message\n return (\n <ul className=\"ml-4 flex list-disc flex-col gap-1\">\n {unique.map(\n (error) =>\n error?.message && <li key={error.message}>{error.message}</li>,\n )}\n </ul>\n )\n }, [children, errors])\n\n const hasContent = Boolean(content)\n // a custom id means no element carries field.errorId, so don't advertise it\n const hasCustomId = id != null\n\n // must run before the empty-content early return to keep hook order stable\n React.useEffect(() => {\n if (!setHasError || !hasContent || hasCustomId) return\n setHasError(true)\n return () => setHasError(false)\n }, [setHasError, hasContent, hasCustomId])\n\n if (!content) return null\n\n return (\n <div\n role=\"alert\"\n data-slot=\"field-error\"\n id={id ?? field?.errorId}\n className={cn('mt-0.5 text-sm font-normal text-error', className)}\n {...props}\n >\n {content}\n </div>\n )\n}\n\nexport {\n Field,\n FieldContent,\n FieldDescription,\n FieldError,\n FieldGroup,\n FieldLabel,\n FieldLegend,\n FieldSeparator,\n FieldSet,\n FieldSkeleton,\n FieldTitle,\n FieldValue,\n}\nexport type { FieldProps }\n"],"mappings":";;;;;;;;;;;;;AA8BA,MAAM,eAAeA,MAAM,cAAwC,IAAI;AAEvE,SAAgB,kBAAkB;CAChC,OAAOA,MAAM,WAAW,YAAY;AACtC;AAOA,SAAgB,gBAAgB,SAI7B;CACD,MAAM,QAAQ,gBAAgB;CAC9B,MAAM,QAAQC,yBAAAA,SAAS;CACvB,MAAM,KAAK,SAAS,MAAM,OAAO;CAIjC,MAAM,kBACJ;EAJc,OAAO,WAAW,MAAM,UAAU,KAAA;EAC5B,OAAO,iBAAiB,MAAM,gBAAgB,KAAA;EAGzC,SAAS;CAAe,EAC9C,OAAO,OAAO,EACd,KAAK,GAAG,KAAK,KAAA;CAClB,MAAM,aACJ,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MAAM,cAAc,OAAO;CAC3B,MAAM,UAAUH,MAAM,cAAc;EAClC,IAAI,UAAU,OAAO;EACrB,IAAI,CAAC,QAAQ,QAAQ,OAAO;EAC5B,MAAM,SAAS,CACb,GAAG,IAAI,IAAI,OAAO,KAAK,UAAU,CAAC,OAAO,SAAS,KAAK,CAAC,CAAC,EAAE,OAAO,CACpE;EACA,IAAI,OAAO,WAAW,GAAG,OAAO,OAAO,IAAI;EAC3C,OACE,iBAAA,GAAA,kBAAA,KAAC,MAAD;GAAI,WAAU;aACX,OAAO,KACL,UACC,OAAO,WAAW,iBAAA,GAAA,kBAAA,KAAC,MAAD,EAAA,UAAyB,MAAM,QAAY,GAAlC,MAAM,OAA4B,CACjE;EACE,CAAA;CAER,GAAG,CAAC,UAAU,MAAM,CAAC;CAErB,MAAM,aAAa,QAAQ,OAAO;CAElC,MAAM,cAAc,MAAM;CAG1B,MAAM,gBAAgB;EACpB,IAAI,CAAC,eAAe,CAAC,cAAc,aAAa;EAChD,YAAY,IAAI;EAChB,aAAa,YAAY,KAAK;CAChC,GAAG;EAAC;EAAa;EAAY;CAAW,CAAC;CAEzC,IAAI,CAAC,SAAS,OAAO;CAErB,OACE,iBAAA,GAAA,kBAAA,KAAC,OAAD;EACE,MAAK;EACL,aAAU;EACV,IAAI,MAAM,OAAO;EACjB,YAAA,GAAA,GAAA,IAAc,yCAAyC,SAAS;EAChE,GAAI;YAEH;CACE,CAAA;AAET"}
|
|
1
|
+
{"version":3,"file":"field.cjs","names":["React","useTheme","Skeleton","Separator","Callout"],"sources":["../../src/components/field.tsx"],"sourcesContent":["'use client'\n\nimport { cva } from 'class-variance-authority'\nimport * as React from 'react'\nimport { useId } from 'react'\nimport type {\n SparkInputColor,\n SparkInputStyle,\n SparkLabelPosition,\n} from '../lib/theme-types'\nimport { cn } from '../utils/cn'\nimport { Callout } from './callout'\nimport { Separator } from './separator'\nimport { Skeleton } from './skeleton'\nimport { useTheme } from './theme'\n\ntype FieldContextValue = {\n id: string\n labelId: string\n descriptionId: string\n hasDescription: boolean\n setHasDescription: (has: boolean) => void\n errorId: string\n hasError: boolean\n setHasError: (has: boolean) => void\n readOnly: boolean\n labelPosition: SparkLabelPosition\n inputStyle: SparkInputStyle\n inputColor: SparkInputColor\n}\n\nconst FieldContext = React.createContext<FieldContextValue | null>(null)\n\nexport function useFieldContext() {\n return React.useContext(FieldContext)\n}\n\n// Field→Theme→default resolution + id/aria-describedby wiring, shared by every\n// control that can sit inside a Field (Input, SelectTrigger, …) so they can't\n// drift on how a style/color/id resolves. `variant` is the control's own\n// per-instance override (already normalized — e.g. Input maps its 'none' to\n// undefined before calling this).\nexport function useFieldControl(options?: {\n id?: string\n ariaDescribedBy?: string\n variant?: SparkInputStyle\n}) {\n const field = useFieldContext()\n const theme = useTheme()\n const id = options?.id ?? field?.id\n const errorId = field?.hasError ? field.errorId : undefined\n const descriptionId = field?.hasDescription ? field.descriptionId : undefined\n // error before hint: the actionable message should be announced first\n const ariaDescribedBy =\n [errorId, descriptionId, options?.ariaDescribedBy]\n .filter(Boolean)\n .join(' ') || undefined\n const inputStyle =\n options?.variant ?? field?.inputStyle ?? theme.inputStyle ?? 'soft'\n const inputColor = field?.inputColor ?? theme.inputColor ?? 'brand'\n const ariaInvalid = field?.hasError || undefined\n return { field, id, ariaDescribedBy, ariaInvalid, inputStyle, inputColor }\n}\n\ntype FieldSetIndicator = 'required' | 'optional'\n\ntype FieldSetContextValue = {\n descriptionId: string\n hasDescription: boolean\n setHasDescription: (has: boolean) => void\n errorId: string\n hasError: boolean\n setHasError: (has: boolean) => void\n /** Marks the set invalid without linking `errorId` (error has a custom id). */\n setHasUnlinkedError: (has: boolean) => void\n invalid: boolean\n indicator?: FieldSetIndicator\n indicatorLabel?: string\n}\n\nconst FieldSetContext = React.createContext<FieldSetContextValue | null>(null)\n\n/** True when the nearest enclosing FieldSet has an error; ignores outer sets. */\nfunction useFieldSetInvalid() {\n return React.useContext(FieldSetContext)?.invalid || undefined\n}\n\nfunction useSlotCount() {\n const [count, setCount] = React.useState(0)\n const setHas = React.useCallback(\n (has: boolean) => setCount((n) => n + (has ? 1 : -1)),\n [],\n )\n return [count > 0, setHas] as const\n}\n\ninterface FieldSetProps extends React.ComponentProps<'fieldset'> {\n /** Marks the legend: `*` plus hidden text, or a visible \"(optional)\". */\n indicator?: FieldSetIndicator\n /** Text for the mark; defaults to `'required'` or `'optional'`. */\n indicatorLabel?: string\n}\n\nfunction FieldSet({\n className,\n indicator,\n indicatorLabel,\n 'aria-describedby': ariaDescribedByProp,\n ...props\n}: FieldSetProps) {\n const id = useId()\n const [hasDescription, setHasDescription] = useSlotCount()\n const [hasError, setHasError] = useSlotCount()\n const [hasUnlinkedError, setHasUnlinkedError] = useSlotCount()\n const invalid = hasError || hasUnlinkedError\n const fieldSetId = `field-set-${id}`\n const descriptionId = `${fieldSetId}-description`\n const errorId = `${fieldSetId}-error`\n const value = React.useMemo<FieldSetContextValue>(\n () => ({\n descriptionId,\n hasDescription,\n setHasDescription,\n errorId,\n hasError,\n setHasError,\n setHasUnlinkedError,\n invalid,\n indicator,\n indicatorLabel,\n }),\n [\n descriptionId,\n hasDescription,\n setHasDescription,\n errorId,\n hasError,\n setHasError,\n setHasUnlinkedError,\n invalid,\n indicator,\n indicatorLabel,\n ],\n )\n const ariaDescribedBy =\n [hasError && errorId, hasDescription && descriptionId, ariaDescribedByProp]\n .filter(Boolean)\n .join(' ') || undefined\n\n return (\n <FieldSetContext.Provider value={value}>\n <fieldset\n data-slot=\"field-set\"\n data-invalid={invalid || undefined}\n aria-describedby={ariaDescribedBy}\n className={cn(\n 'group/field-set flex flex-col gap-[calc(var(--spark-layout-gap)*4)]',\n className,\n )}\n {...props}\n />\n </FieldSetContext.Provider>\n )\n}\n\nfunction FieldLegend({\n className,\n variant = 'legend',\n children,\n ...props\n}: React.ComponentProps<'legend'> & { variant?: 'legend' | 'label' }) {\n const fieldSet = React.useContext(FieldSetContext)\n const indicator = fieldSet?.indicator\n const indicatorLabel = fieldSet?.indicatorLabel ?? indicator\n return (\n <legend\n data-invalid={fieldSet?.invalid || undefined}\n data-slot=\"field-legend\"\n data-variant={variant}\n className={cn(\n 'mb-1.5 font-medium text-gray data-[invalid=true]:text-error-active! data-[variant=label]:text-sm data-[variant=legend]:text-base',\n className,\n )}\n {...props}\n >\n {children}\n {indicator === 'required' && (\n <>\n {' '}\n <span aria-hidden=\"true\">*</span>\n <span className=\"sr-only\">{indicatorLabel}</span>\n </>\n )}\n {indicator === 'optional' && (\n <>\n {' '}\n <span className=\"font-normal text-gray-light\">\n ({indicatorLabel})\n </span>\n </>\n )}\n </legend>\n )\n}\n\nfunction FieldGroup({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"field-group\"\n className={cn(\n 'group/field-group flex w-full flex-col gap-[calc(var(--spark-layout-gap)*4)]',\n className,\n )}\n {...props}\n />\n )\n}\n\nconst fieldVariants = cva(\n 'group/field relative flex w-full flex-col data-[invalid=true]:text-error-active',\n {\n variants: {\n labelPosition: {\n // inset puts label + input inside one shell, so the shell IS the input's box —\n // rounded-md tracks Input/Select/etc.'s own control radius, not the container one.\n // focus inside inset is the classic underline cue, not a shell ring\n inset: 'gap-y-1 rounded-md px-4 py-3',\n outset: 'gap-y-2',\n },\n inputStyle: { soft: '', surface: '', outlined: '', ghost: '' },\n inputColor: { brand: '', gray: '' },\n },\n compoundVariants: [\n {\n labelPosition: 'inset',\n inputStyle: 'soft',\n inputColor: 'brand',\n class:\n 'bg-input-base has-[:is(input,textarea,[data-slot=select-trigger]):not(:disabled)]:hover:bg-input-base-hover',\n },\n {\n labelPosition: 'inset',\n inputStyle: 'soft',\n inputColor: 'gray',\n class:\n 'bg-base-gray-soft has-[:is(input,textarea,[data-slot=select-trigger]):not(:disabled)]:hover:bg-gray-a4',\n },\n {\n labelPosition: 'inset',\n inputStyle: 'surface',\n inputColor: 'brand',\n class: 'border border-input bg-base-accent-surface',\n },\n {\n labelPosition: 'inset',\n inputStyle: 'surface',\n inputColor: 'gray',\n class: 'border border-input-gray bg-base-gray-surface',\n },\n {\n labelPosition: 'inset',\n inputStyle: 'outlined',\n inputColor: 'brand',\n class: 'border border-input',\n },\n {\n labelPosition: 'inset',\n inputStyle: 'outlined',\n inputColor: 'gray',\n class: 'border border-input-gray',\n },\n // ghost inset = bare label + underlined input; the input carries the line\n {\n labelPosition: 'inset',\n inputStyle: 'ghost',\n class: 'rounded-none px-0',\n },\n // shared inset states: filled shells swap bg, bordered shells swap border\n // invalid hover deepens the error tint instead of falling back to accent\n {\n labelPosition: 'inset',\n inputStyle: ['soft', 'surface'],\n class:\n 'data-[disabled=true]:bg-base-gray-soft data-[invalid=true]:bg-base-error-soft data-[invalid=true]:has-[:is(input,textarea,[data-slot=select-trigger]):not(:disabled)]:hover:bg-red-a4',\n },\n {\n labelPosition: 'inset',\n inputStyle: ['surface', 'outlined'],\n class:\n 'data-[disabled=true]:border-input-disabled data-[invalid=true]:border-input-invalid',\n },\n ],\n },\n)\n\ninterface FieldProps extends React.ComponentProps<'div'> {\n labelPosition?: SparkLabelPosition\n inputStyle?: SparkInputStyle\n inputColor?: SparkInputColor\n readOnly?: boolean\n 'data-invalid'?: boolean | 'true' | 'false'\n}\n\nfunction Field({\n className,\n children,\n labelPosition: labelPositionProp,\n inputStyle: inputStyleProp,\n inputColor: inputColorProp,\n readOnly = false,\n 'data-invalid': dataInvalid,\n ...props\n}: FieldProps) {\n const id = useId()\n const [descriptionCount, setDescriptionCount] = React.useState(0)\n const [errorCount, setErrorCount] = React.useState(0)\n // counts, not flags: one slot unmounting must not clear what siblings still need\n const setHasDescription = React.useCallback(\n (has: boolean) => setDescriptionCount((n) => n + (has ? 1 : -1)),\n [],\n )\n const setHasError = React.useCallback(\n (has: boolean) => setErrorCount((n) => n + (has ? 1 : -1)),\n [],\n )\n const hasDescription = descriptionCount > 0\n const hasError = errorCount > 0\n // knobs are structural (they move the label / pick the box carrier), so they\n // resolve here via the <Theme> context; props override per instance\n const theme = useTheme()\n const labelPosition = labelPositionProp ?? theme.labelPosition ?? 'inset'\n const inputStyle = inputStyleProp ?? theme.inputStyle ?? 'soft'\n const inputColor = inputColorProp ?? theme.inputColor ?? 'brand'\n const fieldId = `field-${id}`\n const labelId = `${fieldId}-label`\n const value = React.useMemo<FieldContextValue>(\n () => ({\n id: fieldId,\n labelId,\n descriptionId: `${fieldId}-description`,\n hasDescription,\n setHasDescription,\n errorId: `${fieldId}-error`,\n hasError,\n setHasError,\n readOnly,\n labelPosition,\n inputStyle,\n inputColor,\n }),\n [\n fieldId,\n labelId,\n hasDescription,\n setHasDescription,\n hasError,\n setHasError,\n readOnly,\n labelPosition,\n inputStyle,\n inputColor,\n ],\n )\n\n return (\n <FieldContext.Provider value={value}>\n <div\n role=\"group\"\n data-slot=\"field\"\n data-label-position={labelPosition}\n data-input-style={inputStyle}\n data-input-color={inputColor}\n data-invalid={dataInvalid ?? (hasError || undefined)}\n aria-labelledby={readOnly ? labelId : undefined}\n className={cn(\n fieldVariants({ labelPosition, inputStyle, inputColor }),\n className,\n )}\n {...props}\n >\n {children}\n </div>\n </FieldContext.Provider>\n )\n}\n\nfunction FieldContent({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"field-content\"\n className={cn(\n 'flex min-w-0 flex-1 flex-col gap-1 leading-snug',\n className,\n )}\n {...props}\n />\n )\n}\n\nconst fieldLabelClassName =\n 'text-sm leading-5 font-normal text-gray transition-all group-data-[invalid=true]/field:text-error-active! motion-reduce:transition-none'\n\nfunction FieldLabel({\n className,\n htmlFor,\n srOnly,\n children,\n ...props\n}: React.ComponentProps<'label'> & { srOnly?: boolean }) {\n const field = useFieldContext()\n const classNames = cn(\n // labels stay full-contrast even when disabled — the control itself\n // (dimmed text, gray shell) signals the state\n fieldLabelClassName,\n // visually hidden but kept in the a11y tree (still names + focuses the control)\n srOnly && 'sr-only',\n className,\n )\n\n if (field?.readOnly) {\n return (\n <div data-slot=\"field-label\" id={field.labelId} className={classNames}>\n {children}\n </div>\n )\n }\n\n return (\n <label\n data-slot=\"field-label\"\n className={classNames}\n htmlFor={htmlFor ?? field?.id}\n {...props}\n >\n {children}\n </label>\n )\n}\n\nfunction FieldValue({\n className,\n id,\n title,\n truncate,\n children,\n ...props\n}: React.ComponentProps<'div'> & { truncate?: boolean }) {\n return (\n <div\n data-slot=\"field-value\"\n id={id}\n // truncated string values keep the full text reachable on hover\n title={\n title ??\n (truncate && typeof children === 'string' ? children : undefined)\n }\n className={cn(\n // values are content, not controls — disabled dims but stays ≥4.5:1\n 'min-h-8 w-full text-base text-gray tabular-nums group-data-[disabled=true]/field:opacity-70',\n truncate\n ? 'block truncate leading-8'\n : 'inline-flex items-center wrap-anywhere whitespace-pre-wrap',\n className,\n )}\n {...props}\n >\n {children}\n </div>\n )\n}\n\nfunction FieldSkeleton({\n className,\n labelClassName,\n valueClassName,\n truncate,\n ...props\n}: React.ComponentProps<'div'> & {\n truncate?: boolean\n labelClassName?: string\n valueClassName?: string\n}) {\n return (\n <div\n data-slot=\"field-skeleton\"\n aria-hidden=\"true\"\n className={cn('flex w-full flex-col gap-y-1', className)}\n {...props}\n >\n <Skeleton\n data-slot=\"field-skeleton-label\"\n className={cn('h-5 w-24', labelClassName)}\n />\n <Skeleton\n data-slot=\"field-skeleton-value\"\n className={cn(\n 'h-8 min-h-8 w-full',\n truncate && 'max-w-full truncate',\n valueClassName,\n )}\n />\n </div>\n )\n}\n\nfunction FieldTitle({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"field-title\"\n className={cn(\n 'flex w-fit items-center gap-2 text-sm font-medium text-gray',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction FieldDescription({\n className,\n id,\n ...props\n}: React.ComponentProps<'div'>) {\n const field = useFieldContext()\n const fieldSet = React.useContext(FieldSetContext)\n const owner = field ?? fieldSet\n const setHasDescription = owner?.setHasDescription\n\n React.useEffect(() => {\n if (!setHasDescription) return\n setHasDescription(true)\n return () => setHasDescription(false)\n }, [setHasDescription])\n\n return (\n <div\n data-slot=\"field-description\"\n id={id ?? owner?.descriptionId}\n className={cn('text-sm leading-normal text-gray-light', className)}\n {...props}\n />\n )\n}\n\nfunction FieldSeparator({\n children,\n className,\n ...props\n}: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"field-separator\"\n data-content={!!children}\n className={cn('relative -my-2 h-5 text-sm', className)}\n {...props}\n >\n <Separator className=\"absolute inset-0 top-1/2\" />\n {children && (\n <span\n className=\"relative mx-auto block w-fit bg-(--spark-background) px-2 text-gray-light\"\n data-slot=\"field-separator-content\"\n >\n {children}\n </span>\n )}\n </div>\n )\n}\n\nfunction FieldError({\n className,\n children,\n errors,\n id,\n ...props\n}: React.ComponentProps<'div'> & {\n errors?: Array<{ message?: string } | undefined>\n}) {\n const field = useFieldContext()\n const fieldSet = React.useContext(FieldSetContext)\n const owner = field ?? fieldSet\n const setHasError = owner?.setHasError\n const content = React.useMemo(() => {\n if (children) return children\n if (!errors?.length) return null\n const unique = [\n ...new Map(errors.map((error) => [error?.message, error])).values(),\n ]\n if (unique.length === 1) return unique[0]?.message\n return (\n <ul className=\"ml-4 flex list-disc flex-col gap-1\">\n {unique.map(\n (error) =>\n error?.message && <li key={error.message}>{error.message}</li>,\n )}\n </ul>\n )\n }, [children, errors])\n\n const hasContent = Boolean(content)\n // a custom id means no element carries owner.errorId, so don't advertise it\n const hasCustomId = id != null\n const setSetUnlinked = !field ? fieldSet?.setHasUnlinkedError : undefined\n\n // must run before the empty-content early return to keep hook order stable\n React.useEffect(() => {\n if (!hasContent) return\n const set = hasCustomId ? setSetUnlinked : setHasError\n if (!set) return\n set(true)\n return () => set(false)\n }, [setHasError, setSetUnlinked, hasContent, hasCustomId])\n\n if (!content) return null\n\n if (!field && fieldSet) {\n // straight into Callout: CalloutDescription's <p> cannot hold the <ul> above\n return (\n <Callout\n variant=\"error\"\n role=\"alert\"\n data-slot=\"field-error\"\n id={id ?? fieldSet.errorId}\n className={className}\n {...props}\n >\n {content}\n </Callout>\n )\n }\n\n return (\n <div\n role=\"alert\"\n data-slot=\"field-error\"\n id={id ?? field?.errorId}\n className={cn('text-sm font-normal text-error', className)}\n {...props}\n >\n {content}\n </div>\n )\n}\n\nexport {\n useFieldSetInvalid,\n Field,\n FieldContent,\n FieldDescription,\n FieldError,\n FieldGroup,\n FieldLabel,\n FieldLegend,\n FieldSeparator,\n FieldSet,\n FieldSkeleton,\n FieldTitle,\n FieldValue,\n}\nexport type { FieldProps, FieldSetProps }\n"],"mappings":";;;;;;;;;;;;;;AA+BA,MAAM,eAAeA,MAAM,cAAwC,IAAI;AAEvE,SAAgB,kBAAkB;CAChC,OAAOA,MAAM,WAAW,YAAY;AACtC;AAOA,SAAgB,gBAAgB,SAI7B;CACD,MAAM,QAAQ,gBAAgB;CAC9B,MAAM,QAAQC,yBAAAA,SAAS;CACvB,MAAM,KAAK,SAAS,MAAM,OAAO;CAIjC,MAAM,kBACJ;EAJc,OAAO,WAAW,MAAM,UAAU,KAAA;EAC5B,OAAO,iBAAiB,MAAM,gBAAgB,KAAA;EAGzC,SAAS;CAAe,EAC9C,OAAO,OAAO,EACd,KAAK,GAAG,KAAK,KAAA;CAClB,MAAM,aACJ,SAAS,WAAW,OAAO,cAAc,MAAM,cAAc;CAC/D,MAAM,aAAa,OAAO,cAAc,MAAM,cAAc;CAE5D,OAAO;EAAE;EAAO;EAAI;EAAiB,aADjB,OAAO,YAAY,KAAA;EACW;EAAY;CAAW;AAC3E;AAkBA,MAAM,kBAAkBD,MAAM,cAA2C,IAAI;;AAG7E,SAAS,qBAAqB;CAC5B,OAAOA,MAAM,WAAW,eAAe,GAAG,WAAW,KAAA;AACvD;AAEA,SAAS,eAAe;CACtB,MAAM,CAAC,OAAO,YAAYA,MAAM,SAAS,CAAC;CAC1C,MAAM,SAASA,MAAM,aAClB,QAAiB,UAAU,MAAM,KAAK,MAAM,IAAI,GAAG,GACpD,CAAC,CACH;CACA,OAAO,CAAC,QAAQ,GAAG,MAAM;AAC3B;AAS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Q,OAAO;EAC5B,MAAM,SAAS,CACb,GAAG,IAAI,IAAI,OAAO,KAAK,UAAU,CAAC,OAAO,SAAS,KAAK,CAAC,CAAC,EAAE,OAAO,CACpE;EACA,IAAI,OAAO,WAAW,GAAG,OAAO,OAAO,IAAI;EAC3C,OACE,iBAAA,GAAA,kBAAA,KAAC,MAAD;GAAI,WAAU;aACX,OAAO,KACL,UACC,OAAO,WAAW,iBAAA,GAAA,kBAAA,KAAC,MAAD,EAAA,UAAyB,MAAM,QAAY,GAAlC,MAAM,OAA4B,CACjE;EACE,CAAA;CAER,GAAG,CAAC,UAAU,MAAM,CAAC;CAErB,MAAM,aAAa,QAAQ,OAAO;CAElC,MAAM,cAAc,MAAM;CAC1B,MAAM,iBAAiB,CAAC,QAAQ,UAAU,sBAAsB,KAAA;CAGhE,MAAM,gBAAgB;EACpB,IAAI,CAAC,YAAY;EACjB,MAAM,MAAM,cAAc,iBAAiB;EAC3C,IAAI,CAAC,KAAK;EACV,IAAI,IAAI;EACR,aAAa,IAAI,KAAK;CACxB,GAAG;EAAC;EAAa;EAAgB;EAAY;CAAW,CAAC;CAEzD,IAAI,CAAC,SAAS,OAAO;CAErB,IAAI,CAAC,SAAS,UAEZ,OACE,iBAAA,GAAA,kBAAA,KAACI,2BAAAA,SAAD;EACE,SAAQ;EACR,MAAK;EACL,aAAU;EACV,IAAI,MAAM,SAAS;EACR;EACX,GAAI;YAEH;CACM,CAAA;CAIb,OACE,iBAAA,GAAA,kBAAA,KAAC,OAAD;EACE,MAAK;EACL,aAAU;EACV,IAAI,MAAM,OAAO;EACjB,YAAA,GAAA,GAAA,IAAc,kCAAkC,SAAS;EACzD,GAAI;YAEH;CACE,CAAA;AAET"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { c as SparkInputColor, l as SparkInputStyle, u as SparkLabelPosition } from "../theme-types-CKZzOmSa.cjs";
|
|
4
4
|
import * as React$1 from "react";
|
|
5
5
|
|
|
6
6
|
//#region src/components/field.d.ts
|
|
@@ -31,13 +31,26 @@ declare function useFieldControl(options?: {
|
|
|
31
31
|
inputStyle: SparkInputStyle;
|
|
32
32
|
inputColor: SparkInputColor;
|
|
33
33
|
};
|
|
34
|
+
type FieldSetIndicator = 'required' | 'optional';
|
|
35
|
+
/** True when the nearest enclosing FieldSet has an error; ignores outer sets. */
|
|
36
|
+
declare function useFieldSetInvalid(): true | undefined;
|
|
37
|
+
interface FieldSetProps extends React$1.ComponentProps<'fieldset'> {
|
|
38
|
+
/** Marks the legend: `*` plus hidden text, or a visible "(optional)". */
|
|
39
|
+
indicator?: FieldSetIndicator;
|
|
40
|
+
/** Text for the mark; defaults to `'required'` or `'optional'`. */
|
|
41
|
+
indicatorLabel?: string;
|
|
42
|
+
}
|
|
34
43
|
declare function FieldSet({
|
|
35
44
|
className,
|
|
45
|
+
indicator,
|
|
46
|
+
indicatorLabel,
|
|
47
|
+
'aria-describedby': ariaDescribedByProp,
|
|
36
48
|
...props
|
|
37
|
-
}:
|
|
49
|
+
}: FieldSetProps): import("react/jsx-runtime").JSX.Element;
|
|
38
50
|
declare function FieldLegend({
|
|
39
51
|
className,
|
|
40
52
|
variant,
|
|
53
|
+
children,
|
|
41
54
|
...props
|
|
42
55
|
}: React$1.ComponentProps<'legend'> & {
|
|
43
56
|
variant?: 'legend' | 'label';
|
|
@@ -123,5 +136,5 @@ declare function FieldError({
|
|
|
123
136
|
} | undefined>;
|
|
124
137
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
125
138
|
//#endregion
|
|
126
|
-
export { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, type FieldProps, FieldSeparator, FieldSet, FieldSkeleton, FieldTitle, FieldValue, useFieldContext, useFieldControl };
|
|
139
|
+
export { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, type FieldProps, FieldSeparator, FieldSet, type FieldSetProps, FieldSkeleton, FieldTitle, FieldValue, useFieldContext, useFieldControl, useFieldSetInvalid };
|
|
127
140
|
//# sourceMappingURL=field.d.cts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { c as SparkInputColor, l as SparkInputStyle, u as SparkLabelPosition } from "../theme-types-CKZzOmSa.js";
|
|
4
4
|
import * as React$1 from "react";
|
|
5
5
|
|
|
6
6
|
//#region src/components/field.d.ts
|
|
@@ -31,13 +31,26 @@ declare function useFieldControl(options?: {
|
|
|
31
31
|
inputStyle: SparkInputStyle;
|
|
32
32
|
inputColor: SparkInputColor;
|
|
33
33
|
};
|
|
34
|
+
type FieldSetIndicator = 'required' | 'optional';
|
|
35
|
+
/** True when the nearest enclosing FieldSet has an error; ignores outer sets. */
|
|
36
|
+
declare function useFieldSetInvalid(): true | undefined;
|
|
37
|
+
interface FieldSetProps extends React$1.ComponentProps<'fieldset'> {
|
|
38
|
+
/** Marks the legend: `*` plus hidden text, or a visible "(optional)". */
|
|
39
|
+
indicator?: FieldSetIndicator;
|
|
40
|
+
/** Text for the mark; defaults to `'required'` or `'optional'`. */
|
|
41
|
+
indicatorLabel?: string;
|
|
42
|
+
}
|
|
34
43
|
declare function FieldSet({
|
|
35
44
|
className,
|
|
45
|
+
indicator,
|
|
46
|
+
indicatorLabel,
|
|
47
|
+
'aria-describedby': ariaDescribedByProp,
|
|
36
48
|
...props
|
|
37
|
-
}:
|
|
49
|
+
}: FieldSetProps): import("react/jsx-runtime").JSX.Element;
|
|
38
50
|
declare function FieldLegend({
|
|
39
51
|
className,
|
|
40
52
|
variant,
|
|
53
|
+
children,
|
|
41
54
|
...props
|
|
42
55
|
}: React$1.ComponentProps<'legend'> & {
|
|
43
56
|
variant?: 'legend' | 'label';
|
|
@@ -123,5 +136,5 @@ declare function FieldError({
|
|
|
123
136
|
} | undefined>;
|
|
124
137
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
125
138
|
//#endregion
|
|
126
|
-
export { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, type FieldProps, FieldSeparator, FieldSet, FieldSkeleton, FieldTitle, FieldValue, useFieldContext, useFieldControl };
|
|
139
|
+
export { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, type FieldProps, FieldSeparator, FieldSet, type FieldSetProps, FieldSkeleton, FieldTitle, FieldValue, useFieldContext, useFieldControl, useFieldSetInvalid };
|
|
127
140
|
//# sourceMappingURL=field.d.ts.map
|