@sparkwire/mcp 0.0.0-stage → 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.
Files changed (48) hide show
  1. package/data/docs.json +4993 -0
  2. package/data/r/accordion.json +26 -0
  3. package/data/r/alert.json +26 -0
  4. package/data/r/avatar.json +26 -0
  5. package/data/r/base.json +55 -0
  6. package/data/r/button.json +33 -0
  7. package/data/r/card.json +26 -0
  8. package/data/r/charts.json +40 -0
  9. package/data/r/checkbox.json +27 -0
  10. package/data/r/combobox.json +30 -0
  11. package/data/r/command-palette.json +29 -0
  12. package/data/r/dashboard.json +34 -0
  13. package/data/r/data-table.json +39 -0
  14. package/data/r/date-picker.json +56 -0
  15. package/data/r/drawer.json +29 -0
  16. package/data/r/dropdown.json +30 -0
  17. package/data/r/field.json +26 -0
  18. package/data/r/file-upload.json +28 -0
  19. package/data/r/headless.json +27 -0
  20. package/data/r/indicators.json +26 -0
  21. package/data/r/input-base.json +21 -0
  22. package/data/r/menu.json +32 -0
  23. package/data/r/modal.json +29 -0
  24. package/data/r/navigation.json +26 -0
  25. package/data/r/number-field.json +30 -0
  26. package/data/r/provider.json +47 -0
  27. package/data/r/radio-group.json +26 -0
  28. package/data/r/select.json +21 -0
  29. package/data/r/settings.json +37 -0
  30. package/data/r/sidebar.json +30 -0
  31. package/data/r/sign-in.json +31 -0
  32. package/data/r/slider.json +29 -0
  33. package/data/r/spark.json +26 -0
  34. package/data/r/stepper.json +26 -0
  35. package/data/r/styles.json +17 -0
  36. package/data/r/switch.json +26 -0
  37. package/data/r/tabs.json +29 -0
  38. package/data/r/textarea.json +28 -0
  39. package/data/r/textfield.json +57 -0
  40. package/data/r/time-picker.json +32 -0
  41. package/data/r/toast.json +26 -0
  42. package/data/r/toggle-group.json +29 -0
  43. package/data/r/tooltip.json +29 -0
  44. package/data/r/utils.json +69 -0
  45. package/data/registry.json +1224 -0
  46. package/package.json +40 -4
  47. package/src/server.mjs +179 -0
  48. package/README.md +0 -3
@@ -0,0 +1,57 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "textfield",
4
+ "type": "registry:ui",
5
+ "title": "Textfield",
6
+ "description": "A field that charges as you type.",
7
+ "dependencies": [],
8
+ "registryDependencies": [
9
+ "@sparkwire/base",
10
+ "@sparkwire/styles",
11
+ "@sparkwire/utils"
12
+ ],
13
+ "files": [
14
+ {
15
+ "path": "components/spark-ui/Textfield/Textfield.tsx",
16
+ "type": "registry:ui",
17
+ "target": "components/spark-ui/Textfield/Textfield.tsx",
18
+ "content": "import { forwardRef, useId, useRef } from 'react';\nimport { InputBase } from '../base/InputBase';\nimport { TextfieldPropsBase } from './Textfield.types';\nimport { useTextField } from './useTextfield';\nimport { useForkRef } from './useForkRef';\nimport { cx } from '../internal/cx';\nimport { useDefaults, slot, ClassNames } from '../internal/defaults';\n\nconst clamp = (n: number) => Math.max(0, Math.min(1, Number.isFinite(n) ? n : 0));\n\nconst defaultChargeLabel = (percent: number) =>\n percent >= 100 ? 'Fully charged' : percent === 0 ? 'No charge' : `${percent}% charged`;\n\n/**\n * Textfield: in Live Wire, a field can \"charge up\" as its value becomes valid.\n * Pass `charge` (0..1, or a function of the value) to show the meter.\n *\n * Style hooks: `.sp-textfield` with `[data-focused]`, `[data-invalid]`,\n * `[data-charged]`, `[data-disabled]`; parts `__label`, `__control`, `__input`,\n * `__adornment`, `__meter`, `__helper`. Built on InputBase (`.sp-input-base`).\n */\nconst Textfield = forwardRef<HTMLInputElement, TextfieldPropsBase>((props, ref) => {\n const {\n label,\n placeholder,\n disabled,\n error,\n prepend,\n append,\n value,\n defaultValue,\n onChange,\n onFocus,\n onBlur,\n inputSize = 'medium',\n helperText,\n containerStyle,\n isCurrency,\n cardDetection,\n formatPhoneNumber,\n variant,\n charge,\n chargeLabel = defaultChargeLabel,\n type,\n id,\n className,\n classNames,\n ...rest\n } = useDefaults('Textfield', props);\n\n const {\n value: fieldValue,\n onChange: handleChange,\n onFocus: handleFocus,\n onBlur: handleBlur,\n focused,\n disabled: isDisabled,\n error: hasError,\n } = useTextField({ value: value ?? defaultValue, onChange, onFocus, onBlur, disabled, error, type });\n const controlled = value !== undefined;\n\n const level = charge === undefined ? undefined : clamp(typeof charge === 'function' ? charge(fieldValue) : charge);\n const percent = level === undefined ? 0 : Math.round(level * 100);\n const charged = level !== undefined && percent >= 100 && !hasError;\n\n const autoId = useId();\n const inputId = id ?? autoId;\n const helperId = `${inputId}-helper`;\n const meterId = `${inputId}-meter`;\n const describedBy = [helperText && helperId, level !== undefined && meterId].filter(Boolean).join(' ') || undefined;\n\n const inputRef = useRef<HTMLInputElement>(null);\n const handleRef = useForkRef(ref, inputRef);\n\n // Native input types only: the masking types are handled by useTextField.\n const masked = type === 'card' || type === 'currency' || type === 'phone';\n\n return (\n <div\n className={slot('sp-textfield', classNames, 'root', className)}\n data-tone={hasError ? 'error' : 'brand'}\n data-size={inputSize}\n data-focused={focused || undefined}\n data-invalid={hasError || undefined}\n data-charged={charged || undefined}\n data-disabled={isDisabled || undefined}\n >\n {label && (\n <label htmlFor={inputId} className={slot('sp-textfield__label', classNames, 'label')}>\n {label}\n </label>\n )}\n <InputBase\n ref={handleRef}\n id={inputId}\n size={inputSize}\n error={hasError}\n disabled={isDisabled}\n startAdornment={prepend}\n endAdornment={append}\n rootProps={{ style: containerStyle }}\n classNames={{\n root: slot('sp-textfield__control', classNames, 'control'),\n input: slot('sp-textfield__input', classNames, 'input'),\n adornment: slot('sp-textfield__adornment', classNames, 'adornment'),\n }}\n type={masked ? 'text' : type}\n inputMode={masked ? 'numeric' : undefined}\n placeholder={placeholder}\n {...(controlled ? { value: fieldValue } : { defaultValue })}\n aria-describedby={describedBy}\n onChange={handleChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n {...(rest as Omit<typeof rest, 'size'>)}\n />\n {level !== undefined && (\n <div id={meterId} className={slot('sp-textfield__meter', classNames, 'meter')}>\n <div\n role=\"meter\"\n aria-label={typeof label === 'string' ? `${label} charge` : 'Charge'}\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={percent}\n className=\"sp-textfield__meter-track\"\n >\n <div className={cx('sp-textfield__meter-fill', percent >= 100 && 'sp-current')} style={{ width: `${percent}%` }} />\n </div>\n <span className=\"sp-textfield__meter-label\" aria-live=\"polite\">\n {chargeLabel(percent)}\n </span>\n </div>\n )}\n {helperText && (\n <p id={helperId} className={slot('sp-textfield__helper', classNames, 'helper')}>\n {helperText}\n </p>\n )}\n </div>\n );\n});\n\nTextfield.displayName = 'Textfield';\n\nexport default Textfield;\n"
19
+ },
20
+ {
21
+ "path": "components/spark-ui/Textfield/Textfield.types.ts",
22
+ "type": "registry:ui",
23
+ "target": "components/spark-ui/Textfield/Textfield.types.ts",
24
+ "content": "import { ChangeEvent, FocusEvent, InputHTMLAttributes } from 'react';\n\nexport interface UseTextFieldProps {\n value?: string;\n onChange?: (event: ChangeEvent<HTMLInputElement>) => void;\n onFocus?: (event: FocusEvent<HTMLInputElement>) => void;\n onBlur?: (event: FocusEvent<HTMLInputElement>) => void;\n disabled?: boolean;\n error?: boolean;\n type?:\n | \"button\"\n | \"checkbox\"\n | \"color\"\n | \"date\"\n | \"datetime-local\"\n | \"email\"\n | \"file\"\n | \"hidden\"\n | \"image\"\n | \"month\"\n | \"password\"\n | \"radio\"\n | \"range\"\n | \"reset\"\n | \"search\"\n | \"submit\"\n | \"text\"\n | \"time\"\n | \"url\"\n | \"week\"\n | 'card'\n | 'currency'\n | 'phone'\n | (string & {});\n}\n\nexport interface UseTextFieldResult {\n value: string;\n onChange: (event: ChangeEvent<HTMLInputElement>) => void;\n onFocus: (event: FocusEvent<HTMLInputElement>) => void;\n onBlur: (event: FocusEvent<HTMLInputElement>) => void;\n focused: boolean;\n disabled: boolean;\n error: boolean;\n}\n\nexport interface TextfieldPropsBase extends InputHTMLAttributes<HTMLInputElement> {\n /** Visible label, linked to the input. */\n label?: string;\n /** Initial value when uncontrolled (no `value`). Works with React Hook Form's `register`. */\n defaultValue?: string;\n placeholder?: string;\n inputSize?: 'small' | 'medium' | 'large';\n disabled?: boolean;\n error?: boolean;\n value?: string;\n helperText?: string;\n onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;\n onFocus?: (event: FocusEvent<HTMLInputElement>) => void;\n onBlur?: (event: FocusEvent<HTMLInputElement>) => void;\n /**\n * Live Wire charge meter. A number from 0 to 1, or a function that maps the\n * current value to 0..1 (e.g. password strength). At 1 the field is fully\n * charged and current runs along the meter.\n */\n charge?: number | ((value: string) => number);\n /** Text announced next to the meter. Receives the charge as 0..100. */\n chargeLabel?: (percent: number) => React.ReactNode;\n /** Extra classes for each part: root, label, control, input, adornment, meter, helper. */\n classNames?: Partial<Record<'root' | 'label' | 'control' | 'input' | 'adornment' | 'meter' | 'helper', string>>;\n variant?: 'outlined' | 'filled' | 'standard';\n prepend?: React.ReactNode;\n append?: React.ReactNode;\n cardDetection?: (value: string) => string | undefined;\n formatPhoneNumber?: (value: string) => string;\n containerStyle?: React.CSSProperties;\n isCurrency?: boolean;\n type?:\n | \"button\"\n | \"checkbox\"\n | \"color\"\n | \"date\"\n | \"datetime-local\"\n | \"email\"\n | \"file\"\n | \"hidden\"\n | \"image\"\n | \"month\"\n | \"password\"\n | \"radio\"\n | \"range\"\n | \"reset\"\n | \"search\"\n | \"submit\"\n | \"text\"\n | \"time\"\n | \"url\"\n | \"week\"\n | 'card'\n | 'currency'\n | 'phone'\n | (string & {});\n}"
25
+ },
26
+ {
27
+ "path": "components/spark-ui/Textfield/TextfieldDropdown.tsx",
28
+ "type": "registry:ui",
29
+ "target": "components/spark-ui/Textfield/TextfieldDropdown.tsx",
30
+ "content": "import React from 'react';\n\nconst TextFieldDropdown = ({ options }: { options: { label: string; value: string; }[] }) => (\n <select>\n {options.map((option) => (\n <option key={option.value} value={option.value}>{option.label}</option>\n ))}\n </select>\n);\n\nexport default TextFieldDropdown;\n"
31
+ },
32
+ {
33
+ "path": "components/spark-ui/Textfield/TextfieldIcon.tsx",
34
+ "type": "registry:ui",
35
+ "target": "components/spark-ui/Textfield/TextfieldIcon.tsx",
36
+ "content": ""
37
+ },
38
+ {
39
+ "path": "components/spark-ui/Textfield/index.ts",
40
+ "type": "registry:ui",
41
+ "target": "components/spark-ui/Textfield/index.ts",
42
+ "content": "export { default as Textfield } from './Textfield';\nexport type { TextfieldPropsBase as TextfieldProps } from './Textfield.types';\n"
43
+ },
44
+ {
45
+ "path": "components/spark-ui/Textfield/useForkRef.ts",
46
+ "type": "registry:ui",
47
+ "target": "components/spark-ui/Textfield/useForkRef.ts",
48
+ "content": "import React from 'react';\n\nexport function useForkRef<T>(\n refA: React.Ref<T> | null | undefined, \n refB: React.Ref<T> | null | undefined\n): React.Ref<T> {\n return React.useMemo(() => {\n if (refA == null && refB == null) {\n return null;\n }\n return (refValue: T) => {\n if (typeof refA === 'function') {\n refA(refValue);\n } else if (refA) {\n (refA as React.MutableRefObject<T | null>).current = refValue;\n }\n\n if (typeof refB === 'function') {\n refB(refValue);\n } else if (refB) {\n (refB as React.MutableRefObject<T | null>).current = refValue;\n }\n };\n }, [refA, refB]);\n}\n"
49
+ },
50
+ {
51
+ "path": "components/spark-ui/Textfield/useTextfield.tsx",
52
+ "type": "registry:ui",
53
+ "target": "components/spark-ui/Textfield/useTextfield.tsx",
54
+ "content": "import { ChangeEvent, FocusEvent, useState } from \"react\";\nimport { UseTextFieldProps, UseTextFieldResult } from \"./Textfield.types\";\n\n// Enum for Input Types\nenum InputType {\n CURRENCY = 'currency',\n CARD = 'card',\n PHONE = 'phone',\n}\n\n// Utility functions for masking input values\nconst useMasking = (type?: string) => {\n const maskCurrency = (value: string): string => {\n const numericValue = value.replace(/[^\\d]/g, '');\n if (!numericValue) return '';\n \n const decimalPart = numericValue.slice(-2);\n const wholePart = numericValue.slice(0, -2);\n const formattedWholePart = wholePart.replace(/\\B(?=(\\d{3})+(?!\\d))/g, \",\");\n \n return decimalPart.length > 0\n ? `${formattedWholePart}${decimalPart.length > 0 ? '.' + decimalPart : ''}`\n : formattedWholePart;\n };\n\n const maskCreditCard = (value: string): string => {\n return value.replace(/\\d(?=\\d{4})/g, '*');\n };\n\n const formatPhoneNumber = (value: string): string => {\n const cleaned = value.replace(/\\D/g, '');\n const match = cleaned.match(/^(\\d{3})(\\d{3})(\\d{4})$/);\n return match ? `(${match[1]}) ${match[2]}-${match[3]}` : value;\n };\n\n return (value: string): string => {\n switch (type) {\n case InputType.CURRENCY:\n return maskCurrency(value);\n case InputType.CARD:\n return maskCreditCard(value);\n case InputType.PHONE:\n return formatPhoneNumber(value);\n default:\n return value;\n }\n };\n};\n\nexport const useTextField = ({\n value: initialValue = '',\n onChange: onChangeProp,\n onFocus: onFocusProp,\n onBlur: onBlurProp,\n disabled = false,\n error = false,\n type,\n}: UseTextFieldProps): UseTextFieldResult => {\n const [value, setValue] = useState(initialValue);\n const [focused, setFocused] = useState(false);\n\n const applyMasking = useMasking(type);\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const rawValue = event.target.value;\n const newValue = applyMasking(rawValue);\n // Write the masked value back so uncontrolled inputs (and form libraries\n // reading the DOM, like React Hook Form) see it too.\n if (newValue !== rawValue) event.target.value = newValue;\n setValue(newValue);\n onChangeProp?.(event);\n };\n\n const handleFocus = (event: FocusEvent<HTMLInputElement>) => {\n setFocused(true);\n if (onFocusProp) {\n onFocusProp(event);\n }\n };\n\n const handleBlur = (event: FocusEvent<HTMLInputElement>) => {\n setFocused(false);\n if (onBlurProp) {\n onBlurProp(event);\n }\n };\n\n return {\n value,\n onChange: handleChange,\n onFocus: handleFocus,\n onBlur: handleBlur,\n focused,\n disabled,\n error,\n };\n};\n"
55
+ }
56
+ ]
57
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "time-picker",
4
+ "type": "registry:ui",
5
+ "title": "TimePicker",
6
+ "description": "Type a time segment by segment or pick from suggestions every N minutes; min/max and blocked slots.",
7
+ "dependencies": [
8
+ "@internationalized/date@^3.12.4",
9
+ "react-aria@^3.53.1",
10
+ "react-stately@^3.51.0"
11
+ ],
12
+ "registryDependencies": [
13
+ "@sparkwire/base",
14
+ "@sparkwire/date-picker",
15
+ "@sparkwire/styles",
16
+ "@sparkwire/utils"
17
+ ],
18
+ "files": [
19
+ {
20
+ "path": "components/spark-ui/TimePicker/TimePicker.tsx",
21
+ "type": "registry:ui",
22
+ "target": "components/spark-ui/TimePicker/TimePicker.tsx",
23
+ "content": "import React, { useMemo, useRef, useState } from 'react';\nimport { useMessages } from '../internal/messages';\nimport { useButton, useLocale, useTimeField } from 'react-aria';\nimport { useOverlayTriggerState, useSingleSelectListState, useTimeFieldState } from 'react-stately';\nimport { Time } from '@internationalized/date';\ntype TimeValue = { hour: number; minute: number; second: number };\nimport { Popover } from '../base/Popover';\nimport { ListBox, ListOption, renderListItems } from '../base/ListBox';\nimport { useDefaults, slot, ClassNames } from '../internal/defaults';\nimport { Segment } from '../DatePicker/DatePicker';\n\nexport interface TimePickerProps {\n label?: React.ReactNode;\n 'aria-label'?: string;\n /** \"HH:mm\" or \"HH:mm:ss\", 24-hour. `null` when empty. */\n value?: string | null;\n defaultValue?: string | null;\n onChange?: (value: string | null) => void;\n /** Earliest time, \"HH:mm\". */\n min?: string;\n /** Latest time, \"HH:mm\". */\n max?: string;\n /** Minutes between suggestions in the list. Default 30. */\n step?: number;\n /** Turn off the suggestion list (typing only). */\n showList?: boolean;\n /** Grey out suggestions, e.g. booked slots: `(t) => booked.includes(t)`. */\n isTimeDisabled?: (time: string) => boolean;\n /** 12 or 24-hour. Default: the locale's. */\n hourCycle?: 12 | 24;\n /** `minute` (default) or `second`. */\n granularity?: 'hour' | 'minute' | 'second';\n helperText?: React.ReactNode;\n error?: boolean;\n disabled?: boolean;\n required?: boolean;\n clearable?: boolean;\n /** Submits \"HH:mm\" with forms. */\n name?: string;\n size?: 'small' | 'medium' | 'large';\n className?: string;\n classNames?: ClassNames<'root' | 'label' | 'control' | 'field' | 'trigger' | 'helper' | 'popover' | 'list'>;\n}\n\nconst pad = (n: number) => String(n).padStart(2, '0');\n/** \"09:30\" → Time. Invalid input → null. */\nexport function parseTime(s: string | null | undefined): Time | null {\n if (!s) return null;\n const m = /^(\\d{1,2}):(\\d{2})(?::(\\d{2}))?$/.exec(s.trim());\n if (!m) return null;\n const [h, mi, se] = [Number(m[1]), Number(m[2]), Number(m[3] ?? 0)];\n return h < 24 && mi < 60 && se < 60 ? new Time(h, mi, se) : null;\n}\n/** Time → \"09:30\" (or \"09:30:15\" when seconds are set). */\nexport function formatTime(t: TimeValue | null | undefined, seconds = false): string | null {\n if (!t) return null;\n return `${pad(t.hour)}:${pad(t.minute)}${seconds || t.second ? `:${pad(t.second)}` : ''}`;\n}\nconst toMinutes = (t: Time) => t.hour * 60 + t.minute;\n\n/**\n * TimePicker: type a time segment by segment (hours, minutes, AM/PM), or\n * pick from a list of suggestions every `step` minutes. Values are plain\n * 24-hour strings (\"14:30\"), so they store and submit cleanly; the field\n * shows the locale's format. `min`, `max` and `isTimeDisabled` limit both\n * typing and the list.\n *\n * Built on React Aria's `useTimeField` with the same segments as DatePicker,\n * and the Popover and ListBox base components.\n *\n * Style hooks: shares `.sp-date-picker` styles; `.sp-time-picker`, `__list`, `__option[data-disabled]`.\n */\nexport function TimePicker(inProps: TimePickerProps) {\n const props = useDefaults('TimePicker', inProps) as TimePickerProps;\n const m = useMessages();\n const {\n label,\n step = 30,\n showList = true,\n isTimeDisabled,\n hourCycle,\n granularity = 'minute',\n helperText,\n error,\n disabled,\n required,\n clearable,\n name,\n size = 'medium',\n className,\n classNames,\n } = props;\n const { locale, direction } = useLocale();\n const minT = useMemo(() => parseTime(props.min), [props.min]);\n const maxT = useMemo(() => parseTime(props.max), [props.max]);\n const fieldRef = useRef<HTMLDivElement>(null);\n const groupRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const seconds = granularity === 'second';\n\n // Hold the value here (as \"HH:mm\") so the field, the list and Clear all go through one path.\n const [inner, setInner] = useState<string | null>(props.defaultValue ?? null);\n const controlled = props.value !== undefined;\n const setTime = (next: string | null) => {\n if (!controlled) setInner(next);\n props.onChange?.(next);\n };\n const valueStr = controlled ? props.value ?? null : inner;\n const parsed = useMemo(() => parseTime(valueStr), [valueStr]);\n const ariaProps = {\n label,\n 'aria-label': props['aria-label'],\n value: parsed,\n onChange: (v: TimeValue | null) => setTime(formatTime(v, seconds)),\n minValue: minT ?? undefined,\n maxValue: maxT ?? undefined,\n hourCycle,\n granularity,\n isDisabled: disabled,\n isRequired: required,\n isInvalid: error,\n validationBehavior: 'aria' as const,\n description: !error && helperText ? helperText : undefined,\n errorMessage: error && helperText ? helperText : undefined,\n };\n const state = useTimeFieldState({ ...ariaProps, locale });\n const { labelProps, fieldProps, descriptionProps, errorMessageProps } = useTimeField(ariaProps, state, fieldRef);\n const current = formatTime(state.value as TimeValue | null, seconds);\n\n // Suggestions every `step` minutes within [min, max].\n const fmt = useMemo(() => new Intl.DateTimeFormat(locale, { hour: 'numeric', minute: '2-digit', hourCycle: hourCycle === 12 ? 'h12' : hourCycle === 24 ? 'h23' : undefined }), [locale, hourCycle]);\n const options: ListOption<string>[] = useMemo(() => {\n const out: ListOption<string>[] = [];\n const lo = minT ? toMinutes(minT) : 0;\n const hi = maxT ? toMinutes(maxT) : 24 * 60 - 1;\n for (let m = Math.ceil(lo / step) * step; m <= hi; m += Math.max(5, step)) {\n const value = `${pad(Math.floor(m / 60))}:${pad(m % 60)}`;\n out.push({ value, label: fmt.format(new Date(2000, 0, 1, Math.floor(m / 60), m % 60)), disabled: isTimeDisabled?.(value) });\n }\n return out;\n }, [step, props.min, props.max, fmt, isTimeDisabled]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const overlay = useOverlayTriggerState({});\n const list = useSingleSelectListState<ListOption<string>>({\n items: options,\n children: renderListItems(options) as never,\n selectedKey: current?.slice(0, 5) ?? null,\n disabledKeys: options.filter((o) => o.disabled).map((o) => o.value),\n onSelectionChange: (key) => {\n const t = parseTime(String(key));\n if (t) setTime(formatTime(t, seconds));\n overlay.close();\n fieldRef.current?.querySelector<HTMLElement>('[role=\"spinbutton\"]')?.focus();\n },\n });\n const { buttonProps } = useButton(\n { 'aria-label': m.showTimes, isDisabled: disabled, onPress: () => overlay.toggle(), excludeFromTabOrder: false },\n triggerRef,\n );\n\n return (\n <div\n className={slot('sp-date-picker sp-time-picker', classNames, 'root', className)}\n dir={direction}\n data-tone={error ? 'error' : 'brand'}\n data-size={size}\n data-open={overlay.isOpen || undefined}\n data-invalid={error || undefined}\n data-disabled={disabled || undefined}\n data-empty={!state.value || undefined}\n >\n {label && (\n <span {...labelProps} className={slot('sp-date-picker__label', classNames, 'label')}>\n {label}\n {required && <span className=\"sp-field__required\" aria-hidden=\"true\"> *</span>}\n </span>\n )}\n <div ref={groupRef} className={slot('sp-date-picker__control', classNames, 'control')}>\n <div {...fieldProps} ref={fieldRef} className={slot('sp-date-field', classNames, 'field')}>\n {state.segments.map((segment, i) => (\n <Segment key={i} segment={segment} state={state} />\n ))}\n </div>\n {clearable && state.value && !disabled && (\n <button type=\"button\" aria-label={m.clearTime} className=\"sp-date-picker__clear\" onClick={() => setTime(null)}>\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n <path d=\"M3 3l10 10M13 3L3 13\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" />\n </svg>\n </button>\n )}\n {showList && (\n <button {...buttonProps} ref={triggerRef} aria-expanded={overlay.isOpen} aria-haspopup=\"listbox\" className={slot('sp-date-picker__trigger', classNames, 'trigger')}>\n <svg className=\"sp-date-picker__icon\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" aria-hidden=\"true\">\n <circle cx=\"12\" cy=\"12\" r=\"9\" />\n <path d=\"M12 7v5l3 2\" />\n </svg>\n </button>\n )}\n </div>\n {helperText && (\n <p {...(error ? errorMessageProps : descriptionProps)} className={slot('sp-date-picker__helper', classNames, 'helper')}>\n {helperText}\n </p>\n )}\n {name && <input type=\"hidden\" name={name} value={current ?? ''} />}\n {overlay.isOpen && (\n <Popover state={overlay} triggerRef={groupRef} offset={8} matchTriggerWidth className={slot('sp-dropdown__popover sp-time-picker__popover', classNames, 'popover')}>\n <ListBox\n state={list}\n aria-label={typeof label === 'string' ? `${label}: ${m.times}` : m.times}\n autoFocus={list.selectedKey != null ? true : 'first'}\n shouldFocusWrap\n className={slot('sp-time-picker__list', classNames, 'list')}\n optionClassName=\"sp-time-picker__option\"\n />\n </Popover>\n )}\n </div>\n );\n}\n"
24
+ },
25
+ {
26
+ "path": "components/spark-ui/TimePicker/index.ts",
27
+ "type": "registry:ui",
28
+ "target": "components/spark-ui/TimePicker/index.ts",
29
+ "content": "export { TimePicker, parseTime, formatTime } from './TimePicker';\nexport type { TimePickerProps } from './TimePicker';\n"
30
+ }
31
+ ]
32
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "toast",
4
+ "type": "registry:ui",
5
+ "title": "Toast",
6
+ "description": "Notifications.",
7
+ "dependencies": [],
8
+ "registryDependencies": [
9
+ "@sparkwire/styles",
10
+ "@sparkwire/utils"
11
+ ],
12
+ "files": [
13
+ {
14
+ "path": "components/spark-ui/Toast/Toast.tsx",
15
+ "type": "registry:ui",
16
+ "target": "components/spark-ui/Toast/Toast.tsx",
17
+ "content": "import React, { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport { useMessages } from '../internal/messages';\nimport { createPortal } from 'react-dom';\nimport { Tone } from '../internal/tone';\nimport { usePortalTheme } from '../internal/usePortalTheme';\n\nexport interface ToastOptions {\n /** Bold first line. */\n title: React.ReactNode;\n /** Optional second line. */\n description?: React.ReactNode;\n /** Default `brand`. `error` toasts are announced immediately (role=\"alert\"). */\n tone?: Tone;\n /** Auto-dismiss after this many ms. `0` keeps it until closed. Default 4000. */\n duration?: number;\n /** One action button, e.g. Undo. The toast closes after it runs. */\n action?: { label: string; onClick: () => void };\n}\n\ntype ToastItem = ToastOptions & Required<Pick<ToastOptions, 'tone' | 'duration'>> & { id: number };\n\ninterface ToastApi {\n /** Show a toast; returns its id. */\n toast: (options: ToastOptions) => number;\n /** Close a toast by id. */\n dismiss: (id: number) => void;\n}\n\nconst ToastContext = createContext<ToastApi | null>(null);\n\n/** Show toasts from anywhere inside <ToastProvider>. */\nexport const useToast = (): ToastApi => {\n const ctx = useContext(ToastContext);\n if (!ctx) throw new Error('useToast must be used inside <ToastProvider>');\n return ctx;\n};\n\nlet seq = 0;\n\n/**\n * Wrap your app once. Toasts stack bottom-right (max 5); the bottom bar\n * discharges as the timer runs and pauses on hover or focus.\n *\n * Style hooks: `.sp-toast-region`, `.sp-toast[data-tone]`, `__led`, `__title`,\n * `__description`, `__action`, `__close`, `__timer`.\n */\nexport function ToastProvider({ children }: { children: React.ReactNode }) {\n const [items, setItems] = useState<ToastItem[]>([]);\n const [mounted, setMounted] = useState(false);\n useEffect(() => setMounted(true), []);\n const { anchorRef, themeProps } = usePortalTheme(items.length > 0);\n const m = useMessages();\n\n const dismiss = useCallback((id: number) => setItems((all) => all.filter((t) => t.id !== id)), []);\n const toast = useCallback((o: ToastOptions) => {\n const id = ++seq;\n setItems((all) => [...all.slice(-4), { tone: 'brand', duration: 4000, ...o, id }]);\n return id;\n }, []);\n const api = useMemo(() => ({ toast, dismiss }), [toast, dismiss]);\n\n return (\n <ToastContext.Provider value={api}>\n {children}\n <span ref={anchorRef} hidden />\n {mounted &&\n createPortal(\n <div role=\"region\" aria-label={m.notifications} className=\"sp-toast-region\" {...themeProps}>\n {items.map((t) => (\n <ToastCard key={t.id} item={t} onClose={() => dismiss(t.id)} />\n ))}\n </div>,\n document.body,\n )}\n </ToastContext.Provider>\n );\n}\n\nfunction ToastCard({ item, onClose }: { item: ToastItem; onClose: () => void }) {\n const m = useMessages();\n const [paused, setPaused] = useState(false);\n const remaining = useRef(item.duration);\n const started = useRef(Date.now());\n\n useEffect(() => {\n if (!item.duration || paused) return;\n started.current = Date.now();\n const t = window.setTimeout(onClose, remaining.current);\n return () => {\n window.clearTimeout(t);\n remaining.current -= Date.now() - started.current;\n };\n }, [paused, item.duration, onClose]);\n\n return (\n <div\n role={item.tone === 'error' ? 'alert' : 'status'}\n className=\"sp-toast\"\n data-tone={item.tone}\n data-paused={paused || undefined}\n onMouseEnter={() => setPaused(true)}\n onMouseLeave={() => setPaused(false)}\n onFocus={() => setPaused(true)}\n onBlur={() => setPaused(false)}\n >\n <span aria-hidden=\"true\" className=\"sp-toast__led\" />\n <div className=\"sp-toast__content\">\n <strong className=\"sp-toast__title\">{item.title}</strong>\n {item.description && <span className=\"sp-toast__description\">{item.description}</span>}\n {item.action && (\n <button\n type=\"button\"\n className=\"sp-toast__action\"\n onClick={() => {\n item.action!.onClick();\n onClose();\n }}\n >\n {item.action.label}\n </button>\n )}\n </div>\n <button type=\"button\" aria-label={m.dismissNotification} onClick={onClose} className=\"sp-toast__close\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n <path d=\"M3 3l10 10M13 3L3 13\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" />\n </svg>\n </button>\n {item.duration > 0 && (\n <span aria-hidden=\"true\" className=\"sp-toast__timer\" style={{ animationDuration: `${item.duration}ms` }} />\n )}\n </div>\n );\n}\n"
18
+ },
19
+ {
20
+ "path": "components/spark-ui/Toast/index.ts",
21
+ "type": "registry:ui",
22
+ "target": "components/spark-ui/Toast/index.ts",
23
+ "content": "export { ToastProvider, useToast } from './Toast';\nexport type { ToastOptions } from './Toast';\n"
24
+ }
25
+ ]
26
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "toggle-group",
4
+ "type": "registry:ui",
5
+ "title": "ToggleGroup",
6
+ "description": "Segmented control or a row of independent toggles, with arrow-key navigation.",
7
+ "dependencies": [
8
+ "react-aria@^3.53.1",
9
+ "react-stately@^3.51.0"
10
+ ],
11
+ "registryDependencies": [
12
+ "@sparkwire/styles",
13
+ "@sparkwire/utils"
14
+ ],
15
+ "files": [
16
+ {
17
+ "path": "components/spark-ui/ToggleGroup/ToggleGroup.tsx",
18
+ "type": "registry:ui",
19
+ "target": "components/spark-ui/ToggleGroup/ToggleGroup.tsx",
20
+ "content": "import React, { createContext, useContext, useRef } from 'react';\nimport { mergeProps, useFocusRing, useToggleButtonGroup, useToggleButtonGroupItem } from 'react-aria';\nimport { ToggleGroupState, useToggleGroupState } from 'react-stately';\nimport { useDefaults, slot, ClassNames } from '../internal/defaults';\n\ntype Mode = 'single' | 'multiple';\n\nexport interface ToggleGroupProps<M extends Mode = 'single'> {\n /** `single` (default): one at a time, like a segmented control. `multiple`: each toggles on its own (bold / italic / underline). */\n selectionMode?: M;\n /** Selected value(s): a string for `single`, a string[] for `multiple`. */\n value?: M extends 'multiple' ? string[] : string | null;\n defaultValue?: M extends 'multiple' ? string[] : string | null;\n onChange?: (value: M extends 'multiple' ? string[] : string | null) => void;\n /** In `single` mode, allow clicking the selected item to clear it. Default `false`. */\n allowEmpty?: boolean;\n orientation?: 'horizontal' | 'vertical';\n size?: 'small' | 'medium' | 'large';\n /** `segmented` (default): one track with a sliding fill. `outlined`: separate buttons. */\n variant?: 'segmented' | 'outlined';\n /** Stretch to fill the width. */\n fullWidth?: boolean;\n disabled?: boolean;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n children: React.ReactNode;\n className?: string;\n classNames?: ClassNames<'root' | 'item'>;\n}\n\nexport interface ToggleGroupItemProps {\n value: string;\n children?: React.ReactNode;\n /** Icon before the label. For icon-only items, pass `aria-label`. */\n icon?: React.ReactNode;\n 'aria-label'?: string;\n disabled?: boolean;\n className?: string;\n}\n\nconst Ctx = createContext<{ state: ToggleGroupState; itemClass?: string } | null>(null);\n\n/**\n * ToggleGroup: a row of related toggle buttons, as a segmented control\n * (`single`) or independent toggles (`multiple`). Arrow keys move between\n * items, one Tab stop for the group; selected items have `aria-checked` /\n * `aria-pressed`.\n *\n * ```tsx\n * <ToggleGroup aria-label=\"View\" defaultValue=\"grid\">\n * <ToggleGroup.Item value=\"list\">List</ToggleGroup.Item>\n * <ToggleGroup.Item value=\"grid\">Grid</ToggleGroup.Item>\n * </ToggleGroup>\n * ```\n *\n * Style hooks: `.sp-toggle-group[data-variant][data-size]`, `__item[data-selected]`.\n */\nexport function ToggleGroup<M extends Mode = 'single'>(inProps: ToggleGroupProps<M>) {\n const props = useDefaults('ToggleGroup', inProps) as ToggleGroupProps<M>;\n const { selectionMode = 'single' as M, allowEmpty = false, orientation = 'horizontal', size = 'medium', variant = 'segmented', fullWidth, disabled, children, className, classNames } = props;\n const toSet = (v: unknown) => (v == null ? undefined : new Set(Array.isArray(v) ? (v as string[]) : [v as string]));\n const state = useToggleGroupState({\n selectionMode,\n disallowEmptySelection: selectionMode === 'single' && !allowEmpty,\n selectedKeys: toSet(props.value),\n defaultSelectedKeys: toSet(props.defaultValue),\n onSelectionChange: (keys) => {\n const arr = Array.from(keys, String);\n (props.onChange as ((v: unknown) => void) | undefined)?.(selectionMode === 'multiple' ? arr : arr[0] ?? null);\n },\n isDisabled: disabled,\n });\n const ref = useRef<HTMLDivElement>(null);\n const { groupProps } = useToggleButtonGroup({ ...props, isDisabled: disabled, orientation }, state, ref);\n return (\n <div\n {...groupProps}\n ref={ref}\n className={slot('sp-toggle-group', classNames, 'root', className)}\n data-variant={variant}\n data-size={size}\n data-orientation={orientation}\n data-full-width={fullWidth || undefined}\n data-disabled={disabled || undefined}\n >\n <Ctx.Provider value={{ state, itemClass: classNames?.item }}>{children}</Ctx.Provider>\n </div>\n );\n}\n\nfunction ToggleGroupItem({ value, children, icon, disabled, className, ...rest }: ToggleGroupItemProps) {\n const ctx = useContext(Ctx);\n if (!ctx) throw new Error('ToggleGroup.Item must be inside a ToggleGroup');\n const ref = useRef<HTMLButtonElement>(null);\n const { buttonProps, isPressed, isSelected, isDisabled } = useToggleButtonGroupItem({ id: value, isDisabled: disabled, 'aria-label': rest['aria-label'] }, ctx.state, ref);\n const { focusProps, isFocusVisible } = useFocusRing();\n return (\n <button\n {...mergeProps(buttonProps, focusProps)}\n ref={ref}\n className={['sp-toggle-group__item', ctx.itemClass, className].filter(Boolean).join(' ')}\n data-selected={isSelected || undefined}\n data-pressed={isPressed || undefined}\n data-disabled={isDisabled || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-icon-only={(!children && icon) || undefined}\n >\n {icon && <span className=\"sp-toggle-group__icon\" aria-hidden=\"true\">{icon}</span>}\n {children && <span className=\"sp-toggle-group__label\">{children}</span>}\n </button>\n );\n}\n\nToggleGroup.Item = ToggleGroupItem;\nexport { ToggleGroupItem };\n"
21
+ },
22
+ {
23
+ "path": "components/spark-ui/ToggleGroup/index.ts",
24
+ "type": "registry:ui",
25
+ "target": "components/spark-ui/ToggleGroup/index.ts",
26
+ "content": "export { ToggleGroup, ToggleGroupItem } from './ToggleGroup';\nexport type { ToggleGroupProps, ToggleGroupItemProps } from './ToggleGroup';\n"
27
+ }
28
+ ]
29
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "tooltip",
4
+ "type": "registry:ui",
5
+ "title": "Tooltip",
6
+ "description": "A hint that flickers on.",
7
+ "dependencies": [
8
+ "react-aria@^3.53.1",
9
+ "react-stately@^3.51.0"
10
+ ],
11
+ "registryDependencies": [
12
+ "@sparkwire/styles",
13
+ "@sparkwire/utils"
14
+ ],
15
+ "files": [
16
+ {
17
+ "path": "components/spark-ui/Tooltip/Tooltip.tsx",
18
+ "type": "registry:ui",
19
+ "target": "components/spark-ui/Tooltip/Tooltip.tsx",
20
+ "content": "import React, { cloneElement, isValidElement, useRef } from 'react';\nimport { mergeProps, useTooltip, useTooltipTrigger } from 'react-aria';\nimport { useTooltipTriggerState } from 'react-stately';\nimport { useDefaults } from '../internal/defaults';\nimport { cx } from '../internal/cx';\n\nexport interface TooltipProps {\n /** Tooltip text. Keep it short; it is read as the trigger's description. */\n title: React.ReactNode;\n /** Side of the trigger to show on. Default `top`. */\n placement?: 'top' | 'bottom' | 'left' | 'right';\n /** Delay before showing on hover, in ms. Default 250. Keyboard focus shows it at once. */\n delay?: number;\n /** A single focusable element, e.g. a Button. */\n children: React.ReactElement;\n /** Class for the tooltip bubble. */\n className?: string;\n}\n\n/**\n * Tooltip: a short charged label that arcs out from its trigger on hover or\n * keyboard focus. Behaviour comes from React Aria: hover delay with warm-up\n * across nearby tooltips, instant on keyboard focus, Escape dismisses.\n *\n * Style hooks: `.sp-tooltip` (wrapper), `.sp-tooltip__bubble[data-placement]`.\n */\nexport function Tooltip(inProps: TooltipProps) {\n const { title, placement = 'top', delay = 250, children, className } = useDefaults('Tooltip', inProps);\n const wrapperRef = useRef<HTMLSpanElement>(null);\n const state = useTooltipTriggerState({ delay, closeDelay: 0 });\n const { triggerProps, tooltipProps } = useTooltipTrigger({ delay, closeDelay: 0 }, state, wrapperRef);\n const { tooltipProps: bubbleProps } = useTooltip(tooltipProps, state);\n\n // React Aria's focus handling only listens on the focusable element itself\n // (it ignores focus bubbling up from children), so merge the trigger props\n // into the child. The wrapper only positions the bubble.\n const trigger = isValidElement(children)\n ? cloneElement(\n children as React.ReactElement<Record<string, unknown>>,\n mergeProps((children as React.ReactElement<Record<string, unknown>>).props, triggerProps),\n )\n : children;\n\n return (\n <span ref={wrapperRef} className=\"sp-tooltip\">\n {trigger}\n {state.isOpen && (\n <span {...bubbleProps} data-placement={placement} className={cx('sp-tooltip__bubble', className)}>\n {title}\n </span>\n )}\n </span>\n );\n}\n\nexport default Tooltip;\n"
21
+ },
22
+ {
23
+ "path": "components/spark-ui/Tooltip/index.ts",
24
+ "type": "registry:ui",
25
+ "target": "components/spark-ui/Tooltip/index.ts",
26
+ "content": "export * from './Tooltip';\n"
27
+ }
28
+ ]
29
+ }
@@ -0,0 +1,69 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "utils",
4
+ "type": "registry:lib",
5
+ "title": "Spark UI utilities",
6
+ "description": "Shared helpers: class names, defaults and slots, tones, portal theming.",
7
+ "dependencies": [
8
+ "react-aria@^3.53.1"
9
+ ],
10
+ "registryDependencies": [
11
+ "@sparkwire/styles"
12
+ ],
13
+ "files": [
14
+ {
15
+ "path": "components/spark-ui/internal/cx.ts",
16
+ "type": "registry:lib",
17
+ "target": "components/spark-ui/internal/cx.ts",
18
+ "content": "/** Join class names, skipping falsy values. */\nexport const cx = (...parts: Array<string | false | null | undefined>) => parts.filter(Boolean).join(' ');\n"
19
+ },
20
+ {
21
+ "path": "components/spark-ui/internal/defaults.ts",
22
+ "type": "registry:lib",
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 * 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
+ },
26
+ {
27
+ "path": "components/spark-ui/internal/energy.ts",
28
+ "type": "registry:lib",
29
+ "target": "components/spark-ui/internal/energy.ts",
30
+ "content": "/**\n * The energy dial. One attribute, `data-spark-energy`, sets how lively the\n * whole UI is; CSS reads it for flow speed and glow, and these helpers read\n * it for spark bursts and haptics. It is read from the DOM at the moment of\n * use, so it works from SparkProvider, from a plain `<html data-spark-energy>`\n * (server-rendered, no JS), and inside portals that copy the attribute.\n */\nexport type Energy = 'off' | 'calm' | 'default' | 'electric';\n\n/** How much of each effect a level keeps: particle count, spread, haptic strength. */\nexport const ENERGY_SCALE: Record<Energy, number> = { off: 0, calm: 0.4, default: 1, electric: 1.8 };\n\nexport function prefersReducedMotion() {\n return typeof window !== 'undefined' && typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n\n/** Energy in effect at an element. Reduced motion always means `off`. */\nexport function readEnergy(el?: Element | null): Energy {\n if (prefersReducedMotion()) return 'off';\n const host = (el ?? (typeof document !== 'undefined' ? document.documentElement : null))?.closest?.('[data-spark-energy]');\n const v = host?.getAttribute('data-spark-energy');\n return v === 'off' || v === 'calm' || v === 'electric' ? v : 'default';\n}\n\nexport type HapticKind = 'toggle' | 'burst' | 'error';\n\n/**\n * A short vibration where the browser supports it (mostly Android), only\n * when haptics are switched on (`data-spark-haptics=\"on\"`, set by\n * `SparkProvider haptics`) and energy isn't `off`. Silent everywhere else.\n */\nexport function haptic(kind: HapticKind = 'toggle', el?: Element | null) {\n if (typeof navigator === 'undefined' || typeof navigator.vibrate !== 'function') return false;\n const host = (el ?? document.documentElement)?.closest?.('[data-spark-haptics]');\n if (host?.getAttribute('data-spark-haptics') !== 'on') return false;\n const scale = ENERGY_SCALE[readEnergy(el)];\n if (!scale) return false;\n const ms = (n: number) => Math.max(4, Math.round(n * Math.min(scale, 1.5)));\n const pattern = kind === 'toggle' ? ms(10) : kind === 'burst' ? [ms(8), 28, ms(8)] : [ms(30), 40, ms(30)];\n try {\n return navigator.vibrate(pattern);\n } catch {\n return false;\n }\n}\n\n/**\n * Plays the power-cut flicker on any element (the effect Modal's backdrop\n * uses). Resolves when it ends; does nothing when energy is `off`.\n */\nexport function powerCut(el: HTMLElement | null): Promise<void> {\n if (!el || readEnergy(el) === 'off' || typeof el.animate !== 'function') return Promise.resolve();\n const calm = readEnergy(el) === 'calm';\n const frames: Keyframe[] = calm\n ? [{ opacity: 0.6 }, { opacity: 1 }]\n : [{ opacity: 1 }, { opacity: 0.2, offset: 0.12 }, { opacity: 0.9, offset: 0.24 }, { opacity: 0.1, offset: 0.36 }, { opacity: 1, offset: 0.6 }, { opacity: 1 }];\n const anim = el.animate(frames, { duration: calm ? 200 : 420, easing: 'linear' });\n return anim.finished.then(\n () => undefined,\n () => undefined,\n );\n}\n"
31
+ },
32
+ {
33
+ "path": "components/spark-ui/internal/messages.tsx",
34
+ "type": "registry:lib",
35
+ "target": "components/spark-ui/internal/messages.tsx",
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
+ },
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
+ },
44
+ {
45
+ "path": "components/spark-ui/internal/tone.ts",
46
+ "type": "registry:lib",
47
+ "target": "components/spark-ui/internal/tone.ts",
48
+ "content": "/** The four tones every coloured component accepts. Styled via `[data-tone]` in base.css. */\nexport type Tone = 'brand' | 'error' | 'success' | 'warning';\n"
49
+ },
50
+ {
51
+ "path": "components/spark-ui/internal/useIsoLayoutEffect.ts",
52
+ "type": "registry:lib",
53
+ "target": "components/spark-ui/internal/useIsoLayoutEffect.ts",
54
+ "content": "import { useEffect, useLayoutEffect } from 'react';\n\n/** useLayoutEffect in the browser, useEffect on the server (no SSR warning). */\nexport const useIsoLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n"
55
+ },
56
+ {
57
+ "path": "components/spark-ui/internal/usePortalTheme.ts",
58
+ "type": "registry:lib",
59
+ "target": "components/spark-ui/internal/usePortalTheme.ts",
60
+ "content": "import React, { useRef, useState } from 'react';\nimport { useIsoLayoutEffect } from './useIsoLayoutEffect';\n\n/**\n * Portals render into document.body, outside any `[data-spark-theme]` wrapper.\n * Put `anchorRef` on an element in the normal tree (or pass `sourceRef`, e.g.\n * the trigger); spread `themeProps` on the portal's root so it gets the same\n * mode and token overrides.\n */\nexport function usePortalTheme(active: boolean, sourceRef?: React.RefObject<Element | null>) {\n const anchorRef = useRef<HTMLSpanElement>(null);\n const [themeProps, setThemeProps] = useState<{ 'data-spark-theme'?: string; 'data-spark-energy'?: string; 'data-spark-haptics'?: string; style?: React.CSSProperties }>({});\n\n useIsoLayoutEffect(() => {\n if (!active) return;\n const host = (sourceRef?.current ?? anchorRef.current)?.closest<HTMLElement>('[data-spark-theme]');\n if (!host) return;\n const style: Record<string, string> = {};\n for (let i = 0; i < host.style.length; i++) {\n const name = host.style[i];\n if (name.startsWith('--')) style[name] = host.style.getPropertyValue(name);\n }\n // The energy dial and haptics travel with the theme into the portal.\n const from = sourceRef?.current ?? anchorRef.current;\n const energy = from?.closest('[data-spark-energy]')?.getAttribute('data-spark-energy') ?? undefined;\n const haptics = from?.closest('[data-spark-haptics]')?.getAttribute('data-spark-haptics') ?? undefined;\n setThemeProps({ 'data-spark-theme': host.getAttribute('data-spark-theme') ?? undefined, 'data-spark-energy': energy, 'data-spark-haptics': haptics, style: style as React.CSSProperties });\n }, [active]);\n\n return { anchorRef, themeProps };\n}\n"
61
+ },
62
+ {
63
+ "path": "components/spark-ui/internal/spark-utils.ts",
64
+ "type": "registry:lib",
65
+ "target": "components/spark-ui/internal/spark-utils.ts",
66
+ "content": "import type { ComponentPropsWithRef, ElementType } from 'react';\n\n/** True when the user asked the OS to reduce motion. */\nexport function prefersReducedMotion(): boolean {\n if (typeof window === 'undefined' || !window.matchMedia) return false;\n return window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n\n/** Props of a polymorphic component rendered as `C`. */\nexport type OverrideProps<\n M extends { props: object; defaultComponent: ElementType },\n C extends ElementType,\n> = M['props'] & Omit<ComponentPropsWithRef<C>, keyof M['props']>;\n"
67
+ }
68
+ ]
69
+ }