@sparkwire/mcp 0.1.0 → 0.2.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/data/docs.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.0",
2
+ "version": "0.2.0",
3
3
  "site": "https://phoenix-am.github.io/spark-ui",
4
4
  "components": [
5
5
  {
@@ -47,6 +47,12 @@
47
47
  "required": false,
48
48
  "description": "Stretch to the container's width."
49
49
  },
50
+ {
51
+ "name": "render",
52
+ "type": "RenderProp<{ disabled: boolean; }>",
53
+ "required": false,
54
+ "description": "Render a different element with the button's behaviour and look, e.g. `render={<Link href=\"/pricing\" />}`."
55
+ },
50
56
  {
51
57
  "name": "spark",
52
58
  "type": "boolean",
@@ -1575,6 +1581,12 @@
1575
1581
  "required": false,
1576
1582
  "description": "Show a close button. Called after it hides."
1577
1583
  },
1584
+ {
1585
+ "name": "render",
1586
+ "type": "RenderProp<{ tone: AlertTone; }>",
1587
+ "required": false,
1588
+ "description": "Render any element as the root, e.g. a `section` with your own landmark."
1589
+ },
1578
1590
  {
1579
1591
  "name": "title",
1580
1592
  "type": "ReactNode",
@@ -4324,6 +4336,12 @@
4324
4336
  "type": "\"none\" | \"small\" | \"medium\" | \"large\"",
4325
4337
  "required": false,
4326
4338
  "description": "Inner spacing. Default `medium`."
4339
+ },
4340
+ {
4341
+ "name": "render",
4342
+ "type": "RenderProp<{ live: boolean; interactive: boolean; }>",
4343
+ "required": false,
4344
+ "description": "Render any element instead, e.g. `<Link href=\"/p/1\" />` or a motion component."
4327
4345
  }
4328
4346
  ]
4329
4347
  },
@@ -4509,6 +4527,12 @@
4509
4527
  "required": false,
4510
4528
  "description": "Pulse the LED: something is live or in progress."
4511
4529
  },
4530
+ {
4531
+ "name": "render",
4532
+ "type": "RenderProp<{ tone: string; }>",
4533
+ "required": false,
4534
+ "description": "Render any element instead, e.g. a link: `render={<a href=\"/inbox\" />}`."
4535
+ },
4512
4536
  {
4513
4537
  "name": "tone",
4514
4538
  "type": "Tone | \"neutral\"",
@@ -4684,6 +4708,12 @@
4684
4708
  "required": false,
4685
4709
  "description": "Link target when rendered as an anchor."
4686
4710
  },
4711
+ {
4712
+ "name": "render",
4713
+ "type": "RenderProp<{ disabled: boolean; }>",
4714
+ "required": false,
4715
+ "description": "Render a different element (e.g. a router link) with the button's behaviour and styling."
4716
+ },
4687
4717
  {
4688
4718
  "name": "spark",
4689
4719
  "type": "boolean",
package/data/r/alert.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "path": "components/spark-ui/Alert/Alert.tsx",
15
15
  "type": "registry:ui",
16
16
  "target": "components/spark-ui/Alert/Alert.tsx",
17
- "content": "import React, { useState } from 'react';\nimport { useMessages } from '../internal/messages';\nimport { useDefaults, slot, ClassNames } from '../internal/defaults';\n\nexport type AlertTone = 'info' | 'success' | 'warning' | 'error';\n\nexport interface AlertProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> {\n /** Default `info`. Each tone ships with its own icon, so meaning is never colour alone. */\n tone?: AlertTone;\n title?: React.ReactNode;\n children?: React.ReactNode;\n /** Replace the tone icon, or `false` to hide it. */\n icon?: React.ReactNode | false;\n /** Buttons or links on the right (or below on narrow screens). */\n action?: React.ReactNode;\n /** Show a close button. Called after it hides. */\n onDismiss?: () => void;\n /** `soft` (default), `outlined`, or `banner` (full-width, square, for the top of a page). */\n variant?: 'soft' | 'outlined' | 'banner';\n /**\n * `polite` announces it when it appears, `assertive` interrupts (errors).\n * Default: `assertive` for error, otherwise none (static content).\n */\n live?: 'polite' | 'assertive' | 'off';\n dismissLabel?: string;\n classNames?: ClassNames<'root' | 'icon' | 'title' | 'body' | 'action' | 'dismiss'>;\n}\n\nconst paths: Record<AlertTone, string> = {\n info: 'M12 8h.01M11 12h1v4h1',\n success: 'M8 12.5l2.5 2.5L16 9.5',\n warning: 'M12 8v5M12 16h.01',\n error: 'M9 9l6 6M15 9l-6 6',\n};\n\nfunction ToneIcon({ tone }: { tone: AlertTone }) {\n return (\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n {tone === 'warning' ? <path d=\"M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z\" /> : <circle cx=\"12\" cy=\"12\" r=\"9\" />}\n <path d={paths[tone]} />\n </svg>\n );\n}\n\n/**\n * Alert: a message about the page or a task — info, success, warning or\n * error — with an icon, optional title, actions and a dismiss button. Use\n * `variant=\"banner\"` for a site-wide strip. Errors are announced at once;\n * others are static unless you set `live`.\n *\n * Style hooks: `.sp-alert[data-tone][data-variant]`, `__icon`, `__title`, `__body`, `__action`, `__dismiss`.\n */\nexport function Alert(inProps: AlertProps) {\n const m = useMessages();\n const { tone = 'info', title, children, icon, action, onDismiss, variant = 'soft', live, dismissLabel = m.dismiss, className, classNames, ...rest } = useDefaults(\n 'Alert',\n inProps,\n ) as AlertProps;\n const [open, setOpen] = useState(true);\n if (!open) return null;\n const mode = live ?? (tone === 'error' ? 'assertive' : 'off');\n const role = mode === 'assertive' ? 'alert' : mode === 'polite' ? 'status' : undefined;\n return (\n <div {...rest} role={role} className={slot('sp-alert', classNames, 'root', className)} data-tone={tone === 'info' ? 'brand' : tone} data-kind={tone} data-variant={variant}>\n {icon !== false && <span className={slot('sp-alert__icon', classNames, 'icon')}>{icon ?? <ToneIcon tone={tone} />}</span>}\n <div className=\"sp-alert__content\">\n {title && <div className={slot('sp-alert__title', classNames, 'title')}>{title}</div>}\n {children && <div className={slot('sp-alert__body', classNames, 'body')}>{children}</div>}\n </div>\n {action && <div className={slot('sp-alert__action', classNames, 'action')}>{action}</div>}\n {onDismiss && (\n <button\n type=\"button\"\n className={slot('sp-alert__dismiss', classNames, 'dismiss')}\n aria-label={dismissLabel}\n onClick={() => {\n setOpen(false);\n onDismiss();\n }}\n >\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" aria-hidden=\"true\">\n <path d=\"M6 6l12 12M18 6 6 18\" />\n </svg>\n </button>\n )}\n </div>\n );\n}\n"
17
+ "content": "import React, { useState } from 'react';\nimport { renderElement, type RenderProp } from '../internal/render';\nimport { useMessages } from '../internal/messages';\nimport { useDefaults, slot, ClassNames } from '../internal/defaults';\n\nexport type AlertTone = 'info' | 'success' | 'warning' | 'error';\n\nexport interface AlertProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> {\n /** Default `info`. Each tone ships with its own icon, so meaning is never colour alone. */\n tone?: AlertTone;\n title?: React.ReactNode;\n children?: React.ReactNode;\n /** Replace the tone icon, or `false` to hide it. */\n icon?: React.ReactNode | false;\n /** Buttons or links on the right (or below on narrow screens). */\n action?: React.ReactNode;\n /** Show a close button. Called after it hides. */\n onDismiss?: () => void;\n /** `soft` (default), `outlined`, or `banner` (full-width, square, for the top of a page). */\n variant?: 'soft' | 'outlined' | 'banner';\n /**\n * `polite` announces it when it appears, `assertive` interrupts (errors).\n * Default: `assertive` for error, otherwise none (static content).\n */\n live?: 'polite' | 'assertive' | 'off';\n dismissLabel?: string;\n /** Render any element as the root, e.g. a `section` with your own landmark. */\n render?: RenderProp<{ tone: AlertTone }>;\n classNames?: ClassNames<'root' | 'icon' | 'title' | 'body' | 'action' | 'dismiss'>;\n}\n\nconst paths: Record<AlertTone, string> = {\n info: 'M12 8h.01M11 12h1v4h1',\n success: 'M8 12.5l2.5 2.5L16 9.5',\n warning: 'M12 8v5M12 16h.01',\n error: 'M9 9l6 6M15 9l-6 6',\n};\n\nfunction ToneIcon({ tone }: { tone: AlertTone }) {\n return (\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n {tone === 'warning' ? <path d=\"M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z\" /> : <circle cx=\"12\" cy=\"12\" r=\"9\" />}\n <path d={paths[tone]} />\n </svg>\n );\n}\n\n/**\n * Alert: a message about the page or a task — info, success, warning or\n * error — with an icon, optional title, actions and a dismiss button. Use\n * `variant=\"banner\"` for a site-wide strip. Errors are announced at once;\n * others are static unless you set `live`.\n *\n * Style hooks: `.sp-alert[data-tone][data-variant]`, `__icon`, `__title`, `__body`, `__action`, `__dismiss`.\n */\nexport function Alert(inProps: AlertProps) {\n const m = useMessages();\n const { tone = 'info', title, children, icon, action, onDismiss, variant = 'soft', live, dismissLabel = m.dismiss, render, className, classNames, ...rest } = useDefaults(\n 'Alert',\n inProps,\n ) as AlertProps;\n const [open, setOpen] = useState(true);\n if (!open) return null;\n const mode = live ?? (tone === 'error' ? 'assertive' : 'off');\n const role = mode === 'assertive' ? 'alert' : mode === 'polite' ? 'status' : undefined;\n return renderElement('div', render, {\n ...rest,\n role,\n className: slot('sp-alert', classNames, 'root', className),\n 'data-tone': tone === 'info' ? 'brand' : tone,\n 'data-kind': tone,\n 'data-variant': variant,\n children: (\n <>\n {icon !== false && <span className={slot('sp-alert__icon', classNames, 'icon')}>{icon ?? <ToneIcon tone={tone} />}</span>}\n <div className=\"sp-alert__content\">\n {title && <div className={slot('sp-alert__title', classNames, 'title')}>{title}</div>}\n {children && <div className={slot('sp-alert__body', classNames, 'body')}>{children}</div>}\n </div>\n {action && <div className={slot('sp-alert__action', classNames, 'action')}>{action}</div>}\n {onDismiss && (\n <button\n type=\"button\"\n className={slot('sp-alert__dismiss', classNames, 'dismiss')}\n aria-label={dismissLabel}\n onClick={() => {\n setOpen(false);\n onDismiss();\n }}\n >\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" aria-hidden=\"true\">\n <path d=\"M6 6l12 12M18 6 6 18\" />\n </svg>\n </button>\n )}\n </>\n ),\n }, { tone });\n}\n"
18
18
  },
19
19
  {
20
20
  "path": "components/spark-ui/Alert/index.ts",
package/data/r/base.json CHANGED
@@ -19,7 +19,7 @@
19
19
  "path": "components/spark-ui/base/ButtonBase.tsx",
20
20
  "type": "registry:ui",
21
21
  "target": "components/spark-ui/base/ButtonBase.tsx",
22
- "content": "import React, { ElementType, forwardRef, useRef } from 'react';\nimport { Spark, SparkHandle } from '../Spark';\nimport { cx } from '../internal/cx';\n\nexport interface ButtonBaseProps extends React.ButtonHTMLAttributes<HTMLElement> {\n /** Render as another element or component, e.g. `\"a\"` or a router Link. */\n as?: ElementType;\n /** Dead circuit: no clicks, no sparks. Uses `disabled` on buttons, `aria-disabled` otherwise. */\n disabled?: boolean;\n /** Throw sparks from the press point on click. Default `true`. */\n spark?: boolean;\n /** Spark colours. Default: the theme's spark colours. */\n sparkColors?: string[];\n /** Link target when rendered as an anchor. */\n href?: string;\n [key: `data-${string}`]: unknown;\n}\n\n/**\n * ButtonBase: the pressable foundation under Button, IconButton and menu\n * triggers. Handles disabled state for any element, `type=\"button\"` by\n * default, and the spark burst. No visual style of its own beyond\n * `.sp-button-base`; build your own buttons on it.\n */\nexport const ButtonBase = forwardRef<HTMLElement, ButtonBaseProps>(function ButtonBase(\n { as: Component = 'button', disabled = false, spark = true, sparkColors, onClick, className, children, type, ...rest },\n ref,\n) {\n const sparkRef = useRef<SparkHandle>(null);\n const isButton = Component === 'button';\n return (\n <Component\n ref={ref}\n className={cx('sp-button-base', className)}\n data-disabled={disabled || undefined}\n disabled={isButton ? disabled : undefined}\n aria-disabled={!isButton && disabled ? true : undefined}\n type={isButton ? type ?? 'button' : type}\n onClick={(event: React.MouseEvent<HTMLElement>) => {\n if (disabled) {\n event.preventDefault();\n return;\n }\n if (spark) sparkRef.current?.burst(event);\n onClick?.(event as React.MouseEvent<HTMLButtonElement>);\n }}\n {...rest}\n >\n {children}\n {spark && <Spark ref={sparkRef} colors={sparkColors} />}\n </Component>\n );\n});\n\nexport default ButtonBase;\n"
22
+ "content": "import React, { ElementType, forwardRef, useRef } from 'react';\nimport { renderElement, type RenderProp } from '../internal/render';\nimport { Spark, SparkHandle } from '../Spark';\nimport { cx } from '../internal/cx';\n\nexport interface ButtonBaseProps extends React.ButtonHTMLAttributes<HTMLElement> {\n /** Render as another element or component, e.g. `\"a\"` or a router Link. */\n as?: ElementType;\n /** Render a different element (e.g. a router link) with the button's behaviour and styling. */\n render?: RenderProp<{ disabled: boolean }>;\n /** Dead circuit: no clicks, no sparks. Uses `disabled` on buttons, `aria-disabled` otherwise. */\n disabled?: boolean;\n /** Throw sparks from the press point on click. Default `true`. */\n spark?: boolean;\n /** Spark colours. Default: the theme's spark colours. */\n sparkColors?: string[];\n /** Link target when rendered as an anchor. */\n href?: string;\n [key: `data-${string}`]: unknown;\n}\n\n/**\n * ButtonBase: the pressable foundation under Button, IconButton and menu\n * triggers. Handles disabled state for any element, `type=\"button\"` by\n * default, and the spark burst. No visual style of its own beyond\n * `.sp-button-base`; build your own buttons on it.\n */\nexport const ButtonBase = forwardRef<HTMLElement, ButtonBaseProps>(function ButtonBase(\n { as: Component = 'button', render, disabled = false, spark = true, sparkColors, onClick, className, children, type, ...rest },\n ref,\n) {\n const sparkRef = useRef<SparkHandle>(null);\n // A rendered element (link, motion component) is not a native button: no `disabled`/`type`, aria-disabled instead.\n const isButton = Component === 'button' && !render;\n return renderElement(Component, render, {\n ref,\n className: cx('sp-button-base', className),\n 'data-disabled': disabled || undefined,\n disabled: isButton ? disabled : undefined,\n 'aria-disabled': !isButton && disabled ? true : undefined,\n type: isButton ? type ?? 'button' : type,\n onClick: (event: React.MouseEvent<HTMLElement>) => {\n if (disabled) {\n event.preventDefault();\n return;\n }\n if (spark) sparkRef.current?.burst(event);\n onClick?.(event as React.MouseEvent<HTMLButtonElement>);\n },\n ...rest,\n children: (\n <>\n {children}\n {spark && <Spark ref={sparkRef} colors={sparkColors} />}\n </>\n ),\n }, { disabled });\n});\n\nexport default ButtonBase;\n"
23
23
  },
24
24
  {
25
25
  "path": "components/spark-ui/base/InputBase.tsx",
@@ -21,7 +21,7 @@
21
21
  "path": "components/spark-ui/Button/Button.types.ts",
22
22
  "type": "registry:ui",
23
23
  "target": "components/spark-ui/Button/Button.types.ts",
24
- "content": "import { ReactNode, ElementType } from 'react';\nimport { OverrideProps } from '../internal/spark-utils';\n\nexport type ButtonVariant = 'text' | 'outlined' | 'contained';\nexport type ButtonSize = 'small' | 'medium' | 'large';\nexport type ButtonColor = 'brand' | 'error' | 'success' | 'warning';\n\n// Base interface for Button props\nexport interface ButtonPropsBase {\n children?: ReactNode;\n className?: string;\n /** Dead circuit: no clicks, no sparks, dashed outline. */\n disabled?: boolean;\n /** Icon before the label. Coloured with the text. */\n startIcon?: ReactNode;\n /** Icon after the label. Coloured with the text. */\n endIcon?: ReactNode;\n /** Stretch to the container's width. */\n fullWidth?: boolean;\n /** Throw sparks from the press point on click. Default `true`. */\n spark?: boolean;\n /** @deprecated Use `spark`. Kept so existing code keeps working. */\n ripple?: boolean;\n /** Extra classes for each part: root, icon. */\n classNames?: Partial<Record<'root' | 'icon', string>>;\n}\n\n// Type map for Button with default component and props\nexport type ButtonTypeMap<P = {}, D extends ElementType = 'button'> = {\n props: P &\n ButtonPropsBase & {\n /** `contained` (filled, default), `outlined` or `text`. */\n variant?: ButtonVariant;\n /** Tone of the current. Default `brand`. */\n color?: ButtonColor;\n /** Height 36, 44 or 52px. Default `medium`. */\n size?: ButtonSize;\n /** Use with `as=\"a\"` to render a link that looks like a button. */\n href?: string;\n /** Remove the glow around contained buttons. */\n disableElevation?: boolean;\n };\n defaultComponent: D;\n};\n\n// Utility type for polymorphic Button props\nexport type PolymorphicButtonProps<\n D extends ElementType = ButtonTypeMap['defaultComponent'],\n P = {}\n> = OverrideProps<ButtonTypeMap<P, D>, D> & {\n /** Render as another element or component, e.g. `as=\"a\"`. */\n as?: ElementType;\n};\n\n// Slot props for Button (if applicable)\nexport type ButtonSlotProps = {\n root?: PolymorphicButtonProps;\n startIcon?: ReactNode;\n endIcon?: ReactNode;\n};\n\n\nexport type { ElementType, ReactNode };\n"
24
+ "content": "import { ReactNode, ElementType } from 'react';\nimport type { RenderProp } from '../internal/render';\nimport { OverrideProps } from '../internal/spark-utils';\n\n/**\n * Add your own variants (defined in SparkProvider's `components.Button.variants`)\n * and get them type-checked:\n *\n * ```ts\n * declare module '@sparkwire/core' {\n * interface ButtonVariantOverrides { danger: true }\n * }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface ButtonVariantOverrides {}\nexport type ButtonVariant = 'text' | 'outlined' | 'contained' | keyof ButtonVariantOverrides;\nexport type ButtonSize = 'small' | 'medium' | 'large';\nexport type ButtonColor = 'brand' | 'error' | 'success' | 'warning';\n\n// Base interface for Button props\nexport interface ButtonPropsBase {\n children?: ReactNode;\n className?: string;\n /** Dead circuit: no clicks, no sparks, dashed outline. */\n disabled?: boolean;\n /** Icon before the label. Coloured with the text. */\n startIcon?: ReactNode;\n /** Icon after the label. Coloured with the text. */\n endIcon?: ReactNode;\n /** Stretch to the container's width. */\n fullWidth?: boolean;\n /** Throw sparks from the press point on click. Default `true`. */\n spark?: boolean;\n /** @deprecated Use `spark`. Kept so existing code keeps working. */\n ripple?: boolean;\n /** Extra classes for each part: root, icon. */\n classNames?: Partial<Record<'root' | 'icon', string>>;\n /** Render a different element with the button's behaviour and look, e.g. `render={<Link href=\"/pricing\" />}`. */\n render?: RenderProp<{ disabled: boolean }>;\n}\n\n// Type map for Button with default component and props\nexport type ButtonTypeMap<P = {}, D extends ElementType = 'button'> = {\n props: P &\n ButtonPropsBase & {\n /** `contained` (filled, default), `outlined` or `text`. */\n variant?: ButtonVariant;\n /** Tone of the current. Default `brand`. */\n color?: ButtonColor;\n /** Height 36, 44 or 52px. Default `medium`. */\n size?: ButtonSize;\n /** Use with `as=\"a\"` to render a link that looks like a button. */\n href?: string;\n /** Remove the glow around contained buttons. */\n disableElevation?: boolean;\n };\n defaultComponent: D;\n};\n\n// Utility type for polymorphic Button props\nexport type PolymorphicButtonProps<\n D extends ElementType = ButtonTypeMap['defaultComponent'],\n P = {}\n> = OverrideProps<ButtonTypeMap<P, D>, D> & {\n /** Render as another element or component, e.g. `as=\"a\"`. */\n as?: ElementType;\n};\n\n// Slot props for Button (if applicable)\nexport type ButtonSlotProps = {\n root?: PolymorphicButtonProps;\n startIcon?: ReactNode;\n endIcon?: ReactNode;\n};\n\n\nexport type { ElementType, ReactNode };\n"
25
25
  },
26
26
  {
27
27
  "path": "components/spark-ui/Button/index.ts",
package/data/r/card.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "path": "components/spark-ui/Card/Card.tsx",
15
15
  "type": "registry:ui",
16
16
  "target": "components/spark-ui/Card/Card.tsx",
17
- "content": "import React from 'react';\nimport { useMessages } from '../internal/messages';\nimport { cx } from '../internal/cx';\nimport { useDefaults } from '../internal/defaults';\n\n/* ------------------------------------------------------------------- Card */\n\nexport interface CardProps extends React.HTMLAttributes<HTMLElement> {\n /** A live card has current running along its top edge. */\n live?: boolean;\n /** Hover lift and glow, for clickable cards. Put the link or button inside. */\n interactive?: boolean;\n /** Render as another element, e.g. `article` or `section`. */\n as?: 'div' | 'article' | 'section' | 'li';\n /** Inner spacing. Default `medium`. */\n padding?: 'none' | 'small' | 'medium' | 'large';\n}\n\n/**\n * Card: a raised panel. `live` cards carry current; `interactive` cards glow on hover.\n * Style hooks: `.sp-card[data-live][data-interactive][data-padding]`, `__current`.\n */\nexport function Card(inProps: CardProps) {\n const { live = false, interactive = false, as: Tag = 'div', padding = 'medium', className, children, ...rest } = useDefaults('Card', inProps);\n return (\n <Tag\n className={cx('sp-card', className)}\n data-live={live || undefined}\n data-interactive={interactive || undefined}\n data-padding={padding}\n {...rest}\n >\n {live && <span aria-hidden=\"true\" className=\"sp-card__current sp-current\" />}\n {children}\n </Tag>\n );\n}\n\nexport interface CardHeaderProps {\n title: React.ReactNode;\n subtitle?: React.ReactNode;\n /** Shown on the left, e.g. an Avatar or icon. */\n media?: React.ReactNode;\n /** Shown on the right, e.g. a Badge or menu button. */\n action?: React.ReactNode;\n}\n\nexport function CardHeader({ title, subtitle, media, action }: CardHeaderProps) {\n return (\n <div className=\"sp-card__header\">\n {media}\n <div className=\"sp-card__heading\">\n <h3 className=\"sp-card__title\">{title}</h3>\n {subtitle && <p className=\"sp-card__subtitle\">{subtitle}</p>}\n </div>\n {action}\n </div>\n );\n}\n\nexport function CardFooter({ children }: { children: React.ReactNode }) {\n return <div className=\"sp-card__footer\">{children}</div>;\n}\n\n/* --------------------------------------------------------------- Skeleton */\n\nexport interface SkeletonProps {\n /** Number (px) or any CSS length. Defaults to 100%. */\n width?: number | string;\n /** Number (px) or any CSS length. */\n height?: number | string;\n /** `circle` for avatars, `text` for lines of copy. */\n shape?: 'rect' | 'circle' | 'text';\n /** For `text`: number of lines. The last line is shorter. */\n lines?: number;\n}\n\nconst len = (v: number | string | undefined, fallback: string) => (typeof v === 'number' ? `${v}px` : v ?? fallback);\n\n/** Skeleton: a placeholder that shimmers like a line charging up. */\nexport function Skeleton({ width, height, shape = 'rect', lines = 1 }: SkeletonProps) {\n const m = useMessages();\n if (shape === 'text') {\n return (\n <span role=\"status\" aria-label={m.loading} className=\"sp-skeleton-text\" style={{ width: len(width, '100%') }}>\n {Array.from({ length: lines }, (_, i) => (\n <span\n key={i}\n aria-hidden=\"true\"\n className=\"sp-skeleton\"\n style={{ width: i === lines - 1 && lines > 1 ? '60%' : '100%', height: len(height, '0.8rem') }}\n />\n ))}\n </span>\n );\n }\n const size = shape === 'circle' ? width ?? height ?? 40 : undefined;\n const w = len(size ?? width, '100%');\n return (\n <span role=\"status\" aria-label={m.loading} className=\"sp-skeleton-wrap\" style={{ width: w }}>\n <span aria-hidden=\"true\" className=\"sp-skeleton\" data-shape={shape} style={{ width: w, height: len(size ?? height, '1rem') }} />\n </span>\n );\n}\n"
17
+ "content": "import React from 'react';\nimport { renderElement, type RenderProp } from '../internal/render';\nimport { useMessages } from '../internal/messages';\nimport { cx } from '../internal/cx';\nimport { useDefaults } from '../internal/defaults';\n\n/* ------------------------------------------------------------------- Card */\n\nexport interface CardProps extends React.HTMLAttributes<HTMLElement> {\n /** A live card has current running along its top edge. */\n live?: boolean;\n /** Hover lift and glow, for clickable cards. Put the link or button inside. */\n interactive?: boolean;\n /** Render as another element, e.g. `article` or `section`. */\n as?: 'div' | 'article' | 'section' | 'li';\n /** Render any element instead, e.g. `<Link href=\"/p/1\" />` or a motion component. */\n render?: RenderProp<{ live: boolean; interactive: boolean }>;\n /** Inner spacing. Default `medium`. */\n padding?: 'none' | 'small' | 'medium' | 'large';\n}\n\n/**\n * Card: a raised panel. `live` cards carry current; `interactive` cards glow on hover.\n * Style hooks: `.sp-card[data-live][data-interactive][data-padding]`, `__current`.\n */\nexport function Card(inProps: CardProps) {\n const { live = false, interactive = false, as: Tag = 'div', render, padding = 'medium', className, children, ...rest } = useDefaults('Card', inProps);\n return renderElement(Tag, render, {\n className: cx('sp-card', className),\n 'data-live': live || undefined,\n 'data-interactive': interactive || undefined,\n 'data-padding': padding,\n ...rest,\n children: (\n <>\n {live && <span aria-hidden=\"true\" className=\"sp-card__current sp-current\" />}\n {children}\n </>\n ),\n }, { live, interactive });\n}\n\nexport interface CardHeaderProps {\n title: React.ReactNode;\n subtitle?: React.ReactNode;\n /** Shown on the left, e.g. an Avatar or icon. */\n media?: React.ReactNode;\n /** Shown on the right, e.g. a Badge or menu button. */\n action?: React.ReactNode;\n}\n\nexport function CardHeader({ title, subtitle, media, action }: CardHeaderProps) {\n return (\n <div className=\"sp-card__header\">\n {media}\n <div className=\"sp-card__heading\">\n <h3 className=\"sp-card__title\">{title}</h3>\n {subtitle && <p className=\"sp-card__subtitle\">{subtitle}</p>}\n </div>\n {action}\n </div>\n );\n}\n\nexport function CardFooter({ children }: { children: React.ReactNode }) {\n return <div className=\"sp-card__footer\">{children}</div>;\n}\n\n/* --------------------------------------------------------------- Skeleton */\n\nexport interface SkeletonProps {\n /** Number (px) or any CSS length. Defaults to 100%. */\n width?: number | string;\n /** Number (px) or any CSS length. */\n height?: number | string;\n /** `circle` for avatars, `text` for lines of copy. */\n shape?: 'rect' | 'circle' | 'text';\n /** For `text`: number of lines. The last line is shorter. */\n lines?: number;\n}\n\nconst len = (v: number | string | undefined, fallback: string) => (typeof v === 'number' ? `${v}px` : v ?? fallback);\n\n/** Skeleton: a placeholder that shimmers like a line charging up. */\nexport function Skeleton({ width, height, shape = 'rect', lines = 1 }: SkeletonProps) {\n const m = useMessages();\n if (shape === 'text') {\n return (\n <span role=\"status\" aria-label={m.loading} className=\"sp-skeleton-text\" style={{ width: len(width, '100%') }}>\n {Array.from({ length: lines }, (_, i) => (\n <span\n key={i}\n aria-hidden=\"true\"\n className=\"sp-skeleton\"\n style={{ width: i === lines - 1 && lines > 1 ? '60%' : '100%', height: len(height, '0.8rem') }}\n />\n ))}\n </span>\n );\n }\n const size = shape === 'circle' ? width ?? height ?? 40 : undefined;\n const w = len(size ?? width, '100%');\n return (\n <span role=\"status\" aria-label={m.loading} className=\"sp-skeleton-wrap\" style={{ width: w }}>\n <span aria-hidden=\"true\" className=\"sp-skeleton\" data-shape={shape} style={{ width: w, height: len(size ?? height, '1rem') }} />\n </span>\n );\n}\n"
18
18
  },
19
19
  {
20
20
  "path": "components/spark-ui/Card/index.ts",
@@ -14,7 +14,7 @@
14
14
  "path": "components/spark-ui/Indicators/Indicators.tsx",
15
15
  "type": "registry:ui",
16
16
  "target": "components/spark-ui/Indicators/Indicators.tsx",
17
- "content": "import React from 'react';\nimport { useMessages } from '../internal/messages';\nimport { Tone } from '../internal/tone';\nimport { cx } from '../internal/cx';\nimport { useDefaults, slot, ClassNames } from '../internal/defaults';\n\n/* ------------------------------------------------------------------ Badge */\n\nexport interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {\n /** Default `brand`. */\n tone?: Tone | 'neutral';\n /** Show the status LED. Default `true`. */\n led?: boolean;\n /** Pulse the LED: something is live or in progress. */\n pulse?: boolean;\n /** `soft` tinted background (default) or `solid` fill. */\n variant?: 'soft' | 'solid';\n /** Extra classes for each part: root, led. */\n classNames?: ClassNames<'root' | 'led'>;\n}\n\n/** Badge: a status label with an LED. Pulsing means \"live\". Style hooks: `.sp-badge`, `__led`. */\nexport function Badge(inProps: BadgeProps) {\n const { tone = 'brand', led = true, pulse = false, variant = 'soft', className, classNames, children, ...rest } = useDefaults('Badge', inProps);\n return (\n <span\n className={slot('sp-badge', classNames, 'root', className)}\n data-tone={tone}\n data-variant={variant}\n data-pulse={pulse || undefined}\n {...rest}\n >\n {led && <span aria-hidden=\"true\" className={slot('sp-badge__led', classNames, 'led')} />}\n {children}\n </span>\n );\n}\n\n/* --------------------------------------------------------------- Progress */\n\nexport interface ProgressProps {\n /** 0–100. Leave undefined for an indeterminate bar. */\n value?: number;\n /** Text above the bar; also its accessible name when a string. */\n label?: React.ReactNode;\n /** Show the percentage next to the label. Default `true` when determinate. */\n showValue?: boolean;\n /** Default `brand`. */\n tone?: Tone;\n /** Bar thickness: 4, 8 or 12px. Default `medium`. */\n size?: 'small' | 'medium' | 'large';\n}\n\n/**\n * Progress: a charge bar. At 100% the bar is fully charged and current flows.\n * Style hooks: `.sp-progress[data-state=\"charging\"|\"charged\"|\"indeterminate\"]`, `__track`, `__fill`.\n */\nexport function Progress(inProps: ProgressProps) {\n const { value, label, showValue, tone = 'brand', size = 'medium' } = useDefaults('Progress', inProps);\n const v = value === undefined ? undefined : Math.max(0, Math.min(100, value));\n const state = v === undefined ? 'indeterminate' : v === 100 ? 'charged' : 'charging';\n const showNumber = v !== undefined && showValue !== false;\n\n return (\n <div className=\"sp-progress\" data-tone={tone} data-size={size} data-state={state}>\n {(label || showNumber) && (\n <div className=\"sp-progress__header\">\n <span>{label}</span>\n {showNumber && <span className=\"sp-progress__value\">{Math.round(v!)}%</span>}\n </div>\n )}\n <div\n role=\"progressbar\"\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={v}\n aria-label={typeof label === 'string' ? label : undefined}\n className=\"sp-progress__track\"\n >\n {v === undefined ? (\n <span className=\"sp-progress__sweep\" />\n ) : (\n <span className={cx('sp-progress__fill', state === 'charged' && 'sp-current')} style={{ width: `${v}%` }} />\n )}\n </div>\n </div>\n );\n}\n\n/* ---------------------------------------------------------------- Spinner */\n\nexport interface SpinnerProps {\n /** 16, 24 or 36px. Default `medium`. */\n size?: 'small' | 'medium' | 'large';\n /** Default `brand`. */\n tone?: Tone;\n /** Accessible label. Default \"Loading\". */\n label?: string;\n}\n\nconst spinners = { small: 16, medium: 24, large: 36 };\n\n/** Spinner: an arc of current with a spark at its head. Style hooks: `.sp-spinner`, `__track`, `__arc`, `__head`. */\nexport function Spinner(inProps: SpinnerProps) {\n const m = useMessages();\n const { size = 'medium', tone = 'brand', label = m.loading } = useDefaults('Spinner', inProps);\n const s = spinners[size];\n const stroke = Math.max(2, s / 10);\n const r = (s - stroke) / 2;\n const c = 2 * Math.PI * r;\n const a = 0.3 * 2 * Math.PI - Math.PI / 2;\n\n return (\n <span role=\"status\" aria-label={label} className=\"sp-spinner\" data-tone={tone} style={{ width: s, height: s }}>\n <svg width={s} height={s} viewBox={`0 0 ${s} ${s}`} aria-hidden=\"true\">\n <circle className=\"sp-spinner__track\" cx={s / 2} cy={s / 2} r={r} fill=\"none\" strokeWidth={stroke} />\n <circle\n className=\"sp-spinner__arc\"\n cx={s / 2}\n cy={s / 2}\n r={r}\n fill=\"none\"\n strokeWidth={stroke}\n strokeLinecap=\"round\"\n strokeDasharray={`${c * 0.3} ${c}`}\n transform={`rotate(-90 ${s / 2} ${s / 2})`}\n />\n <circle className=\"sp-spinner__head\" cx={s / 2 + r * Math.cos(a)} cy={s / 2 + r * Math.sin(a)} r={stroke * 0.9} />\n </svg>\n </span>\n );\n}\n"
17
+ "content": "import React from 'react';\nimport { renderElement, type RenderProp } from '../internal/render';\nimport { useMessages } from '../internal/messages';\nimport { Tone } from '../internal/tone';\nimport { cx } from '../internal/cx';\nimport { useDefaults, slot, ClassNames } from '../internal/defaults';\n\n/* ------------------------------------------------------------------ Badge */\n\nexport interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {\n /** Default `brand`. */\n tone?: Tone | 'neutral';\n /** Show the status LED. Default `true`. */\n led?: boolean;\n /** Pulse the LED: something is live or in progress. */\n pulse?: boolean;\n /** `soft` tinted background (default) or `solid` fill. */\n variant?: 'soft' | 'solid';\n /** Extra classes for each part: root, led. */\n classNames?: ClassNames<'root' | 'led'>;\n /** Render any element instead, e.g. a link: `render={<a href=\"/inbox\" />}`. */\n render?: RenderProp<{ tone: string }>;\n}\n\n/** Badge: a status label with an LED. Pulsing means \"live\". Style hooks: `.sp-badge`, `__led`. */\nexport function Badge(inProps: BadgeProps) {\n const { tone = 'brand', led = true, pulse = false, variant = 'soft', render, className, classNames, children, ...rest } = useDefaults('Badge', inProps);\n return renderElement('span', render, {\n className: slot('sp-badge', classNames, 'root', className),\n 'data-tone': tone,\n 'data-variant': variant,\n 'data-pulse': pulse || undefined,\n ...rest,\n children: (\n <>\n {led && <span aria-hidden=\"true\" className={slot('sp-badge__led', classNames, 'led')} />}\n {children}\n </>\n ),\n }, { tone });\n}\n\n/* --------------------------------------------------------------- Progress */\n\nexport interface ProgressProps {\n /** 0–100. Leave undefined for an indeterminate bar. */\n value?: number;\n /** Text above the bar; also its accessible name when a string. */\n label?: React.ReactNode;\n /** Show the percentage next to the label. Default `true` when determinate. */\n showValue?: boolean;\n /** Default `brand`. */\n tone?: Tone;\n /** Bar thickness: 4, 8 or 12px. Default `medium`. */\n size?: 'small' | 'medium' | 'large';\n}\n\n/**\n * Progress: a charge bar. At 100% the bar is fully charged and current flows.\n * Style hooks: `.sp-progress[data-state=\"charging\"|\"charged\"|\"indeterminate\"]`, `__track`, `__fill`.\n */\nexport function Progress(inProps: ProgressProps) {\n const { value, label, showValue, tone = 'brand', size = 'medium' } = useDefaults('Progress', inProps);\n const v = value === undefined ? undefined : Math.max(0, Math.min(100, value));\n const state = v === undefined ? 'indeterminate' : v === 100 ? 'charged' : 'charging';\n const showNumber = v !== undefined && showValue !== false;\n\n return (\n <div className=\"sp-progress\" data-tone={tone} data-size={size} data-state={state}>\n {(label || showNumber) && (\n <div className=\"sp-progress__header\">\n <span>{label}</span>\n {showNumber && <span className=\"sp-progress__value\">{Math.round(v!)}%</span>}\n </div>\n )}\n <div\n role=\"progressbar\"\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={v}\n aria-label={typeof label === 'string' ? label : undefined}\n className=\"sp-progress__track\"\n >\n {v === undefined ? (\n <span className=\"sp-progress__sweep\" />\n ) : (\n <span className={cx('sp-progress__fill', state === 'charged' && 'sp-current')} style={{ width: `${v}%` }} />\n )}\n </div>\n </div>\n );\n}\n\n/* ---------------------------------------------------------------- Spinner */\n\nexport interface SpinnerProps {\n /** 16, 24 or 36px. Default `medium`. */\n size?: 'small' | 'medium' | 'large';\n /** Default `brand`. */\n tone?: Tone;\n /** Accessible label. Default \"Loading\". */\n label?: string;\n}\n\nconst spinners = { small: 16, medium: 24, large: 36 };\n\n/** Spinner: an arc of current with a spark at its head. Style hooks: `.sp-spinner`, `__track`, `__arc`, `__head`. */\nexport function Spinner(inProps: SpinnerProps) {\n const m = useMessages();\n const { size = 'medium', tone = 'brand', label = m.loading } = useDefaults('Spinner', inProps);\n const s = spinners[size];\n const stroke = Math.max(2, s / 10);\n const r = (s - stroke) / 2;\n const c = 2 * Math.PI * r;\n const a = 0.3 * 2 * Math.PI - Math.PI / 2;\n\n return (\n <span role=\"status\" aria-label={label} className=\"sp-spinner\" data-tone={tone} style={{ width: s, height: s }}>\n <svg width={s} height={s} viewBox={`0 0 ${s} ${s}`} aria-hidden=\"true\">\n <circle className=\"sp-spinner__track\" cx={s / 2} cy={s / 2} r={r} fill=\"none\" strokeWidth={stroke} />\n <circle\n className=\"sp-spinner__arc\"\n cx={s / 2}\n cy={s / 2}\n r={r}\n fill=\"none\"\n strokeWidth={stroke}\n strokeLinecap=\"round\"\n strokeDasharray={`${c * 0.3} ${c}`}\n transform={`rotate(-90 ${s / 2} ${s / 2})`}\n />\n <circle className=\"sp-spinner__head\" cx={s / 2 + r * Math.cos(a)} cy={s / 2 + r * Math.sin(a)} r={stroke * 0.9} />\n </svg>\n </span>\n );\n}\n"
18
18
  },
19
19
  {
20
20
  "path": "components/spark-ui/Indicators/index.ts",
@@ -35,7 +35,7 @@
35
35
  "path": "components/spark-ui/Provider/SparkProvider.tsx",
36
36
  "type": "registry:ui",
37
37
  "target": "components/spark-ui/Provider/SparkProvider.tsx",
38
- "content": "import React, { useContext, useMemo } from 'react';\nimport { MessagesProvider, type SparkMessagesOverride } from '../internal/messages';\nimport { I18nProvider } from 'react-aria';\nimport { DefaultsContext, DefaultsMap, ComponentConfig } from '../internal/defaults';\nimport type { ButtonTypeMap } from '../Button/Button.types';\nimport type { SwitchProps } from '../Switch';\nimport type { CheckboxProps } from '../Checkbox';\nimport type { TextfieldProps } from '../Textfield';\nimport type { SliderProps } from '../Slider';\nimport type { RadioGroupProps } from '../RadioGroup';\nimport type { TabsProps } from '../Tabs';\nimport type { AccordionProps } from '../Accordion';\nimport type { ModalProps } from '../Modal';\nimport type { TooltipProps } from '../Tooltip';\nimport type { CardProps } from '../Card';\nimport type { BadgeProps, ProgressProps, SpinnerProps } from '../Indicators';\nimport type { AvatarProps } from '../Avatar';\nimport type { DatePickerProps, CalendarProps } from '../DatePicker';\nimport type { SelectProps } from '../Select';\nimport type { DropdownProps } from '../Dropdown';\nimport type { ComboboxProps } from '../Combobox';\nimport type { MenuProps } from '../Menu';\nimport type { FieldProps } from '../Field';\n\n/** App-wide defaults, keyed by component name. */\nexport interface SparkComponentsConfig {\n Button?: ComponentConfig<ButtonTypeMap['props']>;\n Switch?: ComponentConfig<SwitchProps>;\n Checkbox?: ComponentConfig<CheckboxProps>;\n Textfield?: ComponentConfig<TextfieldProps>;\n Slider?: ComponentConfig<SliderProps>;\n RadioGroup?: ComponentConfig<RadioGroupProps>;\n Dropdown?: ComponentConfig<DropdownProps>;\n /** Same component as Dropdown; both keys apply. */\n Select?: ComponentConfig<SelectProps>;\n Combobox?: ComponentConfig<ComboboxProps>;\n Menu?: ComponentConfig<MenuProps>;\n DataTable?: ComponentConfig<Record<string, unknown>>;\n DateRangePicker?: ComponentConfig<Record<string, unknown>>;\n CommandPalette?: ComponentConfig<Record<string, unknown>>;\n Drawer?: ComponentConfig<Record<string, unknown>>;\n Sidebar?: ComponentConfig<Record<string, unknown>>;\n NumberField?: ComponentConfig<Record<string, unknown>>;\n Textarea?: ComponentConfig<Record<string, unknown>>;\n Alert?: ComponentConfig<Record<string, unknown>>;\n Breadcrumbs?: ComponentConfig<Record<string, unknown>>;\n Pagination?: ComponentConfig<Record<string, unknown>>;\n ToggleGroup?: ComponentConfig<Record<string, unknown>>;\n Stepper?: ComponentConfig<Record<string, unknown>>;\n FileUpload?: ComponentConfig<Record<string, unknown>>;\n TimePicker?: ComponentConfig<Record<string, unknown>>;\n LineChart?: ComponentConfig<Record<string, unknown>>;\n BarChart?: ComponentConfig<Record<string, unknown>>;\n DonutChart?: ComponentConfig<Record<string, unknown>>;\n Sparkline?: ComponentConfig<Record<string, unknown>>;\n RangeCalendar?: ComponentConfig<Record<string, unknown>>;\n Field?: ComponentConfig<FieldProps>;\n Tabs?: ComponentConfig<TabsProps>;\n Accordion?: ComponentConfig<AccordionProps>;\n Modal?: ComponentConfig<ModalProps>;\n Tooltip?: ComponentConfig<TooltipProps>;\n Card?: ComponentConfig<CardProps>;\n Badge?: ComponentConfig<BadgeProps>;\n Progress?: ComponentConfig<ProgressProps>;\n Spinner?: ComponentConfig<SpinnerProps>;\n Avatar?: ComponentConfig<AvatarProps>;\n DatePicker?: ComponentConfig<DatePickerProps>;\n Calendar?: ComponentConfig<CalendarProps>;\n}\n\nexport interface SparkProviderProps {\n /**\n * Defaults for every instance of a component, e.g.\n * `{ Button: { defaultProps: { variant: 'outlined' } }, Switch: { classNames: { bulb: 'my-bulb' } } }`.\n * Props set on an instance always win.\n */\n components?: SparkComponentsConfig;\n /**\n * BCP 47 locale for dates, number formats and keyboard direction, e.g.\n * `hi-IN`, `ar-EG`, `en-US`. Right-to-left locales mirror arrow keys.\n * Defaults to the parent provider's, then the browser's.\n */\n locale?: string;\n /**\n * How lively the UI is: `calm` (slow current, soft glow, few sparks),\n * `default`, `electric` (fast current, bloom, big bursts) or `off`\n * (no decorative motion). Reduced-motion users always get `off`.\n * Sets `data-spark-energy` on a wrapper; you can also put that\n * attribute on `<html>` yourself.\n */\n energy?: 'off' | 'calm' | 'default' | 'electric';\n /**\n * Override any built-in text, or add a language: `{ close: 'Fermer', page: (n) => `Page ${n}` }`.\n * Hindi, Gujarati and Tamil are built in and follow `locale`.\n */\n messages?: SparkMessagesOverride;\n /** Short vibrations on Switch, Checkbox and spark bursts (phones that support it). Default `false`. */\n haptics?: boolean;\n children: React.ReactNode;\n}\n\n/**\n * SparkProvider: set app-wide defaults and slot class names once, the way\n * MUI's `theme.components` works. Nested providers merge with their parent.\n * Styling still comes from `styles.css`; this provider only changes props.\n */\nexport function SparkProvider({ components, locale, energy, haptics, messages, children }: SparkProviderProps) {\n const parent = useContext(DefaultsContext);\n const value = useMemo<DefaultsMap>(() => {\n if (!components) return parent;\n const next: DefaultsMap = { ...parent };\n for (const [name, cfg] of Object.entries(components) as [string, ComponentConfig][]) {\n const up = parent[name];\n next[name] = {\n defaultProps: { ...up?.defaultProps, ...cfg.defaultProps },\n classNames: { ...up?.classNames, ...cfg.classNames },\n };\n }\n return next;\n }, [parent, components]);\n let tree = <DefaultsContext.Provider value={value}>{children}</DefaultsContext.Provider>;\n if (messages) tree = <MessagesProvider value={messages}>{tree}</MessagesProvider>;\n if (energy !== undefined || haptics !== undefined)\n tree = (\n <div className=\"sp-energy\" data-spark-energy={energy} data-spark-haptics={haptics === undefined ? undefined : haptics ? 'on' : 'off'}>\n {tree}\n </div>\n );\n return locale ? <I18nProvider locale={locale}>{tree}</I18nProvider> : tree;\n}\n\nexport default SparkProvider;\n"
38
+ "content": "import React, { useContext, useMemo } from 'react';\nimport { MessagesProvider, type SparkMessagesOverride } from '../internal/messages';\nimport { I18nProvider } from 'react-aria';\nimport { DefaultsContext, DefaultsMap, ComponentConfig } from '../internal/defaults';\nimport type { ButtonTypeMap } from '../Button/Button.types';\nimport type { SwitchProps } from '../Switch';\nimport type { CheckboxProps } from '../Checkbox';\nimport type { TextfieldProps } from '../Textfield';\nimport type { SliderProps } from '../Slider';\nimport type { RadioGroupProps } from '../RadioGroup';\nimport type { TabsProps } from '../Tabs';\nimport type { AccordionProps } from '../Accordion';\nimport type { ModalProps } from '../Modal';\nimport type { TooltipProps } from '../Tooltip';\nimport type { CardProps } from '../Card';\nimport type { BadgeProps, ProgressProps, SpinnerProps } from '../Indicators';\nimport type { AvatarProps } from '../Avatar';\nimport type { DatePickerProps, CalendarProps } from '../DatePicker';\nimport type { SelectProps } from '../Select';\nimport type { DropdownProps } from '../Dropdown';\nimport type { ComboboxProps } from '../Combobox';\nimport type { MenuProps } from '../Menu';\nimport type { FieldProps } from '../Field';\n\n/** App-wide defaults, keyed by component name. */\nexport interface SparkComponentsConfig {\n Button?: ComponentConfig<ButtonTypeMap['props']>;\n Switch?: ComponentConfig<SwitchProps>;\n Checkbox?: ComponentConfig<CheckboxProps>;\n Textfield?: ComponentConfig<TextfieldProps>;\n Slider?: ComponentConfig<SliderProps>;\n RadioGroup?: ComponentConfig<RadioGroupProps>;\n Dropdown?: ComponentConfig<DropdownProps>;\n /** Same component as Dropdown; both keys apply. */\n Select?: ComponentConfig<SelectProps>;\n Combobox?: ComponentConfig<ComboboxProps>;\n Menu?: ComponentConfig<MenuProps>;\n DataTable?: ComponentConfig<Record<string, unknown>>;\n DateRangePicker?: ComponentConfig<Record<string, unknown>>;\n CommandPalette?: ComponentConfig<Record<string, unknown>>;\n Drawer?: ComponentConfig<Record<string, unknown>>;\n Sidebar?: ComponentConfig<Record<string, unknown>>;\n NumberField?: ComponentConfig<Record<string, unknown>>;\n Textarea?: ComponentConfig<Record<string, unknown>>;\n Alert?: ComponentConfig<Record<string, unknown>>;\n Breadcrumbs?: ComponentConfig<Record<string, unknown>>;\n Pagination?: ComponentConfig<Record<string, unknown>>;\n ToggleGroup?: ComponentConfig<Record<string, unknown>>;\n Stepper?: ComponentConfig<Record<string, unknown>>;\n FileUpload?: ComponentConfig<Record<string, unknown>>;\n TimePicker?: ComponentConfig<Record<string, unknown>>;\n LineChart?: ComponentConfig<Record<string, unknown>>;\n BarChart?: ComponentConfig<Record<string, unknown>>;\n DonutChart?: ComponentConfig<Record<string, unknown>>;\n Sparkline?: ComponentConfig<Record<string, unknown>>;\n RangeCalendar?: ComponentConfig<Record<string, unknown>>;\n Field?: ComponentConfig<FieldProps>;\n Tabs?: ComponentConfig<TabsProps>;\n Accordion?: ComponentConfig<AccordionProps>;\n Modal?: ComponentConfig<ModalProps>;\n Tooltip?: ComponentConfig<TooltipProps>;\n Card?: ComponentConfig<CardProps>;\n Badge?: ComponentConfig<BadgeProps>;\n Progress?: ComponentConfig<ProgressProps>;\n Spinner?: ComponentConfig<SpinnerProps>;\n Avatar?: ComponentConfig<AvatarProps>;\n DatePicker?: ComponentConfig<DatePickerProps>;\n Calendar?: ComponentConfig<CalendarProps>;\n}\n\nexport interface SparkProviderProps {\n /**\n * Defaults for every instance of a component, e.g.\n * `{ Button: { defaultProps: { variant: 'outlined' } }, Switch: { classNames: { bulb: 'my-bulb' } } }`.\n * Props set on an instance always win.\n */\n components?: SparkComponentsConfig;\n /**\n * BCP 47 locale for dates, number formats and keyboard direction, e.g.\n * `hi-IN`, `ar-EG`, `en-US`. Right-to-left locales mirror arrow keys.\n * Defaults to the parent provider's, then the browser's.\n */\n locale?: string;\n /**\n * How lively the UI is: `calm` (slow current, soft glow, few sparks),\n * `default`, `electric` (fast current, bloom, big bursts) or `off`\n * (no decorative motion). Reduced-motion users always get `off`.\n * Sets `data-spark-energy` on a wrapper; you can also put that\n * attribute on `<html>` yourself.\n */\n energy?: 'off' | 'calm' | 'default' | 'electric';\n /**\n * Override any built-in text, or add a language: `{ close: 'Fermer', page: (n) => `Page ${n}` }`.\n * Hindi, Gujarati and Tamil are built in and follow `locale`.\n */\n messages?: SparkMessagesOverride;\n /** Short vibrations on Switch, Checkbox and spark bursts (phones that support it). Default `false`. */\n haptics?: boolean;\n children: React.ReactNode;\n}\n\n/**\n * SparkProvider: set app-wide defaults and slot class names once, the way\n * MUI's `theme.components` works. Nested providers merge with their parent.\n * Styling still comes from `styles.css`; this provider only changes props.\n */\nexport function SparkProvider({ components, locale, energy, haptics, messages, children }: SparkProviderProps) {\n const parent = useContext(DefaultsContext);\n const value = useMemo<DefaultsMap>(() => {\n if (!components) return parent;\n const next: DefaultsMap = { ...parent };\n for (const [name, cfg] of Object.entries(components) as [string, ComponentConfig][]) {\n const up = parent[name];\n next[name] = {\n defaultProps: { ...up?.defaultProps, ...cfg.defaultProps },\n classNames: { ...up?.classNames, ...cfg.classNames },\n // Parent variants first, so a nested provider's variants apply after (and win).\n variants: [...(up?.variants ?? []), ...(cfg.variants ?? [])],\n };\n }\n return next;\n }, [parent, components]);\n let tree = <DefaultsContext.Provider value={value}>{children}</DefaultsContext.Provider>;\n if (messages) tree = <MessagesProvider value={messages}>{tree}</MessagesProvider>;\n if (energy !== undefined || haptics !== undefined)\n tree = (\n <div className=\"sp-energy\" data-spark-energy={energy} data-spark-haptics={haptics === undefined ? undefined : haptics ? 'on' : 'off'}>\n {tree}\n </div>\n );\n return locale ? <I18nProvider locale={locale}>{tree}</I18nProvider> : tree;\n}\n\nexport default SparkProvider;\n"
39
39
  },
40
40
  {
41
41
  "path": "components/spark-ui/Provider/index.ts",
package/data/r/utils.json CHANGED
@@ -21,7 +21,7 @@
21
21
  "path": "components/spark-ui/internal/defaults.ts",
22
22
  "type": "registry:lib",
23
23
  "target": "components/spark-ui/internal/defaults.ts",
24
- "content": "import { createContext, useContext } from 'react';\nimport { cx } from './cx';\n\n/** Per-slot class names, e.g. `{ root: 'my-switch', bulb: 'my-bulb' }`. */\nexport type ClassNames<Slot extends string> = Partial<Record<Slot, string>>;\n\nexport interface ComponentConfig<P = Record<string, unknown>> {\n /** Props applied when the component doesn't set them itself. */\n defaultProps?: Partial<P>;\n /** Extra class names for named parts. `root` is the outer element. */\n classNames?: Record<string, string>;\n}\n\nexport type DefaultsMap = Record<string, ComponentConfig | undefined>;\n\nexport const DefaultsContext = createContext<DefaultsMap>({});\n\n/**\n * Merge app-wide defaults (from SparkProvider) under a component's own props.\n * Props passed directly always win; class names from both sources are joined.\n */\nexport function useDefaults<P extends object>(name: string, props: P): P {\n const config = useContext(DefaultsContext)[name];\n if (!config) return props;\n const merged: Record<string, unknown> = { ...config.defaultProps };\n for (const [k, v] of Object.entries(props)) if (v !== undefined) merged[k] = v;\n\n const own = (props as { classNames?: Record<string, string> }).classNames;\n if (config.classNames || own) {\n const keys = new Set([...Object.keys(config.classNames ?? {}), ...Object.keys(own ?? {})]);\n const joined: Record<string, string> = {};\n keys.forEach((k) => (joined[k] = cx(config.classNames?.[k], own?.[k])));\n merged.classNames = joined;\n }\n return merged as P;\n}\n\n/** Class for one part: the base class, then app-wide and per-instance additions. */\nexport const slot = <S extends string>(base: string, classNames: ClassNames<S> | undefined, name: S, ...extra: Array<string | false | null | undefined>) =>\n cx(base, classNames?.[name], ...extra);\n"
24
+ "content": "import { createContext, useContext } from 'react';\nimport { cx } from './cx';\n\n/** Per-slot class names, e.g. `{ root: 'my-switch', bulb: 'my-bulb' }`. */\nexport type ClassNames<Slot extends string> = Partial<Record<Slot, string>>;\n\nexport interface ComponentConfig<P = Record<string, unknown>> {\n /** Props applied when the component doesn't set them itself. */\n defaultProps?: Partial<P>;\n /** Extra class names for named parts. `root` is the outer element. */\n classNames?: Record<string, string>;\n /**\n * Named looks defined once for the whole app. A variant applies when every\n * prop in `match` equals the component's prop; it can set props (which win\n * over the matched ones), a root class, and classes for parts.\n *\n * ```ts\n * Button: { variants: [\n * { match: { variant: 'danger' }, props: { variant: 'contained', color: 'error' }, className: 'btn-danger' },\n * { match: { size: 'large', variant: 'outlined' }, classNames: { icon: 'big-icon' } },\n * ] }\n * ```\n */\n variants?: Array<ComponentVariant<P>>;\n}\n\nexport interface ComponentVariant<P = Record<string, unknown>> {\n /** Props to match, e.g. `{ variant: 'danger' }`. All must be equal. */\n match: Partial<Record<Extract<keyof P, string>, unknown>> & Record<string, unknown>;\n /** Props this variant sets. They win over the matched props, so a custom value can map to a built-in one. */\n props?: Partial<P> & Record<string, unknown>;\n /** Extra class on the root element. */\n className?: string;\n /** Extra classes for named parts. */\n classNames?: Record<string, string>;\n}\n\nexport type DefaultsMap = Record<string, ComponentConfig | undefined>;\n\nexport const DefaultsContext = createContext<DefaultsMap>({});\n\n/**\n * Merge app-wide defaults (from SparkProvider) under a component's own props.\n * Props passed directly always win; class names from both sources are joined.\n */\nexport function useDefaults<P extends object>(name: string, props: P): P {\n const config = useContext(DefaultsContext)[name];\n if (!config) return props;\n const merged: Record<string, unknown> = { ...config.defaultProps };\n for (const [k, v] of Object.entries(props)) if (v !== undefined) merged[k] = v;\n\n // Variants are matched against the props as given (defaults included), before any variant applies.\n const hits = (config.variants ?? []).filter((v) => Object.entries(v.match).every(([k, want]) => merged[k] === want));\n\n const own = (props as { classNames?: Record<string, string> }).classNames;\n const layers = [config.classNames, ...hits.map((h) => h.classNames), own].filter(Boolean) as Array<Record<string, string>>;\n if (layers.length) {\n const keys = new Set(layers.flatMap((l) => Object.keys(l)));\n const joined: Record<string, string> = {};\n keys.forEach((k) => (joined[k] = cx(...layers.map((l) => l[k]))));\n merged.classNames = joined;\n }\n for (const h of hits) {\n if (h.props) Object.assign(merged, h.props);\n if (h.className) merged.className = cx(merged.className as string | undefined, h.className);\n }\n return merged as P;\n}\n\n/** Class for one part: the base class, then app-wide and per-instance additions. */\nexport const slot = <S extends string>(base: string, classNames: ClassNames<S> | undefined, name: S, ...extra: Array<string | false | null | undefined>) =>\n cx(base, classNames?.[name], ...extra);\n"
25
25
  },
26
26
  {
27
27
  "path": "components/spark-ui/internal/energy.ts",
@@ -35,6 +35,12 @@
35
35
  "target": "components/spark-ui/internal/messages.tsx",
36
36
  "content": "import React, { createContext, useContext, useMemo } from 'react';\nimport { useLocale } from 'react-aria';\n\n/**\n * Every piece of text Spark UI writes itself: button labels, screen-reader\n * names, empty states, file-upload errors. Components pick the table for the\n * current locale (`SparkProvider locale=\"hi-IN\"`), and `SparkProvider\n * messages={{ … }}` overrides any key, so you can fix a wording or add a\n * language without waiting for a release.\n *\n * Numbers inside messages arrive already formatted for the locale, so\n * `hi-IN-u-nu-deva` gives Devanagari digits.\n */\nexport interface SparkMessages {\n close: string;\n dismiss: string;\n clear: string;\n loading: string;\n noResults: string;\n noOptions: string;\n selectPlaceholder: string;\n search: string;\n searchNamed: (name: string) => string;\n notifications: string;\n dismissNotification: string;\n // navigation\n breadcrumb: string;\n moreItems: (n: string) => string;\n pagination: string;\n previousPage: string;\n nextPage: string;\n page: (n: string) => string;\n pageOf: (page: string, count: string) => string;\n rowsPerPage: string;\n mainNavigation: string;\n expandSidebar: string;\n collapseSidebar: string;\n progress: string;\n stepOf: (n: string, total: string) => string;\n stepStatus: { complete: string; current: string; upcoming: string; error: string };\n // dates and times\n today: string;\n thisWeek: string;\n thisMonth: string;\n thisYear: string;\n /** \"Next 7 days\": `amount` is already a localized \"7 days\". */\n nextAmount: (amount: string) => string;\n lastAmount: (amount: string) => string;\n clearDate: string;\n clearDates: string;\n clearTime: string;\n showTimes: string;\n times: string;\n // command palette\n commandPalette: string;\n commandPlaceholder: string;\n commands: string;\n searchCommands: string;\n // file upload\n dropFiles: (multiple: boolean) => string;\n browse: string;\n files: string;\n uploaded: string;\n uploading: (name: string) => string;\n uploadFailed: string;\n remove: (name: string) => string;\n fileTypeRejected: (name: string) => string;\n fileTooLarge: (name: string, max: string) => string;\n tooManyFiles: (name: string, max: string) => string;\n upTo: (size: string) => string;\n maxFiles: (n: string) => string;\n // data display\n dataTable: string;\n series: string;\n chart: string;\n total: string;\n}\n\nconst en: SparkMessages = {\n close: 'Close',\n dismiss: 'Dismiss',\n clear: 'Clear',\n loading: 'Loading',\n noResults: 'No results',\n noOptions: 'No options',\n selectPlaceholder: 'Select an option',\n search: 'Search…',\n searchNamed: (name) => `Search ${name}`,\n notifications: 'Notifications',\n dismissNotification: 'Dismiss notification',\n breadcrumb: 'Breadcrumb',\n moreItems: (n) => `${n} more`,\n pagination: 'Pagination',\n previousPage: 'Previous page',\n nextPage: 'Next page',\n page: (n) => `Page ${n}`,\n pageOf: (p, c) => `Page ${p} of ${c}`,\n rowsPerPage: 'Rows per page',\n mainNavigation: 'Main',\n expandSidebar: 'Expand sidebar',\n collapseSidebar: 'Collapse sidebar',\n progress: 'Progress',\n stepOf: (n, t) => `Step ${n} of ${t}`,\n stepStatus: { complete: 'completed', current: 'current', upcoming: 'not started', error: 'has an error' },\n today: 'Today',\n thisWeek: 'This week',\n thisMonth: 'This month',\n thisYear: 'This year',\n nextAmount: (a) => `Next ${a}`,\n lastAmount: (a) => `Last ${a}`,\n clearDate: 'Clear date',\n clearDates: 'Clear dates',\n clearTime: 'Clear time',\n showTimes: 'Show times',\n times: 'Times',\n commandPalette: 'Command palette',\n commandPlaceholder: 'Type a command or search…',\n commands: 'Commands',\n searchCommands: 'Search commands',\n dropFiles: (m) => (m ? 'Drop files here or' : 'Drop a file here or'),\n browse: 'browse',\n files: 'Files',\n uploaded: 'Uploaded',\n uploading: (name) => `Uploading ${name}`,\n uploadFailed: 'Upload failed',\n remove: (name) => `Remove ${name}`,\n fileTypeRejected: (name) => `${name}: this file type isn't accepted.`,\n fileTooLarge: (name, max) => `${name}: larger than ${max}.`,\n tooManyFiles: (name, max) => `${name}: you can add up to ${max} files.`,\n upTo: (s) => `up to ${s}`,\n maxFiles: (n) => `max ${n} files`,\n dataTable: 'Data table',\n series: 'Series',\n chart: 'Chart',\n total: 'Total',\n};\n\nconst hi: SparkMessages = {\n close: 'बंद करें',\n dismiss: 'हटाएँ',\n clear: 'साफ़ करें',\n loading: 'लोड हो रहा है',\n noResults: 'कोई परिणाम नहीं',\n noOptions: 'कोई विकल्प नहीं',\n selectPlaceholder: 'एक विकल्प चुनें',\n search: 'खोजें…',\n searchNamed: (name) => `${name} में खोजें`,\n notifications: 'सूचनाएँ',\n dismissNotification: 'सूचना हटाएँ',\n breadcrumb: 'ब्रेडक्रंब',\n moreItems: (n) => `${n} और`,\n pagination: 'पेज नेविगेशन',\n previousPage: 'पिछला पेज',\n nextPage: 'अगला पेज',\n page: (n) => `पेज ${n}`,\n pageOf: (p, c) => `पेज ${p} / ${c}`,\n rowsPerPage: 'प्रति पेज पंक्तियाँ',\n mainNavigation: 'मुख्य',\n expandSidebar: 'साइडबार खोलें',\n collapseSidebar: 'साइडबार छोटा करें',\n progress: 'प्रगति',\n stepOf: (n, t) => `चरण ${n} / ${t}`,\n stepStatus: { complete: 'पूरा', current: 'वर्तमान', upcoming: 'शुरू नहीं हुआ', error: 'त्रुटि है' },\n today: 'आज',\n thisWeek: 'इस सप्ताह',\n thisMonth: 'इस महीने',\n thisYear: 'इस वर्ष',\n nextAmount: (a) => `अगले ${a}`,\n lastAmount: (a) => `पिछले ${a}`,\n clearDate: 'तारीख साफ़ करें',\n clearDates: 'तारीखें साफ़ करें',\n clearTime: 'समय साफ़ करें',\n showTimes: 'समय दिखाएँ',\n times: 'समय',\n commandPalette: 'कमांड पैलेट',\n commandPlaceholder: 'कमांड लिखें या खोजें…',\n commands: 'कमांड',\n searchCommands: 'कमांड खोजें',\n dropFiles: (m) => (m ? 'फ़ाइलें यहाँ छोड़ें या' : 'फ़ाइल यहाँ छोड़ें या'),\n browse: 'चुनें',\n files: 'फ़ाइलें',\n uploaded: 'अपलोड हो गया',\n uploading: (name) => `${name} अपलोड हो रही है`,\n uploadFailed: 'अपलोड विफल रहा',\n remove: (name) => `${name} हटाएँ`,\n fileTypeRejected: (name) => `${name}: इस प्रकार की फ़ाइल स्वीकार नहीं है।`,\n fileTooLarge: (name, max) => `${name}: ${max} से बड़ी है।`,\n tooManyFiles: (name, max) => `${name}: आप अधिकतम ${max} फ़ाइलें जोड़ सकते हैं।`,\n upTo: (s) => `${s} तक`,\n maxFiles: (n) => `अधिकतम ${n} फ़ाइलें`,\n dataTable: 'डेटा तालिका',\n series: 'शृंखला',\n chart: 'चार्ट',\n total: 'कुल',\n};\n\nconst gu: SparkMessages = {\n close: 'બંધ કરો',\n dismiss: 'દૂર કરો',\n clear: 'સાફ કરો',\n loading: 'લોડ થઈ રહ્યું છે',\n noResults: 'કોઈ પરિણામ નથી',\n noOptions: 'કોઈ વિકલ્પ નથી',\n selectPlaceholder: 'એક વિકલ્પ પસંદ કરો',\n search: 'શોધો…',\n searchNamed: (name) => `${name}માં શોધો`,\n notifications: 'સૂચનાઓ',\n dismissNotification: 'સૂચના દૂર કરો',\n breadcrumb: 'બ્રેડક્રમ્બ',\n moreItems: (n) => `${n} વધુ`,\n pagination: 'પેજ નેવિગેશન',\n previousPage: 'પાછલું પેજ',\n nextPage: 'આગલું પેજ',\n page: (n) => `પેજ ${n}`,\n pageOf: (p, c) => `પેજ ${p} / ${c}`,\n rowsPerPage: 'પેજ દીઠ પંક્તિઓ',\n mainNavigation: 'મુખ્ય',\n expandSidebar: 'સાઇડબાર ખોલો',\n collapseSidebar: 'સાઇડબાર નાનું કરો',\n progress: 'પ્રગતિ',\n stepOf: (n, t) => `પગલું ${n} / ${t}`,\n stepStatus: { complete: 'પૂર્ણ', current: 'હાલનું', upcoming: 'શરૂ થયું નથી', error: 'ભૂલ છે' },\n today: 'આજે',\n thisWeek: 'આ અઠવાડિયે',\n thisMonth: 'આ મહિને',\n thisYear: 'આ વર્ષે',\n nextAmount: (a) => `આગામી ${a}`,\n lastAmount: (a) => `છેલ્લા ${a}`,\n clearDate: 'તારીખ સાફ કરો',\n clearDates: 'તારીખો સાફ કરો',\n clearTime: 'સમય સાફ કરો',\n showTimes: 'સમય બતાવો',\n times: 'સમય',\n commandPalette: 'કમાન્ડ પેલેટ',\n commandPlaceholder: 'કમાન્ડ લખો અથવા શોધો…',\n commands: 'કમાન્ડ',\n searchCommands: 'કમાન્ડ શોધો',\n dropFiles: (m) => (m ? 'ફાઇલો અહીં મૂકો અથવા' : 'ફાઇલ અહીં મૂકો અથવા'),\n browse: 'પસંદ કરો',\n files: 'ફાઇલો',\n uploaded: 'અપલોડ થઈ ગયું',\n uploading: (name) => `${name} અપલોડ થઈ રહી છે`,\n uploadFailed: 'અપલોડ નિષ્ફળ ગયું',\n remove: (name) => `${name} દૂર કરો`,\n fileTypeRejected: (name) => `${name}: આ પ્રકારની ફાઇલ સ્વીકાર્ય નથી.`,\n fileTooLarge: (name, max) => `${name}: ${max}થી મોટી છે.`,\n tooManyFiles: (name, max) => `${name}: તમે વધુમાં વધુ ${max} ફાઇલો ઉમેરી શકો છો.`,\n upTo: (s) => `${s} સુધી`,\n maxFiles: (n) => `વધુમાં વધુ ${n} ફાઇલો`,\n dataTable: 'ડેટા કોષ્ટક',\n series: 'શ્રેણી',\n chart: 'ચાર્ટ',\n total: 'કુલ',\n};\n\nconst ta: SparkMessages = {\n close: 'மூடு',\n dismiss: 'நிராகரி',\n clear: 'அழி',\n loading: 'ஏற்றுகிறது',\n noResults: 'முடிவுகள் இல்லை',\n noOptions: 'விருப்பங்கள் இல்லை',\n selectPlaceholder: 'ஒரு விருப்பத்தைத் தேர்ந்தெடுக்கவும்',\n search: 'தேடு…',\n searchNamed: (name) => `${name} இல் தேடு`,\n notifications: 'அறிவிப்புகள்',\n dismissNotification: 'அறிவிப்பை நிராகரி',\n breadcrumb: 'பிரெட்க்ரம்ப்',\n moreItems: (n) => `மேலும் ${n}`,\n pagination: 'பக்க வழிசெலுத்தல்',\n previousPage: 'முந்தைய பக்கம்',\n nextPage: 'அடுத்த பக்கம்',\n page: (n) => `பக்கம் ${n}`,\n pageOf: (p, c) => `பக்கம் ${p} / ${c}`,\n rowsPerPage: 'ஒரு பக்கத்திற்கான வரிசைகள்',\n mainNavigation: 'முதன்மை',\n expandSidebar: 'பக்கப்பட்டியை விரி',\n collapseSidebar: 'பக்கப்பட்டியைச் சுருக்கு',\n progress: 'முன்னேற்றம்',\n stepOf: (n, t) => `படி ${n} / ${t}`,\n stepStatus: { complete: 'முடிந்தது', current: 'தற்போதைய', upcoming: 'தொடங்கவில்லை', error: 'பிழை உள்ளது' },\n today: 'இன்று',\n thisWeek: 'இந்த வாரம்',\n thisMonth: 'இந்த மாதம்',\n thisYear: 'இந்த ஆண்டு',\n nextAmount: (a) => `அடுத்த ${a}`,\n lastAmount: (a) => `கடந்த ${a}`,\n clearDate: 'தேதியை அழி',\n clearDates: 'தேதிகளை அழி',\n clearTime: 'நேரத்தை அழி',\n showTimes: 'நேரங்களைக் காட்டு',\n times: 'நேரங்கள்',\n commandPalette: 'கட்டளைத் தட்டு',\n commandPlaceholder: 'கட்டளையை உள்ளிடவும் அல்லது தேடவும்…',\n commands: 'கட்டளைகள்',\n searchCommands: 'கட்டளைகளைத் தேடு',\n dropFiles: (m) => (m ? 'கோப்புகளை இங்கே விடவும் அல்லது' : 'கோப்பை இங்கே விடவும் அல்லது'),\n browse: 'தேர்ந்தெடு',\n files: 'கோப்புகள்',\n uploaded: 'பதிவேற்றப்பட்டது',\n uploading: (name) => `${name} பதிவேற்றப்படுகிறது`,\n uploadFailed: 'பதிவேற்றம் தோல்வியடைந்தது',\n remove: (name) => `${name} ஐ நீக்கு`,\n fileTypeRejected: (name) => `${name}: இந்த வகைக் கோப்பு ஏற்கப்படாது.`,\n fileTooLarge: (name, max) => `${name}: ${max} ஐ விடப் பெரியது.`,\n tooManyFiles: (name, max) => `${name}: அதிகபட்சம் ${max} கோப்புகளைச் சேர்க்கலாம்.`,\n upTo: (s) => `${s} வரை`,\n maxFiles: (n) => `அதிகபட்சம் ${n} கோப்புகள்`,\n dataTable: 'தரவு அட்டவணை',\n series: 'தொடர்',\n chart: 'விளக்கப்படம்',\n total: 'மொத்தம்',\n};\n\n/** Built-in tables by language. Add your own with `SparkProvider messages`. */\nexport const builtInMessages: Record<string, SparkMessages> = { en, hi, gu, ta };\n\n/** Partial override: plain keys, plus a partial `stepStatus`. */\nexport type SparkMessagesOverride = Partial<Omit<SparkMessages, 'stepStatus'>> & { stepStatus?: Partial<SparkMessages['stepStatus']> };\n\nexport const MessagesContext = createContext<SparkMessagesOverride | null>(null);\n\n/** Text for the current locale, with any SparkProvider overrides applied. */\nexport function useMessages(): SparkMessages & { locale: string; num: (n: number) => string } {\n const { locale } = useLocale();\n const override = useContext(MessagesContext);\n return useMemo(() => {\n const base = builtInMessages[locale.split('-')[0].toLowerCase()] ?? en;\n const fmt = new Intl.NumberFormat(locale);\n return {\n ...base,\n ...override,\n stepStatus: { ...base.stepStatus, ...override?.stepStatus },\n locale,\n num: (n: number) => fmt.format(n),\n } as SparkMessages & { locale: string; num: (n: number) => string };\n }, [locale, override]);\n}\n\n/** Wraps children with message overrides (used by SparkProvider). */\nexport function MessagesProvider({ value, children }: { value: SparkMessagesOverride; children: React.ReactNode }) {\n const parent = useContext(MessagesContext);\n const merged = useMemo(() => ({ ...parent, ...value, stepStatus: { ...parent?.stepStatus, ...value.stepStatus } }), [parent, value]);\n return <MessagesContext.Provider value={merged}>{children}</MessagesContext.Provider>;\n}\n"
37
37
  },
38
+ {
39
+ "path": "components/spark-ui/internal/render.tsx",
40
+ "type": "registry:lib",
41
+ "target": "components/spark-ui/internal/render.tsx",
42
+ "content": "import React, { cloneElement, createElement, isValidElement } from 'react';\nimport { mergeProps, mergeRefs } from 'react-aria';\n\n/**\n * Swap the element a component renders, keeping its behaviour and styling:\n *\n * ```tsx\n * <Button render={<Link href=\"/pricing\" />}>Pricing</Button> // Next.js link styled as a button\n * <Card render={<motion.article layout />}>…</Card> // animated card\n * <Badge render={(props, state) => <a href=\"/inbox\" {...props} />}>3</Badge>\n * ```\n *\n * An element gets the component's props merged in: class names are joined,\n * styles combined, event handlers chained (both run) and refs merged. A\n * function receives the props and the component's state and returns the\n * element itself, for full control.\n */\nexport type RenderProp<State = Record<string, unknown>> =\n | React.ReactElement\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | ((props: React.HTMLAttributes<any> & { ref?: React.Ref<any> }, state: State) => React.ReactElement);\n\n/** The ref an element was created with (React 19 keeps it in props, React 18 on the element). */\nfunction elementRef(el: React.ReactElement): React.Ref<unknown> | undefined {\n const props = el.props as { ref?: React.Ref<unknown> };\n return props.ref ?? (el as unknown as { ref?: React.Ref<unknown> }).ref ?? undefined;\n}\n\nexport function renderElement<State extends object>(\n defaultTag: React.ElementType,\n render: RenderProp<State> | undefined,\n props: Record<string, unknown> & { ref?: React.Ref<HTMLElement>; children?: React.ReactNode },\n state: State = {} as State,\n): React.ReactElement {\n if (!render) return createElement(defaultTag, props);\n if (typeof render === 'function') return render(props as never, state);\n if (!isValidElement(render)) return createElement(defaultTag, props);\n\n const own = render.props as Record<string, unknown> & { style?: React.CSSProperties; children?: React.ReactNode };\n const { ref, children, style, ...rest } = props as typeof props & { style?: React.CSSProperties };\n const merged = mergeProps(rest, own) as Record<string, unknown>;\n merged.style = style || own.style ? { ...style, ...own.style } : undefined;\n merged.ref = mergeRefs(ref ?? null, (elementRef(render) as React.Ref<HTMLElement>) ?? null);\n // The component's content wins; an element's own children are kept only when the component has none.\n return cloneElement(render, merged, children ?? own.children);\n}\n"
43
+ },
38
44
  {
39
45
  "path": "components/spark-ui/internal/tone.ts",
40
46
  "type": "registry:lib",
@@ -35,6 +35,11 @@
35
35
  "type": "registry:lib",
36
36
  "target": "components/spark-ui/internal/messages.tsx"
37
37
  },
38
+ {
39
+ "path": "components/spark-ui/internal/render.tsx",
40
+ "type": "registry:lib",
41
+ "target": "components/spark-ui/internal/render.tsx"
42
+ },
38
43
  {
39
44
  "path": "components/spark-ui/internal/tone.ts",
40
45
  "type": "registry:lib",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sparkwire/mcp",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "MCP server for Spark UI: lets AI coding agents look up components, props, install commands and source.",
5
5
  "type": "module",
6
6
  "bin": {