@codefast/ui 0.3.1-canary.8 → 0.3.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"components/calendar.js","sources":["webpack://@codefast/ui/./src/components/calendar.tsx"],"sourcesContent":["\n\nimport type { ComponentProps, JSX, ReactNode } from \"react\";\nimport type { CustomComponents, DateRange } from \"react-day-picker\";\n\nimport { format } from \"date-fns\";\nimport { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, DotIcon } from \"lucide-react\";\nimport { DayFlag, DayPicker, SelectionState, UI } from \"react-day-picker\";\n\nimport { buttonVariants } from \"@/components/button\";\nimport { cn } from \"@/lib/utils\";\n\n/* -----------------------------------------------------------------------------\n * Component: Chevron\n * -------------------------------------------------------------------------- */\n\nfunction Chevron({ orientation, className, ...props }: ComponentProps<CustomComponents[\"Chevron\"]>): JSX.Element {\n switch (orientation) {\n case \"up\": {\n return <ChevronUpIcon className={cn(\"size-4\", className)} {...props} />;\n }\n\n case \"down\": {\n return <ChevronDownIcon className={cn(\"size-4\", className)} {...props} />;\n }\n\n case \"left\": {\n return <ChevronLeftIcon className={cn(\"size-4\", className)} {...props} />;\n }\n\n case \"right\": {\n return <ChevronRightIcon className={cn(\"size-4\", className)} {...props} />;\n }\n\n default: {\n return <DotIcon className={cn(\"size-4\", className)} {...props} />;\n }\n }\n}\n\n/* -----------------------------------------------------------------------------\n * Component: Calendar\n * -------------------------------------------------------------------------- */\n\nfunction Calendar({ showOutsideDays = true, classNames, ...props }: ComponentProps<typeof DayPicker>): JSX.Element {\n const isInteractive = props.mode !== undefined || props.onDayClick !== undefined;\n\n return (\n <DayPicker\n classNames={{\n [UI.Root]: cn(\"p-3\", classNames?.[UI.Root]),\n [UI.Chevron]: cn(classNames?.[UI.Chevron]),\n [UI.Day]: cn(\n \"grid place-items-center text-center text-sm\",\n isInteractive ? \"min-w-8.5 has-focus-visible:z-20 group\" : \"min-w-8.5 h-8\",\n classNames?.[UI.Day],\n ),\n [UI.DayButton]: cn(\n \"group-[.is-outside]:text-muted-foreground hover:not-disabled:not-group-aria-selected:bg-secondary hover:not-disabled:not-group-aria-selected:text-secondary-foreground group-data-today:not-group-aria-selected:bg-secondary group-data-today:not-group-aria-selected:text-secondary-foreground group-aria-selected:not-group-[.is-range-middle]:bg-primary group-aria-selected:not-group-[.is-range-middle]:text-primary-foreground outline-hidden focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-3 group-[.is-selected]:not-group-[.is-range-middle]:focus-visible:ring-primary/20 dark:group-[.is-selected]:not-group-[.is-range-middle]:focus-visible:ring-primary/40 group-[.is-selected]:not-group-[.is-range-middle]:focus-visible:border-primary size-8 rounded-lg border border-transparent disabled:opacity-50\",\n classNames?.[UI.DayButton],\n ),\n [UI.CaptionLabel]: cn(\"flex items-center gap-2 [&>svg]:opacity-50\", classNames?.[UI.CaptionLabel]),\n [UI.Dropdowns]: cn(\"flex gap-4\", classNames?.[UI.Dropdowns]),\n [UI.Dropdown]: cn(\"absolute opacity-0\", classNames?.[UI.Dropdown]),\n [UI.DropdownRoot]: cn(\"relative\", classNames?.[UI.DropdownRoot]),\n [UI.Footer]: cn(classNames?.[UI.Footer]),\n [UI.MonthGrid]: cn(classNames?.[UI.MonthGrid]),\n [UI.MonthCaption]: cn(\"py-1 text-sm font-medium\", classNames?.[UI.MonthCaption]),\n [UI.MonthsDropdown]: cn(classNames?.[UI.MonthsDropdown]),\n [UI.Month]: cn(\"flex flex-col gap-4\", classNames?.[UI.Month]),\n [UI.Months]: cn(\"relative flex gap-4\", classNames?.[UI.Months]),\n [UI.Nav]: cn(\"absolute end-0 flex gap-2\", classNames?.[UI.Nav]),\n [UI.NextMonthButton]: buttonVariants({\n variant: \"ghost\",\n size: \"icon\",\n className: [\"size-7\", classNames?.[UI.NextMonthButton]],\n }),\n [UI.PreviousMonthButton]: buttonVariants({\n variant: \"ghost\",\n size: \"icon\",\n className: [\"size-7\", classNames?.[UI.PreviousMonthButton]],\n }),\n [UI.Week]: cn(\"mt-2 flex justify-between\", classNames?.[UI.Week]),\n [UI.Weeks]: cn(classNames?.[UI.Weeks]),\n [UI.Weekday]: cn(\"text-muted-foreground min-w-8.5 text-xs font-medium\", classNames?.[UI.Weekday]),\n [UI.Weekdays]: cn(\"flex w-full justify-between\", classNames?.[UI.Weekdays]),\n [UI.WeekNumber]: cn(\n \"text-muted-foreground min-w-8.5 grid h-8 place-items-center text-xs font-normal [&+*]:rounded-l-lg\",\n classNames?.[UI.WeekNumber],\n ),\n [UI.WeekNumberHeader]: cn(\"min-w-8.5\", classNames?.[UI.WeekNumberHeader]),\n [UI.YearsDropdown]: cn(classNames?.[UI.YearsDropdown]),\n\n [SelectionState.range_end]: cn(\n \"to-secondary is-range-end rounded-r-lg bg-gradient-to-l first:rounded-l-lg\",\n classNames?.[SelectionState.range_end],\n ),\n [SelectionState.range_middle]: cn(\n \"is-range-middle bg-secondary text-secondary-foreground first:rounded-l-lg last:rounded-r-lg\",\n classNames?.[SelectionState.range_middle],\n ),\n [SelectionState.range_start]: cn(\n \"to-secondary is-range-start rounded-l-lg bg-gradient-to-r last:rounded-r-lg\",\n classNames?.[SelectionState.range_start],\n ),\n [SelectionState.selected]: cn(\"is-selected\", classNames?.[SelectionState.selected]),\n\n [DayFlag.disabled]: cn(\"is-disabled\", classNames?.[DayFlag.disabled]),\n [DayFlag.focused]: cn(\"is-focused\", classNames?.[DayFlag.focused]),\n [DayFlag.hidden]: cn(\"is-hidden size-8\", classNames?.[DayFlag.hidden]),\n [DayFlag.outside]: cn(\"is-outside\", classNames?.[DayFlag.outside]),\n [DayFlag.today]: cn(\"is-today\", classNames?.[DayFlag.today]),\n }}\n components={{\n Chevron,\n }}\n showOutsideDays={showOutsideDays}\n {...props}\n />\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Component: CalendarRangeLabel\n * -------------------------------------------------------------------------- */\n\nfunction CalendarRangeLabel({\n date,\n formatStr = \"LLL dd, y\",\n placeholder = \"Pick a date\",\n}: {\n date: DateRange | undefined;\n formatStr?: string;\n placeholder?: string;\n}): ReactNode {\n if (!date?.from) {\n return <span className=\"truncate\">{placeholder}</span>;\n }\n\n const formattedFromDate = format(date.from, formatStr);\n\n if (!date.to) {\n return <span className=\"truncate\">{formattedFromDate}</span>;\n }\n\n const formattedToDate = format(date.to, formatStr);\n\n return (\n <span className=\"truncate\">\n {formattedFromDate} - {formattedToDate}\n </span>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Component: CalendarLabel\n * -------------------------------------------------------------------------- */\n\nfunction CalendarLabel({\n date,\n formatStr = \"PPP\",\n placeholder = \"Pick a date\",\n}: {\n date: Date | undefined;\n formatStr?: string;\n placeholder?: string;\n}): ReactNode {\n if (!date) {\n return <span className=\"truncate\">{placeholder}</span>;\n }\n\n return <span className=\"truncate\">{format(date, formatStr)}</span>;\n}\n\n/* -----------------------------------------------------------------------------\n * Exports\n * -------------------------------------------------------------------------- */\n\nexport type { DateRange, Matcher } from \"react-day-picker\";\nexport { Calendar, CalendarLabel, CalendarRangeLabel };\n"],"names":["Chevron","orientation","className","props","ChevronUpIcon","cn","ChevronDownIcon","ChevronLeftIcon","ChevronRightIcon","DotIcon","Calendar","showOutsideDays","classNames","isInteractive","undefined","DayPicker","UI","buttonVariants","SelectionState","DayFlag","CalendarRangeLabel","date","formatStr","placeholder","formattedFromDate","format","formattedToDate","CalendarLabel"],"mappings":";iMAgBA,SAASA,EAAQ,CAAEC,YAAAA,CAAW,CAAEC,UAAAA,CAAS,CAAE,GAAGC,EAAoD,EAChG,OAAQF,GACN,IAAK,KACH,MAAO,UAACG,EAAAA,aAAaA,CAAAA,CAAC,UAAWC,GAAAA,EAAAA,EAAAA,EAAG,SAAUH,GAAa,GAAGC,CAAK,EAGrE,KAAK,OACH,MAAO,UAACG,EAAAA,eAAeA,CAAAA,CAAC,UAAWD,GAAAA,EAAAA,EAAAA,EAAG,SAAUH,GAAa,GAAGC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AAe,CAAC,CAAEd,GAAAA,EAAAA,EAAAA,EAAG,aAAcO,GAAY,CAACO,EAAAA,OAAAA,CAAAA,OAAe,CAAC,EACjE,CAACA,EAAAA,OAAAA,CAAAA,KAAa,CAAC,CAAEd,GAAAA,EAAAA,EAAAA,EAAG,WAAYO,GAAY,CAACO,EAAAA,OAAAA,CAAAA,KAAa,CAAC,CAC7D,EACA,WAAY,CACVnB,QAAAA,CACF,EACA,gBAAiBW,EAChB,GAAGR,CAAK,EAGf,CAMA,SAASiB,EAAmB,CAC1BC,KAAAA,CAAI,CACJC,UAAAA,EAAY,WAAW,CACvBC,YAAAA,EAAc,aAAa,CAK5B,EACC,GAAI,CAACF,GAAM,KACT,MAAO,UAAC,QAAK,UAAU,W,SAAYE,C,GAGrC,IAAMC,EAAoBC,GAAAA,EAAAA,MAAAA,EAAOJ,EAAK,IAAI,CAAEC,GAE5C,GAAI,CAACD,EAAK,EAAE,CACV,MAAO,UAAC,QAAK,UAAU,W,SAAYG,C,GAGrC,IAAME,EAAkBD,GAAAA,EAAAA,MAAAA,EAAOJ,EAAK,EAAE,CAAEC,GAExC,MACE,WAAC,QAAK,UAAU,W,UACbE,EAAkB,MAAIE,E,EAG7B,CAMA,SAASC,EAAc,CACrBN,KAAAA,CAAI,CACJC,UAAAA,EAAY,KAAK,CACjBC,YAAAA,EAAc,aAAa,CAK5B,SACC,EAIO,UAAC,QAAK,UAAU,W,SAAYE,GAAAA,EAAAA,MAAAA,EAAOJ,EAAMC,E,GAHvC,UAAC,QAAK,UAAU,W,SAAYC,C,EAIvC,Q"}
1
+ {"version":3,"file":"components/calendar.js","sources":["webpack://@codefast/ui/./src/components/calendar.tsx"],"sourcesContent":["\n\nimport type { ComponentProps, JSX, ReactNode } from \"react\";\nimport type { CustomComponents, DateRange } from \"react-day-picker\";\n\nimport { format } from \"date-fns\";\nimport { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, DotIcon } from \"lucide-react\";\nimport { DayFlag, DayPicker, SelectionState, UI } from \"react-day-picker\";\n\nimport { buttonVariants } from \"@/components/button\";\nimport { cn } from \"@/lib/utils\";\n\n/* -----------------------------------------------------------------------------\n * Component: Chevron\n * -------------------------------------------------------------------------- */\n\nfunction Chevron({ orientation, className, ...props }: ComponentProps<CustomComponents[\"Chevron\"]>): JSX.Element {\n switch (orientation) {\n case \"up\": {\n return <ChevronUpIcon className={cn(\"size-4\", className)} {...props} />;\n }\n\n case \"down\": {\n return <ChevronDownIcon className={cn(\"size-4\", className)} {...props} />;\n }\n\n case \"left\": {\n return <ChevronLeftIcon className={cn(\"size-4\", className)} {...props} />;\n }\n\n case \"right\": {\n return <ChevronRightIcon className={cn(\"size-4\", className)} {...props} />;\n }\n\n default: {\n return <DotIcon className={cn(\"size-4\", className)} {...props} />;\n }\n }\n}\n\n/* -----------------------------------------------------------------------------\n * Component: Calendar\n * -------------------------------------------------------------------------- */\n\nfunction Calendar({ showOutsideDays = true, classNames, ...props }: ComponentProps<typeof DayPicker>): JSX.Element {\n const isInteractive = props.mode !== undefined || props.onDayClick !== undefined;\n\n return (\n <DayPicker\n classNames={{\n [UI.Root]: cn(\"p-3\", classNames?.[UI.Root]),\n [UI.Chevron]: cn(classNames?.[UI.Chevron]),\n [UI.Day]: cn(\n \"grid place-items-center text-center text-sm\",\n isInteractive ? \"min-w-8.5 has-focus-visible:z-20 group\" : \"min-w-8.5 h-8\",\n classNames?.[UI.Day],\n ),\n [UI.DayButton]: cn(\n \"group-[.is-outside]:text-muted-foreground hover:not-disabled:not-group-aria-selected:bg-secondary hover:not-disabled:not-group-aria-selected:text-secondary-foreground group-data-today:not-group-aria-selected:bg-secondary group-data-today:not-group-aria-selected:text-secondary-foreground group-aria-selected:not-group-[.is-range-middle]:bg-primary group-aria-selected:not-group-[.is-range-middle]:text-primary-foreground outline-hidden focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-3 group-[.is-selected]:not-group-[.is-range-middle]:focus-visible:ring-primary/20 dark:group-[.is-selected]:not-group-[.is-range-middle]:focus-visible:ring-primary/40 group-[.is-selected]:not-group-[.is-range-middle]:focus-visible:border-primary size-8 rounded-lg border border-transparent disabled:opacity-50\",\n classNames?.[UI.DayButton],\n ),\n [UI.CaptionLabel]: cn(\"flex items-center gap-2 [&>svg]:opacity-50\", classNames?.[UI.CaptionLabel]),\n [UI.Dropdowns]: cn(\"flex gap-4\", classNames?.[UI.Dropdowns]),\n [UI.Dropdown]: cn(\"absolute opacity-0\", classNames?.[UI.Dropdown]),\n [UI.DropdownRoot]: cn(\"relative\", classNames?.[UI.DropdownRoot]),\n [UI.Footer]: cn(classNames?.[UI.Footer]),\n [UI.MonthGrid]: cn(classNames?.[UI.MonthGrid]),\n [UI.MonthCaption]: cn(\"py-1 text-sm font-medium\", classNames?.[UI.MonthCaption]),\n [UI.MonthsDropdown]: cn(classNames?.[UI.MonthsDropdown]),\n [UI.Month]: cn(\"flex flex-col gap-4\", classNames?.[UI.Month]),\n [UI.Months]: cn(\"relative flex gap-4\", classNames?.[UI.Months]),\n [UI.Nav]: cn(\"absolute end-0 flex gap-2\", classNames?.[UI.Nav]),\n [UI.NextMonthButton]: buttonVariants({\n variant: \"ghost\",\n size: \"icon\",\n className: [\"size-7\", classNames?.[UI.NextMonthButton]],\n }),\n [UI.PreviousMonthButton]: buttonVariants({\n variant: \"ghost\",\n size: \"icon\",\n className: [\"size-7\", classNames?.[UI.PreviousMonthButton]],\n }),\n [UI.Week]: cn(\"mt-2 flex justify-between\", classNames?.[UI.Week]),\n [UI.Weeks]: cn(classNames?.[UI.Weeks]),\n [UI.Weekday]: cn(\"text-muted-foreground min-w-8.5 text-xs font-medium\", classNames?.[UI.Weekday]),\n [UI.Weekdays]: cn(\"flex w-full justify-between\", classNames?.[UI.Weekdays]),\n [UI.WeekNumber]: cn(\n \"text-muted-foreground min-w-8.5 grid h-8 place-items-center text-xs font-normal [&+*]:rounded-l-lg\",\n classNames?.[UI.WeekNumber],\n ),\n [UI.WeekNumberHeader]: cn(\"min-w-8.5\", classNames?.[UI.WeekNumberHeader]),\n [UI.YearsDropdown]: cn(classNames?.[UI.YearsDropdown]),\n\n [SelectionState.range_end]: cn(\n \"to-secondary is-range-end rounded-r-lg bg-gradient-to-l first:rounded-l-lg\",\n classNames?.[SelectionState.range_end],\n ),\n [SelectionState.range_middle]: cn(\n \"is-range-middle bg-secondary text-secondary-foreground first:rounded-l-lg last:rounded-r-lg\",\n classNames?.[SelectionState.range_middle],\n ),\n [SelectionState.range_start]: cn(\n \"to-secondary is-range-start rounded-l-lg bg-gradient-to-r last:rounded-r-lg\",\n classNames?.[SelectionState.range_start],\n ),\n [SelectionState.selected]: cn(\"is-selected\", classNames?.[SelectionState.selected]),\n\n [DayFlag.disabled]: cn(\"is-disabled\", classNames?.[DayFlag.disabled]),\n [DayFlag.focused]: cn(\"is-focused\", classNames?.[DayFlag.focused]),\n [DayFlag.hidden]: cn(\"is-hidden size-8\", classNames?.[DayFlag.hidden]),\n [DayFlag.outside]: cn(\"is-outside\", classNames?.[DayFlag.outside]),\n [DayFlag.today]: cn(\"is-today\", classNames?.[DayFlag.today]),\n }}\n components={{\n Chevron,\n }}\n showOutsideDays={showOutsideDays}\n {...props}\n />\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Component: CalendarRangeLabel\n * -------------------------------------------------------------------------- */\n\nfunction CalendarRangeLabel({\n date,\n formatStr = \"LLL dd, y\",\n placeholder = \"Pick a date\",\n}: {\n date: DateRange | undefined;\n formatStr?: string;\n placeholder?: string;\n}): ReactNode {\n if (!date?.from) {\n return <span className=\"truncate\">{placeholder}</span>;\n }\n\n const formattedFromDate = format(date.from, formatStr);\n\n if (!date.to) {\n return <span className=\"truncate\">{formattedFromDate}</span>;\n }\n\n const formattedToDate = format(date.to, formatStr);\n\n return (\n <span className=\"truncate\">\n {formattedFromDate} - {formattedToDate}\n </span>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Component: CalendarLabel\n * -------------------------------------------------------------------------- */\n\nfunction CalendarLabel({\n date,\n formatStr = \"PPP\",\n placeholder = \"Pick a date\",\n}: {\n date: Date | undefined;\n formatStr?: string;\n placeholder?: string;\n}): ReactNode {\n if (!date) {\n return <span className=\"truncate\">{placeholder}</span>;\n }\n\n return <span className=\"truncate\">{format(date, formatStr)}</span>;\n}\n\n/* -----------------------------------------------------------------------------\n * Exports\n * -------------------------------------------------------------------------- */\n\nexport type { DateRange, Matcher } from \"react-day-picker\";\nexport { Calendar, CalendarLabel, CalendarRangeLabel };\n"],"names":["Chevron","orientation","className","props","ChevronUpIcon","cn","ChevronDownIcon","ChevronLeftIcon","ChevronRightIcon","DotIcon","Calendar","showOutsideDays","classNames","isInteractive","undefined","DayPicker","UI","buttonVariants","SelectionState","DayFlag","CalendarRangeLabel","date","formatStr","placeholder","formattedFromDate","format","formattedToDate","CalendarLabel"],"mappings":";iMAgBA,SAASA,EAAQ,CAAEC,YAAAA,CAAW,CAAEC,UAAAA,CAAS,CAAE,GAAGC,EAAoD,EAChG,OAAQF,GACN,IAAK,KACH,MAAO,UAACG,EAAAA,aAAaA,CAAAA,CAAC,UAAWC,GAAAA,EAAAA,EAAAA,EAAG,SAAUH,GAAa,GAAGC,CAAK,EAGrE,KAAK,OACH,MAAO,UAACG,EAAAA,eAAeA,CAAAA,CAAC,UAAWD,GAAAA,EAAAA,EAAAA,EAAG,SAAUH,GAAa,GAAGC,CAAK,EAGvE,KAAK,OACH,MAAO,UAACI,EAAAA,eAAeA,CAAAA,CAAC,UAAWF,GAAAA,EAAAA,EAAAA,EAAG,SAAUH,GAAa,GAAGC,CAAK,EAGvE,KAAK,QACH,MAAO,UAACK,EAAAA,gBAAgBA,CAAAA,CAAC,UAAWH,GAAAA,EAAAA,EAAAA,EAAG,SAAUH,GAAa,GAAGC,CAAK,EAGxE,SACE,MAAO,UAACM,EAAAA,OAAOA,CAAAA,CAAC,UAAWJ,GAAAA,EAAAA,EAAAA,EAAG,SAAUH,GAAa,GAAGC,CAAK,EAEjE,CACF,CAMA,SAAS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Aa,CAK5B,EACC,GAAI,CAACF,GAAM,KACT,MAAO,UAAC,QAAK,UAAU,W,SAAYE,C,GAGrC,IAAMC,EAAoBC,GAAAA,EAAAA,MAAAA,EAAOJ,EAAK,IAAI,CAAEC,GAE5C,GAAI,CAACD,EAAK,EAAE,CACV,MAAO,UAAC,QAAK,UAAU,W,SAAYG,C,GAGrC,IAAME,EAAkBD,GAAAA,EAAAA,MAAAA,EAAOJ,EAAK,EAAE,CAAEC,GAExC,MACE,WAAC,QAAK,UAAU,W,UACbE,EAAkB,MAAIE,E,EAG7B,CAMA,SAASC,EAAc,CACrBN,KAAAA,CAAI,CACJC,UAAAA,EAAY,KAAK,CACjBC,YAAAA,EAAc,aAAa,CAK5B,SACC,EAIO,UAAC,QAAK,UAAU,W,SAAYE,GAAAA,EAAAA,MAAAA,EAAOJ,EAAMC,E,GAHvC,UAAC,QAAK,UAAU,W,SAAYC,C,EAIvC,Q"}
@@ -1 +1 @@
1
- {"version":3,"file":"components/chart.js","sources":["webpack://@codefast/ui/./src/components/chart.tsx"],"sourcesContent":["\n\nimport type { Scope } from \"@radix-ui/react-context\";\nimport type { ComponentProps, ComponentType, CSSProperties, JSX, ReactNode } from \"react\";\nimport type { NameType, Payload, ValueType } from \"recharts/types/component/DefaultTooltipContent\";\n\nimport { createContextScope } from \"@radix-ui/react-context\";\nimport { useId, useMemo } from \"react\";\nimport * as RechartsPrimitive from \"recharts\";\n\nimport { cn } from \"@/lib/utils\";\n\n/* -----------------------------------------------------------------------------\n * Context: ChartProvider\n * ---------------------------------------------------------------------------*/\n\nconst CHART_PROVIDER_NAME = \"ChartProvider\";\n\ntype ScopedProps<P> = P & { __scopeChart?: Scope };\n\n/**\n * Supported themes in the application\n */\ntype Theme = \"dark\" | \"light\";\n\n/**\n * Mapping between themes and their corresponding CSS classes\n */\nconst THEMES: Record<Theme, string> = {\n dark: \".dark\",\n light: \"\",\n};\n\n/**\n * Configuration for icon and label display in charts\n */\ninterface IconLabelConfig {\n /** Icon to display with data */\n icon?: ComponentType;\n /** Label to display with data */\n label?: ReactNode;\n}\n\n/**\n * Single color configuration for chart elements\n */\ntype ColorConfig = {\n /** Valid CSS color (hex, rgba, etc.) */\n color?: string;\n} & { theme?: never };\n\n/**\n * Theme-based color configuration for chart elements\n */\ntype ThemeConfig = {\n /** Map of colors for each theme mode */\n theme: Record<Theme, string>;\n} & { color?: never };\n\n/**\n * Complete configuration for a chart element\n */\ntype ChartConfigItem = (ColorConfig | ThemeConfig) & IconLabelConfig;\n\n/**\n * Configuration for the entire chart organized by series/data keys\n * Where keys are the names of data in the chart\n */\ntype ChartConfig = Record<string, ChartConfigItem | undefined>;\n\n/**\n * Value provided by Chart Context\n */\ninterface ChartContextValue {\n /** Display configuration for the chart */\n config: ChartConfig;\n}\n\nconst [createChartContext, createChartScope] = createContextScope(CHART_PROVIDER_NAME);\n\nconst [ChartContextProvider, useChartContext] = createChartContext<ChartContextValue>(CHART_PROVIDER_NAME);\n\n/* -----------------------------------------------------------------------------\n * Component: Chart\n * -------------------------------------------------------------------------- */\n\nfunction ChartContainer({\n __scopeChart,\n id,\n children,\n className,\n config,\n ...props\n}: ScopedProps<\n ComponentProps<\"div\"> & {\n children: ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>[\"children\"];\n config: ChartConfig;\n }\n>): JSX.Element {\n const uniqueId = useId();\n const chartId = `chart-${id || uniqueId}`;\n\n return (\n <ChartContextProvider config={config} scope={__scopeChart}>\n <div\n className={cn(\n \"[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-surface]:outline-hidden flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-sector[stroke='#fff']]:stroke-transparent\",\n className,\n )}\n data-chart={chartId}\n data-slot=\"chart\"\n {...props}\n >\n <ChartStyle config={config} id={chartId} />\n <RechartsPrimitive.ResponsiveContainer>{children}</RechartsPrimitive.ResponsiveContainer>\n </div>\n </ChartContextProvider>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Component: ChartStyle\n * -------------------------------------------------------------------------- */\n\nfunction ChartStyle({ id, config }: { config: ChartConfig; id: string }): ReactNode {\n const cssString = useMemo(() => generateCSS(id, config), [id, config]);\n\n return <style dangerouslySetInnerHTML={{ __html: cssString }} />;\n}\n\n/* -----------------------------------------------------------------------------\n * Component: ChartTooltip\n * -------------------------------------------------------------------------- */\n\nconst ChartTooltip = RechartsPrimitive.Tooltip;\n\n/* -----------------------------------------------------------------------------\n * Component: ChartTooltipContent\n * -------------------------------------------------------------------------- */\n\nconst CHART_TOOLTIP_CONTENT_NAME = \"ChartTooltipContent\";\n\nfunction ChartTooltipContent({\n __scopeChart,\n active,\n className,\n color,\n formatter,\n hideIndicator = false,\n hideLabel = false,\n indicator = \"dot\",\n label,\n labelClassName,\n labelFormatter,\n labelKey,\n nameKey,\n payload,\n}: ScopedProps<\n ComponentProps<typeof RechartsPrimitive.Tooltip> &\n Omit<ComponentProps<\"div\">, \"content\"> & {\n hideIndicator?: boolean;\n hideLabel?: boolean;\n indicator?: \"dashed\" | \"dot\" | \"line\";\n labelKey?: string;\n nameKey?: string;\n }\n>): ReactNode {\n const { config } = useChartContext(CHART_TOOLTIP_CONTENT_NAME, __scopeChart);\n\n const tooltipLabel = useMemo(() => {\n if (hideLabel || !payload?.length) {\n return null;\n }\n\n const [item] = payload;\n\n const key = `${labelKey || item.dataKey || item.name || \"value\"}`;\n const itemConfig = getPayloadConfigFromPayload(config, item, key);\n const value = !labelKey && typeof label === \"string\" ? config[label]?.label || label : itemConfig?.label;\n\n if (labelFormatter) {\n return <div className={cn(\"font-medium\", labelClassName)}>{labelFormatter(value, payload)}</div>;\n }\n\n if (!value) {\n return null;\n }\n\n return <div className={cn(\"font-medium\", labelClassName)}>{value}</div>;\n }, [config, hideLabel, label, labelClassName, labelFormatter, labelKey, payload]);\n\n if (!active || !payload?.length) {\n return null;\n }\n\n const nestLabel = payload.length === 1 && indicator !== \"dot\";\n\n return (\n <div\n className={cn(\n \"bg-background grid min-w-32 items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl\",\n className,\n )}\n >\n {nestLabel ? null : tooltipLabel}\n <div className=\"grid gap-1.5\">\n {payload.map((item, index) => {\n const key = `${nameKey || item.name || item.dataKey || \"value\"}`;\n const itemConfig = getPayloadConfigFromPayload(config, item, key);\n const indicatorColor = color || (item.payload as { fill?: string }).fill || item.color;\n\n return (\n <div\n key={item.dataKey}\n className={cn(\n \"[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:size-2.5\",\n indicator === \"dot\" && \"items-center\",\n )}\n >\n {formatter && item.value !== undefined && item.name ? (\n formatter(item.value, item.name, item, index, item.payload as Payload<ValueType, NameType>[])\n ) : (\n <>\n {itemConfig?.icon ? (\n <itemConfig.icon />\n ) : (\n !hideIndicator && (\n <div\n className={cn(\"border-(--color-border) bg-(--color-bg) rounded-xs shrink-0\", {\n \"h-2.5 w-2.5\": indicator === \"dot\",\n \"my-0.5\": nestLabel && indicator === \"dashed\",\n \"w-0 border border-dashed bg-transparent\": indicator === \"dashed\",\n \"w-1\": indicator === \"line\",\n })}\n style={\n {\n \"--color-bg\": indicatorColor,\n \"--color-border\": indicatorColor,\n } as CSSProperties\n }\n />\n )\n )}\n <div\n className={cn(\"flex flex-1 justify-between leading-none\", nestLabel ? \"items-end\" : \"items-center\")}\n >\n <div className=\"grid gap-1.5\">\n {nestLabel ? tooltipLabel : null}\n <span className=\"text-muted-foreground\">{itemConfig?.label || item.name}</span>\n </div>\n {item.value ? (\n <span className=\"text-foreground font-mono font-medium tabular-nums\">\n {item.value.toLocaleString()}\n </span>\n ) : null}\n </div>\n </>\n )}\n </div>\n );\n })}\n </div>\n </div>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Component: ChartLegend\n * -------------------------------------------------------------------------- */\n\nconst ChartLegend = RechartsPrimitive.Legend;\n\n/* -----------------------------------------------------------------------------\n * Component: ChartLegendContent\n * -------------------------------------------------------------------------- */\n\nconst CHART_LEGEND_CONTENT_NAME = \"ChartLegendContent\";\n\nfunction ChartLegendContent({\n __scopeChart,\n className,\n hideIcon = false,\n nameKey,\n payload,\n verticalAlign = \"bottom\",\n}: ScopedProps<\n ComponentProps<\"div\"> &\n Pick<RechartsPrimitive.LegendProps, \"payload\" | \"verticalAlign\"> & {\n hideIcon?: boolean;\n nameKey?: string;\n }\n>): ReactNode {\n const { config } = useChartContext(CHART_LEGEND_CONTENT_NAME, __scopeChart);\n\n if (!payload?.length) {\n return null;\n }\n\n return (\n <div className={cn(\"flex items-center justify-center gap-4\", verticalAlign === \"top\" ? \"pb-3\" : \"pt-3\", className)}>\n {payload.map((item) => {\n let key = \"value\";\n\n if (nameKey) {\n key = nameKey;\n } else if (item.dataKey) {\n key = String(item.dataKey);\n }\n\n const itemConfig = getPayloadConfigFromPayload(config, item, key);\n\n return (\n <div\n key={String(item.value)}\n className={cn(\"[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:size-3\")}\n >\n {itemConfig?.icon && !hideIcon ? (\n <itemConfig.icon />\n ) : (\n <div\n className=\"size-2 shrink-0 rounded-md\"\n style={{\n backgroundColor: item.color,\n }}\n />\n )}\n {itemConfig?.label}\n </div>\n );\n })}\n </div>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Helpers\n * -------------------------------------------------------------------------- */\n\n/**\n * Extracts and returns the appropriate configuration object from\n * the payload based on the specified key.\n *\n * @param config - The chart configuration object that contains various\n * settings.\n * @param payload - The payload object that might contain nested payload data.\n * @param key - The key used to retrieve the specific configuration from the\n * chart config.\n * @returns Returns a configuration object with optional properties `icon`,\n * `label`, `color` or `theme`, or `undefined` if the payload is invalid or\n * no configuration is found for the provided key.\n */\nfunction getPayloadConfigFromPayload(config: ChartConfig, payload: unknown, key: string): ChartConfigItem | undefined {\n if (!isValidObject(payload)) {\n return undefined;\n }\n\n const nestedPayload = \"payload\" in payload && isValidObject(payload.payload) ? payload.payload : undefined;\n\n const configLabelKey = getConfigLabelKey(payload, nestedPayload, key);\n\n return configLabelKey in config ? config[configLabelKey] : config[key];\n}\n\n/**\n * Checks if the provided value is a valid object.\n *\n * @param obj - The value to check.\n * @returns - Returns true if the value is an object and not null, false\n * otherwise.\n */\nfunction isValidObject(obj: unknown): obj is Record<string, unknown> {\n return typeof obj === \"object\" && obj !== null;\n}\n\n/**\n * Retrieves the configuration label key from either the payload or\n * nestedPayload. If the key exists in the payload and is a string, the\n * corresponding value is returned. Otherwise, if the key exists in the\n * nestedPayload and is a string, its value is returned. If the key is not\n * found as a string in either object, the key itself is returned.\n *\n * @param payload - The primary payload containing key-value pairs.\n * @param nestedPayload - An optional nested payload containing additional\n * key-value pairs.\n * @param key - The key to search for within the payload and nestedPayload.\n *\n * @returns The string value associated with the key if found; otherwise, the\n * key itself.\n */\nfunction getConfigLabelKey(\n payload: Record<string, unknown>,\n nestedPayload: Record<string, unknown> | undefined,\n key: string,\n): string {\n if (key in payload && typeof payload[key] === \"string\") {\n return payload[key];\n }\n\n if (nestedPayload && key in nestedPayload && typeof nestedPayload[key] === \"string\") {\n return nestedPayload[key];\n }\n\n return key;\n}\n\n/**\n * Generates CSS for a specified theme and chart configuration.\n *\n * @param theme - The theme to be used (for example, 'light', 'dark').\n * @param id - The unique identifier of the chart.\n * @param configEntries - A list of configuration entries, each containing a\n * key and a chart configuration.\n * @returns The generated CSS as a string.\n */\nfunction generateThemeCSS(theme: Theme, id: string, configEntries: [string, ChartConfig[string]][]): string {\n const rules: string[] = [];\n\n rules.push(`${THEMES[theme]} [data-chart=${id}] {`);\n\n for (const [key, itemConfig] of configEntries) {\n const color = itemConfig?.theme?.[theme] || itemConfig?.color;\n\n if (color) {\n rules.push(` --color-${key}: ${color};`);\n }\n }\n\n rules.push(\"}\");\n\n return rules.join(\"\\n\");\n}\n\n/**\n * Generates CSS styles for a chart based on the provided configuration and\n * themes.\n *\n * @param id - The unique identifier for the chart element.\n * @param config - Configuration object for the chart. This includes theme and\n * color settings.\n * @returns A string containing the generated CSS rules.\n */\nfunction generateCSS(id: string, config: ChartConfig): string {\n const themeOrColorConfig = Object.entries(config).filter(([_, itemConfig]) => itemConfig?.theme || itemConfig?.color);\n\n const allRules: string[] = [];\n\n for (const theme of Object.keys(THEMES)) {\n const themeCSS = generateThemeCSS(theme as Theme, id, themeOrColorConfig);\n\n allRules.push(themeCSS);\n }\n\n return allRules.join(\"\\n\");\n}\n\n/* -----------------------------------------------------------------------------\n * Exports\n * -------------------------------------------------------------------------- */\n\nexport type { ChartConfig };\nexport {\n ChartContainer,\n ChartLegend,\n ChartLegendContent,\n ChartStyle,\n ChartTooltip,\n ChartTooltipContent,\n createChartScope,\n};\n"],"names":["CHART_PROVIDER_NAME","THEMES","createChartContext","createChartScope","createContextScope","ChartContextProvider","useChartContext","ChartContainer","__scopeChart","id","children","className","config","props","uniqueId","useId","chartId","cn","ChartStyle","RechartsPrimitive","cssString","useMemo","generateCSS","themeOrColorConfig","Object","_","itemConfig","allRules","theme","themeCSS","generateThemeCSS","configEntries","rules","key","color","ChartTooltip","ChartTooltipContent","active","formatter","hideIndicator","hideLabel","indicator","label","labelClassName","labelFormatter","labelKey","nameKey","payload","tooltipLabel","item","getPayloadConfigFromPayload","value","nestLabel","index","indicatorColor","undefined","ChartLegend","ChartLegendContent","hideIcon","verticalAlign","String","nestedPayload","isValidObject","configLabelKey","obj"],"mappings":";mKAgBA,IAAMA,EAAsB,gBAYtBC,EAAgC,CACpC,KAAM,QACN,MAAO,EACT,EA+CM,CAACC,EAAoBC,EAAiB,CAAGC,GAAAA,EAAAA,kBAA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CAFA5B,EAlCiEA,KAoCtDc,GAAW,iBAAOA,CAAO,CAACd,EAAI,CAChCc,CAAO,CAACd,EAAI,CAGjB4B,GAAiB5B,KAAO4B,GAAiB,iBAAOA,CAAa,CAAC5B,EAAI,CAC7D4B,CAAa,CAAC5B,EAAI,CAGpBA,GA1CP,OAAO8B,KAAkBnD,EAASA,CAAM,CAACmD,EAAe,CAAGnD,CAAM,CAACqB,EAAI,CAUxE,SAAS6B,EAAcE,CAAY,EACjC,MAAO,iBAAOA,GAAoBA,OAAAA,CACpC,Q"}
1
+ {"version":3,"file":"components/chart.js","sources":["webpack://@codefast/ui/./src/components/chart.tsx"],"sourcesContent":["\n\nimport type { Scope } from \"@radix-ui/react-context\";\nimport type { ComponentProps, ComponentType, CSSProperties, JSX, ReactNode } from \"react\";\nimport type { NameType, Payload, ValueType } from \"recharts/types/component/DefaultTooltipContent\";\n\nimport { createContextScope } from \"@radix-ui/react-context\";\nimport { useId, useMemo } from \"react\";\nimport * as RechartsPrimitive from \"recharts\";\n\nimport { cn } from \"@/lib/utils\";\n\n/* -----------------------------------------------------------------------------\n * Context: ChartProvider\n * ---------------------------------------------------------------------------*/\n\nconst CHART_PROVIDER_NAME = \"ChartProvider\";\n\ntype ScopedProps<P> = P & { __scopeChart?: Scope };\n\n/**\n * Supported themes in the application\n */\ntype Theme = \"dark\" | \"light\";\n\n/**\n * Mapping between themes and their corresponding CSS classes\n */\nconst THEMES: Record<Theme, string> = {\n dark: \".dark\",\n light: \"\",\n};\n\n/**\n * Configuration for icon and label display in charts\n */\ninterface IconLabelConfig {\n /** Icon to display with data */\n icon?: ComponentType;\n /** Label to display with data */\n label?: ReactNode;\n}\n\n/**\n * Single color configuration for chart elements\n */\ntype ColorConfig = {\n /** Valid CSS color (hex, rgba, etc.) */\n color?: string;\n} & { theme?: never };\n\n/**\n * Theme-based color configuration for chart elements\n */\ntype ThemeConfig = {\n /** Map of colors for each theme mode */\n theme: Record<Theme, string>;\n} & { color?: never };\n\n/**\n * Complete configuration for a chart element\n */\ntype ChartConfigItem = (ColorConfig | ThemeConfig) & IconLabelConfig;\n\n/**\n * Configuration for the entire chart organized by series/data keys\n * Where keys are the names of data in the chart\n */\ntype ChartConfig = Record<string, ChartConfigItem | undefined>;\n\n/**\n * Value provided by Chart Context\n */\ninterface ChartContextValue {\n /** Display configuration for the chart */\n config: ChartConfig;\n}\n\nconst [createChartContext, createChartScope] = createContextScope(CHART_PROVIDER_NAME);\n\nconst [ChartContextProvider, useChartContext] = createChartContext<ChartContextValue>(CHART_PROVIDER_NAME);\n\n/* -----------------------------------------------------------------------------\n * Component: Chart\n * -------------------------------------------------------------------------- */\n\nfunction ChartContainer({\n __scopeChart,\n id,\n children,\n className,\n config,\n ...props\n}: ScopedProps<\n ComponentProps<\"div\"> & {\n children: ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>[\"children\"];\n config: ChartConfig;\n }\n>): JSX.Element {\n const uniqueId = useId();\n const chartId = `chart-${id || uniqueId}`;\n\n return (\n <ChartContextProvider config={config} scope={__scopeChart}>\n <div\n className={cn(\n \"[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-surface]:outline-hidden flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-sector[stroke='#fff']]:stroke-transparent\",\n className,\n )}\n data-chart={chartId}\n data-slot=\"chart\"\n {...props}\n >\n <ChartStyle config={config} id={chartId} />\n <RechartsPrimitive.ResponsiveContainer>{children}</RechartsPrimitive.ResponsiveContainer>\n </div>\n </ChartContextProvider>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Component: ChartStyle\n * -------------------------------------------------------------------------- */\n\nfunction ChartStyle({ id, config }: { config: ChartConfig; id: string }): ReactNode {\n const cssString = useMemo(() => generateCSS(id, config), [id, config]);\n\n return <style dangerouslySetInnerHTML={{ __html: cssString }} />;\n}\n\n/* -----------------------------------------------------------------------------\n * Component: ChartTooltip\n * -------------------------------------------------------------------------- */\n\nconst ChartTooltip = RechartsPrimitive.Tooltip;\n\n/* -----------------------------------------------------------------------------\n * Component: ChartTooltipContent\n * -------------------------------------------------------------------------- */\n\nconst CHART_TOOLTIP_CONTENT_NAME = \"ChartTooltipContent\";\n\nfunction ChartTooltipContent({\n __scopeChart,\n active,\n className,\n color,\n formatter,\n hideIndicator = false,\n hideLabel = false,\n indicator = \"dot\",\n label,\n labelClassName,\n labelFormatter,\n labelKey,\n nameKey,\n payload,\n}: ScopedProps<\n ComponentProps<typeof RechartsPrimitive.Tooltip> &\n Omit<ComponentProps<\"div\">, \"content\"> & {\n hideIndicator?: boolean;\n hideLabel?: boolean;\n indicator?: \"dashed\" | \"dot\" | \"line\";\n labelKey?: string;\n nameKey?: string;\n }\n>): ReactNode {\n const { config } = useChartContext(CHART_TOOLTIP_CONTENT_NAME, __scopeChart);\n\n const tooltipLabel = useMemo(() => {\n if (hideLabel || !payload?.length) {\n return null;\n }\n\n const [item] = payload;\n\n const key = `${labelKey || item.dataKey || item.name || \"value\"}`;\n const itemConfig = getPayloadConfigFromPayload(config, item, key);\n const value = !labelKey && typeof label === \"string\" ? config[label]?.label || label : itemConfig?.label;\n\n if (labelFormatter) {\n return <div className={cn(\"font-medium\", labelClassName)}>{labelFormatter(value, payload)}</div>;\n }\n\n if (!value) {\n return null;\n }\n\n return <div className={cn(\"font-medium\", labelClassName)}>{value}</div>;\n }, [config, hideLabel, label, labelClassName, labelFormatter, labelKey, payload]);\n\n if (!active || !payload?.length) {\n return null;\n }\n\n const nestLabel = payload.length === 1 && indicator !== \"dot\";\n\n return (\n <div\n className={cn(\n \"bg-background grid min-w-32 items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl\",\n className,\n )}\n >\n {nestLabel ? null : tooltipLabel}\n <div className=\"grid gap-1.5\">\n {payload.map((item, index) => {\n const key = `${nameKey || item.name || item.dataKey || \"value\"}`;\n const itemConfig = getPayloadConfigFromPayload(config, item, key);\n const indicatorColor = color || (item.payload as { fill?: string }).fill || item.color;\n\n return (\n <div\n key={item.dataKey}\n className={cn(\n \"[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:size-2.5\",\n indicator === \"dot\" && \"items-center\",\n )}\n >\n {formatter && item.value !== undefined && item.name ? (\n formatter(item.value, item.name, item, index, item.payload as Payload<ValueType, NameType>[])\n ) : (\n <>\n {itemConfig?.icon ? (\n <itemConfig.icon />\n ) : (\n !hideIndicator && (\n <div\n className={cn(\"border-(--color-border) bg-(--color-bg) rounded-xs shrink-0\", {\n \"h-2.5 w-2.5\": indicator === \"dot\",\n \"my-0.5\": nestLabel && indicator === \"dashed\",\n \"w-0 border border-dashed bg-transparent\": indicator === \"dashed\",\n \"w-1\": indicator === \"line\",\n })}\n style={\n {\n \"--color-bg\": indicatorColor,\n \"--color-border\": indicatorColor,\n } as CSSProperties\n }\n />\n )\n )}\n <div\n className={cn(\"flex flex-1 justify-between leading-none\", nestLabel ? \"items-end\" : \"items-center\")}\n >\n <div className=\"grid gap-1.5\">\n {nestLabel ? tooltipLabel : null}\n <span className=\"text-muted-foreground\">{itemConfig?.label || item.name}</span>\n </div>\n {item.value ? (\n <span className=\"text-foreground font-mono font-medium tabular-nums\">\n {item.value.toLocaleString()}\n </span>\n ) : null}\n </div>\n </>\n )}\n </div>\n );\n })}\n </div>\n </div>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Component: ChartLegend\n * -------------------------------------------------------------------------- */\n\nconst ChartLegend = RechartsPrimitive.Legend;\n\n/* -----------------------------------------------------------------------------\n * Component: ChartLegendContent\n * -------------------------------------------------------------------------- */\n\nconst CHART_LEGEND_CONTENT_NAME = \"ChartLegendContent\";\n\nfunction ChartLegendContent({\n __scopeChart,\n className,\n hideIcon = false,\n nameKey,\n payload,\n verticalAlign = \"bottom\",\n}: ScopedProps<\n ComponentProps<\"div\"> &\n Pick<RechartsPrimitive.LegendProps, \"payload\" | \"verticalAlign\"> & {\n hideIcon?: boolean;\n nameKey?: string;\n }\n>): ReactNode {\n const { config } = useChartContext(CHART_LEGEND_CONTENT_NAME, __scopeChart);\n\n if (!payload?.length) {\n return null;\n }\n\n return (\n <div className={cn(\"flex items-center justify-center gap-4\", verticalAlign === \"top\" ? \"pb-3\" : \"pt-3\", className)}>\n {payload.map((item) => {\n let key = \"value\";\n\n if (nameKey) {\n key = nameKey;\n } else if (item.dataKey) {\n key = String(item.dataKey);\n }\n\n const itemConfig = getPayloadConfigFromPayload(config, item, key);\n\n return (\n <div\n key={String(item.value)}\n className={cn(\"[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:size-3\")}\n >\n {itemConfig?.icon && !hideIcon ? (\n <itemConfig.icon />\n ) : (\n <div\n className=\"size-2 shrink-0 rounded-md\"\n style={{\n backgroundColor: item.color,\n }}\n />\n )}\n {itemConfig?.label}\n </div>\n );\n })}\n </div>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Helpers\n * -------------------------------------------------------------------------- */\n\n/**\n * Extracts and returns the appropriate configuration object from\n * the payload based on the specified key.\n *\n * @param config - The chart configuration object that contains various\n * settings.\n * @param payload - The payload object that might contain nested payload data.\n * @param key - The key used to retrieve the specific configuration from the\n * chart config.\n * @returns Returns a configuration object with optional properties `icon`,\n * `label`, `color` or `theme`, or `undefined` if the payload is invalid or\n * no configuration is found for the provided key.\n */\nfunction getPayloadConfigFromPayload(config: ChartConfig, payload: unknown, key: string): ChartConfigItem | undefined {\n if (!isValidObject(payload)) {\n return undefined;\n }\n\n const nestedPayload = \"payload\" in payload && isValidObject(payload.payload) ? payload.payload : undefined;\n\n const configLabelKey = getConfigLabelKey(payload, nestedPayload, key);\n\n return configLabelKey in config ? config[configLabelKey] : config[key];\n}\n\n/**\n * Checks if the provided value is a valid object.\n *\n * @param obj - The value to check.\n * @returns - Returns true if the value is an object and not null, false\n * otherwise.\n */\nfunction isValidObject(obj: unknown): obj is Record<string, unknown> {\n return typeof obj === \"object\" && obj !== null;\n}\n\n/**\n * Retrieves the configuration label key from either the payload or\n * nestedPayload. If the key exists in the payload and is a string, the\n * corresponding value is returned. Otherwise, if the key exists in the\n * nestedPayload and is a string, its value is returned. If the key is not\n * found as a string in either object, the key itself is returned.\n *\n * @param payload - The primary payload containing key-value pairs.\n * @param nestedPayload - An optional nested payload containing additional\n * key-value pairs.\n * @param key - The key to search for within the payload and nestedPayload.\n *\n * @returns The string value associated with the key if found; otherwise, the\n * key itself.\n */\nfunction getConfigLabelKey(\n payload: Record<string, unknown>,\n nestedPayload: Record<string, unknown> | undefined,\n key: string,\n): string {\n if (key in payload && typeof payload[key] === \"string\") {\n return payload[key];\n }\n\n if (nestedPayload && key in nestedPayload && typeof nestedPayload[key] === \"string\") {\n return nestedPayload[key];\n }\n\n return key;\n}\n\n/**\n * Generates CSS for a specified theme and chart configuration.\n *\n * @param theme - The theme to be used (for example, 'light', 'dark').\n * @param id - The unique identifier of the chart.\n * @param configEntries - A list of configuration entries, each containing a\n * key and a chart configuration.\n * @returns The generated CSS as a string.\n */\nfunction generateThemeCSS(theme: Theme, id: string, configEntries: [string, ChartConfig[string]][]): string {\n const rules: string[] = [];\n\n rules.push(`${THEMES[theme]} [data-chart=${id}] {`);\n\n for (const [key, itemConfig] of configEntries) {\n const color = itemConfig?.theme?.[theme] || itemConfig?.color;\n\n if (color) {\n rules.push(` --color-${key}: ${color};`);\n }\n }\n\n rules.push(\"}\");\n\n return rules.join(\"\\n\");\n}\n\n/**\n * Generates CSS styles for a chart based on the provided configuration and\n * themes.\n *\n * @param id - The unique identifier for the chart element.\n * @param config - Configuration object for the chart. This includes theme and\n * color settings.\n * @returns A string containing the generated CSS rules.\n */\nfunction generateCSS(id: string, config: ChartConfig): string {\n const themeOrColorConfig = Object.entries(config).filter(([_, itemConfig]) => itemConfig?.theme || itemConfig?.color);\n\n const allRules: string[] = [];\n\n for (const theme of Object.keys(THEMES)) {\n const themeCSS = generateThemeCSS(theme as Theme, id, themeOrColorConfig);\n\n allRules.push(themeCSS);\n }\n\n return allRules.join(\"\\n\");\n}\n\n/* -----------------------------------------------------------------------------\n * Exports\n * -------------------------------------------------------------------------- */\n\nexport type { ChartConfig };\nexport {\n ChartContainer,\n ChartLegend,\n ChartLegendContent,\n ChartStyle,\n ChartTooltip,\n ChartTooltipContent,\n createChartScope,\n};\n"],"names":["CHART_PROVIDER_NAME","THEMES","createChartContext","createChartScope","createContextScope","ChartContextProvider","useChartContext","ChartContainer","__scopeChart","id","children","className","config","props","uniqueId","useId","chartId","cn","ChartStyle","RechartsPrimitive","cssString","useMemo","generateCSS","themeOrColorConfig","Object","_","itemConfig","allRules","theme","themeCSS","generateThemeCSS","configEntries","rules","key","color","ChartTooltip","ChartTooltipContent","active","formatter","hideIndicator","hideLabel","indicator","label","labelClassName","labelFormatter","labelKey","nameKey","payload","tooltipLabel","item","getPayloadConfigFromPayload","value","nestLabel","index","indicatorColor","undefined","ChartLegend","ChartLegendContent","hideIcon","verticalAlign","String","nestedPayload","isValidObject","configLabelKey","obj"],"mappings":";mKAgBA,IAAMA,EAAsB,gBAYtBC,EAAgC,CACpC,KAAM,QACN,MAAO,EACT,EA+CM,CAACC,EAAoBC,EAAiB,CAAGC,GAAAA,EAAAA,kBAAAA,EAAmBJ,GAE5D,CAACK,EAAsBC,EAAgB,CAAGJ,EAAsCF,GAMtF,SAASO,EAAe,CACtBC,aAAAA,CAAY,CACZC,GAAAA,CAAE,CACFC,SAAAA,CAAQ,CACRC,UAAAA,CAAS,CACTC,OAAAA,CAAM,CACN,GAAGC,EAMJ,EACC,IAAMC,EAAWC,GAAAA,EAAAA,KAAAA,IACXC,EAAU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AI,CAUxE,SAAS6B,EAAcE,CAAY,EACjC,MAAO,iBAAOA,GAAoBA,OAAAA,CACpC,Q"}
@@ -1 +1 @@
1
- {"version":3,"file":"components/form.js","sources":["webpack://@codefast/ui/./src/components/form.tsx"],"sourcesContent":["\n\nimport type { Scope } from \"@radix-ui/react-context\";\nimport type * as LabelPrimitive from \"@radix-ui/react-label\";\nimport type { ComponentProps, JSX, ReactNode } from \"react\";\nimport type { ControllerProps, FieldError, FieldPath, FieldValues } from \"react-hook-form\";\n\nimport { createContextScope } from \"@radix-ui/react-context\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { useId } from \"react\";\nimport { Controller, FormProvider, useFormContext, useFormState } from \"react-hook-form\";\n\nimport { Label } from \"@/components/label\";\nimport { cn } from \"@/lib/utils\";\n\n/* -----------------------------------------------------------------------------\n * Component: Form\n * -------------------------------------------------------------------------- */\n\nconst Form = FormProvider;\n\n/* -----------------------------------------------------------------------------\n * Context: FormField\n * -------------------------------------------------------------------------- */\n\nconst FORM_FIELD_NAME = \"FormField\";\n\ntype ScopedProps<P> = P & { __scopeFormField?: Scope };\n\nconst [createFormFieldContext, createFormFieldScope] = createContextScope(FORM_FIELD_NAME);\n\ninterface FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> {\n name: TName;\n}\n\nconst [FormFieldContextProvider, useFormFieldContext] = createFormFieldContext<FormFieldContextValue>(FORM_FIELD_NAME);\n\nfunction useFormItem(\n consumerName: string,\n scope: Scope,\n): {\n formDescriptionId: string;\n formItemId: string;\n formMessageId: string;\n id: string;\n invalid: boolean;\n isDirty: boolean;\n isTouched: boolean;\n isValidating: boolean;\n name: string;\n error?: FieldError;\n} {\n const { id } = useFormItemContext(consumerName, scope);\n const { name } = useFormFieldContext(consumerName, scope);\n const { getFieldState } = useFormContext();\n const formState = useFormState({ name });\n const fieldState = getFieldState(name, formState);\n\n return {\n id,\n name,\n formDescriptionId: `form-item-description-${id}`,\n formItemId: `form-item-${id}`,\n formMessageId: `form-item-message-${id}`,\n ...fieldState,\n };\n}\n\n/* -----------------------------------------------------------------------------\n * Component: FormField\n * -------------------------------------------------------------------------- */\n\nfunction FormField<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>(formFieldProps: ScopedProps<ControllerProps<TFieldValues, TName>>): JSX.Element {\n const { __scopeFormField, ...props } = formFieldProps;\n\n return (\n <FormFieldContextProvider name={props.name} scope={__scopeFormField}>\n <Controller {...props} />\n </FormFieldContextProvider>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Context: FormItem\n * -------------------------------------------------------------------------- */\n\nconst FORM_ITEM_NAME = \"FormItem\";\n\ninterface FormItemContextValue {\n id: string;\n}\n\nconst [FormItemContextProvider, useFormItemContext] = createFormFieldContext<FormItemContextValue>(FORM_ITEM_NAME);\n\n/* -----------------------------------------------------------------------------\n * Component: FormItem\n * -------------------------------------------------------------------------- */\n\nfunction FormItem({ __scopeFormField, className, ...props }: ScopedProps<ComponentProps<\"div\">>): JSX.Element {\n const id = useId();\n\n return (\n <FormItemContextProvider id={id} scope={__scopeFormField}>\n <div className={cn(\"grid gap-2\", className)} data-slot=\"form-item\" {...props} />\n </FormItemContextProvider>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Component: FormLabel\n * -------------------------------------------------------------------------- */\n\nconst FORM_LABEL_NAME = \"FormLabel\";\n\nfunction FormLabel({\n __scopeFormField,\n ...props\n}: ScopedProps<ComponentProps<typeof LabelPrimitive.Root>>): JSX.Element {\n const { formItemId, error } = useFormItem(FORM_LABEL_NAME, __scopeFormField);\n\n return <Label data-invalid={error ? true : undefined} data-slot=\"form-label\" htmlFor={formItemId} {...props} />;\n}\n\n/* -----------------------------------------------------------------------------\n * Component: FormControl\n * -------------------------------------------------------------------------- */\n\nconst FORM_CONTROL_NAME = \"FormControl\";\n\nfunction FormControl({ __scopeFormField, ...props }: ScopedProps<ComponentProps<typeof Slot>>): JSX.Element {\n const { formDescriptionId, formItemId, formMessageId, error } = useFormItem(FORM_CONTROL_NAME, __scopeFormField);\n\n return (\n <Slot\n aria-describedby={error ? `${formDescriptionId} ${formMessageId}` : formDescriptionId}\n aria-invalid={Boolean(error)}\n data-slot=\"form-control\"\n id={formItemId}\n {...props}\n />\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Component: FormDescription\n * -------------------------------------------------------------------------- */\n\nfunction FormDescription({ __scopeFormField, className, ...props }: ScopedProps<ComponentProps<\"p\">>): JSX.Element {\n const { formDescriptionId } = useFormItem(FORM_MESSAGE_NAME, __scopeFormField);\n\n return (\n <p\n className={cn(\"text-muted-foreground text-xs\", className)}\n data-slot=\"form-description\"\n id={formDescriptionId}\n {...props}\n />\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Component: FormMessage\n * -------------------------------------------------------------------------- */\n\nconst FORM_MESSAGE_NAME = \"FormMessage\";\n\nfunction FormMessage({ __scopeFormField, children, className, ...props }: ScopedProps<ComponentProps<\"p\">>): ReactNode {\n const { formMessageId, error } = useFormItem(FORM_MESSAGE_NAME, __scopeFormField);\n const body = error?.message ? String(error.message) : children;\n\n if (!body) {\n return null;\n }\n\n return (\n <p\n className={cn(\"text-xs\", error?.message ? \"text-destructive font-medium\" : \"text-muted-foreground\", className)}\n data-slot=\"form-message\"\n id={formMessageId}\n {...props}\n >\n {body}\n </p>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Exports\n * -------------------------------------------------------------------------- */\n\nexport { createFormFieldScope, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage };\n"],"names":["Form","FormProvider","FORM_FIELD_NAME","createFormFieldContext","createFormFieldScope","createContextScope","FormFieldContextProvider","useFormFieldContext","useFormItem","consumerName","scope","id","useFormItemContext","name","getFieldState","useFormContext","formState","useFormState","fieldState","FormField","formFieldProps","__scopeFormField","props","Controller","FormItemContextProvider","FormItem","className","useId","cn","FormLabel","formItemId","error","Label","undefined","FormControl","formDescriptionId","formMessageId","Slot","Boolean","FormDescription","FORM_MESSAGE_NAME","FormMessage","children","body","String"],"mappings":";8OAmBA,IAAMA,EAAOC,EAAAA,YAAYA,CAMnBC,EAAkB,YAIlB,CAACC,EAAwBC,EAAqB,CAAGC,GAAAA,EAAAA,kBAAAA,EAAmBH,GASpE,CAACI,EAA0BC,EAAoB,CAAGJ,EAA8CD,GAEtG,SAASM,EACPC,CAAoB,CACpBC,CAAY,EAaZ,GAAM,CAAEC,GAAAA,CAAE,CAAE,CAAGC,EAAmBH,EAAcC,GAC1C,CAAEG,KAAAA,CAAI,CAAE,CAAGN,EAAoBE,EAAcC,GAC7C,CAAEI,cAAAA,CAAa,CAAE,CAAGC,GAAAA,EAAAA,cAAAA,IACpBC,EAAYC,GAAAA,EAAAA,YAAAA,EAAa,CAAEJ,KAAAA,CAAK,GAChCK,EAAaJ,EAAcD,EAAMG,GAEvC,MAAO,CACLL,GAAAA,EACAE,KAAAA,EACA,kBAAmB,CAAC,sBAAsB,EAAEF,EAAG,CAAC,CAChD,WAAY,CAAC,UAAU,EAAEA,EAAG,CAAC,CAC7B,cAAe,CAAC,kBAAkB,EAAEA,EAAG,CAAC,CACxC,GAAGO,CAAU,CAEjB,CAMA,SAASC,EAGPC,CAAiE,EACjE,GAAM,CAAEC,iBAAAA,CAAgB,CAAE,GAAGC,EAAO,CAAGF,EAEvC,MACE,UAACd,EAAAA,CAAyB,KAAMgB,EAAM,IAAI,CAAE,MAAOD,E,SACjD,UAACE,EAAAA,UAAUA,CAAAA,CAAE,GAAGD,CAAK,IAG3B,CAYA,GAAM,CAACE,EAAyBZ,EAAmB,CAAGT,EAN/B,YAYvB,SAASsB,EAAS,CAAEJ,iBAAAA,CAAgB,CAAEK,UAAAA,CAAS,CAAE,GAAGJ,EAA2C,EAC7F,IAAMX,EAAKgB,GAAAA,EAAAA,KAAAA,IAEX,MACE,UAACH,EAAAA,CAAwB,GAAIb,EAAI,MAAOU,E,SACtC,UAAC,OAAI,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,GAAO,QAAUa,OAAOb,EAAM,OAAO,EAAIW,SAEtD,EAKE,UAAC,KACC,UAAWd,GAAAA,EAAAA,EAAAA,EAAG,UAAWG,GAAO,QAAU,+BAAiC,wBAAyBL,GACpG,YAAU,eACV,GAAIU,EACH,GAAGd,CAAK,C,SAERqB,C,GAVI,IAaX,Q"}
1
+ {"version":3,"file":"components/form.js","sources":["webpack://@codefast/ui/./src/components/form.tsx"],"sourcesContent":["\n\nimport type { Scope } from \"@radix-ui/react-context\";\nimport type * as LabelPrimitive from \"@radix-ui/react-label\";\nimport type { ComponentProps, JSX, ReactNode } from \"react\";\nimport type { ControllerProps, FieldError, FieldPath, FieldValues } from \"react-hook-form\";\n\nimport { createContextScope } from \"@radix-ui/react-context\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { useId } from \"react\";\nimport { Controller, FormProvider, useFormContext, useFormState } from \"react-hook-form\";\n\nimport { Label } from \"@/components/label\";\nimport { cn } from \"@/lib/utils\";\n\n/* -----------------------------------------------------------------------------\n * Component: Form\n * -------------------------------------------------------------------------- */\n\nconst Form = FormProvider;\n\n/* -----------------------------------------------------------------------------\n * Context: FormField\n * -------------------------------------------------------------------------- */\n\nconst FORM_FIELD_NAME = \"FormField\";\n\ntype ScopedProps<P> = P & { __scopeFormField?: Scope };\n\nconst [createFormFieldContext, createFormFieldScope] = createContextScope(FORM_FIELD_NAME);\n\ninterface FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> {\n name: TName;\n}\n\nconst [FormFieldContextProvider, useFormFieldContext] = createFormFieldContext<FormFieldContextValue>(FORM_FIELD_NAME);\n\nfunction useFormItem(\n consumerName: string,\n scope: Scope,\n): {\n formDescriptionId: string;\n formItemId: string;\n formMessageId: string;\n id: string;\n invalid: boolean;\n isDirty: boolean;\n isTouched: boolean;\n isValidating: boolean;\n name: string;\n error?: FieldError;\n} {\n const { id } = useFormItemContext(consumerName, scope);\n const { name } = useFormFieldContext(consumerName, scope);\n const { getFieldState } = useFormContext();\n const formState = useFormState({ name });\n const fieldState = getFieldState(name, formState);\n\n return {\n id,\n name,\n formDescriptionId: `form-item-description-${id}`,\n formItemId: `form-item-${id}`,\n formMessageId: `form-item-message-${id}`,\n ...fieldState,\n };\n}\n\n/* -----------------------------------------------------------------------------\n * Component: FormField\n * -------------------------------------------------------------------------- */\n\nfunction FormField<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>(formFieldProps: ScopedProps<ControllerProps<TFieldValues, TName>>): JSX.Element {\n const { __scopeFormField, ...props } = formFieldProps;\n\n return (\n <FormFieldContextProvider name={props.name} scope={__scopeFormField}>\n <Controller {...props} />\n </FormFieldContextProvider>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Context: FormItem\n * -------------------------------------------------------------------------- */\n\nconst FORM_ITEM_NAME = \"FormItem\";\n\ninterface FormItemContextValue {\n id: string;\n}\n\nconst [FormItemContextProvider, useFormItemContext] = createFormFieldContext<FormItemContextValue>(FORM_ITEM_NAME);\n\n/* -----------------------------------------------------------------------------\n * Component: FormItem\n * -------------------------------------------------------------------------- */\n\nfunction FormItem({ __scopeFormField, className, ...props }: ScopedProps<ComponentProps<\"div\">>): JSX.Element {\n const id = useId();\n\n return (\n <FormItemContextProvider id={id} scope={__scopeFormField}>\n <div className={cn(\"grid gap-2\", className)} data-slot=\"form-item\" {...props} />\n </FormItemContextProvider>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Component: FormLabel\n * -------------------------------------------------------------------------- */\n\nconst FORM_LABEL_NAME = \"FormLabel\";\n\nfunction FormLabel({\n __scopeFormField,\n ...props\n}: ScopedProps<ComponentProps<typeof LabelPrimitive.Root>>): JSX.Element {\n const { formItemId, error } = useFormItem(FORM_LABEL_NAME, __scopeFormField);\n\n return <Label data-invalid={error ? true : undefined} data-slot=\"form-label\" htmlFor={formItemId} {...props} />;\n}\n\n/* -----------------------------------------------------------------------------\n * Component: FormControl\n * -------------------------------------------------------------------------- */\n\nconst FORM_CONTROL_NAME = \"FormControl\";\n\nfunction FormControl({ __scopeFormField, ...props }: ScopedProps<ComponentProps<typeof Slot>>): JSX.Element {\n const { formDescriptionId, formItemId, formMessageId, error } = useFormItem(FORM_CONTROL_NAME, __scopeFormField);\n\n return (\n <Slot\n aria-describedby={error ? `${formDescriptionId} ${formMessageId}` : formDescriptionId}\n aria-invalid={Boolean(error)}\n data-slot=\"form-control\"\n id={formItemId}\n {...props}\n />\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Component: FormDescription\n * -------------------------------------------------------------------------- */\n\nfunction FormDescription({ __scopeFormField, className, ...props }: ScopedProps<ComponentProps<\"p\">>): JSX.Element {\n const { formDescriptionId } = useFormItem(FORM_MESSAGE_NAME, __scopeFormField);\n\n return (\n <p\n className={cn(\"text-muted-foreground text-xs\", className)}\n data-slot=\"form-description\"\n id={formDescriptionId}\n {...props}\n />\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Component: FormMessage\n * -------------------------------------------------------------------------- */\n\nconst FORM_MESSAGE_NAME = \"FormMessage\";\n\nfunction FormMessage({ __scopeFormField, children, className, ...props }: ScopedProps<ComponentProps<\"p\">>): ReactNode {\n const { formMessageId, error } = useFormItem(FORM_MESSAGE_NAME, __scopeFormField);\n const body = error?.message ? String(error.message) : children;\n\n if (!body) {\n return null;\n }\n\n return (\n <p\n className={cn(\"text-xs\", error?.message ? \"text-destructive font-medium\" : \"text-muted-foreground\", className)}\n data-slot=\"form-message\"\n id={formMessageId}\n {...props}\n >\n {body}\n </p>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Exports\n * -------------------------------------------------------------------------- */\n\nexport { createFormFieldScope, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage };\n"],"names":["Form","FormProvider","FORM_FIELD_NAME","createFormFieldContext","createFormFieldScope","createContextScope","FormFieldContextProvider","useFormFieldContext","useFormItem","consumerName","scope","id","useFormItemContext","name","getFieldState","useFormContext","formState","useFormState","fieldState","FormField","formFieldProps","__scopeFormField","props","Controller","FormItemContextProvider","FormItem","className","useId","cn","FormLabel","formItemId","error","Label","undefined","FormControl","formDescriptionId","formMessageId","Slot","Boolean","FormDescription","FORM_MESSAGE_NAME","FormMessage","children","body","String"],"mappings":";8OAmBA,IAAMA,EAAOC,EAAAA,YAAYA,CAMnBC,EAAkB,YAIlB,CAACC,EAAwBC,EAAqB,CAAGC,GAAAA,EAAAA,kBAAAA,EAAmBH,GASpE,CAACI,EAA0BC,EAAoB,CAAGJ,EAA8CD,GAEtG,SAASM,EACPC,CAAoB,CACpBC,CAAY,EAaZ,GAAM,CAAEC,GAAAA,CAAE,CAAE,CAAGC,EAAmBH,EAAcC,GAC1C,CAAEG,KAAAA,CAAI,CAAE,CAAGN,EAAoBE,EAAcC,GAC7C,CAAEI,cAAAA,CAAa,CAAE,CAAGC,GAAAA,EAAAA,cAAAA,IACpBC,EAAYC,GAAAA,EAAAA,YAAAA,EAAa,CAAEJ,KAAAA,CAAK,GAChCK,EAAaJ,EAAcD,EAAMG,GAEvC,MAAO,CACLL,GAAAA,EACAE,KAAAA,EACA,kBAAmB,CAAC,sBAAsB,EAAEF,EAAG,CAAC,CAChD,WAAY,CAAC,UAAU,EAAEA,EAAG,CAAC,CAC7B,cAAe,CAAC,kBAAkB,EAAEA,EAAG,CAAC,CACxC,GAAGO,CAAU,CAEjB,CAMA,SAASC,EAGPC,CAAiE,EACjE,GAAM,CAAEC,iBAAAA,CAAgB,CAAE,GAAGC,EAAO,CAAGF,EAEvC,MACE,UAACd,EAAAA,CAAyB,KAAMgB,EAAM,IAAI,CAAE,MAAOD,E,SACjD,UAACE,EAAAA,UAAUA,CAAAA,CAAE,GAAGD,CAAK,IAG3B,CAYA,GAAM,CAACE,EAAyBZ,EAAmB,CAAGT,EAN/B,YAYvB,SAASsB,EAAS,CAAEJ,iBAAAA,CAAgB,CAAEK,UAAAA,CAAS,CAAE,GAAGJ,EAA2C,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,EACxG,GAAM,CAAEc,cAAAA,CAAa,CAAEL,MAAAA,CAAK,CAAE,CAAGvB,EAAYgC,EAAmBnB,GAC1DsB,EAAOZ,GAAO,QAAUa,OAAOb,EAAM,OAAO,EAAIW,SAEtD,EAKE,UAAC,KACC,UAAWd,GAAAA,EAAAA,EAAAA,EAAG,UAAWG,GAAO,QAAU,+BAAiC,wBAAyBL,GACpG,YAAU,eACV,GAAIU,EACH,GAAGd,CAAK,C,SAERqB,C,GAVI,IAaX,Q"}
@@ -1 +1 @@
1
- {"version":3,"file":"components/pagination.js","sources":["webpack://@codefast/ui/./src/components/pagination.tsx"],"sourcesContent":["import type { ComponentProps, JSX } from \"react\";\n\nimport { ChevronLeftIcon, ChevronRightIcon, EllipsisIcon } from \"lucide-react\";\n\nimport type { VariantProps } from \"@/lib/utils\";\n\nimport { buttonVariants } from \"@/components/button\";\nimport { cn } from \"@/lib/utils\";\n\n/* -----------------------------------------------------------------------------\n * Component: Pagination\n * -------------------------------------------------------------------------- */\n\nfunction Pagination({ className, ...props }: ComponentProps<\"nav\">): JSX.Element {\n return (\n <nav\n aria-label=\"pagination\"\n className={cn(\"mx-auto flex w-full justify-center\", className)}\n data-slot=\"pagination\"\n role=\"navigation\"\n {...props}\n />\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Component: PaginationContent\n * -------------------------------------------------------------------------- */\n\nfunction PaginationContent({ className, ...props }: ComponentProps<\"ul\">): JSX.Element {\n return <ul className={cn(\"flex flex-row items-center gap-1\", className)} data-slot=\"pagination-content\" {...props} />;\n}\n\n/* -----------------------------------------------------------------------------\n * Component: PaginationItem\n * -------------------------------------------------------------------------- */\n\nfunction PaginationItem(props: ComponentProps<\"li\">): JSX.Element {\n return <li data-slot=\"pagination-item\" {...props} />;\n}\n\n/* -----------------------------------------------------------------------------\n * Component: PaginationLink\n * -------------------------------------------------------------------------- */\n\nfunction PaginationLink({\n children,\n className,\n isActive,\n size = \"icon\",\n ...props\n}: ComponentProps<\"a\"> &\n Pick<VariantProps<typeof buttonVariants>, \"size\"> & {\n isActive?: boolean;\n }): JSX.Element {\n return (\n <a\n aria-current={isActive ? \"page\" : undefined}\n className={buttonVariants({ className, size, variant: isActive ? \"outline\" : \"ghost\" })}\n data-slot=\"pagination-link\"\n {...props}\n >\n {children}\n </a>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Component: PaginationPrevious\n * -------------------------------------------------------------------------- */\n\nfunction PaginationPrevious({\n ...props\n}: ComponentProps<\"a\"> &\n Pick<VariantProps<typeof buttonVariants>, \"size\"> & {\n isActive?: boolean;\n }): JSX.Element {\n return (\n <PaginationLink aria-label=\"Go to previous page\" data-slot=\"pagination-previous\" size=\"md\" {...props}>\n <ChevronLeftIcon className=\"size-4\" />\n <span>Previous</span>\n </PaginationLink>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Component: PaginationNext\n * -------------------------------------------------------------------------- */\n\nfunction PaginationNext({\n ...props\n}: ComponentProps<\"a\"> &\n Pick<VariantProps<typeof buttonVariants>, \"size\"> & {\n isActive?: boolean;\n }): JSX.Element {\n return (\n <PaginationLink aria-label=\"Go to next page\" data-slot=\"pagination-next\" size=\"md\" {...props}>\n <span>Next</span>\n <ChevronRightIcon />\n </PaginationLink>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Component: PaginationEllipsis\n * -------------------------------------------------------------------------- */\n\nfunction PaginationEllipsis({ className, ...props }: ComponentProps<\"span\">): JSX.Element {\n return (\n <span\n aria-hidden\n className={cn(\"flex size-10 items-center justify-center\", className)}\n data-slot=\"pagination-ellipsis\"\n {...props}\n >\n <EllipsisIcon className=\"size-4\" />\n <span className=\"sr-only\">More pages</span>\n </span>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Exports\n * -------------------------------------------------------------------------- */\n\nexport {\n Pagination,\n PaginationContent,\n PaginationEllipsis,\n PaginationItem,\n PaginationLink,\n PaginationNext,\n PaginationPrevious,\n};\n"],"names":["Pagination","className","props","cn","PaginationContent","PaginationItem","PaginationLink","children","isActive","size","undefined","buttonVariants","PaginationPrevious","ChevronLeftIcon","PaginationNext","ChevronRightIcon","PaginationEllipsis","EllipsisIcon"],"mappings":"mIAaA,SAASA,EAAW,CAAEC,UAAAA,CAAS,CAAE,GAAGC,EAA8B,EAChE,MACE,UAAC,OACC,aAAW,aACX,UAAWC,AAAAA,GAAAA,EAAAA,EAAAA,AAAAA,EAAG,qCAAsCF,GACpD,YAAU,aACV,KAAK,aACJ,GAAGC,CAAK,A,EAGf,CAMA,SAASE,EAAkB,CAAEH,UAAAA,CAAS,CAAE,GAAGC,EAA6B,EACtE,MAAO,UAAC,MAAG,UAAWC,AAAAA,GAAAA,EAAAA,EAAAA,AAAAA,EAAG,mCAAoCF,GAAY,YAAU,qBAAsB,GAAGC,CAAK,A,EACnH,CAMA,SAASG,EAAeH,CAA2B,EACjD,MAAO,UAAC,MAAG,YAAU,kBAAmB,GAAGA,CAAK,A,EAClD,CAMA,SAASI,EAAe,CACtBC,SAAAA,CAAQ,CACRN,UAAAA,CAAS,CACTO,SAAAA,CAAQ,CACRC,KAAAA,EAAO,MAAM,CACb,GAAGP,EAIF,EACD,MACE,UAAC,KACC,eAAcM,EAAW,OAASE,KAAAA,EAClC,UAAWC,AAAAA,GAAAA,EAAAA,cAAAA,AAAAA,EAAe,CAAEV,UAAAA,EAAWQ,KAAAA,EAAM,QAASD,EAAW,UAAY,OAAQ,GACrF,YAAU,kBACT,GAAGN,CAAK,C,SAERK,C,EAGP,CAMA,SAASK,EAAmB,CAC1B,GAAGV,EAIF,EACD,MACE,WAACI,EAAAA,CAAe,aAAW,sBAAsB,YAAU,sBAAsB,KAAK,KAAM,GAAGJ,CAAK,C,UAClG,UAACW,EAAAA,eAAeA,CAAAA,CAAC,UAAU,Q,GAC3B,UAAC,Q,SAAK,U,KAGZ,CAMA,SAASC,EAAe,CACtB,GAAGZ,EAIF,EACD,MACE,WAACI,EAAAA,CAAe,aAAW,kBAAkB,YAAU,kBAAkB,KAAK,KAAM,GAAGJ,CAAK,C,UAC1F,UAAC,Q,SAAK,M,GACN,UAACa,EAAAA,gBAAgBA,CAAAA,CAAAA,G,EAGvB,CAMA,SAASC,EAAmB,CAAEf,UAAAA,CAAS,CAAE,GAAGC,EAA+B,EACzE,MACE,WAAC,QACC,cAAW,GACX,UAAWC,AAAAA,GAAAA,EAAAA,EAAAA,AAAAA,EAAG,2CAA4CF,GAC1D,YAAU,sBACT,GAAGC,CAAK,C,UAET,UAACe,EAAAA,YAAYA,CAAAA,CAAC,UAAU,Q,GACxB,UAAC,QAAK,UAAU,U,SAAU,Y,KAGhC,Q"}
1
+ {"version":3,"file":"components/pagination.js","sources":["webpack://@codefast/ui/./src/components/pagination.tsx"],"sourcesContent":["import type { ComponentProps, JSX } from \"react\";\n\nimport { ChevronLeftIcon, ChevronRightIcon, EllipsisIcon } from \"lucide-react\";\n\nimport type { VariantProps } from \"@/lib/utils\";\n\nimport { buttonVariants } from \"@/components/button\";\nimport { cn } from \"@/lib/utils\";\n\n/* -----------------------------------------------------------------------------\n * Component: Pagination\n * -------------------------------------------------------------------------- */\n\nfunction Pagination({ className, ...props }: ComponentProps<\"nav\">): JSX.Element {\n return (\n <nav\n aria-label=\"pagination\"\n className={cn(\"mx-auto flex w-full justify-center\", className)}\n data-slot=\"pagination\"\n role=\"navigation\"\n {...props}\n />\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Component: PaginationContent\n * -------------------------------------------------------------------------- */\n\nfunction PaginationContent({ className, ...props }: ComponentProps<\"ul\">): JSX.Element {\n return <ul className={cn(\"flex flex-row items-center gap-1\", className)} data-slot=\"pagination-content\" {...props} />;\n}\n\n/* -----------------------------------------------------------------------------\n * Component: PaginationItem\n * -------------------------------------------------------------------------- */\n\nfunction PaginationItem(props: ComponentProps<\"li\">): JSX.Element {\n return <li data-slot=\"pagination-item\" {...props} />;\n}\n\n/* -----------------------------------------------------------------------------\n * Component: PaginationLink\n * -------------------------------------------------------------------------- */\n\nfunction PaginationLink({\n children,\n className,\n isActive,\n size = \"icon\",\n ...props\n}: ComponentProps<\"a\"> &\n Pick<VariantProps<typeof buttonVariants>, \"size\"> & {\n isActive?: boolean;\n }): JSX.Element {\n return (\n <a\n aria-current={isActive ? \"page\" : undefined}\n className={buttonVariants({ className, size, variant: isActive ? \"outline\" : \"ghost\" })}\n data-slot=\"pagination-link\"\n {...props}\n >\n {children}\n </a>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Component: PaginationPrevious\n * -------------------------------------------------------------------------- */\n\nfunction PaginationPrevious({\n ...props\n}: ComponentProps<\"a\"> &\n Pick<VariantProps<typeof buttonVariants>, \"size\"> & {\n isActive?: boolean;\n }): JSX.Element {\n return (\n <PaginationLink aria-label=\"Go to previous page\" data-slot=\"pagination-previous\" size=\"md\" {...props}>\n <ChevronLeftIcon className=\"size-4\" />\n <span>Previous</span>\n </PaginationLink>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Component: PaginationNext\n * -------------------------------------------------------------------------- */\n\nfunction PaginationNext({\n ...props\n}: ComponentProps<\"a\"> &\n Pick<VariantProps<typeof buttonVariants>, \"size\"> & {\n isActive?: boolean;\n }): JSX.Element {\n return (\n <PaginationLink aria-label=\"Go to next page\" data-slot=\"pagination-next\" size=\"md\" {...props}>\n <span>Next</span>\n <ChevronRightIcon />\n </PaginationLink>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Component: PaginationEllipsis\n * -------------------------------------------------------------------------- */\n\nfunction PaginationEllipsis({ className, ...props }: ComponentProps<\"span\">): JSX.Element {\n return (\n <span\n aria-hidden\n className={cn(\"flex size-10 items-center justify-center\", className)}\n data-slot=\"pagination-ellipsis\"\n {...props}\n >\n <EllipsisIcon className=\"size-4\" />\n <span className=\"sr-only\">More pages</span>\n </span>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Exports\n * -------------------------------------------------------------------------- */\n\nexport {\n Pagination,\n PaginationContent,\n PaginationEllipsis,\n PaginationItem,\n PaginationLink,\n PaginationNext,\n PaginationPrevious,\n};\n"],"names":["Pagination","className","props","cn","PaginationContent","PaginationItem","PaginationLink","children","isActive","size","undefined","buttonVariants","PaginationPrevious","ChevronLeftIcon","PaginationNext","ChevronRightIcon","PaginationEllipsis","EllipsisIcon"],"mappings":"mIAaA,SAASA,EAAW,CAAEC,UAAAA,CAAS,CAAE,GAAGC,EAA8B,EAChE,MACE,UAAC,OACC,aAAW,aACX,UAAWC,AAAAA,GAAAA,EAAAA,EAAAA,AAAAA,EAAG,qCAAsCF,GACpD,YAAU,aACV,KAAK,aACJ,GAAGC,CAAK,A,EAGf,CAMA,SAASE,EAAkB,CAAEH,UAAAA,CAAS,CAAE,GAAGC,EAA6B,EACtE,MAAO,UAAC,MAAG,UAAWC,AAAAA,GAAAA,EAAAA,EAAAA,AAAAA,EAAG,mCAAoCF,GAAY,YAAU,qBAAsB,GAAGC,CAAK,A,EACnH,CAMA,SAASG,EAAeH,CAA2B,EACjD,MAAO,UAAC,MAAG,YAAU,kBAAmB,GAAGA,CAAK,A,EAClD,CAMA,SAASI,EAAe,CACtBC,SAAAA,CAAQ,CACRN,UAAAA,CAAS,CACTO,SAAAA,CAAQ,CACRC,KAAAA,EAAO,MAAM,CACb,GAAGP,EAIF,EACD,MACE,UAAC,KACC,eAAcM,EAAW,OAASE,OAClC,UAAWC,AAAAA,GAAAA,EAAAA,cAAAA,AAAAA,EAAe,CAAEV,UAAAA,EAAWQ,KAAAA,EAAM,QAASD,EAAW,UAAY,OAAQ,GACrF,YAAU,kBACT,GAAGN,CAAK,C,SAERK,C,EAGP,CAMA,SAASK,EAAmB,CAC1B,GAAGV,EAIF,EACD,MACE,WAACI,EAAAA,CAAe,aAAW,sBAAsB,YAAU,sBAAsB,KAAK,KAAM,GAAGJ,CAAK,C,UAClG,UAACW,EAAAA,eAAeA,CAAAA,CAAC,UAAU,Q,GAC3B,UAAC,Q,SAAK,U,KAGZ,CAMA,SAASC,EAAe,CACtB,GAAGZ,EAIF,EACD,MACE,WAACI,EAAAA,CAAe,aAAW,kBAAkB,YAAU,kBAAkB,KAAK,KAAM,GAAGJ,CAAK,C,UAC1F,UAAC,Q,SAAK,M,GACN,UAACa,EAAAA,gBAAgBA,CAAAA,CAAAA,G,EAGvB,CAMA,SAASC,EAAmB,CAAEf,UAAAA,CAAS,CAAE,GAAGC,EAA+B,EACzE,MACE,WAAC,QACC,cAAW,GACX,UAAWC,AAAAA,GAAAA,EAAAA,EAAAA,AAAAA,EAAG,2CAA4CF,GAC1D,YAAU,sBACT,GAAGC,CAAK,C,UAET,UAACe,EAAAA,YAAYA,CAAAA,CAAC,UAAU,Q,GACxB,UAAC,QAAK,UAAU,U,SAAU,Y,KAGhC,Q"}
@@ -1 +1 @@
1
- {"version":3,"file":"components/progress-circle.js","sources":["webpack://@codefast/ui/./src/components/progress-circle.tsx"],"sourcesContent":["\n\nimport type { ComponentProps, CSSProperties, JSX } from \"react\";\n\nimport * as ProgressCirclePrimitive from \"@codefast-ui/progress-circle\";\nimport { useAnimatedValue } from \"@codefast/hooks\";\nimport { useCallback, useMemo } from \"react\";\n\nimport type { VariantProps } from \"@/lib/utils\";\n\nimport { tv } from \"@/lib/utils\";\n\n/* -------------------------------------------------------------------------------------------------\n * Variant: ProgressCircle\n * -----------------------------------------------------------------------------------------------*/\n\nconst progressCircleVariants = tv({\n slots: {\n root: \"relative inline-flex items-center justify-center\",\n svg: \"size-full\",\n track: \"origin-center\",\n indicator: \"origin-center\",\n label: \"absolute inset-0 flex items-center justify-center text-xs font-medium\",\n },\n variants: {\n variant: {\n default: { indicator: \"text-primary\", track: \"text-primary/20\" },\n destructive: { indicator: \"text-destructive\", track: \"text-destructive/20\" },\n },\n size: {\n sm: { label: \"text-[10px]\" },\n md: { label: \"text-xs\" },\n lg: { label: \"text-sm\" },\n xl: { label: \"text-base\" },\n \"2xl\": { label: \"text-lg\" },\n },\n thickness: { thin: {}, regular: {}, thick: {} },\n },\n defaultVariants: { variant: \"default\", size: \"md\", thickness: \"regular\" },\n});\n\n/* -------------------------------------------------------------------------------------------------\n * Component: ProgressCircle\n * -----------------------------------------------------------------------------------------------*/\n\nfunction ProgressCircle({\n value = 0,\n classNames,\n customLabel,\n showValue = false,\n variant = \"default\",\n size,\n sizeInPixels,\n thickness = \"regular\",\n animate = true,\n animationDuration = 1000,\n className,\n strokeWidth,\n ...props\n}: Omit<ComponentProps<typeof ProgressCirclePrimitive.Provider>, \"children\" | \"size\"> &\n VariantProps<typeof progressCircleVariants> & {\n /**\n * Enables animation effect when value changes\n */\n animate?: boolean;\n\n /**\n * Duration of the animation in milliseconds\n */\n animationDuration?: number;\n\n /**\n * CSS class to customize the entire component\n */\n className?: string;\n\n /**\n * CSS classes to customize specific parts of the component\n */\n classNames?: {\n /**\n * Class for the progress indicator\n */\n indicator?: string;\n\n /**\n * Class for the label in the center of the circle\n */\n label?: string;\n\n /**\n * Class for the root element of the component\n */\n root?: string;\n\n /**\n * Class for the SVG element\n */\n svg?: string;\n\n /**\n * Class for the circle track\n */\n track?: string;\n };\n\n /**\n * Custom function to render content in the center of the circle\n * @param value - Current value of the component\n * @returns React element to display in the center of the circle\n */\n customLabel?: ({ value }: { value: number }) => JSX.Element;\n\n /**\n * Display the numeric value in the center of the circle\n */\n showValue?: boolean;\n\n /**\n * Custom size in pixels\n * When provided, this value overrides the size variant option\n */\n sizeInPixels?: number;\n }): JSX.Element {\n const displayValue = useAnimatedValue(value, animationDuration, animate);\n\n const actualSize = useMemo(() => sizeInPixels || getActualSize(size), [sizeInPixels, size]);\n\n const actualThickness = useMemo(\n () => strokeWidth || getStrokeWidth(thickness, actualSize),\n [strokeWidth, thickness, actualSize],\n );\n\n const slots = useMemo(() => progressCircleVariants({ variant, size, thickness }), [variant, size, thickness]);\n\n const shouldShowLabel = showValue || Boolean(customLabel);\n\n const renderLabel = useCallback(() => {\n if (customLabel) {\n return customLabel({ value: displayValue });\n }\n\n return `${displayValue}%`;\n }, [customLabel, displayValue]);\n\n return (\n <ProgressCirclePrimitive.Provider size={actualSize} strokeWidth={actualThickness} value={value} {...props}>\n <ProgressCirclePrimitive.Root className={slots.root({ className: [className, classNames?.root] })}>\n <ProgressCirclePrimitive.SVG className={slots.svg({ className: classNames?.svg })}>\n <ProgressCirclePrimitive.Track className={slots.track({ className: classNames?.track })} />\n <ProgressCirclePrimitive.Indicator\n className={slots.indicator({ className: classNames?.indicator })}\n style={\n {\n transitionDuration: `${animationDuration}ms`,\n transitionProperty: \"stroke-dashoffset\",\n } as CSSProperties\n }\n />\n </ProgressCirclePrimitive.SVG>\n {shouldShowLabel ? (\n <ProgressCirclePrimitive.Value className={slots.label({ className: classNames?.label })}>\n {renderLabel()}\n </ProgressCirclePrimitive.Value>\n ) : null}\n </ProgressCirclePrimitive.Root>\n </ProgressCirclePrimitive.Provider>\n );\n}\n\nProgressCircle.displayName = \"ProgressCircle\";\n\n/* -----------------------------------------------------------------------------\n * Helpers\n * -------------------------------------------------------------------------- */\n\n/**\n * Maps size variants to actual pixel sizes\n */\nconst getActualSize = (size?: VariantProps<typeof progressCircleVariants>[\"size\"]): number => {\n const sizeMap: Record<NonNullable<typeof size>, number> = {\n sm: 32,\n md: 48,\n lg: 64,\n xl: 96,\n \"2xl\": 128,\n };\n\n return size ? sizeMap[size] : 48;\n};\n\n/**\n * Calculates stroke width based on thickness variant and circle size\n */\nconst getStrokeWidth = (thickness: VariantProps<typeof progressCircleVariants>[\"thickness\"], size: number): number => {\n const thicknessMap: Record<NonNullable<typeof thickness>, number> = {\n thin: Math.max(2, size * 0.025),\n regular: Math.max(3, size * 0.05),\n thick: Math.max(4, size * 0.075),\n };\n\n return thickness ? thicknessMap[thickness] : Math.max(3, size * 0.05);\n};\n\n/* -----------------------------------------------------------------------------\n * Exports\n * -------------------------------------------------------------------------- */\n\nexport { ProgressCircle };\n"],"names":["progressCircleVariants","tv","ProgressCircle","value","classNames","customLabel","showValue","variant","size","sizeInPixels","thickness","animate","animationDuration","className","strokeWidth","props","displayValue","useAnimatedValue","actualSize","useMemo","getActualSize","actualThickness","getStrokeWidth","slots","sh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QAASuB,KAAK,GAAG,CAAC,EAAGvB,IAAAA,GACrB,MAAOuB,KAAK,GAAG,CAAC,EAAGvB,KAAAA,EACrB,EAE+B,CAACE,EAAU,CAAGqB,KAAK,GAAG,CAAC,EAAGvB,IAAAA,U"}
1
+ {"version":3,"file":"components/progress-circle.js","sources":["webpack://@codefast/ui/./src/components/progress-circle.tsx"],"sourcesContent":["\n\nimport type { ComponentProps, CSSProperties, JSX } from \"react\";\n\nimport * as ProgressCirclePrimitive from \"@codefast-ui/progress-circle\";\nimport { useAnimatedValue } from \"@codefast/hooks\";\nimport { useCallback, useMemo } from \"react\";\n\nimport type { VariantProps } from \"@/lib/utils\";\n\nimport { tv } from \"@/lib/utils\";\n\n/* -------------------------------------------------------------------------------------------------\n * Variant: ProgressCircle\n * -----------------------------------------------------------------------------------------------*/\n\nconst progressCircleVariants = tv({\n slots: {\n root: \"relative inline-flex items-center justify-center\",\n svg: \"size-full\",\n track: \"origin-center\",\n indicator: \"origin-center\",\n label: \"absolute inset-0 flex items-center justify-center text-xs font-medium\",\n },\n variants: {\n variant: {\n default: { indicator: \"text-primary\", track: \"text-primary/20\" },\n destructive: { indicator: \"text-destructive\", track: \"text-destructive/20\" },\n },\n size: {\n sm: { label: \"text-[10px]\" },\n md: { label: \"text-xs\" },\n lg: { label: \"text-sm\" },\n xl: { label: \"text-base\" },\n \"2xl\": { label: \"text-lg\" },\n },\n thickness: { thin: {}, regular: {}, thick: {} },\n },\n defaultVariants: { variant: \"default\", size: \"md\", thickness: \"regular\" },\n});\n\n/* -------------------------------------------------------------------------------------------------\n * Component: ProgressCircle\n * -----------------------------------------------------------------------------------------------*/\n\nfunction ProgressCircle({\n value = 0,\n classNames,\n customLabel,\n showValue = false,\n variant = \"default\",\n size,\n sizeInPixels,\n thickness = \"regular\",\n animate = true,\n animationDuration = 1000,\n className,\n strokeWidth,\n ...props\n}: Omit<ComponentProps<typeof ProgressCirclePrimitive.Provider>, \"children\" | \"size\"> &\n VariantProps<typeof progressCircleVariants> & {\n /**\n * Enables animation effect when value changes\n */\n animate?: boolean;\n\n /**\n * Duration of the animation in milliseconds\n */\n animationDuration?: number;\n\n /**\n * CSS class to customize the entire component\n */\n className?: string;\n\n /**\n * CSS classes to customize specific parts of the component\n */\n classNames?: {\n /**\n * Class for the progress indicator\n */\n indicator?: string;\n\n /**\n * Class for the label in the center of the circle\n */\n label?: string;\n\n /**\n * Class for the root element of the component\n */\n root?: string;\n\n /**\n * Class for the SVG element\n */\n svg?: string;\n\n /**\n * Class for the circle track\n */\n track?: string;\n };\n\n /**\n * Custom function to render content in the center of the circle\n * @param value - Current value of the component\n * @returns React element to display in the center of the circle\n */\n customLabel?: ({ value }: { value: number }) => JSX.Element;\n\n /**\n * Display the numeric value in the center of the circle\n */\n showValue?: boolean;\n\n /**\n * Custom size in pixels\n * When provided, this value overrides the size variant option\n */\n sizeInPixels?: number;\n }): JSX.Element {\n const displayValue = useAnimatedValue(value, animationDuration, animate);\n\n const actualSize = useMemo(() => sizeInPixels || getActualSize(size), [sizeInPixels, size]);\n\n const actualThickness = useMemo(\n () => strokeWidth || getStrokeWidth(thickness, actualSize),\n [strokeWidth, thickness, actualSize],\n );\n\n const slots = useMemo(() => progressCircleVariants({ variant, size, thickness }), [variant, size, thickness]);\n\n const shouldShowLabel = showValue || Boolean(customLabel);\n\n const renderLabel = useCallback(() => {\n if (customLabel) {\n return customLabel({ value: displayValue });\n }\n\n return `${displayValue}%`;\n }, [customLabel, displayValue]);\n\n return (\n <ProgressCirclePrimitive.Provider size={actualSize} strokeWidth={actualThickness} value={value} {...props}>\n <ProgressCirclePrimitive.Root className={slots.root({ className: [className, classNames?.root] })}>\n <ProgressCirclePrimitive.SVG className={slots.svg({ className: classNames?.svg })}>\n <ProgressCirclePrimitive.Track className={slots.track({ className: classNames?.track })} />\n <ProgressCirclePrimitive.Indicator\n className={slots.indicator({ className: classNames?.indicator })}\n style={\n {\n transitionDuration: `${animationDuration}ms`,\n transitionProperty: \"stroke-dashoffset\",\n } as CSSProperties\n }\n />\n </ProgressCirclePrimitive.SVG>\n {shouldShowLabel ? (\n <ProgressCirclePrimitive.Value className={slots.label({ className: classNames?.label })}>\n {renderLabel()}\n </ProgressCirclePrimitive.Value>\n ) : null}\n </ProgressCirclePrimitive.Root>\n </ProgressCirclePrimitive.Provider>\n );\n}\n\nProgressCircle.displayName = \"ProgressCircle\";\n\n/* -----------------------------------------------------------------------------\n * Helpers\n * -------------------------------------------------------------------------- */\n\n/**\n * Maps size variants to actual pixel sizes\n */\nconst getActualSize = (size?: VariantProps<typeof progressCircleVariants>[\"size\"]): number => {\n const sizeMap: Record<NonNullable<typeof size>, number> = {\n sm: 32,\n md: 48,\n lg: 64,\n xl: 96,\n \"2xl\": 128,\n };\n\n return size ? sizeMap[size] : 48;\n};\n\n/**\n * Calculates stroke width based on thickness variant and circle size\n */\nconst getStrokeWidth = (thickness: VariantProps<typeof progressCircleVariants>[\"thickness\"], size: number): number => {\n const thicknessMap: Record<NonNullable<typeof thickness>, number> = {\n thin: Math.max(2, size * 0.025),\n regular: Math.max(3, size * 0.05),\n thick: Math.max(4, size * 0.075),\n };\n\n return thickness ? thicknessMap[thickness] : Math.max(3, size * 0.05);\n};\n\n/* -----------------------------------------------------------------------------\n * Exports\n * -------------------------------------------------------------------------- */\n\nexport { ProgressCircle };\n"],"names":["progressCircleVariants","tv","ProgressCircle","value","classNames","customLabel","showValue","variant","size","sizeInPixels","thickness","animate","animationDuration","className","strokeWidth","props","displayValue","useAnimatedValue","actualSize","useMemo","getActualSize","actualThickness","getStrokeWidth","slots","shouldShowLabel","Boolean","renderLabel","useCallback","ProgressCirclePrimitive","sizeMap","thicknessMap","Math"],"mappings":";+KAgBA,IAAMA,EAAyBC,GAAAA,EAAAA,EAAAA,EAAG,CAChC,MAAO,CACL,KAAM,mDACN,IAAK,YACL,MAAO,gBACP,UAAW,gBACX,MAAO,uEACT,EACA,SAAU,CACR,QAAS,CACP,QAAS,CAAE,UAAW,eAAgB,MAAO,iB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,EAAa,CAAC,CAAC,CACxB,CAACX,EAAaW,EAAa,EAE9B,MACE,UAACY,EAAAA,QAAgC,EAAC,KAAMV,EAAY,YAAaG,EAAiB,MAAOlB,EAAQ,GAAGY,CAAK,C,SACvG,WAACa,EAAAA,IAA4B,EAAC,UAAWL,EAAM,IAAI,CAAC,CAAE,UAAW,CAACV,EAAWT,GAAY,KAAK,G,UAC5F,WAACwB,EAAAA,GAA2B,EAAC,UAAWL,EAAM,GAAG,CAAC,CAAE,UAAWnB,GAAY,GAAI,G,UAC7E,UAACwB,EAAAA,KAA6B,EAAC,UAAWL,EAAM,KAAK,CAAC,CAAE,UAAWnB,GAAY,KAAM,E,GACrF,UAACwB,EAAAA,SAAiC,EAChC,UAAWL,EAAM,SAAS,CAAC,CAAE,UAAWnB,GAAY,SAAU,GAC9D,MACE,CACE,mBAAoB,CAAC,EAAEQ,EAAkB,EAAE,CAAC,CAC5C,mBAAoB,mBACtB,C,MAILY,EACC,UAACI,EAAAA,KAA6B,EAAC,UAAWL,EAAM,KAAK,CAAC,CAAE,UAAWnB,GAAY,KAAM,G,SAClFsB,G,GAED,K,IAIZ,CAEAxB,EAAe,WAAW,CAAG,iBAS7B,IAAMkB,EAAgB,GASbZ,EAAOqB,EAPZ,GAAI,GACJ,GAAI,GACJ,GAAI,GACJ,GAAI,GACJ,MAAO,GACT,EAEqB,CAACrB,EAAK,CAAG,GAM1Bc,EAAiB,CAACZ,EAAqEF,IAOpFE,EAAYoB,EALjB,KAAMC,KAAK,GAAG,CAAC,EAAGvB,KAAAA,GAClB,QAASuB,KAAK,GAAG,CAAC,EAAGvB,IAAAA,GACrB,MAAOuB,KAAK,GAAG,CAAC,EAAGvB,KAAAA,EACrB,EAE+B,CAACE,EAAU,CAAGqB,KAAK,GAAG,CAAC,EAAGvB,IAAAA,U"}
@@ -1 +1 @@
1
- {"version":3,"file":"components/spinner.js","sources":["webpack://@codefast/ui/./src/components/spinner.tsx"],"sourcesContent":["import type { ComponentProps, CSSProperties, ReactNode } from \"react\";\n\nimport { VisuallyHidden } from \"@radix-ui/react-visually-hidden\";\n\nimport { cn } from \"@/lib/utils\";\n\n/* -----------------------------------------------------------------------------\n * Component: Spinner\n * -------------------------------------------------------------------------- */\n\nconst SPINNER_COUNT = 8;\n\nfunction Spinner({\n children,\n className,\n loading = true,\n ...props\n}: ComponentProps<\"span\"> & {\n loading?: boolean;\n}): ReactNode {\n if (!loading) {\n return children;\n }\n\n const spinner = (\n <span className={cn(\"relative flex size-4 items-center justify-center opacity-60\", className)} {...props}>\n {Array.from({ length: SPINNER_COUNT }, (_, i) => (\n <span\n key={i}\n className={cn(\n \"rotate-(--spinner-rotate) before:animate-out before:fade-out-25 before:animation-repeat-infinite before:animation-delay-(--spinner-delay) before:animation-duration-(--spinner-duration) absolute h-full before:block before:h-1/3 before:w-full before:rounded-full before:bg-current\",\n )}\n style={\n {\n \"--spinner-delay\": `-${((SPINNER_COUNT - i) * 100).toString()}ms`,\n \"--spinner-duration\": `${(SPINNER_COUNT * 100).toString()}ms`,\n \"--spinner-rotate\": `${((360 / SPINNER_COUNT) * i).toString()}deg`,\n width: `${(100 / SPINNER_COUNT).toString()}%`,\n } as CSSProperties\n }\n />\n ))}\n </span>\n );\n\n if (children === undefined) {\n return spinner;\n }\n\n return (\n <span className=\"relative\">\n <span aria-hidden className=\"invisible contents\">\n {children}\n </span>\n <VisuallyHidden>{children}</VisuallyHidden>\n <span className=\"absolute inset-0 flex items-center justify-center\">{spinner}</span>\n </span>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Exports\n * -------------------------------------------------------------------------- */\n\nexport { Spinner };\n"],"names":["Spinner","children","className","loading","props","spinner","cn","Array","_","i","SPINNER_COUNT","undefined","VisuallyHidden"],"mappings":"wHAYA,SAASA,EAAQ,CACfC,SAAAA,CAAQ,CACRC,UAAAA,CAAS,CACTC,QAAAA,EAAU,EAAI,CACd,GAAGC,EAGJ,EACC,GAAI,CAACD,EACH,OAAOF,EAGT,IAAMI,EACJ,UAAC,QAAK,UAAWC,AAAAA,GAAAA,EAAAA,EAAAA,AAAAA,EAAG,8DAA+DJ,GAAa,GAAGE,CAAK,C,SACrGG,MAAM,IAAI,CAAC,CAAE,OAhBE,CAgBoB,EAAG,CAACC,EAAGC,IACzC,UAAC,QAEC,UAAWH,AAAAA,GAAAA,EAAAA,EAAAA,AAAAA,EACT,0RAEF,MACE,CACE,kBAAmB,CAAC,CAAC,EAAG,AAACI,CAAAA,CAAAA,AAxBjB,EAwBiCD,CAAAA,EAAK,GAAE,EAAG,QAAQ,GAAG,EAAE,CAAC,CACjE,qBAAsB,QACtB,mBAAoB,CAAC,EAAG,AAAC,IAAuBA,CAAAA,EAAG,QAAQ,GAAG,GAAG,CAAC,CAClE,MAAO,OACT,C,EAVGA,G,UAiBb,AAAIR,AAAaU,KAAAA,IAAbV,EACKI,EAIP,WAAC,QAAK,UAAU,W,UACd,UAAC,QAAK,cAAW,GAAC,UAAU,qB,SACzBJ,C,GAEH,UAACW,EAAAA,cAAcA,CAAAA,C,SAAEX,C,GACjB,UAAC,QAAK,UAAU,oD,SAAqDI,C,KAG3E,Q"}
1
+ {"version":3,"file":"components/spinner.js","sources":["webpack://@codefast/ui/./src/components/spinner.tsx"],"sourcesContent":["import type { ComponentProps, CSSProperties, ReactNode } from \"react\";\n\nimport { VisuallyHidden } from \"@radix-ui/react-visually-hidden\";\n\nimport { cn } from \"@/lib/utils\";\n\n/* -----------------------------------------------------------------------------\n * Component: Spinner\n * -------------------------------------------------------------------------- */\n\nconst SPINNER_COUNT = 8;\n\nfunction Spinner({\n children,\n className,\n loading = true,\n ...props\n}: ComponentProps<\"span\"> & {\n loading?: boolean;\n}): ReactNode {\n if (!loading) {\n return children;\n }\n\n const spinner = (\n <span className={cn(\"relative flex size-4 items-center justify-center opacity-60\", className)} {...props}>\n {Array.from({ length: SPINNER_COUNT }, (_, i) => (\n <span\n key={i}\n className={cn(\n \"rotate-(--spinner-rotate) before:animate-out before:fade-out-25 before:animation-repeat-infinite before:animation-delay-(--spinner-delay) before:animation-duration-(--spinner-duration) absolute h-full before:block before:h-1/3 before:w-full before:rounded-full before:bg-current\",\n )}\n style={\n {\n \"--spinner-delay\": `-${((SPINNER_COUNT - i) * 100).toString()}ms`,\n \"--spinner-duration\": `${(SPINNER_COUNT * 100).toString()}ms`,\n \"--spinner-rotate\": `${((360 / SPINNER_COUNT) * i).toString()}deg`,\n width: `${(100 / SPINNER_COUNT).toString()}%`,\n } as CSSProperties\n }\n />\n ))}\n </span>\n );\n\n if (children === undefined) {\n return spinner;\n }\n\n return (\n <span className=\"relative\">\n <span aria-hidden className=\"invisible contents\">\n {children}\n </span>\n <VisuallyHidden>{children}</VisuallyHidden>\n <span className=\"absolute inset-0 flex items-center justify-center\">{spinner}</span>\n </span>\n );\n}\n\n/* -----------------------------------------------------------------------------\n * Exports\n * -------------------------------------------------------------------------- */\n\nexport { Spinner };\n"],"names":["Spinner","children","className","loading","props","spinner","cn","Array","_","i","SPINNER_COUNT","undefined","VisuallyHidden"],"mappings":"wHAYA,SAASA,EAAQ,CACfC,SAAAA,CAAQ,CACRC,UAAAA,CAAS,CACTC,QAAAA,EAAU,EAAI,CACd,GAAGC,EAGJ,EACC,GAAI,CAACD,EACH,OAAOF,EAGT,IAAMI,EACJ,UAAC,QAAK,UAAWC,AAAAA,GAAAA,EAAAA,EAAAA,AAAAA,EAAG,8DAA+DJ,GAAa,GAAGE,CAAK,C,SACrGG,MAAM,IAAI,CAAC,CAAE,OAhBE,CAgBoB,EAAG,CAACC,EAAGC,IACzC,UAAC,QAEC,UAAWH,AAAAA,GAAAA,EAAAA,EAAAA,AAAAA,EACT,0RAEF,MACE,CACE,kBAAmB,CAAC,CAAC,EAAG,AAACI,CAAAA,CAxBjB,EAwBiCD,CAAAA,EAAK,GAAE,EAAG,QAAQ,GAAG,EAAE,CAAC,CACjE,qBAAsB,QACtB,mBAAoB,CAAC,EAAG,AAAC,IAAuBA,CAAAA,EAAG,QAAQ,GAAG,GAAG,CAAC,CAClE,MAAO,OACT,C,EAVGA,G,UAiBb,AAAIR,AAAaU,SAAbV,EACKI,EAIP,WAAC,QAAK,UAAU,W,UACd,UAAC,QAAK,cAAW,GAAC,UAAU,qB,SACzBJ,C,GAEH,UAACW,EAAAA,cAAcA,CAAAA,C,SAAEX,C,GACjB,UAAC,QAAK,UAAU,oD,SAAqDI,C,KAG3E,Q"}