@devalok/shilp-sutra 0.50.0 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +1 -1
- package/MIGRATION.md +12 -0
- package/dist/tokens/semantic.css +20 -1
- package/dist/ui/button-group.js +2 -0
- package/dist/ui/button-group.js.map +1 -1
- package/dist/ui/button-processing.d.ts.map +1 -1
- package/dist/ui/button-processing.js +1 -0
- package/dist/ui/button-processing.js.map +1 -1
- package/dist/ui/button.d.ts +3 -3
- package/dist/ui/button.d.ts.map +1 -1
- package/dist/ui/button.js +26 -0
- package/dist/ui/button.js.map +1 -1
- package/dist/ui/card.d.ts +5 -4
- package/dist/ui/card.d.ts.map +1 -1
- package/dist/ui/card.js +1 -1
- package/dist/ui/card.js.map +1 -1
- package/dist/ui/color-input.d.ts.map +1 -1
- package/dist/ui/color-input.js +82 -82
- package/dist/ui/color-input.js.map +1 -1
- package/dist/ui/icon.d.ts +2 -0
- package/dist/ui/icon.d.ts.map +1 -1
- package/dist/ui/icon.js +31 -26
- package/dist/ui/icon.js.map +1 -1
- package/dist/ui/search-input.d.ts.map +1 -1
- package/dist/ui/search-input.js +1 -0
- package/dist/ui/search-input.js.map +1 -1
- package/dist/ui/segmented-control.d.ts +28 -6
- package/dist/ui/segmented-control.d.ts.map +1 -1
- package/dist/ui/segmented-control.js +61 -43
- package/dist/ui/segmented-control.js.map +1 -1
- package/dist/ui/split-button.d.ts.map +1 -1
- package/dist/ui/split-button.js +7 -0
- package/dist/ui/split-button.js.map +1 -1
- package/dist/ui/stat-card.d.ts +3 -3
- package/dist/ui/stat-card.d.ts.map +1 -1
- package/dist/ui/stat-card.js.map +1 -1
- package/docs/components/ui/button.md +2 -2
- package/docs/components/ui/segmented-control.md +31 -11
- package/docs/components/ui/stat-card.md +1 -1
- package/docs/recipes/install-remix.md +3 -3
- package/docs/recipes/install-vite.md +3 -3
- package/docs/recipes/server-components.md +2 -2
- package/llms.txt +1 -1
- package/make-kit/components/card.md +4 -4
- package/make-kit/foundations/color.md +20 -0
- package/make-kit/foundations/dark-mode.md +6 -9
- package/make-kit/foundations/icons.md +3 -3
- package/make-kit/setup.md +4 -4
- package/mcp-manifest.json +62 -11
- package/package.json +1 -1
- package/scripts/welcome.mjs +59 -1
- package/skill/SKILL.md +1 -1
- package/skill/references/components.md +1 -1
- package/skill/references/server-components.md +2 -2
- package/skill/references/setup-remix.md +3 -3
- package/skill/references/setup-vite.md +3 -3
package/dist/ui/card.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.js","names":[],"sources":["../../src/ui/card.tsx"],"sourcesContent":["'use client'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { motion } from 'framer-motion'\nimport * as React from 'react'\n\nimport { motionProps, springs } from './lib/motion'\nimport { cn } from './lib/utils'\n\n// Bundlers (Vite, Next.js, webpack) define process.env.NODE_ENV; guard for raw ESM.\ndeclare const process: { env: { NODE_ENV?: string } } | undefined\n\ntype CardSize = 'sm' | 'md' | 'lg'\n\nconst cardVariants = cva(\n // Gap model, variable-driven: `size` sets --card-spacing / --card-gap once on the\n // container; the container reads them for its vertical edge (py) and inter-slot\n // rhythm (gap), slots read the same variables for their horizontal inset (px), and\n // CardAction/CardBleed read them for corner offsets / negative margins. One variable\n // pair is the whole size system — override it with a single arbitrary property\n // (`[--card-spacing:var(--spacing-ds-07)]`) and every part follows.\n // No per-slot py, no pt-0, no per-element margins — adding/removing a slot can't\n // unbalance the bottom edge (make-kit rule: shadow ring is the edge, gap is the rhythm).\n // `relative` establishes the positioning context for <CardAction> corner slots.\n 'relative flex text-surface-fg rounded-surface transition-shadow duration-fast-02 ease-productive-standard',\n {\n variants: {\n variant: {\n // Elevation-led: the shadow's own ring is the edge (make-kit rule #6 — no\n // border+shadow double-edge). border-transparent keeps the `color` prop able to\n // paint a deliberate colored edge without a grey one by default.\n default: 'bg-surface-raised border border-transparent shadow-raised',\n elevated: 'bg-surface-raised border border-transparent shadow-raised-hover',\n // Border-led: a visible edge, no shadow.\n outline: 'bg-transparent border border-surface-border-strong shadow-none',\n flat: 'bg-surface-raised border-none shadow-none',\n },\n color: {\n default: '',\n accent: 'border-accent-7',\n error: 'border-error-7',\n success: 'border-success-7',\n warning: 'border-warning-7',\n info: 'border-info-7',\n neutral: '',\n },\n // size only assigns the two variables; the orientation axis decides where\n // they're consumed (container in vertical, <CardSection> in horizontal).\n size: {\n sm: '[--card-spacing:var(--spacing-ds-05)] [--card-gap:var(--spacing-ds-03)]',\n md: '[--card-spacing:var(--spacing-ds-05b)] [--card-gap:var(--spacing-ds-04)]',\n lg: '[--card-spacing:var(--spacing-ds-06)] [--card-gap:var(--spacing-ds-05)]',\n },\n // vertical: the container owns py + gap (the default gap model).\n // horizontal: the container is a padding-less row; a <CardSection> child\n // re-establishes py + gap for the text column while a media pane owns an edge.\n orientation: {\n vertical: 'flex-col py-(--card-spacing) gap-(--card-gap)',\n horizontal: 'flex-row items-stretch',\n },\n },\n defaultVariants: { variant: 'default', color: 'default', size: 'md', orientation: 'vertical' },\n },\n)\n\n/**\n * Props for Card — a general-purpose content container with 4 elevation/style variants and\n * an optional interactive hover state.\n *\n * **Variants (elevation-led vs border-led — never both):** `default` (ring-in-shadow, no border) |\n * `elevated` (stronger shadow-raised-hover, no border) | `outline` (visible border, no shadow) |\n * `flat` (filled background, no edge). The shadow tokens carry their own 1px ring, so elevated\n * variants need no explicit border (make-kit rule #6).\n *\n * **Composition:** Use sub-components `<CardHeader>`, `<CardTitle>`, `<CardDescription>`,\n * `<CardContent>`, and `<CardFooter>` for consistent internal spacing. Text content must live\n * inside a slot — raw text as a direct child gets no horizontal inset (direct children span the\n * full card width by design, which is what makes full-width dividers and bands free).\n *\n * **Spacing:** `size` sets `--card-spacing` / `--card-gap` once; container, slots, `CardAction`,\n * and `CardBleed` all read the same pair. Retune a card with a single override:\n * `className=\"[--card-spacing:var(--spacing-ds-07)]\"`.\n *\n * **Interactive:** Pass `interactive` to enable hover shadow lift and pointer cursor —\n * useful for clickable cards in grids.\n *\n * @example\n * // Standard content card with header and body:\n * <Card>\n * <CardHeader>\n * <CardTitle>Project Alpha</CardTitle>\n * <CardDescription>Last updated 2 hours ago</CardDescription>\n * </CardHeader>\n * <CardContent>\n * <p>Sprint 4 is in progress with 12 open tasks.</p>\n * </CardContent>\n * </Card>\n *\n * @example\n * // Full-bleed cover image + edge-to-edge divider:\n * <Card>\n * <CardBleed side=\"top\"><img src={cover} alt=\"\" /></CardBleed>\n * <CardHeader><CardTitle>Muhurat launch site</CardTitle></CardHeader>\n * <Separator />\n * <CardFooter><Badge color=\"success\">On track</Badge></CardFooter>\n * </Card>\n *\n * @example\n * // Horizontal media card — media pane owns the left edge, CardSection restores rhythm:\n * <Card orientation=\"horizontal\">\n * <div className=\"w-32 shrink-0 rounded-l-surface overflow-hidden\">\n * <img src={thumb} alt=\"\" className=\"h-full w-full object-cover\" />\n * </div>\n * <CardSection>\n * <CardHeader><CardTitle>Field notes</CardTitle></CardHeader>\n * <CardFooter>edited yesterday</CardFooter>\n * </CardSection>\n * </Card>\n *\n * @example\n * // Flat card for a sidebar panel section (no shadow):\n * <Card variant=\"flat\">\n * <CardContent>\n * <p className=\"text-surface-fg-muted text-body-sm\">No recent activity</p>\n * </CardContent>\n * </Card>\n */\nexport interface CardProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>,\n VariantProps<typeof cardVariants> {\n interactive?: boolean\n}\n\nexport type { CardSize }\n\nconst Card = React.forwardRef<HTMLDivElement, CardProps>(\n ({ className, variant, color, size, orientation, interactive, children, ...props }, ref) => {\n if (typeof process !== 'undefined' && process?.env.NODE_ENV !== 'production') {\n warnOnUnwrappedTextChildren(children)\n }\n const classes = cn(\n cardVariants({ variant, color, size, orientation }),\n interactive && 'hover:shadow-raised-hover cursor-pointer transition-shadow duration-fast-02 ease-productive-standard',\n className,\n )\n\n if (interactive) {\n return (\n <motion.div\n ref={ref}\n whileHover={{ y: -3 }}\n whileTap={{ scale: 0.98 }}\n transition={springs.snappy}\n className={classes}\n {...motionProps(props)}\n >\n {children}\n </motion.div>\n )\n }\n\n return (\n <div ref={ref} className={classes} {...props}>\n {children}\n </div>\n )\n },\n)\nCard.displayName = 'Card'\n\nconst CardHeader = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn(\n 'flex flex-col gap-ds-02b px-(--card-spacing) [&>:first-child]:mt-0 [&>:last-child]:mb-0',\n className,\n )}\n {...props}\n />\n))\nCardHeader.displayName = 'CardHeader'\n\nconst CardTitle = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn('font-sans font-semibold leading-ds-none tracking-normal text-surface-fg', className)}\n {...props}\n />\n))\nCardTitle.displayName = 'CardTitle'\n\nconst CardDescription = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn('text-body-md text-surface-fg-muted', className)}\n {...props}\n />\n))\nCardDescription.displayName = 'CardDescription'\n\nconst CardContent = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn(\n // Reset first/last child margins so a raw <p>/<h*>'s UA margin can't leak\n // past the slot onto the container's gap-model padding (the bottom-heavy bug).\n 'px-(--card-spacing) [&>:first-child]:mt-0 [&>:last-child]:mb-0',\n className,\n )}\n {...props}\n />\n))\nCardContent.displayName = 'CardContent'\n\nconst CardFooter = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn('flex items-center gap-ds-03 px-(--card-spacing)', className)}\n {...props}\n />\n))\nCardFooter.displayName = 'CardFooter'\n\n/**\n * A vertical stack that re-establishes the card's padding + gap rhythm — the text column\n * of a `<Card orientation=\"horizontal\">`. Reads the same `--card-spacing` / `--card-gap`\n * variables the container sets, so the horizontal card's content column matches a vertical\n * card of the same `size` exactly.\n */\nconst CardSection = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn('flex min-w-0 flex-1 flex-col py-(--card-spacing) gap-(--card-gap)', className)}\n {...props}\n />\n))\nCardSection.displayName = 'CardSection'\n\ntype CardBleedSide = 'x' | 'top' | 'bottom' | 'y' | 'all'\n\nconst bleedSideClasses: Record<CardBleedSide, string> = {\n // Inside a slot: escape the slot's horizontal inset.\n x: '-mx-(--card-spacing)',\n // As a direct child: escape the container's vertical edge (direct children are\n // already full-width — never add `x` bleed to a direct child, it would overflow).\n top: '-mt-(--card-spacing) rounded-t-surface overflow-hidden',\n bottom: '-mb-(--card-spacing) rounded-b-surface overflow-hidden',\n y: '-my-(--card-spacing) rounded-surface overflow-hidden',\n // Inside a slot, escaping every edge (e.g. an image-only card body).\n all: '-my-(--card-spacing) -mx-(--card-spacing) rounded-surface overflow-hidden',\n}\n\nexport interface CardBleedProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Which card padding to negate. `top`/`bottom`/`y` are for direct children of Card\n * (full-bleed media, edge bands) and inherit the card's corner radius; `x`/`all` are\n * for content INSIDE a slot that needs to escape the slot's horizontal inset.\n * Direct children of Card already span its full width — don't use `x`/`all` there.\n * @default 'x'\n */\n side?: CardBleedSide\n}\n\n/**\n * Escape hatch from the card's padding — the shilp-sutra equivalent of Radix Themes'\n * `Inset` / Polaris `Bleed`. Negates the same `--card-spacing` variable the padding\n * reads, so it stays exact across sizes and overrides.\n *\n * @example\n * // Cover image touching the card's top + side edges:\n * <Card>\n * <CardBleed side=\"top\"><img src={cover} alt=\"\" /></CardBleed>\n * <CardHeader><CardTitle>Project</CardTitle></CardHeader>\n * </Card>\n *\n * @example\n * // A tinted band inside CardContent, running edge-to-edge:\n * <CardContent>\n * <CardBleed><div className=\"bg-accent-2 px-(--card-spacing) py-ds-03\">Heads up…</div></CardBleed>\n * </CardContent>\n */\nconst CardBleed = React.forwardRef<HTMLDivElement, CardBleedProps>(\n ({ className, side = 'x', ...props }, ref) => (\n <div ref={ref} className={cn(bleedSideClasses[side], className)} {...props} />\n ),\n)\nCardBleed.displayName = 'CardBleed'\n\ntype CardActionPlacement = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'\n\n// Corner inset reads --card-spacing so an action's edge lines up with the slot\n// content edge at every size.\nconst cornerPositions: Record<CardActionPlacement, string> = {\n 'top-right': 'top-(--card-spacing) right-(--card-spacing)',\n 'top-left': 'top-(--card-spacing) left-(--card-spacing)',\n 'bottom-right': 'bottom-(--card-spacing) right-(--card-spacing)',\n 'bottom-left': 'bottom-(--card-spacing) left-(--card-spacing)',\n}\n\nexport interface CardActionProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Which corner the action sits in. @default 'top-right' */\n placement?: CardActionPlacement\n /**\n * Pull the action a step toward its corner (`-m-ds-02`) so an icon button's GLYPH —\n * not its padding box — aligns to the content-edge line. Use for ghost/icon buttons\n * placed in a corner; leave off for badges/text where the padding box is the edge.\n */\n tuck?: boolean\n}\n\n/**\n * An absolutely-positioned corner slot for a Card — a menu/icon button, a status badge,\n * an overflow action. The Card is `relative`, so this pins to one of its four corners\n * with an inset that matches the card's content padding.\n *\n * @example\n * <Card>\n * <CardAction><IconButton aria-label=\"More\" icon={<IconDots />} variant=\"ghost\" tuck /></CardAction>\n * <CardHeader><CardTitle>Project Alpha</CardTitle></CardHeader>\n * </Card>\n *\n * @example\n * // Accent status badge in the top-right:\n * <Card>\n * <CardAction><Badge color=\"accent\" size=\"xs\">LIVE</Badge></CardAction>\n * ...\n * </Card>\n */\nconst CardAction = React.forwardRef<HTMLDivElement, CardActionProps>(\n ({ className, placement = 'top-right', tuck, ...props }, ref) => (\n <div\n ref={ref}\n className={cn(\n 'absolute z-[1] flex items-center gap-ds-02',\n cornerPositions[placement],\n tuck && '-m-ds-02',\n className,\n )}\n {...props}\n />\n ),\n)\nCardAction.displayName = 'CardAction'\n\n// Text-shaped tags that almost certainly expected a slot's horizontal inset.\n// Structural tags (div, section, img, table, hr…) are legitimate full-width direct\n// children, so they stay silent.\nconst TEXTUAL_TAGS = new Set(['p', 'span', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'a', 'label', 'small', 'strong', 'em'])\nlet warnedUnwrappedText = false\n\nfunction warnOnUnwrappedTextChildren(children: React.ReactNode): void {\n if (warnedUnwrappedText) return\n React.Children.forEach(children, (child) => {\n const isBareText = typeof child === 'string' && child.trim() !== ''\n const isTextualTag =\n React.isValidElement(child) &&\n typeof child.type === 'string' &&\n TEXTUAL_TAGS.has(child.type)\n if (isBareText || isTextualTag) {\n warnedUnwrappedText = true\n console.warn(\n '[shilp-sutra] <Card> received text content as a direct child. Direct children span the full card width and get no horizontal inset — wrap text in <CardContent> (or <CardHeader>/<CardFooter>). See the Card docs, \"Composition\".',\n )\n }\n })\n}\n\nexport { Card, CardAction, CardBleed, CardContent, CardDescription, CardFooter, CardHeader, CardSection, CardTitle, cardVariants }\nexport type { CardActionPlacement, CardBleedSide }\n"],"mappings":";;;;;;;;AAcA,IAAM,IAAe,EAUnB,6GACA;CACE,UAAU;EACR,SAAS;GAIP,SAAS;GACT,UAAU;GAEV,SAAS;GACT,MAAM;EACR;EACA,OAAO;GACL,SAAS;GACT,QAAQ;GACR,OAAO;GACP,SAAS;GACT,SAAS;GACT,MAAM;GACN,SAAS;EACX;EAGA,MAAM;GACJ,IAAI;GACJ,IAAI;GACJ,IAAI;EACN;EAIA,aAAa;GACX,UAAU;GACV,YAAY;EACd;CACF;CACA,iBAAiB;EAAE,SAAS;EAAW,OAAO;EAAW,MAAM;EAAM,aAAa;CAAW;AAC/F,CACF,GAwEM,IAAO,EAAM,YAChB,EAAE,cAAW,YAAS,UAAO,SAAM,gBAAa,gBAAa,aAAU,GAA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,IAAM,IAAc,EAAM,YAGvB,EAAE,cAAW,GAAG,KAAS,MAC1B,kBAAC,OAAD;CACO;CACL,WAAW,EAAG,qEAAqE,CAAS;CAC5F,GAAI;AACL,CAAA,CACF;AACD,EAAY,cAAc;AAI1B,IAAM,IAAkD;CAEtD,GAAG;CAGH,KAAK;CACL,QAAQ;CACR,GAAG;CAEH,KAAK;AACP,GA+BM,IAAY,EAAM,YACrB,EAAE,cAAW,UAAO,KAAK,GAAG,KAAS,MACpC,kBAAC,OAAD;CAAU;CAAK,WAAW,EAAG,EAAiB,IAAO,CAAS;CAAG,GAAI;AAAQ,CAAA,CAEjF;AACA,EAAU,cAAc;AAMxB,IAAM,IAAuD;CAC3D,aAAa;CACb,YAAY;CACZ,gBAAgB;CAChB,eAAe;AACjB,GA+BM,IAAa,EAAM,YACtB,EAAE,cAAW,eAAY,aAAa,SAAM,GAAG,KAAS,MACvD,kBAAC,OAAD;CACO;CACL,WAAW,EACT,8CACA,EAAgB,IAChB,KAAQ,YACR,CACF;CACA,GAAI;AACL,CAAA,CAEL;AACA,EAAW,cAAc;AAKzB,IAAM,oBAAe,IAAI,IAAI;CAAC;CAAK;CAAQ;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAK;CAAS;CAAS;CAAU;AAAI,CAAC,GACjH,IAAsB;AAE1B,SAAS,EAA4B,GAAiC;CAChE,KACJ,EAAM,SAAS,QAAQ,IAAW,MAAU;EAC1C,IAAM,IAAa,OAAO,KAAU,YAAY,EAAM,KAAK,MAAM,IAC3D,IACJ,EAAM,eAAe,CAAK,KAC1B,OAAO,EAAM,QAAS,YACtB,EAAa,IAAI,EAAM,IAAI;EAC7B,CAAI,KAAc,OAChB,IAAsB,IACtB,QAAQ,KACN,qOACF;CAEJ,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"card.js","names":[],"sources":["../../src/ui/card.tsx"],"sourcesContent":["'use client'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { motion } from 'framer-motion'\nimport * as React from 'react'\n\nimport { motionProps, springs } from './lib/motion'\nimport { cn } from './lib/utils'\n\n// Bundlers (Vite, Next.js, webpack) define process.env.NODE_ENV; guard for raw ESM.\ndeclare const process: { env: { NODE_ENV?: string } } | undefined\n\ntype CardSize = 'sm' | 'md' | 'lg'\n\nconst cardVariants = cva(\n // Gap model, variable-driven: `size` sets --card-spacing / --card-gap once on the\n // container; the container reads them for its vertical edge (py) and inter-slot\n // rhythm (gap), slots read the same variables for their horizontal inset (px), and\n // CardAction/CardBleed read them for corner offsets / negative margins. One variable\n // pair is the whole size system — override it with a single arbitrary property\n // (`[--card-spacing:var(--spacing-ds-07)]`) and every part follows.\n // No per-slot py, no pt-0, no per-element margins — adding/removing a slot can't\n // unbalance the bottom edge (make-kit rule: shadow ring is the edge, gap is the rhythm).\n // `relative` establishes the positioning context for <CardAction> corner slots.\n 'relative flex text-surface-fg rounded-surface transition-shadow duration-fast-02 ease-productive-standard',\n {\n variants: {\n variant: {\n // Tonal (default): depth from a surface-tone shift + a whisper hairline in the\n // surface's own colour (`border-card`), NO shadow — the DS-wide anti-slop edge\n // (Setu tonal-elevation). The `color` prop overrides the hairline colour to paint\n // a deliberate accent/status edge.\n default: 'bg-surface-raised border border-card shadow-none',\n // Elevation-led: the shadow's own ring is the edge (make-kit rule #6 — no\n // border+shadow double-edge). Reach for it when a card should visibly pop\n // (a dragged tile, a spotlight panel). border-transparent keeps `color` paintable.\n elevated: 'bg-surface-raised border border-transparent shadow-raised-hover',\n // Border-led, strong: a firmly visible edge, no shadow.\n outline: 'bg-transparent border border-surface-border-strong shadow-none',\n flat: 'bg-surface-raised border-none shadow-none',\n },\n color: {\n default: '',\n accent: 'border-accent-7',\n error: 'border-error-7',\n success: 'border-success-7',\n warning: 'border-warning-7',\n info: 'border-info-7',\n neutral: '',\n },\n // size only assigns the two variables; the orientation axis decides where\n // they're consumed (container in vertical, <CardSection> in horizontal).\n size: {\n sm: '[--card-spacing:var(--spacing-ds-05)] [--card-gap:var(--spacing-ds-03)]',\n md: '[--card-spacing:var(--spacing-ds-05b)] [--card-gap:var(--spacing-ds-04)]',\n lg: '[--card-spacing:var(--spacing-ds-06)] [--card-gap:var(--spacing-ds-05)]',\n },\n // vertical: the container owns py + gap (the default gap model).\n // horizontal: the container is a padding-less row; a <CardSection> child\n // re-establishes py + gap for the text column while a media pane owns an edge.\n orientation: {\n vertical: 'flex-col py-(--card-spacing) gap-(--card-gap)',\n horizontal: 'flex-row items-stretch',\n },\n },\n defaultVariants: { variant: 'default', color: 'default', size: 'md', orientation: 'vertical' },\n },\n)\n\n/**\n * Props for Card — a general-purpose content container with 4 elevation/style variants and\n * an optional interactive hover state.\n *\n * **Variants (tonal, elevation-led, or border-led — never border+shadow together):** `default`\n * (tonal — surface shift + `border-card` hairline, no shadow) | `elevated` (shadow-raised-hover,\n * no border — use when a card should visibly pop) | `outline` (strong visible border, no shadow) |\n * `flat` (filled background, no edge). The shadow tokens carry their own 1px ring, so `elevated`\n * needs no explicit border (make-kit rule #6).\n *\n * **Composition:** Use sub-components `<CardHeader>`, `<CardTitle>`, `<CardDescription>`,\n * `<CardContent>`, and `<CardFooter>` for consistent internal spacing. Text content must live\n * inside a slot — raw text as a direct child gets no horizontal inset (direct children span the\n * full card width by design, which is what makes full-width dividers and bands free).\n *\n * **Spacing:** `size` sets `--card-spacing` / `--card-gap` once; container, slots, `CardAction`,\n * and `CardBleed` all read the same pair. Retune a card with a single override:\n * `className=\"[--card-spacing:var(--spacing-ds-07)]\"`.\n *\n * **Interactive:** Pass `interactive` to enable hover shadow lift and pointer cursor —\n * useful for clickable cards in grids.\n *\n * @example\n * // Standard content card with header and body:\n * <Card>\n * <CardHeader>\n * <CardTitle>Project Alpha</CardTitle>\n * <CardDescription>Last updated 2 hours ago</CardDescription>\n * </CardHeader>\n * <CardContent>\n * <p>Sprint 4 is in progress with 12 open tasks.</p>\n * </CardContent>\n * </Card>\n *\n * @example\n * // Full-bleed cover image + edge-to-edge divider:\n * <Card>\n * <CardBleed side=\"top\"><img src={cover} alt=\"\" /></CardBleed>\n * <CardHeader><CardTitle>Muhurat launch site</CardTitle></CardHeader>\n * <Separator />\n * <CardFooter><Badge color=\"success\">On track</Badge></CardFooter>\n * </Card>\n *\n * @example\n * // Horizontal media card — media pane owns the left edge, CardSection restores rhythm:\n * <Card orientation=\"horizontal\">\n * <div className=\"w-32 shrink-0 rounded-l-surface overflow-hidden\">\n * <img src={thumb} alt=\"\" className=\"h-full w-full object-cover\" />\n * </div>\n * <CardSection>\n * <CardHeader><CardTitle>Field notes</CardTitle></CardHeader>\n * <CardFooter>edited yesterday</CardFooter>\n * </CardSection>\n * </Card>\n *\n * @example\n * // Flat card for a sidebar panel section (no shadow):\n * <Card variant=\"flat\">\n * <CardContent>\n * <p className=\"text-surface-fg-muted text-body-sm\">No recent activity</p>\n * </CardContent>\n * </Card>\n */\nexport interface CardProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>,\n VariantProps<typeof cardVariants> {\n interactive?: boolean\n}\n\nexport type { CardSize }\n\nconst Card = React.forwardRef<HTMLDivElement, CardProps>(\n ({ className, variant, color, size, orientation, interactive, children, ...props }, ref) => {\n if (typeof process !== 'undefined' && process?.env.NODE_ENV !== 'production') {\n warnOnUnwrappedTextChildren(children)\n }\n const classes = cn(\n cardVariants({ variant, color, size, orientation }),\n interactive && 'hover:shadow-raised-hover cursor-pointer transition-shadow duration-fast-02 ease-productive-standard',\n className,\n )\n\n if (interactive) {\n return (\n <motion.div\n ref={ref}\n whileHover={{ y: -3 }}\n whileTap={{ scale: 0.98 }}\n transition={springs.snappy}\n className={classes}\n {...motionProps(props)}\n >\n {children}\n </motion.div>\n )\n }\n\n return (\n <div ref={ref} className={classes} {...props}>\n {children}\n </div>\n )\n },\n)\nCard.displayName = 'Card'\n\nconst CardHeader = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn(\n 'flex flex-col gap-ds-02b px-(--card-spacing) [&>:first-child]:mt-0 [&>:last-child]:mb-0',\n className,\n )}\n {...props}\n />\n))\nCardHeader.displayName = 'CardHeader'\n\nconst CardTitle = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn('font-sans font-semibold leading-ds-none tracking-normal text-surface-fg', className)}\n {...props}\n />\n))\nCardTitle.displayName = 'CardTitle'\n\nconst CardDescription = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn('text-body-md text-surface-fg-muted', className)}\n {...props}\n />\n))\nCardDescription.displayName = 'CardDescription'\n\nconst CardContent = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn(\n // Reset first/last child margins so a raw <p>/<h*>'s UA margin can't leak\n // past the slot onto the container's gap-model padding (the bottom-heavy bug).\n 'px-(--card-spacing) [&>:first-child]:mt-0 [&>:last-child]:mb-0',\n className,\n )}\n {...props}\n />\n))\nCardContent.displayName = 'CardContent'\n\nconst CardFooter = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn('flex items-center gap-ds-03 px-(--card-spacing)', className)}\n {...props}\n />\n))\nCardFooter.displayName = 'CardFooter'\n\n/**\n * A vertical stack that re-establishes the card's padding + gap rhythm — the text column\n * of a `<Card orientation=\"horizontal\">`. Reads the same `--card-spacing` / `--card-gap`\n * variables the container sets, so the horizontal card's content column matches a vertical\n * card of the same `size` exactly.\n */\nconst CardSection = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn('flex min-w-0 flex-1 flex-col py-(--card-spacing) gap-(--card-gap)', className)}\n {...props}\n />\n))\nCardSection.displayName = 'CardSection'\n\ntype CardBleedSide = 'x' | 'top' | 'bottom' | 'y' | 'all'\n\nconst bleedSideClasses: Record<CardBleedSide, string> = {\n // Inside a slot: escape the slot's horizontal inset.\n x: '-mx-(--card-spacing)',\n // As a direct child: escape the container's vertical edge (direct children are\n // already full-width — never add `x` bleed to a direct child, it would overflow).\n top: '-mt-(--card-spacing) rounded-t-surface overflow-hidden',\n bottom: '-mb-(--card-spacing) rounded-b-surface overflow-hidden',\n y: '-my-(--card-spacing) rounded-surface overflow-hidden',\n // Inside a slot, escaping every edge (e.g. an image-only card body).\n all: '-my-(--card-spacing) -mx-(--card-spacing) rounded-surface overflow-hidden',\n}\n\nexport interface CardBleedProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Which card padding to negate. `top`/`bottom`/`y` are for direct children of Card\n * (full-bleed media, edge bands) and inherit the card's corner radius; `x`/`all` are\n * for content INSIDE a slot that needs to escape the slot's horizontal inset.\n * Direct children of Card already span its full width — don't use `x`/`all` there.\n * @default 'x'\n */\n side?: CardBleedSide\n}\n\n/**\n * Escape hatch from the card's padding — the shilp-sutra equivalent of Radix Themes'\n * `Inset` / Polaris `Bleed`. Negates the same `--card-spacing` variable the padding\n * reads, so it stays exact across sizes and overrides.\n *\n * @example\n * // Cover image touching the card's top + side edges:\n * <Card>\n * <CardBleed side=\"top\"><img src={cover} alt=\"\" /></CardBleed>\n * <CardHeader><CardTitle>Project</CardTitle></CardHeader>\n * </Card>\n *\n * @example\n * // A tinted band inside CardContent, running edge-to-edge:\n * <CardContent>\n * <CardBleed><div className=\"bg-accent-2 px-(--card-spacing) py-ds-03\">Heads up…</div></CardBleed>\n * </CardContent>\n */\nconst CardBleed = React.forwardRef<HTMLDivElement, CardBleedProps>(\n ({ className, side = 'x', ...props }, ref) => (\n <div ref={ref} className={cn(bleedSideClasses[side], className)} {...props} />\n ),\n)\nCardBleed.displayName = 'CardBleed'\n\ntype CardActionPlacement = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'\n\n// Corner inset reads --card-spacing so an action's edge lines up with the slot\n// content edge at every size.\nconst cornerPositions: Record<CardActionPlacement, string> = {\n 'top-right': 'top-(--card-spacing) right-(--card-spacing)',\n 'top-left': 'top-(--card-spacing) left-(--card-spacing)',\n 'bottom-right': 'bottom-(--card-spacing) right-(--card-spacing)',\n 'bottom-left': 'bottom-(--card-spacing) left-(--card-spacing)',\n}\n\nexport interface CardActionProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Which corner the action sits in. @default 'top-right' */\n placement?: CardActionPlacement\n /**\n * Pull the action a step toward its corner (`-m-ds-02`) so an icon button's GLYPH —\n * not its padding box — aligns to the content-edge line. Use for ghost/icon buttons\n * placed in a corner; leave off for badges/text where the padding box is the edge.\n */\n tuck?: boolean\n}\n\n/**\n * An absolutely-positioned corner slot for a Card — a menu/icon button, a status badge,\n * an overflow action. The Card is `relative`, so this pins to one of its four corners\n * with an inset that matches the card's content padding.\n *\n * @example\n * <Card>\n * <CardAction><IconButton aria-label=\"More\" icon={<IconDots />} variant=\"ghost\" tuck /></CardAction>\n * <CardHeader><CardTitle>Project Alpha</CardTitle></CardHeader>\n * </Card>\n *\n * @example\n * // Accent status badge in the top-right:\n * <Card>\n * <CardAction><Badge color=\"accent\" size=\"xs\">LIVE</Badge></CardAction>\n * ...\n * </Card>\n */\nconst CardAction = React.forwardRef<HTMLDivElement, CardActionProps>(\n ({ className, placement = 'top-right', tuck, ...props }, ref) => (\n <div\n ref={ref}\n className={cn(\n 'absolute z-[1] flex items-center gap-ds-02',\n cornerPositions[placement],\n tuck && '-m-ds-02',\n className,\n )}\n {...props}\n />\n ),\n)\nCardAction.displayName = 'CardAction'\n\n// Text-shaped tags that almost certainly expected a slot's horizontal inset.\n// Structural tags (div, section, img, table, hr…) are legitimate full-width direct\n// children, so they stay silent.\nconst TEXTUAL_TAGS = new Set(['p', 'span', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'a', 'label', 'small', 'strong', 'em'])\nlet warnedUnwrappedText = false\n\nfunction warnOnUnwrappedTextChildren(children: React.ReactNode): void {\n if (warnedUnwrappedText) return\n React.Children.forEach(children, (child) => {\n const isBareText = typeof child === 'string' && child.trim() !== ''\n const isTextualTag =\n React.isValidElement(child) &&\n typeof child.type === 'string' &&\n TEXTUAL_TAGS.has(child.type)\n if (isBareText || isTextualTag) {\n warnedUnwrappedText = true\n console.warn(\n '[shilp-sutra] <Card> received text content as a direct child. Direct children span the full card width and get no horizontal inset — wrap text in <CardContent> (or <CardHeader>/<CardFooter>). See the Card docs, \"Composition\".',\n )\n }\n })\n}\n\nexport { Card, CardAction, CardBleed, CardContent, CardDescription, CardFooter, CardHeader, CardSection, CardTitle, cardVariants }\nexport type { CardActionPlacement, CardBleedSide }\n"],"mappings":";;;;;;;;AAcA,IAAM,IAAe,EAUnB,6GACA;CACE,UAAU;EACR,SAAS;GAKP,SAAS;GAIT,UAAU;GAEV,SAAS;GACT,MAAM;EACR;EACA,OAAO;GACL,SAAS;GACT,QAAQ;GACR,OAAO;GACP,SAAS;GACT,SAAS;GACT,MAAM;GACN,SAAS;EACX;EAGA,MAAM;GACJ,IAAI;GACJ,IAAI;GACJ,IAAI;EACN;EAIA,aAAa;GACX,UAAU;GACV,YAAY;EACd;CACF;CACA,iBAAiB;EAAE,SAAS;EAAW,OAAO;EAAW,MAAM;EAAM,aAAa;CAAW;AAC/F,CACF,GAyEM,IAAO,EAAM,YAChB,EAAE,cAAW,YAAS,UAAO,SAAM,gBAAa,gBAAa,aAAU,GAAG,KAAS,MAAQ;CAC1F,AAAI,OAAO,UAAY,OAAA,QAAA,IAAA,aAAyC,gBAC9D,EAA4B,CAAQ;CAEtC,IAAM,IAAU,EACd,EAAa;EAAE;EAAS;EAAO;EAAM;CAAY,CAAC,GAClD,KAAe,wGACf,CACF;CAiBA,OAfI,IAEA,kBAAC,EAAO,KAAR;EACO;EACL,YAAY,EAAE,GAAG,GAAG;EACpB,UAAU,EAAE,OAAO,IAAK;EACxB,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,2CAA2C;IAC3C,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAA;IAClC;;;;OAIG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;CAC/B;AAuDD,QAAA,MAAM,UAAU,wFA2Yf,CAAA;AAGD,OAAO,EAAE,UAAU,EAAE,CAAA"}
|
package/dist/ui/color-input.js
CHANGED
|
@@ -48,7 +48,7 @@ function g(e, t, n) {
|
|
|
48
48
|
};
|
|
49
49
|
return m(o(0), o(8), o(4));
|
|
50
50
|
}
|
|
51
|
-
var
|
|
51
|
+
var ee = [
|
|
52
52
|
{
|
|
53
53
|
hex: "#C53637",
|
|
54
54
|
label: "Red"
|
|
@@ -90,7 +90,7 @@ var _ = [
|
|
|
90
90
|
label: "Pink"
|
|
91
91
|
}
|
|
92
92
|
];
|
|
93
|
-
function
|
|
93
|
+
function te(e) {
|
|
94
94
|
let t = p(e);
|
|
95
95
|
if (!t) return !1;
|
|
96
96
|
let [n, r, i] = [
|
|
@@ -103,7 +103,7 @@ function v(e) {
|
|
|
103
103
|
});
|
|
104
104
|
return .2126 * n + .7152 * r + .0722 * i > .4;
|
|
105
105
|
}
|
|
106
|
-
function
|
|
106
|
+
function _({ label: e, value: t, onChange: r, onBlur: i, disabled: a, maxLength: o = 3, prefix: s, className: c, id: d }) {
|
|
107
107
|
return /* @__PURE__ */ u("div", {
|
|
108
108
|
className: n("flex flex-col gap-ds-01", c),
|
|
109
109
|
children: [/* @__PURE__ */ l("label", {
|
|
@@ -128,33 +128,33 @@ function y({ label: e, value: t, onChange: r, onBlur: i, disabled: a, maxLength:
|
|
|
128
128
|
})]
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
-
var
|
|
132
|
-
let [
|
|
131
|
+
var v = c.forwardRef(({ value: v = "#000000", onChange: y, presets: b, disabled: x = !1, showPicker: S = !0, defaultFormat: C = "hex", align: ne = "start", variant: re = "default", className: w, id: ie, ...T }, E) => {
|
|
132
|
+
let [D, O] = c.useState(C), [k, A] = c.useState(!1), j = c.useId(), M = r(), N = ie ?? M.inputId, [P, F] = c.useState(v), [I, L] = c.useState(null);
|
|
133
133
|
c.useEffect(() => {
|
|
134
|
-
L(
|
|
135
|
-
}, [
|
|
136
|
-
let [R, z] = c.useState(
|
|
137
|
-
|
|
134
|
+
F(v), L(null);
|
|
135
|
+
}, [v]);
|
|
136
|
+
let [R, z] = c.useState(v), [B, V] = c.useState([]), H = c.useRef(!1), U = (e) => {
|
|
137
|
+
x || (e && (z(P), V([])), L(null), A(e));
|
|
138
138
|
}, W = (e) => {
|
|
139
|
-
if (
|
|
139
|
+
if (x) return;
|
|
140
140
|
let t = (e.startsWith("#") ? e : `#${e}`).toLowerCase();
|
|
141
|
-
V((e) => e[e.length - 1] ===
|
|
141
|
+
V((e) => e[e.length - 1] === P ? e : [...e.slice(-19), P]), F(t), L(null), y?.(t);
|
|
142
142
|
}, G = (e) => {
|
|
143
|
-
if (
|
|
143
|
+
if (x) return;
|
|
144
144
|
let t = (e.startsWith("#") ? e : `#${e}`).toLowerCase();
|
|
145
|
-
H.current || (H.current = !0, V((e) => e[e.length - 1] ===
|
|
145
|
+
H.current || (H.current = !0, V((e) => e[e.length - 1] === P ? e : [...e.slice(-19), P])), F(t), y?.(t);
|
|
146
146
|
}, K = () => {
|
|
147
147
|
H.current = !1;
|
|
148
148
|
}, q = () => {
|
|
149
149
|
if (B.length === 0) return;
|
|
150
150
|
let e = B[B.length - 1];
|
|
151
|
-
V((e) => e.slice(0, -1)),
|
|
151
|
+
V((e) => e.slice(0, -1)), F(e), y?.(e);
|
|
152
152
|
}, J = () => {
|
|
153
|
-
|
|
154
|
-
}, Y =
|
|
153
|
+
F(R), y?.(R), V([]);
|
|
154
|
+
}, Y = b === !1 ? [] : b ? b.map((e) => typeof e == "string" ? {
|
|
155
155
|
hex: e,
|
|
156
156
|
label: e
|
|
157
|
-
} : e) :
|
|
157
|
+
} : e) : ee, X = p(P), Z = h(P), Q = (e, t) => {
|
|
158
158
|
if (!X) return;
|
|
159
159
|
let n = parseInt(t, 10);
|
|
160
160
|
if (isNaN(n)) return;
|
|
@@ -166,27 +166,27 @@ var b = c.forwardRef(({ value: b = "#000000", onChange: x, presets: S, disabled:
|
|
|
166
166
|
if (isNaN(n)) return;
|
|
167
167
|
let r = Math.max(0, Math.min(e === "h" ? 360 : 100, n));
|
|
168
168
|
W(g(e === "h" ? r : Z.h, e === "s" ? r : Z.s, e === "l" ? r : Z.l));
|
|
169
|
-
},
|
|
169
|
+
}, ae = [
|
|
170
170
|
"hex",
|
|
171
171
|
"rgb",
|
|
172
172
|
"hsl"
|
|
173
173
|
];
|
|
174
174
|
return /* @__PURE__ */ l("div", {
|
|
175
|
-
ref:
|
|
176
|
-
className: n("inline-flex flex-col",
|
|
177
|
-
...
|
|
175
|
+
ref: E,
|
|
176
|
+
className: n("inline-flex flex-col", w),
|
|
177
|
+
...T,
|
|
178
178
|
children: /* @__PURE__ */ u(a, {
|
|
179
|
-
open:
|
|
179
|
+
open: k,
|
|
180
180
|
onOpenChange: U,
|
|
181
181
|
children: [/* @__PURE__ */ l(s, {
|
|
182
182
|
asChild: !0,
|
|
183
|
-
children:
|
|
183
|
+
children: re === "inline" ? /* @__PURE__ */ l(f.button, {
|
|
184
184
|
type: "button",
|
|
185
|
-
disabled:
|
|
186
|
-
className: n("group flex items-center justify-center rounded-control px-ds-04 py-ds-02 font-mono text-body-sm font-medium", "focus:outline-hidden focus:ring-2 focus:ring-accent-9 focus:ring-offset-2 focus:ring-offset-surface-base",
|
|
185
|
+
disabled: x,
|
|
186
|
+
className: n("group flex items-center justify-center rounded-control px-ds-04 py-ds-02 font-mono text-body-sm font-medium", "focus:outline-hidden focus:ring-2 focus:ring-accent-9 focus:ring-offset-2 focus:ring-offset-surface-base", x && "cursor-not-allowed opacity-50"),
|
|
187
187
|
animate: {
|
|
188
|
-
backgroundColor:
|
|
189
|
-
color:
|
|
188
|
+
backgroundColor: P,
|
|
189
|
+
color: te(P) ? "rgba(0,0,0,0.8)" : "rgba(255,255,255,0.95)"
|
|
190
190
|
},
|
|
191
191
|
whileHover: {
|
|
192
192
|
y: -1,
|
|
@@ -194,26 +194,26 @@ var b = c.forwardRef(({ value: b = "#000000", onChange: x, presets: S, disabled:
|
|
|
194
194
|
},
|
|
195
195
|
whileTap: { scale: .97 },
|
|
196
196
|
transition: t.smooth,
|
|
197
|
-
id:
|
|
198
|
-
"aria-describedby":
|
|
199
|
-
"aria-invalid":
|
|
200
|
-
"aria-label":
|
|
201
|
-
children:
|
|
197
|
+
id: N,
|
|
198
|
+
"aria-describedby": M.helperTextId,
|
|
199
|
+
"aria-invalid": M.state === "error" || void 0,
|
|
200
|
+
"aria-label": M.inputId ? void 0 : `Color picker: ${P}`,
|
|
201
|
+
children: P.toUpperCase()
|
|
202
202
|
}) : /* @__PURE__ */ u(f.button, {
|
|
203
203
|
type: "button",
|
|
204
|
-
disabled:
|
|
205
|
-
className: n("group relative flex items-center overflow-hidden rounded-control border border-surface-border-strong", "hover:border-accent-7 focus:border-accent-7 focus:outline-hidden focus:ring-1 focus:ring-accent-9",
|
|
204
|
+
disabled: x,
|
|
205
|
+
className: n("group relative flex items-center overflow-hidden rounded-control border border-surface-border-strong", "hover:border-accent-7 focus:border-accent-7 focus:outline-hidden focus:ring-1 focus:ring-accent-9", x && "cursor-not-allowed opacity-50"),
|
|
206
206
|
whileHover: { scale: 1.02 },
|
|
207
207
|
whileTap: { scale: .98 },
|
|
208
208
|
transition: t.snappy,
|
|
209
|
-
id:
|
|
210
|
-
"aria-describedby":
|
|
211
|
-
"aria-invalid":
|
|
212
|
-
"aria-label":
|
|
209
|
+
id: N,
|
|
210
|
+
"aria-describedby": M.helperTextId,
|
|
211
|
+
"aria-invalid": M.state === "error" || void 0,
|
|
212
|
+
"aria-label": M.inputId ? void 0 : `Color picker: ${P}`,
|
|
213
213
|
children: [
|
|
214
214
|
/* @__PURE__ */ l(f.span, {
|
|
215
215
|
className: "absolute inset-0",
|
|
216
|
-
animate: { background: `linear-gradient(to right, ${
|
|
216
|
+
animate: { background: `linear-gradient(to right, ${P} 0%, ${P} 35%, transparent 70%)` },
|
|
217
217
|
transition: { duration: .3 }
|
|
218
218
|
}),
|
|
219
219
|
/* @__PURE__ */ l("span", {
|
|
@@ -225,25 +225,25 @@ var b = c.forwardRef(({ value: b = "#000000", onChange: x, presets: S, disabled:
|
|
|
225
225
|
}),
|
|
226
226
|
/* @__PURE__ */ l("span", {
|
|
227
227
|
className: "relative z-10 py-ds-02 pl-6 pr-ds-03 font-mono text-body-sm text-surface-fg",
|
|
228
|
-
children:
|
|
228
|
+
children: P.toUpperCase()
|
|
229
229
|
})
|
|
230
230
|
]
|
|
231
231
|
})
|
|
232
232
|
}), /* @__PURE__ */ l(o, {
|
|
233
233
|
role: "dialog",
|
|
234
234
|
"aria-label": "Color picker",
|
|
235
|
-
align:
|
|
235
|
+
align: ne,
|
|
236
236
|
sideOffset: 8,
|
|
237
237
|
className: "w-[272px] rounded-overlay-lg bg-surface-overlay p-0 shadow-floating",
|
|
238
238
|
children: /* @__PURE__ */ u("div", {
|
|
239
239
|
className: "flex flex-col",
|
|
240
240
|
children: [
|
|
241
|
-
|
|
241
|
+
S && /* @__PURE__ */ l("div", {
|
|
242
242
|
className: "p-ds-04 pb-ds-03",
|
|
243
243
|
onPointerUp: K,
|
|
244
244
|
onPointerLeave: K,
|
|
245
245
|
children: /* @__PURE__ */ l(i, {
|
|
246
|
-
color:
|
|
246
|
+
color: P,
|
|
247
247
|
onChange: G,
|
|
248
248
|
className: "w-full!",
|
|
249
249
|
style: { height: 160 }
|
|
@@ -253,12 +253,12 @@ var b = c.forwardRef(({ value: b = "#000000", onChange: x, presets: S, disabled:
|
|
|
253
253
|
className: "border-t border-surface-border px-ds-04 py-ds-03",
|
|
254
254
|
children: [/* @__PURE__ */ l("div", {
|
|
255
255
|
className: "mb-ds-03 flex items-center gap-ds-01",
|
|
256
|
-
children:
|
|
256
|
+
children: ae.map((e) => /* @__PURE__ */ u("button", {
|
|
257
257
|
type: "button",
|
|
258
|
-
onClick: () =>
|
|
259
|
-
className: n("relative min-h-6 rounded-control-inner px-ds-02 py-px text-label-xs font-semibold uppercase tracking-wider transition-colors",
|
|
260
|
-
children: [
|
|
261
|
-
layoutId: `color-input-format-pill-${
|
|
258
|
+
onClick: () => O(e),
|
|
259
|
+
className: n("relative min-h-6 rounded-control-inner px-ds-02 py-px text-label-xs font-semibold uppercase tracking-wider transition-colors", D === e ? "text-accent-11" : "text-surface-fg-muted hover:text-surface-fg"),
|
|
260
|
+
children: [D === e && /* @__PURE__ */ l(f.span, {
|
|
261
|
+
layoutId: `color-input-format-pill-${j}`,
|
|
262
262
|
className: "absolute inset-0 rounded-control-inner bg-accent-3",
|
|
263
263
|
transition: t.snappy
|
|
264
264
|
}), /* @__PURE__ */ l("span", {
|
|
@@ -269,7 +269,7 @@ var b = c.forwardRef(({ value: b = "#000000", onChange: x, presets: S, disabled:
|
|
|
269
269
|
}), /* @__PURE__ */ u(d, {
|
|
270
270
|
mode: "wait",
|
|
271
271
|
children: [
|
|
272
|
-
|
|
272
|
+
D === "hex" && /* @__PURE__ */ l(f.div, {
|
|
273
273
|
initial: {
|
|
274
274
|
opacity: 0,
|
|
275
275
|
y: 4
|
|
@@ -284,24 +284,24 @@ var b = c.forwardRef(({ value: b = "#000000", onChange: x, presets: S, disabled:
|
|
|
284
284
|
},
|
|
285
285
|
transition: { duration: e.moderate01 },
|
|
286
286
|
className: "flex gap-ds-02",
|
|
287
|
-
children: /* @__PURE__ */ l(
|
|
288
|
-
id: `${
|
|
287
|
+
children: /* @__PURE__ */ l(_, {
|
|
288
|
+
id: `${j}-hex`,
|
|
289
289
|
label: "Hex",
|
|
290
|
-
value: I.replace("#", "").toUpperCase(),
|
|
290
|
+
value: I ?? P.replace("#", "").toUpperCase(),
|
|
291
291
|
onChange: (e) => {
|
|
292
292
|
let t = e.replace(/[^0-9a-fA-F]/g, "").slice(0, 6);
|
|
293
|
-
t.length === 6 && W(`#${t}`);
|
|
293
|
+
L(t.toUpperCase()), t.length === 6 && W(`#${t}`);
|
|
294
294
|
},
|
|
295
295
|
onBlur: () => {
|
|
296
|
-
|
|
296
|
+
L(null);
|
|
297
297
|
},
|
|
298
|
-
disabled:
|
|
298
|
+
disabled: x,
|
|
299
299
|
maxLength: 6,
|
|
300
300
|
prefix: "#",
|
|
301
301
|
className: "flex-1"
|
|
302
302
|
})
|
|
303
303
|
}, "hex"),
|
|
304
|
-
|
|
304
|
+
D === "rgb" && X && /* @__PURE__ */ u(f.div, {
|
|
305
305
|
initial: {
|
|
306
306
|
opacity: 0,
|
|
307
307
|
y: 4
|
|
@@ -317,33 +317,33 @@ var b = c.forwardRef(({ value: b = "#000000", onChange: x, presets: S, disabled:
|
|
|
317
317
|
transition: { duration: e.moderate01 },
|
|
318
318
|
className: "flex gap-ds-02",
|
|
319
319
|
children: [
|
|
320
|
-
/* @__PURE__ */ l(
|
|
321
|
-
id: `${
|
|
320
|
+
/* @__PURE__ */ l(_, {
|
|
321
|
+
id: `${j}-r`,
|
|
322
322
|
label: "R",
|
|
323
323
|
value: String(X.r),
|
|
324
324
|
onChange: (e) => Q("r", e),
|
|
325
|
-
disabled:
|
|
325
|
+
disabled: x,
|
|
326
326
|
className: "flex-1"
|
|
327
327
|
}),
|
|
328
|
-
/* @__PURE__ */ l(
|
|
329
|
-
id: `${
|
|
328
|
+
/* @__PURE__ */ l(_, {
|
|
329
|
+
id: `${j}-g`,
|
|
330
330
|
label: "G",
|
|
331
331
|
value: String(X.g),
|
|
332
332
|
onChange: (e) => Q("g", e),
|
|
333
|
-
disabled:
|
|
333
|
+
disabled: x,
|
|
334
334
|
className: "flex-1"
|
|
335
335
|
}),
|
|
336
|
-
/* @__PURE__ */ l(
|
|
337
|
-
id: `${
|
|
336
|
+
/* @__PURE__ */ l(_, {
|
|
337
|
+
id: `${j}-b`,
|
|
338
338
|
label: "B",
|
|
339
339
|
value: String(X.b),
|
|
340
340
|
onChange: (e) => Q("b", e),
|
|
341
|
-
disabled:
|
|
341
|
+
disabled: x,
|
|
342
342
|
className: "flex-1"
|
|
343
343
|
})
|
|
344
344
|
]
|
|
345
345
|
}, "rgb"),
|
|
346
|
-
|
|
346
|
+
D === "hsl" && Z && /* @__PURE__ */ u(f.div, {
|
|
347
347
|
initial: {
|
|
348
348
|
opacity: 0,
|
|
349
349
|
y: 4
|
|
@@ -359,28 +359,28 @@ var b = c.forwardRef(({ value: b = "#000000", onChange: x, presets: S, disabled:
|
|
|
359
359
|
transition: { duration: e.moderate01 },
|
|
360
360
|
className: "flex gap-ds-02",
|
|
361
361
|
children: [
|
|
362
|
-
/* @__PURE__ */ l(
|
|
363
|
-
id: `${
|
|
362
|
+
/* @__PURE__ */ l(_, {
|
|
363
|
+
id: `${j}-h`,
|
|
364
364
|
label: "H",
|
|
365
365
|
value: String(Z.h),
|
|
366
366
|
onChange: (e) => $("h", e),
|
|
367
|
-
disabled:
|
|
367
|
+
disabled: x,
|
|
368
368
|
className: "flex-1"
|
|
369
369
|
}),
|
|
370
|
-
/* @__PURE__ */ l(
|
|
371
|
-
id: `${
|
|
370
|
+
/* @__PURE__ */ l(_, {
|
|
371
|
+
id: `${j}-s`,
|
|
372
372
|
label: "S",
|
|
373
373
|
value: String(Z.s),
|
|
374
374
|
onChange: (e) => $("s", e),
|
|
375
|
-
disabled:
|
|
375
|
+
disabled: x,
|
|
376
376
|
className: "flex-1"
|
|
377
377
|
}),
|
|
378
|
-
/* @__PURE__ */ l(
|
|
379
|
-
id: `${
|
|
378
|
+
/* @__PURE__ */ l(_, {
|
|
379
|
+
id: `${j}-l`,
|
|
380
380
|
label: "L",
|
|
381
381
|
value: String(Z.l),
|
|
382
382
|
onChange: (e) => $("l", e),
|
|
383
|
-
disabled:
|
|
383
|
+
disabled: x,
|
|
384
384
|
className: "flex-1"
|
|
385
385
|
})
|
|
386
386
|
]
|
|
@@ -393,10 +393,10 @@ var b = c.forwardRef(({ value: b = "#000000", onChange: x, presets: S, disabled:
|
|
|
393
393
|
children: /* @__PURE__ */ l("div", {
|
|
394
394
|
className: "flex flex-wrap gap-ds-02",
|
|
395
395
|
children: Y.map((e, r) => {
|
|
396
|
-
let i =
|
|
396
|
+
let i = P.toLowerCase() === e.hex.toLowerCase();
|
|
397
397
|
return /* @__PURE__ */ l(f.button, {
|
|
398
398
|
type: "button",
|
|
399
|
-
disabled:
|
|
399
|
+
disabled: x,
|
|
400
400
|
onClick: () => W(e.hex),
|
|
401
401
|
initial: {
|
|
402
402
|
opacity: 0,
|
|
@@ -412,7 +412,7 @@ var b = c.forwardRef(({ value: b = "#000000", onChange: x, presets: S, disabled:
|
|
|
412
412
|
...t.bouncy,
|
|
413
413
|
delay: r * .02
|
|
414
414
|
},
|
|
415
|
-
className: n("h-6 w-6 rounded-control-inner border", i ? "border-accent-7 ring-2 ring-accent-9/30" : "border-surface-border hover:border-surface-border-strong",
|
|
415
|
+
className: n("h-6 w-6 rounded-control-inner border", i ? "border-accent-7 ring-2 ring-accent-9/30" : "border-surface-border hover:border-surface-border-strong", x && "cursor-not-allowed opacity-50"),
|
|
416
416
|
style: { backgroundColor: e.hex },
|
|
417
417
|
title: e.label,
|
|
418
418
|
"aria-label": `${e.label}: ${e.hex}`
|
|
@@ -420,7 +420,7 @@ var b = c.forwardRef(({ value: b = "#000000", onChange: x, presets: S, disabled:
|
|
|
420
420
|
})
|
|
421
421
|
})
|
|
422
422
|
}),
|
|
423
|
-
(B.length > 0 ||
|
|
423
|
+
(B.length > 0 || P !== R) && /* @__PURE__ */ u(f.div, {
|
|
424
424
|
initial: {
|
|
425
425
|
opacity: 0,
|
|
426
426
|
height: 0
|
|
@@ -451,7 +451,7 @@ var b = c.forwardRef(({ value: b = "#000000", onChange: x, presets: S, disabled:
|
|
|
451
451
|
className: "min-h-6 rounded-control-inner px-ds-02 py-px text-caption font-medium text-surface-fg-muted transition-colors hover:text-surface-fg",
|
|
452
452
|
children: "Undo"
|
|
453
453
|
}),
|
|
454
|
-
|
|
454
|
+
P !== R && /* @__PURE__ */ l("button", {
|
|
455
455
|
type: "button",
|
|
456
456
|
onClick: J,
|
|
457
457
|
className: "min-h-6 rounded-control-inner px-ds-02 py-px text-caption font-medium text-surface-fg-muted transition-colors hover:text-error-11",
|
|
@@ -465,6 +465,6 @@ var b = c.forwardRef(({ value: b = "#000000", onChange: x, presets: S, disabled:
|
|
|
465
465
|
})
|
|
466
466
|
});
|
|
467
467
|
});
|
|
468
|
-
|
|
468
|
+
v.displayName = "ColorInput";
|
|
469
469
|
//#endregion
|
|
470
|
-
export {
|
|
470
|
+
export { v as ColorInput };
|