'use client' import { Children, isValidElement, useRef, useState } from 'react' import { cn } from '@/lib/utils' import { HelpPopover } from '@/components/ui/help-popover' import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue, } from '@/components/ui/select' /** * The Fönster settings language (founder-approved concept 2026-07-25): * flat hairline rows with an uppercase micro-label on the left and the * control on the right, section titles in the display serif, groups under * eyebrow labels, and every explanation collapsed behind a "?" popover * (UI-migration convention 7 applied at row level). * * All settings sections compose these primitives; do not hand-roll row * layouts or inline help paragraphs in section components. */ interface SettingsSectionHeaderProps { title: string /** One quiet line under the title. Longer guidance belongs in row help. */ intro?: React.ReactNode /** Right-aligned header action (e.g. "Förhandsvisa faktura", "Skapa nyckel"). */ action?: React.ReactNode /** * Brand mark for a section that represents a third-party channel * (WhatsApp today). Sections that are just Accounted settings leave this * unset: the serif title carries them, and a decorative icon per tab * would turn the settings rail into a sticker album. */ mark?: React.ReactNode } export function SettingsSectionHeader({ title, intro, action, mark }: SettingsSectionHeaderProps) { return (
{mark ? {mark} : null} {/* data-ph-unmask: settings chrome (titles, labels) is static i18n text in session replays; values and controls stay masked. */}

{title}

{action ?
{action}
: null}
{intro ? (

{intro}

) : null}
) } interface SettingsGroupProps { /** Chrome in session replays (data-ph-unmask): wrap any user data (e.g. a team name) in a data-ph-mask element. */ label?: React.ReactNode /** Group-level help ("?" right after the eyebrow) for guidance that spans the rows. */ help?: React.ReactNode children: React.ReactNode className?: string } export function SettingsGroup({ label, help, children, className }: SettingsGroupProps) { return (
{label ? (

{label} {help ? {help} : null}

) : null}
{children}
) } interface SettingsRowProps { label: React.ReactNode /** Ties the label to a control; renders a