@tryghost/shade 0.1.0-alpha.46 → 0.1.0-alpha.48
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/README.md +7 -2
- package/es/components/page-templates/list-page.js +1 -1
- package/es/components/page-templates/list-page.js.map +1 -1
- package/es/components/patterns/color-picker.js +79 -56
- package/es/components/patterns/color-picker.js.map +1 -1
- package/es/components/patterns/page-header.js +1 -1
- package/es/components/patterns/page-header.js.map +1 -1
- package/es/components/ui/command.js +1 -14
- package/es/components/ui/command.js.map +1 -1
- package/es/components/ui/context-menu.js +7 -4
- package/es/components/ui/context-menu.js.map +1 -1
- package/es/components/ui/dropdown-menu.js +7 -4
- package/es/components/ui/dropdown-menu.js.map +1 -1
- package/es/components/ui/floating-sidebar.js +20 -2
- package/es/components/ui/floating-sidebar.js.map +1 -1
- package/es/components/ui/hover-card.js +3 -1
- package/es/components/ui/hover-card.js.map +1 -1
- package/es/components/ui/popover.js +4 -2
- package/es/components/ui/popover.js.map +1 -1
- package/es/components/ui/select.js +20 -15
- package/es/components/ui/select.js.map +1 -1
- package/es/components/ui/sortable-list.js +105 -10
- package/es/components/ui/sortable-list.js.map +1 -1
- package/es/components/ui/sticky-footer.js +7 -4
- package/es/components/ui/sticky-footer.js.map +1 -1
- package/es/components/ui/tooltip.js +4 -2
- package/es/components/ui/tooltip.js.map +1 -1
- package/es/components.js +4 -4
- package/es/index.js +4 -4
- package/es/lib/safe-area.js +168 -0
- package/es/lib/safe-area.js.map +1 -0
- package/es/providers/shade-provider.js +9 -1
- package/es/providers/shade-provider.js.map +1 -1
- package/es/shade-app.js +10 -2
- package/es/shade-app.js.map +1 -1
- package/package.json +1 -1
- package/styles.css +17 -0
- package/types/components/patterns/color-picker.d.ts +5 -0
- package/types/components/patterns/color-picker.d.ts.map +1 -1
- package/types/components/ui/command.d.ts +1 -6
- package/types/components/ui/command.d.ts.map +1 -1
- package/types/components/ui/context-menu.d.ts.map +1 -1
- package/types/components/ui/dropdown-menu.d.ts.map +1 -1
- package/types/components/ui/floating-sidebar.d.ts.map +1 -1
- package/types/components/ui/hover-card.d.ts.map +1 -1
- package/types/components/ui/popover.d.ts.map +1 -1
- package/types/components/ui/select.d.ts.map +1 -1
- package/types/components/ui/sortable-list.d.ts +4 -1
- package/types/components/ui/sortable-list.d.ts.map +1 -1
- package/types/components/ui/sticky-footer.d.ts.map +1 -1
- package/types/components/ui/tooltip.d.ts.map +1 -1
- package/types/lib/safe-area.d.ts +27 -0
- package/types/lib/safe-area.d.ts.map +1 -0
- package/types/providers/shade-provider.d.ts.map +1 -1
- package/types/shade-app.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -66,12 +66,17 @@ import {Button} from '@tryghost/shade/components';
|
|
|
66
66
|
import './styles.css';
|
|
67
67
|
|
|
68
68
|
createRoot(document.getElementById('root')!).render(
|
|
69
|
-
<ShadeApp darkMode={false} className="min-h-dvh
|
|
70
|
-
<
|
|
69
|
+
<ShadeApp darkMode={false} className="min-h-dvh">
|
|
70
|
+
<div className="p-6">
|
|
71
|
+
<Button>Save changes</Button>
|
|
72
|
+
</div>
|
|
71
73
|
</ShadeApp>
|
|
72
74
|
);
|
|
73
75
|
```
|
|
74
76
|
|
|
77
|
+
In a Ghost app, `ShadeApp` pads the app by the safe area Admin leaves it, so pad inside
|
|
78
|
+
`ShadeApp` rather than on it: padding of its own replaces the safe area's.
|
|
79
|
+
|
|
75
80
|
`ShadeApp` supplies the `.shade` container and providers. For dark mode, add
|
|
76
81
|
`.dark` to `document.documentElement` and pass the same state to `ShadeApp` so
|
|
77
82
|
portalled menus and dialogs receive the theme too.
|
|
@@ -58,7 +58,7 @@ function ListPageHeader({ className, children, style, ...rest }) {
|
|
|
58
58
|
const { active, condensed, headerRef } = useContext(ListPageLargeTitleState);
|
|
59
59
|
return /* @__PURE__ */ jsx(Stack, {
|
|
60
60
|
ref: headerRef,
|
|
61
|
-
className: cn("-mx-4 px-4 lg:-mx-5 lg:px-5", "sticky top-
|
|
61
|
+
className: cn("-mx-4 px-4 lg:-mx-5 lg:px-5", "sticky top-[var(--ghost-safe-area-inset-top,0px)] z-50", "bg-gradient-to-b from-background via-background/70 to-background/70 backdrop-blur-md", "py-5", className, active && LARGE_TITLE_HEADER_CLASS_NAME),
|
|
62
62
|
"data-condensed": active && condensed ? "" : void 0,
|
|
63
63
|
"data-large-title-header": active ? "" : void 0,
|
|
64
64
|
"data-list-page": "header",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-page.js","names":[],"sources":["../../../src/components/page-templates/list-page.tsx"],"sourcesContent":["import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';\nimport { Stack } from '@/components/primitives/stack';\nimport { PageHeaderLargeTitleContext } from '@/components/patterns/page-header-large-title';\nimport { cn } from '@/lib/utils';\nimport {\n LARGE_TITLE_HANDOVER,\n LARGE_TITLE_HEADER_OVERLAP,\n useLargeTitleCondense,\n usePageChrome,\n useScrolledPast,\n} from './large-page-title';\n\ntype ListPageProps = React.ComponentPropsWithoutRef<'div'>;\n\n/** The list page's large title, for its header: on, and whether the header has stuck. */\nconst ListPageLargeTitleState = createContext<{\n active: boolean;\n condensed: boolean;\n headerRef?: (element: HTMLElement | null) => void;\n}>({ active: false, condensed: false });\n\n// Under a large title, the header is see-through until the title has handed\n// over, then solid (a layer the handover fades in), with its padding set by\n// LARGE_TITLE_HEADER_OVERLAP; overriding Admin's page chrome, hence important\nconst LARGE_TITLE_HEADER_CLASS_NAME =\n 'bg-none! pt-4! pb-0! backdrop-blur-none! before:pointer-events-none before:absolute before:inset-0 before:-z-10 before:bg-background';\n\n/**\n * Where a list page's title shows large (PageHeader.Title renders into it),\n * with the space above it and the markers its handover to the header is\n * measured by: one spanning the handover, one where the header sticks.\n */\nfunction ListPageLargeTitleSlot({\n hidden,\n slotRef,\n handoverMarkerRef,\n stickMarkerRef,\n}: {\n hidden: boolean;\n slotRef: (element: HTMLElement | null) => void;\n handoverMarkerRef: (element: HTMLElement | null) => void;\n stickMarkerRef: (element: HTMLElement | null) => void;\n}) {\n return (\n <div\n className=\"relative\"\n data-list-page=\"large-title\"\n hidden={hidden}\n style={{ paddingTop: 'var(--large-title-space)' }}\n >\n <div ref={slotRef} />\n <div\n ref={hidden ? undefined : handoverMarkerRef}\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-x-0\"\n data-large-title-marker=\"\"\n style={{\n bottom: `calc(${LARGE_TITLE_HEADER_OVERLAP} - ${LARGE_TITLE_HANDOVER / 2}px)`,\n height: LARGE_TITLE_HANDOVER,\n }}\n />\n <div\n ref={hidden ? undefined : stickMarkerRef}\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-x-0 h-px\"\n style={{ bottom: LARGE_TITLE_HEADER_OVERLAP }}\n />\n </div>\n );\n}\n\n/**\n * Sticky, full-bleed header stack. Place `PageHeader`, `ViewBar`, and/or\n * `FilterBar` directly inside — they stack with a consistent gap.\n *\n * Full-bleed is achieved by negating the parent's horizontal padding\n * (`-mx-4 lg:-mx-8`) and re-applying it (`px-4 lg:px-8`), so the blurred\n * background spans edge-to-edge while content stays aligned with the body.\n *\n * Pass `sticky={false} blurredBackground={false}` to `PageHeader` when using\n * it here — stickiness and blur are handled by `ListPage.Header` instead.\n */\nfunction ListPageHeader({ className, children, style, ...rest }: ListPageProps) {\n const { active, condensed, headerRef } = useContext(ListPageLargeTitleState);\n\n return (\n <Stack\n ref={headerRef}\n className={cn(\n '-mx-4 px-4 lg:-mx-5 lg:px-5',\n 'sticky top-0 z-50',\n 'bg-gradient-to-b from-background via-background/70 to-background/70 backdrop-blur-md',\n 'py-5',\n className,\n active && LARGE_TITLE_HEADER_CLASS_NAME,\n )}\n data-condensed={active && condensed ? '' : undefined}\n data-large-title-header={active ? '' : undefined}\n data-list-page=\"header\"\n gap=\"lg\"\n // Pulled up beside the large title\n style={active ? { marginTop: `calc(-1 * ${LARGE_TITLE_HEADER_OVERLAP})`, ...style } : style}\n {...rest}\n >\n {children}\n </Stack>\n );\n}\n\nfunction ListPageBody({ className, children, ...rest }: ListPageProps) {\n return (\n <Stack\n className={cn('min-h-0 min-w-0 grow pb-4 lg:pb-8', className)}\n data-list-page=\"body\"\n gap=\"none\"\n {...rest}\n >\n {children}\n </Stack>\n );\n}\n\ntype ListPageComponent = React.FC<ListPageProps> & {\n Header: React.FC<ListPageProps>;\n Body: React.FC<ListPageProps>;\n};\n\n/**\n * ListPage is the canonical recipe for the **List page** type — the recurring\n * structure used by Members, Tags, Comments, Automations, etc.\n *\n * It is intentionally thin: a vertical Stack with horizontal padding\n * that grows to fill its flex parent. Drop the named slots in as direct children.\n *\n * Composition:\n * - `<ListPage.Header>` — sticky, blurred, full-bleed chrome band. Place\n * `PageHeader`, `ViewBar`, and/or `FilterBar` directly inside as siblings.\n * `FilterBar` hides itself only when it has no children, so mount it\n * while filters are active (`hasFilters && <FilterBar>…</FilterBar>`).\n * - `<ListPage.Body>` — grows to fill remaining space. Use `flex-1 flex items-center justify-center`\n * on the immediate child to vertically center empty/loading states.\n *\n * With large titles on (PageChromeProvider), the header's PageHeader.Title\n * also shows large above the header, with generous space above it. The\n * header is pulled up beside it, see-through, and as the page scrolls the\n * large title fades out, the header turns solid and sticks, and its own small\n * title fades in. A separator sits under the header's first row, unless a\n * FilterBar follows it, which takes its place. A page without a\n * PageHeader.Title keeps the usual header.\n */\nconst ListPage: ListPageComponent = Object.assign(\n function ListPage({ className, children, style, ...rest }: ListPageProps) {\n const { largeTitles } = usePageChrome();\n const [slot, setSlot] = useState<HTMLElement | null>(null);\n const [titles, setTitles] = useState(0);\n const registerTitle = useCallback(() => {\n setTitles((count) => count + 1);\n return () => setTitles((count) => count - 1);\n }, []);\n const active = largeTitles && titles > 0;\n const { markerRef: handoverMarkerRef } = useLargeTitleCondense();\n const { scrolledPast, markerRef: stickMarkerRef } = useScrolledPast();\n\n const largeTitle = useMemo(\n () => (largeTitles ? { slot, registerTitle } : null),\n [largeTitles, slot, registerTitle],\n );\n // The header's height (it doesn't change under a large title), for the\n // body's table labels to stick beneath it (styles.css). Only large titles\n // stick them, so it's left unset otherwise\n const [host, setHost] = useState<HTMLElement | null>(null);\n const [header, setHeader] = useState<HTMLElement | null>(null);\n useEffect(() => {\n if (!largeTitles || !host || !header || typeof ResizeObserver === 'undefined') {\n return;\n }\n const update = () =>\n host.style.setProperty('--list-page-header-height', `${header.offsetHeight}px`);\n update();\n const observer = new ResizeObserver(update);\n observer.observe(header);\n return () => {\n observer.disconnect();\n host.style.removeProperty('--list-page-header-height');\n };\n }, [largeTitles, host, header]);\n\n const state = useMemo(\n () => ({ active, condensed: scrolledPast, headerRef: setHeader }),\n [active, scrolledPast],\n );\n\n return (\n <PageHeaderLargeTitleContext.Provider value={largeTitle}>\n <ListPageLargeTitleState.Provider value={state}>\n <Stack\n ref={setHost}\n className={cn('h-full min-h-0 grow px-4 lg:px-6', className)}\n data-large-title-host={largeTitles ? '' : undefined}\n data-list-page=\"list-page\"\n gap=\"none\"\n style={style}\n {...rest}\n >\n {largeTitles && (\n <ListPageLargeTitleSlot\n handoverMarkerRef={handoverMarkerRef}\n hidden={!active}\n slotRef={setSlot}\n stickMarkerRef={stickMarkerRef}\n />\n )}\n {children}\n </Stack>\n </ListPageLargeTitleState.Provider>\n </PageHeaderLargeTitleContext.Provider>\n );\n },\n {\n Header: ListPageHeader,\n Body: ListPageBody,\n },\n);\n\nexport { ListPage, ListPageHeader, ListPageBody };\n"],"mappings":";;;;;;;;AAeA,IAAM,0BAA0B,cAI7B;CAAE,QAAQ;CAAO,WAAW;AAAM,CAAC;AAKtC,IAAM,gCACJ;;;;;;AAOF,SAAS,uBAAuB,EAC9B,QACA,SACA,mBACA,kBAMC;CACD,OACE,qBAAC,OAAD;EACE,WAAU;EACV,kBAAe;EACP;EACR,OAAO,EAAE,YAAY,2BAA2B;YAJlD;GAME,oBAAC,OAAD,EAAK,KAAK,QAAU,CAAA;GACpB,oBAAC,OAAD;IACE,KAAK,SAAS,KAAA,IAAY;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WAAW,sBAAsB,sBAAsB;CAC/D,MAAM,EAAE,cAAc,WAAW,mBAAmB,gBAAgB;CAEpE,MAAM,aAAa,cACV,cAAc;EAAE;EAAM;CAAc,IAAI,MAC/C;EAAC;EAAa;EAAM;CAAa,CACnC;CAIA,MAAM,CAAC,MAAM,WAAW,SAA6B,IAAI;CACzD,MAAM,CAAC,QAAQ,aAAa,SAA6B,IAAI;CAC7D,gBAAgB;EACd,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,UAAU,OAAO,mBAAmB,aAChE;EAEF,MAAM,eACJ,KAAK,MAAM,YAAY,6BAA6B,GAAG,OAAO,aAAa,GAAG;EAChF,OAAO;EACP,MAAM,WAAW,IAAI,eAAe,MAAM;EAC1C,SAAS,QAAQ,MAAM;EACvB,aAAa;GACX,SAAS,WAAW;GACpB,KAAK,MAAM,eAAe,2BAA2B;EACvD;CACF,GAAG;EAAC;EAAa;EAAM;CAAM,CAAC;CAE9B,MAAM,QAAQ,eACL;EAAE;EAAQ,WAAW;EAAc,WAAW;CAAU,IAC/D,CAAC,QAAQ,YAAY,CACvB;CAEA,OACE,oBAAC,4BAA4B,UAA7B;EAAsC,OAAO;YAC3C,oBAAC,wBAAwB,UAAzB;GAAkC,OAAO;aACvC,qBAAC,OAAD;IACE,KAAK;IACL,WAAW,GAAG,oCAAoC,SAAS;IAC3D,yBAAuB,cAAc,KAAK,KAAA;IAC1C,kBAAe;IACf,KAAI;IACG;IACP,GAAI;cAPN,CASG,eACC,oBAAC,wBAAD;KACqB;KACnB,QAAQ,CAAC;KACT,SAAS;KACO;IACjB,CAAA,GAEF,QACI;;EACyB,CAAA;CACE,CAAA;AAE1C,GACA;CACE,QAAQ;CACR,MAAM;AACR,CACF"}
|
|
1
|
+
{"version":3,"file":"list-page.js","names":[],"sources":["../../../src/components/page-templates/list-page.tsx"],"sourcesContent":["import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';\nimport { Stack } from '@/components/primitives/stack';\nimport { PageHeaderLargeTitleContext } from '@/components/patterns/page-header-large-title';\nimport { cn } from '@/lib/utils';\nimport {\n LARGE_TITLE_HANDOVER,\n LARGE_TITLE_HEADER_OVERLAP,\n useLargeTitleCondense,\n usePageChrome,\n useScrolledPast,\n} from './large-page-title';\n\ntype ListPageProps = React.ComponentPropsWithoutRef<'div'>;\n\n/** The list page's large title, for its header: on, and whether the header has stuck. */\nconst ListPageLargeTitleState = createContext<{\n active: boolean;\n condensed: boolean;\n headerRef?: (element: HTMLElement | null) => void;\n}>({ active: false, condensed: false });\n\n// Under a large title, the header is see-through until the title has handed\n// over, then solid (a layer the handover fades in), with its padding set by\n// LARGE_TITLE_HEADER_OVERLAP; overriding Admin's page chrome, hence important\nconst LARGE_TITLE_HEADER_CLASS_NAME =\n 'bg-none! pt-4! pb-0! backdrop-blur-none! before:pointer-events-none before:absolute before:inset-0 before:-z-10 before:bg-background';\n\n/**\n * Where a list page's title shows large (PageHeader.Title renders into it),\n * with the space above it and the markers its handover to the header is\n * measured by: one spanning the handover, one where the header sticks.\n */\nfunction ListPageLargeTitleSlot({\n hidden,\n slotRef,\n handoverMarkerRef,\n stickMarkerRef,\n}: {\n hidden: boolean;\n slotRef: (element: HTMLElement | null) => void;\n handoverMarkerRef: (element: HTMLElement | null) => void;\n stickMarkerRef: (element: HTMLElement | null) => void;\n}) {\n return (\n <div\n className=\"relative\"\n data-list-page=\"large-title\"\n hidden={hidden}\n style={{ paddingTop: 'var(--large-title-space)' }}\n >\n <div ref={slotRef} />\n <div\n ref={hidden ? undefined : handoverMarkerRef}\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-x-0\"\n data-large-title-marker=\"\"\n style={{\n bottom: `calc(${LARGE_TITLE_HEADER_OVERLAP} - ${LARGE_TITLE_HANDOVER / 2}px)`,\n height: LARGE_TITLE_HANDOVER,\n }}\n />\n <div\n ref={hidden ? undefined : stickMarkerRef}\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-x-0 h-px\"\n style={{ bottom: LARGE_TITLE_HEADER_OVERLAP }}\n />\n </div>\n );\n}\n\n/**\n * Sticky, full-bleed header stack. Place `PageHeader`, `ViewBar`, and/or\n * `FilterBar` directly inside — they stack with a consistent gap.\n *\n * Full-bleed is achieved by negating the parent's horizontal padding\n * (`-mx-4 lg:-mx-8`) and re-applying it (`px-4 lg:px-8`), so the blurred\n * background spans edge-to-edge while content stays aligned with the body.\n *\n * Pass `sticky={false} blurredBackground={false}` to `PageHeader` when using\n * it here — stickiness and blur are handled by `ListPage.Header` instead.\n */\nfunction ListPageHeader({ className, children, style, ...rest }: ListPageProps) {\n const { active, condensed, headerRef } = useContext(ListPageLargeTitleState);\n\n return (\n <Stack\n ref={headerRef}\n className={cn(\n '-mx-4 px-4 lg:-mx-5 lg:px-5',\n 'sticky top-[var(--ghost-safe-area-inset-top,0px)] z-50',\n 'bg-gradient-to-b from-background via-background/70 to-background/70 backdrop-blur-md',\n 'py-5',\n className,\n active && LARGE_TITLE_HEADER_CLASS_NAME,\n )}\n data-condensed={active && condensed ? '' : undefined}\n data-large-title-header={active ? '' : undefined}\n data-list-page=\"header\"\n gap=\"lg\"\n // Pulled up beside the large title\n style={active ? { marginTop: `calc(-1 * ${LARGE_TITLE_HEADER_OVERLAP})`, ...style } : style}\n {...rest}\n >\n {children}\n </Stack>\n );\n}\n\nfunction ListPageBody({ className, children, ...rest }: ListPageProps) {\n return (\n <Stack\n className={cn('min-h-0 min-w-0 grow pb-4 lg:pb-8', className)}\n data-list-page=\"body\"\n gap=\"none\"\n {...rest}\n >\n {children}\n </Stack>\n );\n}\n\ntype ListPageComponent = React.FC<ListPageProps> & {\n Header: React.FC<ListPageProps>;\n Body: React.FC<ListPageProps>;\n};\n\n/**\n * ListPage is the canonical recipe for the **List page** type — the recurring\n * structure used by Members, Tags, Comments, Automations, etc.\n *\n * It is intentionally thin: a vertical Stack with horizontal padding\n * that grows to fill its flex parent. Drop the named slots in as direct children.\n *\n * Composition:\n * - `<ListPage.Header>` — sticky, blurred, full-bleed chrome band. Place\n * `PageHeader`, `ViewBar`, and/or `FilterBar` directly inside as siblings.\n * `FilterBar` hides itself only when it has no children, so mount it\n * while filters are active (`hasFilters && <FilterBar>…</FilterBar>`).\n * - `<ListPage.Body>` — grows to fill remaining space. Use `flex-1 flex items-center justify-center`\n * on the immediate child to vertically center empty/loading states.\n *\n * With large titles on (PageChromeProvider), the header's PageHeader.Title\n * also shows large above the header, with generous space above it. The\n * header is pulled up beside it, see-through, and as the page scrolls the\n * large title fades out, the header turns solid and sticks, and its own small\n * title fades in. A separator sits under the header's first row, unless a\n * FilterBar follows it, which takes its place. A page without a\n * PageHeader.Title keeps the usual header.\n */\nconst ListPage: ListPageComponent = Object.assign(\n function ListPage({ className, children, style, ...rest }: ListPageProps) {\n const { largeTitles } = usePageChrome();\n const [slot, setSlot] = useState<HTMLElement | null>(null);\n const [titles, setTitles] = useState(0);\n const registerTitle = useCallback(() => {\n setTitles((count) => count + 1);\n return () => setTitles((count) => count - 1);\n }, []);\n const active = largeTitles && titles > 0;\n const { markerRef: handoverMarkerRef } = useLargeTitleCondense();\n const { scrolledPast, markerRef: stickMarkerRef } = useScrolledPast();\n\n const largeTitle = useMemo(\n () => (largeTitles ? { slot, registerTitle } : null),\n [largeTitles, slot, registerTitle],\n );\n // The header's height (it doesn't change under a large title), for the\n // body's table labels to stick beneath it (styles.css). Only large titles\n // stick them, so it's left unset otherwise\n const [host, setHost] = useState<HTMLElement | null>(null);\n const [header, setHeader] = useState<HTMLElement | null>(null);\n useEffect(() => {\n if (!largeTitles || !host || !header || typeof ResizeObserver === 'undefined') {\n return;\n }\n const update = () =>\n host.style.setProperty('--list-page-header-height', `${header.offsetHeight}px`);\n update();\n const observer = new ResizeObserver(update);\n observer.observe(header);\n return () => {\n observer.disconnect();\n host.style.removeProperty('--list-page-header-height');\n };\n }, [largeTitles, host, header]);\n\n const state = useMemo(\n () => ({ active, condensed: scrolledPast, headerRef: setHeader }),\n [active, scrolledPast],\n );\n\n return (\n <PageHeaderLargeTitleContext.Provider value={largeTitle}>\n <ListPageLargeTitleState.Provider value={state}>\n <Stack\n ref={setHost}\n className={cn('h-full min-h-0 grow px-4 lg:px-6', className)}\n data-large-title-host={largeTitles ? '' : undefined}\n data-list-page=\"list-page\"\n gap=\"none\"\n style={style}\n {...rest}\n >\n {largeTitles && (\n <ListPageLargeTitleSlot\n handoverMarkerRef={handoverMarkerRef}\n hidden={!active}\n slotRef={setSlot}\n stickMarkerRef={stickMarkerRef}\n />\n )}\n {children}\n </Stack>\n </ListPageLargeTitleState.Provider>\n </PageHeaderLargeTitleContext.Provider>\n );\n },\n {\n Header: ListPageHeader,\n Body: ListPageBody,\n },\n);\n\nexport { ListPage, ListPageHeader, ListPageBody };\n"],"mappings":";;;;;;;;AAeA,IAAM,0BAA0B,cAI7B;CAAE,QAAQ;CAAO,WAAW;AAAM,CAAC;AAKtC,IAAM,gCACJ;;;;;;AAOF,SAAS,uBAAuB,EAC9B,QACA,SACA,mBACA,kBAMC;CACD,OACE,qBAAC,OAAD;EACE,WAAU;EACV,kBAAe;EACP;EACR,OAAO,EAAE,YAAY,2BAA2B;YAJlD;GAME,oBAAC,OAAD,EAAK,KAAK,QAAU,CAAA;GACpB,oBAAC,OAAD;IACE,KAAK,SAAS,KAAA,IAAY;IAC1B,eAAY;IACZ,WAAU;IACV,2BAAwB;IACxB,OAAO;KACL,QAAQ,QAAQ,2BAA2B,KAAA,KAA4B,EAAE;KACzE,QAAA;IACF;GACD,CAAA;GACD,oBAAC,OAAD;IACE,KAAK,SAAS,KAAA,IAAY;IAC1B,eAAY;IACZ,WAAU;IACV,OAAO,EAAE,QAAQ,2BAA2B;GAC7C,CAAA;EACE;;AAET;;;;;;;;;;;;AAaA,SAAS,eAAe,EAAE,WAAW,UAAU,OAAO,GAAG,QAAuB;CAC9E,MAAM,EAAE,QAAQ,WAAW,cAAc,WAAW,uBAAuB;CAE3E,OACE,oBAAC,OAAD;EACE,KAAK;EACL,WAAW,GACT,+BACA,0DACA,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AAe,MAAM;EAC1C,SAAS,QAAQ,MAAM;EACvB,aAAa;GACX,SAAS,WAAW;GACpB,KAAK,MAAM,eAAe,2BAA2B;EACvD;CACF,GAAG;EAAC;EAAa;EAAM;CAAM,CAAC;CAE9B,MAAM,QAAQ,eACL;EAAE;EAAQ,WAAW;EAAc,WAAW;CAAU,IAC/D,CAAC,QAAQ,YAAY,CACvB;CAEA,OACE,oBAAC,4BAA4B,UAA7B;EAAsC,OAAO;YAC3C,oBAAC,wBAAwB,UAAzB;GAAkC,OAAO;aACvC,qBAAC,OAAD;IACE,KAAK;IACL,WAAW,GAAG,oCAAoC,SAAS;IAC3D,yBAAuB,cAAc,KAAK,KAAA;IAC1C,kBAAe;IACf,KAAI;IACG;IACP,GAAI;cAPN,CASG,eACC,oBAAC,wBAAD;KACqB;KACnB,QAAQ,CAAC;KACT,SAAS;KACO;IACjB,CAAA,GAEF,QACI;;EACyB,CAAA;CACE,CAAA;AAE1C,GACA;CACE,QAAQ;CACR,MAAM;AACR,CACF"}
|
|
@@ -3,7 +3,7 @@ import { Button } from "../ui/button.js";
|
|
|
3
3
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/select.js";
|
|
4
4
|
import { Input } from "../ui/input.js";
|
|
5
5
|
import { PipetteIcon } from "lucide-react";
|
|
6
|
-
import { createContext, forwardRef, memo, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
6
|
+
import { createContext, forwardRef, memo, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import Color from "color";
|
|
9
9
|
import * as Slider from "@radix-ui/react-slider";
|
|
@@ -57,6 +57,17 @@ var ColorPickerTrigger = forwardRef(({ value, className, ...props }, ref) => /*
|
|
|
57
57
|
})]
|
|
58
58
|
}));
|
|
59
59
|
ColorPickerTrigger.displayName = "ColorPickerTrigger";
|
|
60
|
+
var toHsla = (input) => {
|
|
61
|
+
const color = Color(input);
|
|
62
|
+
return {
|
|
63
|
+
hue: color.hue(),
|
|
64
|
+
saturation: color.saturationl(),
|
|
65
|
+
lightness: color.lightness(),
|
|
66
|
+
alpha: color.alpha() * 100
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
var toHex = ({ hue, saturation, lightness, alpha }) => Color.hsl(hue, saturation, lightness).alpha(alpha / 100).hex();
|
|
70
|
+
var isSameHsla = (a, b) => a.hue === b.hue && a.saturation === b.saturation && a.lightness === b.lightness && a.alpha === b.alpha;
|
|
60
71
|
var ColorPickerContext = createContext(void 0);
|
|
61
72
|
var useColorPicker = () => {
|
|
62
73
|
const context = useContext(ColorPickerContext);
|
|
@@ -64,41 +75,36 @@ var useColorPicker = () => {
|
|
|
64
75
|
return context;
|
|
65
76
|
};
|
|
66
77
|
var ColorPickerRoot = ({ value, defaultValue = "rgb(0 0 0)", onChange, className, ...props }) => {
|
|
67
|
-
const
|
|
68
|
-
const [hue, setHue] = useState(initialColor.hue());
|
|
69
|
-
const [saturation, setSaturation] = useState(initialColor.saturationl());
|
|
70
|
-
const [lightness, setLightness] = useState(initialColor.lightness());
|
|
71
|
-
const [alpha, setAlpha] = useState(initialColor.alpha() * 100);
|
|
78
|
+
const [color, setColorState] = useState(() => toHsla(value ?? defaultValue));
|
|
72
79
|
const [mode, setMode] = useState("hex");
|
|
80
|
+
const colorRef = useRef(color);
|
|
81
|
+
const onChangeRef = useRef(onChange);
|
|
82
|
+
useLayoutEffect(() => {
|
|
83
|
+
onChangeRef.current = onChange;
|
|
84
|
+
});
|
|
73
85
|
useEffect(() => {
|
|
74
86
|
if (value) {
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
setLightness(color.lightness());
|
|
79
|
-
setAlpha(color.alpha() * 100);
|
|
87
|
+
const next = toHsla(value);
|
|
88
|
+
colorRef.current = next;
|
|
89
|
+
setColorState(next);
|
|
80
90
|
}
|
|
81
91
|
}, [value]);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
const setColor = useCallback((change) => {
|
|
93
|
+
const previous = colorRef.current;
|
|
94
|
+
const next = {
|
|
95
|
+
...previous,
|
|
96
|
+
...change
|
|
97
|
+
};
|
|
98
|
+
if (isSameHsla(next, previous)) return;
|
|
99
|
+
colorRef.current = next;
|
|
100
|
+
setColorState(next);
|
|
101
|
+
onChangeRef.current?.(toHex(next));
|
|
102
|
+
}, []);
|
|
91
103
|
return /* @__PURE__ */ jsx(ColorPickerContext.Provider, {
|
|
92
104
|
value: {
|
|
93
|
-
|
|
94
|
-
saturation,
|
|
95
|
-
lightness,
|
|
96
|
-
alpha,
|
|
105
|
+
...color,
|
|
97
106
|
mode,
|
|
98
|
-
|
|
99
|
-
setSaturation,
|
|
100
|
-
setLightness,
|
|
101
|
-
setAlpha,
|
|
107
|
+
setColor,
|
|
102
108
|
setMode
|
|
103
109
|
},
|
|
104
110
|
children: /* @__PURE__ */ jsx("div", {
|
|
@@ -112,7 +118,7 @@ var ColorPickerSelection = memo(({ className, ...props }) => {
|
|
|
112
118
|
const activePointerId = useRef(null);
|
|
113
119
|
const [positionX, setPositionX] = useState(0);
|
|
114
120
|
const [positionY, setPositionY] = useState(0);
|
|
115
|
-
const { hue, saturation, lightness,
|
|
121
|
+
const { hue, saturation, lightness, setColor } = useColorPicker();
|
|
116
122
|
const backgroundGradient = useMemo(() => {
|
|
117
123
|
return `linear-gradient(0deg, rgba(0,0,0,1), rgba(0,0,0,0)),
|
|
118
124
|
linear-gradient(90deg, rgba(255,255,255,1), rgba(255,255,255,0)),
|
|
@@ -132,10 +138,12 @@ var ColorPickerSelection = memo(({ className, ...props }) => {
|
|
|
132
138
|
const y = Math.max(0, Math.min(1, (event.clientY - rect.top) / rect.height));
|
|
133
139
|
setPositionX(x);
|
|
134
140
|
setPositionY(y);
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
141
|
+
const topLightness = x < .01 ? 100 : 50 + 50 * (1 - x);
|
|
142
|
+
setColor({
|
|
143
|
+
saturation: x * 100,
|
|
144
|
+
lightness: topLightness * (1 - y)
|
|
145
|
+
});
|
|
146
|
+
}, [setColor]);
|
|
139
147
|
return /* @__PURE__ */ jsx("div", {
|
|
140
148
|
ref: containerRef,
|
|
141
149
|
className: cn("relative size-full cursor-crosshair rounded", className),
|
|
@@ -171,13 +179,13 @@ var ColorPickerSelection = memo(({ className, ...props }) => {
|
|
|
171
179
|
});
|
|
172
180
|
ColorPickerSelection.displayName = "ColorPickerSelection";
|
|
173
181
|
var ColorPickerHue = ({ className, ...props }) => {
|
|
174
|
-
const { hue,
|
|
182
|
+
const { hue, setColor } = useColorPicker();
|
|
175
183
|
return /* @__PURE__ */ jsxs(Slider.Root, {
|
|
176
184
|
className: cn("relative flex h-4 w-full touch-none", className),
|
|
177
185
|
max: 360,
|
|
178
186
|
step: 1,
|
|
179
187
|
value: [hue],
|
|
180
|
-
onValueChange: ([value]) =>
|
|
188
|
+
onValueChange: ([value]) => setColor({ hue: value }),
|
|
181
189
|
...props,
|
|
182
190
|
children: [/* @__PURE__ */ jsx(Slider.Track, {
|
|
183
191
|
className: "relative my-0.5 h-3 w-full grow rounded-full bg-[linear-gradient(90deg,red,yellow,lime,aqua,blue,magenta,red)]",
|
|
@@ -186,13 +194,13 @@ var ColorPickerHue = ({ className, ...props }) => {
|
|
|
186
194
|
});
|
|
187
195
|
};
|
|
188
196
|
var ColorPickerAlpha = ({ className, ...props }) => {
|
|
189
|
-
const { alpha,
|
|
197
|
+
const { alpha, setColor } = useColorPicker();
|
|
190
198
|
return /* @__PURE__ */ jsxs(Slider.Root, {
|
|
191
199
|
className: cn("relative flex h-4 w-full touch-none", className),
|
|
192
200
|
max: 100,
|
|
193
201
|
step: 1,
|
|
194
202
|
value: [alpha],
|
|
195
|
-
onValueChange: ([value]) =>
|
|
203
|
+
onValueChange: ([value]) => setColor({ alpha: value }),
|
|
196
204
|
...props,
|
|
197
205
|
children: [/* @__PURE__ */ jsxs(Slider.Track, {
|
|
198
206
|
className: "relative my-0.5 h-3 w-full grow rounded-full bg-[url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==')] bg-center bg-repeat-x dark:bg-[url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAALklEQVR4nGP8+vWrCAMewM3N/QafPBM+SWLAqAGDwQBGQgoIpZOB98KoAVQwAADxzQcSVIRCfQAAAABJRU5ErkJggg==')]",
|
|
@@ -201,17 +209,31 @@ var ColorPickerAlpha = ({ className, ...props }) => {
|
|
|
201
209
|
});
|
|
202
210
|
};
|
|
203
211
|
var ColorPickerEyeDropper = ({ className, ...props }) => {
|
|
204
|
-
const {
|
|
212
|
+
const { setColor } = useColorPicker();
|
|
213
|
+
const isMounted = useRef(false);
|
|
214
|
+
useLayoutEffect(() => {
|
|
215
|
+
isMounted.current = true;
|
|
216
|
+
return () => {
|
|
217
|
+
isMounted.current = false;
|
|
218
|
+
};
|
|
219
|
+
}, []);
|
|
205
220
|
if (!(typeof window !== "undefined" && "EyeDropper" in window)) return null;
|
|
206
221
|
const handleEyeDropper = async () => {
|
|
222
|
+
let picked;
|
|
207
223
|
try {
|
|
208
|
-
|
|
209
|
-
setHue(h);
|
|
210
|
-
setSaturation(s);
|
|
211
|
-
setLightness(l);
|
|
212
|
-
setAlpha(100);
|
|
224
|
+
picked = Color((await new EyeDropper().open()).sRGBHex).hsl().array();
|
|
213
225
|
} catch (error) {
|
|
214
226
|
console.error("EyeDropper failed:", error);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if (isMounted.current) {
|
|
230
|
+
const [hue, saturation, lightness] = picked;
|
|
231
|
+
setColor({
|
|
232
|
+
hue,
|
|
233
|
+
saturation,
|
|
234
|
+
lightness,
|
|
235
|
+
alpha: 100
|
|
236
|
+
});
|
|
215
237
|
}
|
|
216
238
|
};
|
|
217
239
|
return /* @__PURE__ */ jsx(Button, {
|
|
@@ -246,26 +268,27 @@ var ColorPickerOutput = ({ ...props }) => {
|
|
|
246
268
|
});
|
|
247
269
|
};
|
|
248
270
|
var ColorPickerFormat = ({ className, ...props }) => {
|
|
249
|
-
const { hue, saturation, lightness, mode,
|
|
271
|
+
const { hue, saturation, lightness, mode, setColor } = useColorPicker();
|
|
250
272
|
const color = Color.hsl(hue, saturation, lightness);
|
|
251
273
|
const [inputValue, setInputValue] = useState(null);
|
|
252
274
|
const handleInputChange = (value, index) => {
|
|
275
|
+
let change;
|
|
253
276
|
try {
|
|
254
|
-
if (mode === "hex")
|
|
255
|
-
|
|
256
|
-
setHue(newColor.hue());
|
|
257
|
-
setSaturation(newColor.saturationl());
|
|
258
|
-
setLightness(newColor.lightness());
|
|
259
|
-
setAlpha(newColor.alpha() * 100);
|
|
260
|
-
} else if ((mode === "rgb" || mode === "hsl") && index !== void 0) {
|
|
277
|
+
if (mode === "hex") change = toHsla(value);
|
|
278
|
+
else if ((mode === "rgb" || mode === "hsl") && index !== void 0) {
|
|
261
279
|
const values = color[mode]().array().map((v) => Math.round(v));
|
|
262
280
|
values[index] = parseInt(value, 10) || 0;
|
|
263
281
|
const newColor = Color[mode](values[0], values[1], values[2]);
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
282
|
+
change = {
|
|
283
|
+
hue: newColor.hue(),
|
|
284
|
+
saturation: newColor.saturationl(),
|
|
285
|
+
lightness: newColor.lightness()
|
|
286
|
+
};
|
|
287
|
+
} else return;
|
|
288
|
+
} catch {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
setColor(change);
|
|
269
292
|
};
|
|
270
293
|
if (mode === "hex") {
|
|
271
294
|
const hex = color.hex();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color-picker.js","names":[],"sources":["../../../src/components/patterns/color-picker.tsx"],"sourcesContent":["/* eslint-disable react/no-array-index-key */\nimport Color from 'color';\nimport { PipetteIcon } from 'lucide-react';\nimport * as Slider from '@radix-ui/react-slider';\nimport {\n type ButtonHTMLAttributes,\n type ComponentProps,\n createContext,\n type HTMLAttributes,\n forwardRef,\n memo,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { Button } from '@/components/ui/button';\nimport { Input } from '@/components/ui/input';\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@/components/ui/select';\nimport { cn } from '@/lib/utils';\n\nexport interface ColorSwatchOption {\n title: string;\n hex: string;\n value?: string | null;\n}\n\nexport interface ColorSwatchProps extends Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n 'value' | 'onSelect'\n> {\n color: string;\n selected?: boolean;\n size?: 'md' | 'lg';\n}\n\nconst isTransparent = (color: string) => {\n const normalized = color.toLowerCase();\n return (\n normalized === 'transparent' ||\n (normalized.length === 5 && normalized[4] === '0') ||\n (normalized.length === 9 && normalized.slice(7) === '00')\n );\n};\n\nexport const ColorSwatch = ({\n color,\n selected,\n size = 'md',\n className,\n style,\n ...props\n}: ColorSwatchProps) => (\n <button\n aria-pressed={selected}\n className={cn(\n 'relative flex shrink-0 cursor-pointer items-center overflow-hidden rounded-full border border-control-border',\n size === 'lg' ? 'size-6' : 'size-5',\n selected && 'ring-2 ring-focus-ring',\n className,\n )}\n style={{ backgroundColor: color, ...style }}\n type=\"button\"\n {...props}\n >\n {isTransparent(color) && (\n <span\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute top-1/2 left-[-30%] block h-px w-[160%] -translate-y-1/2 -rotate-45 bg-destructive\"\n data-testid=\"transparent-indicator\"\n />\n )}\n </button>\n);\n\nexport interface ColorSwatchRowProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> {\n swatches: ColorSwatchOption[];\n value?: string | null;\n size?: 'md' | 'lg';\n onSelect: (value: string | null) => void;\n}\n\nexport const ColorSwatchRow = ({\n swatches,\n value,\n size = 'md',\n onSelect,\n className,\n ...props\n}: ColorSwatchRowProps) => (\n <div className={cn('flex items-center gap-1', className)} {...props}>\n {swatches.map((swatch) => {\n const swatchValue = swatch.value === undefined ? swatch.hex : swatch.value;\n return (\n <ColorSwatch\n key={swatch.title}\n aria-label={swatch.title}\n color={swatch.hex}\n selected={swatchValue === value || swatch.hex.toLowerCase() === value?.toLowerCase()}\n size={size}\n title={swatch.title}\n onClick={() => onSelect(swatchValue)}\n />\n );\n })}\n </div>\n);\n\nexport interface ColorPickerTriggerProps extends Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n 'value'\n> {\n value?: string | null;\n}\n\nexport const ColorPickerTrigger = forwardRef<HTMLButtonElement, ColorPickerTriggerProps>(\n ({ value, className, ...props }, ref) => (\n <button\n ref={ref}\n aria-label=\"Pick color\"\n className={cn(\n 'relative size-6 cursor-pointer rounded-full border border-control-border',\n className,\n )}\n type=\"button\"\n {...props}\n >\n <span\n aria-hidden=\"true\"\n className=\"absolute inset-0 rounded-full bg-[conic-gradient(hsl(360,100%,50%),hsl(315,100%,50%),hsl(270,100%,50%),hsl(225,100%,50%),hsl(180,100%,50%),hsl(135,100%,50%),hsl(90,100%,50%),hsl(45,100%,50%),hsl(0,100%,50%))]\"\n />\n {value && (\n <span\n className=\"absolute inset-[3px] overflow-hidden rounded-full border border-background\"\n style={{ backgroundColor: value }}\n />\n )}\n </button>\n ),\n);\n\nColorPickerTrigger.displayName = 'ColorPickerTrigger';\n\ninterface ColorPickerContextValue {\n hue: number;\n saturation: number;\n lightness: number;\n alpha: number;\n mode: string;\n setHue: (hue: number) => void;\n setSaturation: (saturation: number) => void;\n setLightness: (lightness: number) => void;\n setAlpha: (alpha: number) => void;\n setMode: (mode: string) => void;\n}\n\nconst ColorPickerContext = createContext<ColorPickerContextValue | undefined>(undefined);\n\nconst useColorPicker = () => {\n const context = useContext(ColorPickerContext);\n\n if (!context) {\n throw new Error('useColorPicker must be used within a ColorPickerProvider');\n }\n\n return context;\n};\n\nexport type ColorPickerProps = Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> & {\n value?: Parameters<typeof Color>[0];\n defaultValue?: Parameters<typeof Color>[0];\n onChange?: (value: string) => void;\n};\n\nexport const ColorPickerRoot = ({\n value,\n defaultValue = 'rgb(0 0 0)',\n onChange,\n className,\n ...props\n}: ColorPickerProps) => {\n const initialColor = Color(value ?? defaultValue);\n\n const [hue, setHue] = useState(initialColor.hue());\n const [saturation, setSaturation] = useState(initialColor.saturationl());\n const [lightness, setLightness] = useState(initialColor.lightness());\n const [alpha, setAlpha] = useState(initialColor.alpha() * 100);\n const [mode, setMode] = useState('hex');\n\n // Update color when controlled value changes\n useEffect(() => {\n if (value) {\n const color = Color(value);\n setHue(color.hue());\n setSaturation(color.saturationl());\n setLightness(color.lightness());\n setAlpha(color.alpha() * 100);\n }\n }, [value]);\n\n // Notify parent of changes\n useEffect(() => {\n if (onChange) {\n const color = Color.hsl(hue, saturation, lightness).alpha(alpha / 100);\n const hex = color.hex();\n onChange(hex);\n }\n }, [hue, saturation, lightness, alpha, onChange]);\n\n return (\n <ColorPickerContext.Provider\n value={{\n hue,\n saturation,\n lightness,\n alpha,\n mode,\n setHue,\n setSaturation,\n setLightness,\n setAlpha,\n setMode,\n }}\n >\n <div className={cn('flex size-full flex-col gap-4', className)} {...props} />\n </ColorPickerContext.Provider>\n );\n};\n\nexport type ColorPickerSelectionProps = HTMLAttributes<HTMLDivElement>;\n\nexport const ColorPickerSelection = memo(({ className, ...props }: ColorPickerSelectionProps) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const activePointerId = useRef<number | null>(null);\n const [positionX, setPositionX] = useState(0);\n const [positionY, setPositionY] = useState(0);\n const { hue, saturation, lightness, setSaturation, setLightness } = useColorPicker();\n\n const backgroundGradient = useMemo(() => {\n return `linear-gradient(0deg, rgba(0,0,0,1), rgba(0,0,0,0)),\n linear-gradient(90deg, rgba(255,255,255,1), rgba(255,255,255,0)),\n hsl(${hue}, 100%, 50%)`;\n }, [hue]);\n\n // Update position based on current saturation and lightness values\n useEffect(() => {\n const x = saturation / 100;\n const topLightness = x < 0.01 ? 100 : 50 + 50 * (1 - x);\n const y = Math.max(0, Math.min(1, 1 - lightness / topLightness));\n\n setPositionX(x);\n setPositionY(y);\n }, [saturation, lightness]);\n\n const updateColorFromPointer = useCallback(\n (event: PointerEvent) => {\n if (!containerRef.current) {\n return;\n }\n const rect = containerRef.current.getBoundingClientRect();\n const x = Math.max(0, Math.min(1, (event.clientX - rect.left) / rect.width));\n const y = Math.max(0, Math.min(1, (event.clientY - rect.top) / rect.height));\n setPositionX(x);\n setPositionY(y);\n setSaturation(x * 100);\n const topLightness = x < 0.01 ? 100 : 50 + 50 * (1 - x);\n const newLightness = topLightness * (1 - y);\n\n setLightness(newLightness);\n },\n [setSaturation, setLightness],\n );\n\n return (\n <div\n ref={containerRef}\n className={cn('relative size-full cursor-crosshair rounded', className)}\n style={{\n background: backgroundGradient,\n }}\n onPointerCancel={(e) => {\n if (activePointerId.current === e.pointerId) {\n activePointerId.current = null;\n }\n }}\n onPointerDown={(e) => {\n e.preventDefault();\n activePointerId.current = e.pointerId;\n e.currentTarget.setPointerCapture?.(e.pointerId);\n updateColorFromPointer(e.nativeEvent);\n }}\n onPointerMove={(e) => {\n if (activePointerId.current === e.pointerId) {\n updateColorFromPointer(e.nativeEvent);\n }\n }}\n onPointerUp={(e) => {\n if (activePointerId.current === e.pointerId) {\n activePointerId.current = null;\n e.currentTarget.releasePointerCapture?.(e.pointerId);\n }\n }}\n {...props}\n >\n <div\n className=\"pointer-events-none absolute size-4 -translate-1/2 rounded-full border-2 border-white\"\n style={{\n left: `${positionX * 100}%`,\n top: `${positionY * 100}%`,\n boxShadow: '0 0 0 1px rgba(0,0,0,0.5)',\n }}\n />\n </div>\n );\n});\n\nColorPickerSelection.displayName = 'ColorPickerSelection';\n\nexport type ColorPickerHueProps = ComponentProps<typeof Slider.Root>;\n\nexport const ColorPickerHue = ({ className, ...props }: ColorPickerHueProps) => {\n const { hue, setHue } = useColorPicker();\n\n return (\n <Slider.Root\n className={cn('relative flex h-4 w-full touch-none', className)}\n max={360}\n step={1}\n value={[hue]}\n onValueChange={([value]) => setHue(value)}\n {...props}\n >\n <Slider.Track className=\"relative my-0.5 h-3 w-full grow rounded-full bg-[linear-gradient(90deg,red,yellow,lime,aqua,blue,magenta,red)]\">\n <Slider.Range className=\"absolute h-full\" />\n </Slider.Track>\n <Slider.Thumb className=\"block size-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:ring-1 focus-visible:ring-focus-ring focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50\" />\n </Slider.Root>\n );\n};\n\nexport type ColorPickerAlphaProps = ComponentProps<typeof Slider.Root>;\n\nexport const ColorPickerAlpha = ({ className, ...props }: ColorPickerAlphaProps) => {\n const { alpha, setAlpha } = useColorPicker();\n\n return (\n <Slider.Root\n className={cn('relative flex h-4 w-full touch-none', className)}\n max={100}\n step={1}\n value={[alpha]}\n onValueChange={([value]) => setAlpha(value)}\n {...props}\n >\n <Slider.Track className=\"relative my-0.5 h-3 w-full grow rounded-full bg-[url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==')] bg-center bg-repeat-x dark:bg-[url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAALklEQVR4nGP8+vWrCAMewM3N/QafPBM+SWLAqAGDwQBGQgoIpZOB98KoAVQwAADxzQcSVIRCfQAAAABJRU5ErkJggg==')]\">\n <div className=\"absolute inset-0 rounded-full bg-gradient-to-r from-transparent to-black/50 dark:to-white/50\" />\n <Slider.Range className=\"absolute h-full rounded-full bg-transparent\" />\n </Slider.Track>\n <Slider.Thumb className=\"block size-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:ring-1 focus-visible:ring-focus-ring focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50\" />\n </Slider.Root>\n );\n};\n\nexport type ColorPickerEyeDropperProps = ComponentProps<typeof Button>;\n\nexport const ColorPickerEyeDropper = ({ className, ...props }: ColorPickerEyeDropperProps) => {\n const { setHue, setSaturation, setLightness, setAlpha } = useColorPicker();\n\n // Check if EyeDropper API is supported\n const isSupported = typeof window !== 'undefined' && 'EyeDropper' in window;\n if (!isSupported) {\n return null;\n }\n\n const handleEyeDropper = async () => {\n try {\n // @ts-expect-error - EyeDropper API is experimental\n const eyeDropper = new EyeDropper();\n const result = await eyeDropper.open();\n const color = Color(result.sRGBHex);\n const [h, s, l] = color.hsl().array();\n\n setHue(h);\n setSaturation(s);\n setLightness(l);\n setAlpha(100);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('EyeDropper failed:', error);\n }\n };\n\n return (\n <Button\n className={cn('size-8 shrink-0 text-muted-foreground', className)}\n size=\"icon\"\n type=\"button\"\n variant=\"outline\"\n onClick={handleEyeDropper}\n {...props}\n >\n <PipetteIcon size={16} />\n </Button>\n );\n};\n\nexport type ColorPickerOutputProps = ComponentProps<typeof SelectTrigger>;\n\nconst formats = ['hex', 'rgb', 'hsl'];\n\nexport const ColorPickerOutput = ({ ...props }: ColorPickerOutputProps) => {\n const { mode, setMode } = useColorPicker();\n\n return (\n <Select value={mode} onValueChange={setMode}>\n <SelectTrigger className=\"h-8 w-20 shrink-0 text-xs\" {...props}>\n <SelectValue placeholder=\"Mode\" />\n </SelectTrigger>\n <SelectContent>\n {formats.map((format) => (\n <SelectItem key={format} className=\"text-xs\" value={format}>\n {format.toUpperCase()}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n );\n};\n\nexport type ColorPickerFormatProps = HTMLAttributes<HTMLDivElement>;\n\nexport const ColorPickerFormat = ({ className, ...props }: ColorPickerFormatProps) => {\n const { hue, saturation, lightness, mode, setHue, setSaturation, setLightness, setAlpha } =\n useColorPicker();\n const color = Color.hsl(hue, saturation, lightness);\n const [inputValue, setInputValue] = useState<string | null>(null);\n\n const handleInputChange = (value: string, index?: number) => {\n try {\n if (mode === 'hex') {\n const newColor = Color(value);\n setHue(newColor.hue());\n setSaturation(newColor.saturationl());\n setLightness(newColor.lightness());\n setAlpha(newColor.alpha() * 100);\n } else if ((mode === 'rgb' || mode === 'hsl') && index !== undefined) {\n const values = color[mode]()\n .array()\n .map((v) => Math.round(v));\n values[index] = parseInt(value, 10) || 0;\n const newColor = Color[mode](values[0], values[1], values[2]);\n setHue(newColor.hue());\n setSaturation(newColor.saturationl());\n setLightness(newColor.lightness());\n }\n } catch {\n // Invalid color, ignore\n }\n };\n\n if (mode === 'hex') {\n const hex = color.hex();\n\n return (\n <div\n className={cn('relative flex w-full items-center -space-x-px rounded-md', className)}\n {...props}\n >\n <Input\n aria-label=\"Hex color\"\n className=\"h-8 px-2 font-mono text-xs shadow-none\"\n type=\"text\"\n value={inputValue ?? hex}\n onBlur={() => {\n setInputValue(null);\n }}\n onChange={(e) => {\n setInputValue(e.target.value);\n handleInputChange(e.target.value);\n }}\n />\n </div>\n );\n }\n\n if (mode === 'rgb' || mode === 'hsl') {\n const values = color[mode]()\n .array()\n .map((value) => Math.round(value));\n\n return (\n <div className={cn('flex flex-1 items-stretch -space-x-px rounded-md', className)} {...props}>\n {values.map((value, index) => (\n <Input\n key={index}\n aria-label={`${mode.toUpperCase()} channel ${index + 1}`}\n className={cn(\n 'h-8 flex-1 px-2 font-mono text-xs shadow-none focus:z-10',\n index && 'rounded-l-none',\n index < values.length - 1 && 'rounded-r-none',\n )}\n maxLength={3}\n size={4}\n type=\"text\"\n value={value}\n onChange={(e) => {\n handleInputChange(e.target.value, index);\n }}\n />\n ))}\n </div>\n );\n }\n\n return null;\n};\n\nconst ColorPicker = (props: ColorPickerProps) => (\n <ColorPickerRoot className=\"w-auto min-w-80\" {...props}>\n <ColorPickerSelection className=\"aspect-square\" />\n <div className=\"flex items-center gap-4\">\n <ColorPickerEyeDropper />\n <ColorPickerHue />\n </div>\n <div className=\"flex items-center gap-4\">\n <ColorPickerOutput />\n <ColorPickerFormat />\n </div>\n </ColorPickerRoot>\n);\n\nexport default ColorPicker;\n"],"mappings":";;;;;;;;;;AA4CA,IAAM,iBAAiB,UAAkB;CACvC,MAAM,aAAa,MAAM,YAAY;CACrC,OACE,eAAe,iBACd,WAAW,WAAW,KAAK,WAAW,OAAO,OAC7C,WAAW,WAAW,KAAK,WAAW,MAAM,CAAC,MAAM;AAExD;AAEA,IAAa,eAAe,EAC1B,OACA,UACA,OAAO,MACP,WACA,OACA,GAAG,YAEH,oBAAC,UAAD;CACE,gBAAc;CACd,WAAW,GACT,gHACA,SAAS,OAAO,WAAW,UAC3B,YAAY,0BACZ,SACF;CACA,OAAO;EAAE,iBAAiB;EAAO,GAAG;CAAM;CAC1C,MAAK;CACL,GAAI;WAEH,cAAc,KAAK,KAClB,oBAAC,QAAD;EACE,eAAY;EACZ,WAAU;EACV,eAAY;CACb,CAAA;AAEG,CAAA;AAUV,IAAa,kBAAkB,EAC7B,UACA,OACA,OAAO,MACP,UACA,WACA,GAAG,YAEH,oBAAC,OAAD;CAAK,WAAW,GAAG,2BAA2B,SAAS;CAAG,GAAI;WAC3D,SAAS,KAAK,WAAW;EACxB,MAAM,cAAc,OAAO,UAAU,KAAA,IAAY,OAAO,MAAM,OAAO;EACrE,OACE,oBAAC,aAAD;GAEE,cAAY,OAAO;GACnB,OAAO,OAAO;GACd,UAAU,gBAAgB,SAAS,OAAO,IAAI,YAAY,MAAM,OAAO,YAAY;GAC7E;GACN,OAAO,OAAO;GACd,eAAe,SAAS,WAAW;EACpC,GAPM,OAAO,KAOb;CAEL,CAAC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ACX,WAAU;IACV,MAAK;IACL,OAAO,cAAc;IACrB,cAAc;KACZ,cAAc,IAAI;IACpB;IACA,WAAW,MAAM;KACf,cAAc,EAAE,OAAO,KAAK;KAC5B,kBAAkB,EAAE,OAAO,KAAK;IAClC;GACD,CAAA;EACE,CAAA;CAET;CAEA,IAAI,SAAS,SAAS,SAAS,OAAO;EACpC,MAAM,SAAS,MAAM,KAAK,CAAC,CAAC,CACzB,MAAM,CAAC,CACP,KAAK,UAAU,KAAK,MAAM,KAAK,CAAC;EAEnC,OACE,oBAAC,OAAD;GAAK,WAAW,GAAG,oDAAoD,SAAS;GAAG,GAAI;aACpF,OAAO,KAAK,OAAO,UAClB,oBAAC,OAAD;IAEE,cAAY,GAAG,KAAK,YAAY,EAAE,WAAW,QAAQ;IACrD,WAAW,GACT,4DACA,SAAS,kBACT,QAAQ,OAAO,SAAS,KAAK,gBAC/B;IACA,WAAW;IACX,MAAM;IACN,MAAK;IACE;IACP,WAAW,MAAM;KACf,kBAAkB,EAAE,OAAO,OAAO,KAAK;IACzC;GACD,GAdM,KAcN,CACF;EACE,CAAA;CAET;CAEA,OAAO;AACT;AAEA,IAAM,eAAe,UACnB,qBAAC,iBAAD;CAAiB,WAAU;CAAkB,GAAI;WAAjD;EACE,oBAAC,sBAAD,EAAsB,WAAU,gBAAiB,CAAA;EACjD,qBAAC,OAAD;GAAK,WAAU;aAAf,CACE,oBAAC,uBAAD,CAAwB,CAAA,GACxB,oBAAC,gBAAD,CAAiB,CAAA,CACd;;EACL,qBAAC,OAAD;GAAK,WAAU;aAAf,CACE,oBAAC,mBAAD,CAAoB,CAAA,GACpB,oBAAC,mBAAD,CAAoB,CAAA,CACjB;;CACU"}
|
|
1
|
+
{"version":3,"file":"color-picker.js","names":[],"sources":["../../../src/components/patterns/color-picker.tsx"],"sourcesContent":["/* eslint-disable react/no-array-index-key */\nimport Color from 'color';\nimport { PipetteIcon } from 'lucide-react';\nimport * as Slider from '@radix-ui/react-slider';\nimport {\n type ButtonHTMLAttributes,\n type ComponentProps,\n createContext,\n type HTMLAttributes,\n forwardRef,\n memo,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { Button } from '@/components/ui/button';\nimport { Input } from '@/components/ui/input';\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@/components/ui/select';\nimport { cn } from '@/lib/utils';\n\nexport interface ColorSwatchOption {\n title: string;\n hex: string;\n value?: string | null;\n}\n\nexport interface ColorSwatchProps extends Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n 'value' | 'onSelect'\n> {\n color: string;\n selected?: boolean;\n size?: 'md' | 'lg';\n}\n\nconst isTransparent = (color: string) => {\n const normalized = color.toLowerCase();\n return (\n normalized === 'transparent' ||\n (normalized.length === 5 && normalized[4] === '0') ||\n (normalized.length === 9 && normalized.slice(7) === '00')\n );\n};\n\nexport const ColorSwatch = ({\n color,\n selected,\n size = 'md',\n className,\n style,\n ...props\n}: ColorSwatchProps) => (\n <button\n aria-pressed={selected}\n className={cn(\n 'relative flex shrink-0 cursor-pointer items-center overflow-hidden rounded-full border border-control-border',\n size === 'lg' ? 'size-6' : 'size-5',\n selected && 'ring-2 ring-focus-ring',\n className,\n )}\n style={{ backgroundColor: color, ...style }}\n type=\"button\"\n {...props}\n >\n {isTransparent(color) && (\n <span\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute top-1/2 left-[-30%] block h-px w-[160%] -translate-y-1/2 -rotate-45 bg-destructive\"\n data-testid=\"transparent-indicator\"\n />\n )}\n </button>\n);\n\nexport interface ColorSwatchRowProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> {\n swatches: ColorSwatchOption[];\n value?: string | null;\n size?: 'md' | 'lg';\n onSelect: (value: string | null) => void;\n}\n\nexport const ColorSwatchRow = ({\n swatches,\n value,\n size = 'md',\n onSelect,\n className,\n ...props\n}: ColorSwatchRowProps) => (\n <div className={cn('flex items-center gap-1', className)} {...props}>\n {swatches.map((swatch) => {\n const swatchValue = swatch.value === undefined ? swatch.hex : swatch.value;\n return (\n <ColorSwatch\n key={swatch.title}\n aria-label={swatch.title}\n color={swatch.hex}\n selected={swatchValue === value || swatch.hex.toLowerCase() === value?.toLowerCase()}\n size={size}\n title={swatch.title}\n onClick={() => onSelect(swatchValue)}\n />\n );\n })}\n </div>\n);\n\nexport interface ColorPickerTriggerProps extends Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n 'value'\n> {\n value?: string | null;\n}\n\nexport const ColorPickerTrigger = forwardRef<HTMLButtonElement, ColorPickerTriggerProps>(\n ({ value, className, ...props }, ref) => (\n <button\n ref={ref}\n aria-label=\"Pick color\"\n className={cn(\n 'relative size-6 cursor-pointer rounded-full border border-control-border',\n className,\n )}\n type=\"button\"\n {...props}\n >\n <span\n aria-hidden=\"true\"\n className=\"absolute inset-0 rounded-full bg-[conic-gradient(hsl(360,100%,50%),hsl(315,100%,50%),hsl(270,100%,50%),hsl(225,100%,50%),hsl(180,100%,50%),hsl(135,100%,50%),hsl(90,100%,50%),hsl(45,100%,50%),hsl(0,100%,50%))]\"\n />\n {value && (\n <span\n className=\"absolute inset-[3px] overflow-hidden rounded-full border border-background\"\n style={{ backgroundColor: value }}\n />\n )}\n </button>\n ),\n);\n\nColorPickerTrigger.displayName = 'ColorPickerTrigger';\n\ninterface HslaColor {\n hue: number;\n saturation: number;\n lightness: number;\n alpha: number;\n}\n\nconst toHsla = (input: Parameters<typeof Color>[0]): HslaColor => {\n const color = Color(input);\n return {\n hue: color.hue(),\n saturation: color.saturationl(),\n lightness: color.lightness(),\n alpha: color.alpha() * 100,\n };\n};\n\nconst toHex = ({ hue, saturation, lightness, alpha }: HslaColor) =>\n Color.hsl(hue, saturation, lightness)\n .alpha(alpha / 100)\n .hex();\n\nconst isSameHsla = (a: HslaColor, b: HslaColor) =>\n a.hue === b.hue &&\n a.saturation === b.saturation &&\n a.lightness === b.lightness &&\n a.alpha === b.alpha;\n\ninterface ColorPickerContextValue extends HslaColor {\n mode: string;\n // Applies a change made in the picker and reports it through onChange.\n setColor: (change: Partial<HslaColor>) => void;\n setMode: (mode: string) => void;\n}\n\nconst ColorPickerContext = createContext<ColorPickerContextValue | undefined>(undefined);\n\nconst useColorPicker = () => {\n const context = useContext(ColorPickerContext);\n\n if (!context) {\n throw new Error('useColorPicker must be used within a ColorPickerProvider');\n }\n\n return context;\n};\n\nexport type ColorPickerProps = Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> & {\n value?: Parameters<typeof Color>[0];\n defaultValue?: Parameters<typeof Color>[0];\n /**\n * Called with the new colour as upper-case `#RRGGBB` when someone changes it in the picker,\n * never on mount or when `value` changes. It can run twice before your component\n * re-renders, so compare with the last colour you stored, not with `value`.\n */\n onChange?: (value: string) => void;\n};\n\nexport const ColorPickerRoot = ({\n value,\n defaultValue = 'rgb(0 0 0)',\n onChange,\n className,\n ...props\n}: ColorPickerProps) => {\n const [color, setColorState] = useState(() => toHsla(value ?? defaultValue));\n const [mode, setMode] = useState('hex');\n // Several changes can land before a re-render, so each one builds on the latest colour.\n const colorRef = useRef(color);\n // An eye dropper pick resolves later, so it reports to the latest onChange. A layout effect\n // updates it at commit, before a pick resolving after a slow commit can read it.\n const onChangeRef = useRef(onChange);\n\n useLayoutEffect(() => {\n onChangeRef.current = onChange;\n });\n\n // Follow a controlled value without reporting it back through onChange.\n useEffect(() => {\n if (value) {\n const next = toHsla(value);\n colorRef.current = next;\n setColorState(next);\n }\n }, [value]);\n\n const setColor = useCallback((change: Partial<HslaColor>) => {\n const previous = colorRef.current;\n const next = { ...previous, ...change };\n // Like the separate channel states this replaced, a change to any channel is reported,\n // even when the hex stays the same (e.g. transparent black to opaque black).\n if (isSameHsla(next, previous)) {\n return;\n }\n colorRef.current = next;\n setColorState(next);\n onChangeRef.current?.(toHex(next));\n }, []);\n\n return (\n <ColorPickerContext.Provider value={{ ...color, mode, setColor, setMode }}>\n <div className={cn('flex size-full flex-col gap-4', className)} {...props} />\n </ColorPickerContext.Provider>\n );\n};\n\nexport type ColorPickerSelectionProps = HTMLAttributes<HTMLDivElement>;\n\nexport const ColorPickerSelection = memo(({ className, ...props }: ColorPickerSelectionProps) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const activePointerId = useRef<number | null>(null);\n const [positionX, setPositionX] = useState(0);\n const [positionY, setPositionY] = useState(0);\n const { hue, saturation, lightness, setColor } = useColorPicker();\n\n const backgroundGradient = useMemo(() => {\n return `linear-gradient(0deg, rgba(0,0,0,1), rgba(0,0,0,0)),\n linear-gradient(90deg, rgba(255,255,255,1), rgba(255,255,255,0)),\n hsl(${hue}, 100%, 50%)`;\n }, [hue]);\n\n // Update position based on current saturation and lightness values\n useEffect(() => {\n const x = saturation / 100;\n const topLightness = x < 0.01 ? 100 : 50 + 50 * (1 - x);\n const y = Math.max(0, Math.min(1, 1 - lightness / topLightness));\n\n setPositionX(x);\n setPositionY(y);\n }, [saturation, lightness]);\n\n const updateColorFromPointer = useCallback(\n (event: PointerEvent) => {\n if (!containerRef.current) {\n return;\n }\n const rect = containerRef.current.getBoundingClientRect();\n const x = Math.max(0, Math.min(1, (event.clientX - rect.left) / rect.width));\n const y = Math.max(0, Math.min(1, (event.clientY - rect.top) / rect.height));\n setPositionX(x);\n setPositionY(y);\n const topLightness = x < 0.01 ? 100 : 50 + 50 * (1 - x);\n\n setColor({ saturation: x * 100, lightness: topLightness * (1 - y) });\n },\n [setColor],\n );\n\n return (\n <div\n ref={containerRef}\n className={cn('relative size-full cursor-crosshair rounded', className)}\n style={{\n background: backgroundGradient,\n }}\n onPointerCancel={(e) => {\n if (activePointerId.current === e.pointerId) {\n activePointerId.current = null;\n }\n }}\n onPointerDown={(e) => {\n e.preventDefault();\n activePointerId.current = e.pointerId;\n e.currentTarget.setPointerCapture?.(e.pointerId);\n updateColorFromPointer(e.nativeEvent);\n }}\n onPointerMove={(e) => {\n if (activePointerId.current === e.pointerId) {\n updateColorFromPointer(e.nativeEvent);\n }\n }}\n onPointerUp={(e) => {\n if (activePointerId.current === e.pointerId) {\n activePointerId.current = null;\n e.currentTarget.releasePointerCapture?.(e.pointerId);\n }\n }}\n {...props}\n >\n <div\n className=\"pointer-events-none absolute size-4 -translate-1/2 rounded-full border-2 border-white\"\n style={{\n left: `${positionX * 100}%`,\n top: `${positionY * 100}%`,\n boxShadow: '0 0 0 1px rgba(0,0,0,0.5)',\n }}\n />\n </div>\n );\n});\n\nColorPickerSelection.displayName = 'ColorPickerSelection';\n\nexport type ColorPickerHueProps = ComponentProps<typeof Slider.Root>;\n\nexport const ColorPickerHue = ({ className, ...props }: ColorPickerHueProps) => {\n const { hue, setColor } = useColorPicker();\n\n return (\n <Slider.Root\n className={cn('relative flex h-4 w-full touch-none', className)}\n max={360}\n step={1}\n value={[hue]}\n onValueChange={([value]) => setColor({ hue: value })}\n {...props}\n >\n <Slider.Track className=\"relative my-0.5 h-3 w-full grow rounded-full bg-[linear-gradient(90deg,red,yellow,lime,aqua,blue,magenta,red)]\">\n <Slider.Range className=\"absolute h-full\" />\n </Slider.Track>\n <Slider.Thumb className=\"block size-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:ring-1 focus-visible:ring-focus-ring focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50\" />\n </Slider.Root>\n );\n};\n\nexport type ColorPickerAlphaProps = ComponentProps<typeof Slider.Root>;\n\nexport const ColorPickerAlpha = ({ className, ...props }: ColorPickerAlphaProps) => {\n const { alpha, setColor } = useColorPicker();\n\n return (\n <Slider.Root\n className={cn('relative flex h-4 w-full touch-none', className)}\n max={100}\n step={1}\n value={[alpha]}\n onValueChange={([value]) => setColor({ alpha: value })}\n {...props}\n >\n <Slider.Track className=\"relative my-0.5 h-3 w-full grow rounded-full bg-[url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==')] bg-center bg-repeat-x dark:bg-[url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAALklEQVR4nGP8+vWrCAMewM3N/QafPBM+SWLAqAGDwQBGQgoIpZOB98KoAVQwAADxzQcSVIRCfQAAAABJRU5ErkJggg==')]\">\n <div className=\"absolute inset-0 rounded-full bg-gradient-to-r from-transparent to-black/50 dark:to-white/50\" />\n <Slider.Range className=\"absolute h-full rounded-full bg-transparent\" />\n </Slider.Track>\n <Slider.Thumb className=\"block size-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:ring-1 focus-visible:ring-focus-ring focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50\" />\n </Slider.Root>\n );\n};\n\nexport type ColorPickerEyeDropperProps = ComponentProps<typeof Button>;\n\nexport const ColorPickerEyeDropper = ({ className, ...props }: ColorPickerEyeDropperProps) => {\n const { setColor } = useColorPicker();\n // A pick that resolves after the picker has gone away isn't reported. A layout effect\n // clears this as the picker is removed, not after the commit.\n const isMounted = useRef(false);\n\n useLayoutEffect(() => {\n isMounted.current = true;\n return () => {\n isMounted.current = false;\n };\n }, []);\n\n // Check if EyeDropper API is supported\n const isSupported = typeof window !== 'undefined' && 'EyeDropper' in window;\n if (!isSupported) {\n return null;\n }\n\n const handleEyeDropper = async () => {\n let picked: number[];\n try {\n // @ts-expect-error - EyeDropper API is experimental\n const eyeDropper = new EyeDropper();\n const result = await eyeDropper.open();\n picked = Color(result.sRGBHex).hsl().array();\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('EyeDropper failed:', error);\n return;\n }\n\n if (isMounted.current) {\n // Outside the try, so an error thrown by onChange isn't taken for a failed pick.\n const [hue, saturation, lightness] = picked;\n setColor({ hue, saturation, lightness, alpha: 100 });\n }\n };\n\n return (\n <Button\n className={cn('size-8 shrink-0 text-muted-foreground', className)}\n size=\"icon\"\n type=\"button\"\n variant=\"outline\"\n onClick={handleEyeDropper}\n {...props}\n >\n <PipetteIcon size={16} />\n </Button>\n );\n};\n\nexport type ColorPickerOutputProps = ComponentProps<typeof SelectTrigger>;\n\nconst formats = ['hex', 'rgb', 'hsl'];\n\nexport const ColorPickerOutput = ({ ...props }: ColorPickerOutputProps) => {\n const { mode, setMode } = useColorPicker();\n\n return (\n <Select value={mode} onValueChange={setMode}>\n <SelectTrigger className=\"h-8 w-20 shrink-0 text-xs\" {...props}>\n <SelectValue placeholder=\"Mode\" />\n </SelectTrigger>\n <SelectContent>\n {formats.map((format) => (\n <SelectItem key={format} className=\"text-xs\" value={format}>\n {format.toUpperCase()}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n );\n};\n\nexport type ColorPickerFormatProps = HTMLAttributes<HTMLDivElement>;\n\nexport const ColorPickerFormat = ({ className, ...props }: ColorPickerFormatProps) => {\n const { hue, saturation, lightness, mode, setColor } = useColorPicker();\n const color = Color.hsl(hue, saturation, lightness);\n const [inputValue, setInputValue] = useState<string | null>(null);\n\n const handleInputChange = (value: string, index?: number) => {\n let change: Partial<HslaColor>;\n try {\n if (mode === 'hex') {\n change = toHsla(value);\n } else if ((mode === 'rgb' || mode === 'hsl') && index !== undefined) {\n const values = color[mode]()\n .array()\n .map((v) => Math.round(v));\n values[index] = parseInt(value, 10) || 0;\n const newColor = Color[mode](values[0], values[1], values[2]);\n change = {\n hue: newColor.hue(),\n saturation: newColor.saturationl(),\n lightness: newColor.lightness(),\n };\n } else {\n return;\n }\n } catch {\n // Invalid color, ignore\n return;\n }\n // Outside the try, so an error thrown by onChange isn't taken for an invalid colour.\n setColor(change);\n };\n\n if (mode === 'hex') {\n const hex = color.hex();\n\n return (\n <div\n className={cn('relative flex w-full items-center -space-x-px rounded-md', className)}\n {...props}\n >\n <Input\n aria-label=\"Hex color\"\n className=\"h-8 px-2 font-mono text-xs shadow-none\"\n type=\"text\"\n value={inputValue ?? hex}\n onBlur={() => {\n setInputValue(null);\n }}\n onChange={(e) => {\n setInputValue(e.target.value);\n handleInputChange(e.target.value);\n }}\n />\n </div>\n );\n }\n\n if (mode === 'rgb' || mode === 'hsl') {\n const values = color[mode]()\n .array()\n .map((value) => Math.round(value));\n\n return (\n <div className={cn('flex flex-1 items-stretch -space-x-px rounded-md', className)} {...props}>\n {values.map((value, index) => (\n <Input\n key={index}\n aria-label={`${mode.toUpperCase()} channel ${index + 1}`}\n className={cn(\n 'h-8 flex-1 px-2 font-mono text-xs shadow-none focus:z-10',\n index && 'rounded-l-none',\n index < values.length - 1 && 'rounded-r-none',\n )}\n maxLength={3}\n size={4}\n type=\"text\"\n value={value}\n onChange={(e) => {\n handleInputChange(e.target.value, index);\n }}\n />\n ))}\n </div>\n );\n }\n\n return null;\n};\n\nconst ColorPicker = (props: ColorPickerProps) => (\n <ColorPickerRoot className=\"w-auto min-w-80\" {...props}>\n <ColorPickerSelection className=\"aspect-square\" />\n <div className=\"flex items-center gap-4\">\n <ColorPickerEyeDropper />\n <ColorPickerHue />\n </div>\n <div className=\"flex items-center gap-4\">\n <ColorPickerOutput />\n <ColorPickerFormat />\n </div>\n </ColorPickerRoot>\n);\n\nexport default ColorPicker;\n"],"mappings":";;;;;;;;;;AA6CA,IAAM,iBAAiB,UAAkB;CACvC,MAAM,aAAa,MAAM,YAAY;CACrC,OACE,eAAe,iBACd,WAAW,WAAW,KAAK,WAAW,OAAO,OAC7C,WAAW,WAAW,KAAK,WAAW,MAAM,CAAC,MAAM;AAExD;AAEA,IAAa,eAAe,EAC1B,OACA,UACA,OAAO,MACP,WACA,OACA,GAAG,YAEH,oBAAC,UAAD;CACE,gBAAc;CACd,WAAW,GACT,gHACA,SAAS,OAAO,WAAW,UAC3B,YAAY,0BACZ,SACF;CACA,OAAO;EAAE,iBAAiB;EAAO,GAAG;CAAM;CAC1C,MAAK;CACL,GAAI;WAEH,cAAc,KAAK,KAClB,oBAAC,QAAD;EACE,eAAY;EACZ,WAAU;EACV,eAAY;CACb,CAAA;AAEG,CAAA;A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E,WAAW,QAAQ;IACrD,WAAW,GACT,4DACA,SAAS,kBACT,QAAQ,OAAO,SAAS,KAAK,gBAC/B;IACA,WAAW;IACX,MAAM;IACN,MAAK;IACE;IACP,WAAW,MAAM;KACf,kBAAkB,EAAE,OAAO,OAAO,KAAK;IACzC;GACD,GAdM,KAcN,CACF;EACE,CAAA;CAET;CAEA,OAAO;AACT;AAEA,IAAM,eAAe,UACnB,qBAAC,iBAAD;CAAiB,WAAU;CAAkB,GAAI;WAAjD;EACE,oBAAC,sBAAD,EAAsB,WAAU,gBAAiB,CAAA;EACjD,qBAAC,OAAD;GAAK,WAAU;aAAf,CACE,oBAAC,uBAAD,CAAwB,CAAA,GACxB,oBAAC,gBAAD,CAAiB,CAAA,CACd;;EACL,qBAAC,OAAD;GAAK,WAAU;aAAf,CACE,oBAAC,mBAAD,CAAoB,CAAA,GACpB,oBAAC,mBAAD,CAAoB,CAAA,CACjB;;CACU"}
|
|
@@ -322,7 +322,7 @@ function PageHeaderActions({ className, children }) {
|
|
|
322
322
|
*/
|
|
323
323
|
var PageHeader = Object.assign(function PageHeader({ className, children, sticky = true, blurredBackground = true }) {
|
|
324
324
|
return /* @__PURE__ */ jsx("header", {
|
|
325
|
-
className: cn("flex flex-col", sticky && "sticky top-
|
|
325
|
+
className: cn("flex flex-col", sticky && "sticky top-[var(--ghost-safe-area-inset-top,0px)] z-50", blurredBackground && "bg-gradient-to-b from-background via-background/70 to-background/70 backdrop-blur-md", className),
|
|
326
326
|
"data-page-header": "page-header",
|
|
327
327
|
children: /* @__PURE__ */ jsx(Inline, {
|
|
328
328
|
align: "start",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-header.js","names":[],"sources":["../../../src/components/patterns/page-header.tsx"],"sourcesContent":["import { HeaderTooltipProvider } from '@/providers/header-tooltip-provider';\nimport { useShade } from '@/providers/shade-context';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuTrigger,\n} from '@/components/ui/dropdown-menu';\nimport { Button, type ButtonProps } from '@/components/ui/button';\nimport { SelectTrigger } from '@/components/ui/select';\nimport { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';\nimport { Kbd } from '@/components/ui/kbd';\nimport { H1 } from '@/components/layout/heading';\nimport { Inline, Stack, Text } from '@/components/primitives';\nimport { cn } from '@/lib/utils';\n\nimport React from 'react';\nimport { createPortal } from 'react-dom';\nimport { ListFilter } from 'lucide-react';\nimport { PageHeaderLargeTitleContext } from './page-header-large-title';\n\ntype PropsWithChildrenAndClassName = React.PropsWithChildren & {\n className?: string;\n};\n\ntype PageHeaderProps = PropsWithChildrenAndClassName & {\n sticky?: boolean;\n blurredBackground?: boolean;\n};\n\n/**\n * Header tooltips never belong on primary actions. A tooltip without a label\n * shows only the shortcut, for a control whose text already names it.\n */\nfunction PageHeaderTooltip({\n children,\n label,\n shortcut,\n}: React.PropsWithChildren<{ label?: string; shortcut?: string }>) {\n return (\n <Tooltip>\n {children}\n <TooltipContent side=\"bottom\" variant=\"white\">\n <Inline align=\"center\" gap=\"sm\">\n {label}\n {shortcut && <Kbd>{shortcut}</Kbd>}\n </Inline>\n </TooltipContent>\n </Tooltip>\n );\n}\n\nconst PrimaryActionContext = React.createContext(false);\n\ntype PageHeaderActionProps = ButtonProps & {\n label: string;\n iconOnly?: boolean;\n primary?: boolean;\n /**\n * A key the screen binds for this action. It shows in the tooltip and sets\n * `aria-keyshortcuts`, so pass it only when the screen handles the key.\n */\n shortcut?: string;\n /** Show an explanation for a changing value; static labels need no tooltip. */\n tooltip?: boolean;\n};\n\nconst PageHeaderAction = React.forwardRef<HTMLButtonElement, PageHeaderActionProps>(\n (\n {\n label,\n iconOnly = false,\n primary: primaryProp,\n shortcut,\n tooltip = iconOnly || Boolean(shortcut),\n className,\n ...props\n },\n ref,\n ) => {\n const primaryContext = React.useContext(PrimaryActionContext);\n const primary = primaryProp ?? primaryContext;\n const button = (\n <Button\n ref={ref}\n aria-keyshortcuts={shortcut}\n aria-label={label}\n className={cn('[&_svg]:stroke-2!', className)}\n size={iconOnly ? 'icon' : undefined}\n variant={primary ? 'default' : 'ghost'}\n {...props}\n />\n );\n // A labelled action already shows its name, so its shortcut tooltip shows the keys alone.\n const tooltipLabel = iconOnly || !shortcut ? label : undefined;\n return primary || !tooltip ? (\n button\n ) : (\n <PageHeaderTooltip label={tooltipLabel} shortcut={shortcut}>\n <TooltipTrigger asChild>{button}</TooltipTrigger>\n </PageHeaderTooltip>\n );\n },\n);\nPageHeaderAction.displayName = 'PageHeaderAction';\n\nconst PageHeaderFilterTrigger = React.forwardRef<\n HTMLButtonElement,\n Omit<PageHeaderActionProps, 'label'>\n>((props, ref) => (\n <PageHeaderAction\n ref={ref}\n data-slot=\"filters-add\"\n label=\"Filter\"\n shortcut=\"F\"\n type=\"button\"\n {...props}\n >\n <ListFilter className=\"size-4\" />\n Filter\n </PageHeaderAction>\n));\nPageHeaderFilterTrigger.displayName = 'PageHeaderFilterTrigger';\n\nconst PageHeaderSelectTrigger = React.forwardRef<\n React.ElementRef<typeof SelectTrigger>,\n React.ComponentPropsWithoutRef<typeof SelectTrigger> & { label: string; tooltip?: boolean }\n>(({ label, tooltip = true, className, ...props }, ref) => {\n const { controlShape } = useShade();\n const trigger = (\n <SelectTrigger\n ref={ref}\n aria-label={label}\n className={cn(\n 'w-auto gap-1.5 font-medium [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2! [&>svg]:mr-0',\n className,\n )}\n shape={controlShape}\n showChevron={false}\n variant=\"ghost\"\n {...props}\n />\n );\n return tooltip ? (\n <PageHeaderTooltip label={label}>\n <TooltipTrigger asChild>{trigger}</TooltipTrigger>\n </PageHeaderTooltip>\n ) : (\n trigger\n );\n});\nPageHeaderSelectTrigger.displayName = 'PageHeaderSelectTrigger';\n\n// ---------------------------------------------------------------------------\n// Title-block primitives\n// ---------------------------------------------------------------------------\n\n// Crumbs truncate rather than wrapping under the title or running under the\n// actions. They render as blocks, since a flex link can't show an ellipsis.\n// Earlier crumbs keep their width up to a cap, so a long one can't crowd out\n// the current page, which shrinks to fit the rest.\nconst breadcrumbFitClassName =\n 'min-w-0 [&_nav]:min-w-0 [&_ol]:flex-nowrap [&_li]:shrink-0 [&_li>*]:block [&_li>*]:truncate [&_li:not(:last-child)>*]:max-w-40 [&_li:last-child]:min-w-0 [&_li:last-child]:shrink';\n\nfunction PageHeaderBreadcrumb({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <Inline\n align=\"center\"\n className={cn('pt-1 text-sm text-muted-foreground', breadcrumbFitClassName, className)}\n data-page-header=\"breadcrumb\"\n gap=\"sm\"\n >\n {children}\n </Inline>\n );\n}\n\nfunction PageHeaderCount({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <Text\n as=\"span\"\n className={cn('ml-1 text-base tabular-nums', className)}\n data-page-header=\"count\"\n tone=\"secondary\"\n weight=\"regular\"\n >\n {children}\n </Text>\n );\n}\n\nfunction PageHeaderDescription({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <Text as=\"p\" className={className} data-page-header=\"description\" size=\"sm\" tone=\"secondary\">\n {children}\n </Text>\n );\n}\n\nfunction PageHeaderMeta({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <Text\n as=\"p\"\n className={cn('mt-0.5', className)}\n data-page-header=\"meta\"\n size=\"sm\"\n tone=\"secondary\"\n >\n {children}\n </Text>\n );\n}\n\n/**\n * `Title` accepts heading text plus optional `Count`, `Description`, and `Meta`\n * children. `Count` flows inline inside the H1; `Description` and `Meta` stack\n * below the heading.\n */\nfunction PageHeaderTitle({ className, children }: PropsWithChildrenAndClassName) {\n const largeTitle = React.useContext(PageHeaderLargeTitleContext);\n const registerLargeTitle = largeTitle?.registerTitle;\n React.useLayoutEffect(() => registerLargeTitle?.(), [registerLargeTitle]);\n\n const headingChildren: React.ReactNode[] = [];\n const subTextChildren: React.ReactNode[] = [];\n\n React.Children.forEach(children, (child) => {\n if (!React.isValidElement(child)) {\n headingChildren.push(child);\n return;\n }\n\n switch (child.type) {\n case PageHeaderDescription:\n case PageHeaderMeta:\n subTextChildren.push(child);\n break;\n default:\n headingChildren.push(child);\n }\n });\n\n // Shown large above the page's header, the title is that heading; the one\n // in the header is a stand-in, fading in as the header takes over\n if (largeTitle) {\n return (\n <>\n <H1\n aria-hidden=\"true\"\n className={cn(\n 'large-title-header-title text-lg font-semibold tracking-[0.1px] whitespace-nowrap',\n className,\n )}\n data-page-header=\"title\"\n >\n {headingChildren}\n </H1>\n {largeTitle.slot &&\n createPortal(\n <Stack data-page-header=\"large-title\" gap=\"none\">\n <H1\n className=\"flex items-baseline gap-3 font-medium tracking-[-0.03em] whitespace-nowrap [&_[data-page-header=count]]:tracking-normal\"\n data-large-title=\"\"\n // Inline, over Text's own line height\n style={{ fontSize: 'var(--large-title-size)', lineHeight: 1.15 }}\n >\n {headingChildren}\n </H1>\n {subTextChildren}\n </Stack>,\n largeTitle.slot,\n )}\n </>\n );\n }\n\n const heading = (\n <H1\n className={cn('text-lg font-semibold tracking-[0.1px] whitespace-nowrap', className)}\n data-page-header=\"title\"\n >\n {headingChildren}\n </H1>\n );\n\n if (subTextChildren.length > 0) {\n return (\n <Stack data-page-header=\"title-body\" gap=\"none\">\n {heading}\n {subTextChildren}\n </Stack>\n );\n }\n\n return heading;\n}\n\n// ---------------------------------------------------------------------------\n// Main row — Left (stack: Breadcrumb + Title) + Actions\n// ---------------------------------------------------------------------------\n\nfunction PageHeaderLeft({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <Stack\n className={cn('h-full min-h-(--control-height) min-w-0', className)}\n data-page-header=\"left\"\n gap=\"xs\"\n justify=\"center\"\n >\n {children}\n </Stack>\n );\n}\n\ntype PageHeaderActionGroupPrimaryProps = PropsWithChildrenAndClassName;\nfunction PageHeaderActionGroupPrimary({ children, className }: PageHeaderActionGroupPrimaryProps) {\n if (React.Children.toArray(children).length === 0) {\n return null;\n }\n return (\n <PrimaryActionContext.Provider value={true}>\n <Inline\n className={cn('ms-3 shrink-0 first:ms-0', className)}\n data-page-header=\"primary\"\n gap=\"none\"\n >\n {children}\n </Inline>\n </PrimaryActionContext.Provider>\n );\n}\n\ntype PageHeaderActionGroupMobileMenuProps = React.PropsWithChildren;\nfunction PageHeaderActionGroupMobileMenu({ children }: PageHeaderActionGroupMobileMenuProps) {\n return <DropdownMenu>{children}</DropdownMenu>;\n}\n\ntype PageHeaderActionGroupMobileMenuTriggerProps = React.ComponentPropsWithoutRef<\n typeof DropdownMenuTrigger\n>;\nfunction PageHeaderActionGroupMobileMenuTrigger({\n children,\n ...props\n}: PageHeaderActionGroupMobileMenuTriggerProps) {\n return (\n <DropdownMenuTrigger asChild {...props}>\n {children}\n </DropdownMenuTrigger>\n );\n}\n\ntype PageHeaderActionGroupMobileMenuContentProps = React.ComponentPropsWithoutRef<\n typeof DropdownMenuContent\n>;\nfunction PageHeaderActionGroupMobileMenuContent({\n children,\n ...props\n}: PageHeaderActionGroupMobileMenuContentProps) {\n return (\n <DropdownMenuContent align=\"end\" sideOffset={8} {...props}>\n {children}\n </DropdownMenuContent>\n );\n}\n\nconst DEFAULT_MOBILE_MENU_BREAKPOINT = 640;\n\nconst isBelowBreakpoint = (breakpoint: number) => {\n if (typeof window === 'undefined') {\n return false;\n }\n\n return window.innerWidth < breakpoint;\n};\n\nconst useShouldCollapseActionGroup = (breakpoint: number) => {\n const [shouldCollapse, setShouldCollapse] = React.useState(() => isBelowBreakpoint(breakpoint));\n\n React.useEffect(() => {\n const onResize = () => {\n setShouldCollapse(isBelowBreakpoint(breakpoint));\n };\n\n onResize();\n window.addEventListener('resize', onResize);\n\n return () => {\n window.removeEventListener('resize', onResize);\n };\n }, [breakpoint]);\n\n return shouldCollapse;\n};\n\ntype PageHeaderActionGroupProps = PropsWithChildrenAndClassName & {\n mobileMenuBreakpoint?: number;\n};\ntype PageHeaderActionGroupComponent = React.FC<PageHeaderActionGroupProps> & {\n Primary: React.FC<PageHeaderActionGroupPrimaryProps>;\n MobileMenu: React.FC<PageHeaderActionGroupMobileMenuProps>;\n MobileMenuTrigger: React.FC<PageHeaderActionGroupMobileMenuTriggerProps>;\n MobileMenuContent: React.FC<PageHeaderActionGroupMobileMenuContentProps>;\n};\n\nconst PageHeaderActionGroup: PageHeaderActionGroupComponent = Object.assign(\n function PageHeaderActionGroup({\n className,\n children,\n mobileMenuBreakpoint = DEFAULT_MOBILE_MENU_BREAKPOINT,\n }: PageHeaderActionGroupProps) {\n const gap = 'sm';\n const childNodes = React.Children.toArray(children);\n const desktopChildren: React.ReactNode[] = [];\n let mobileMenu: React.ReactElement | null = null;\n let primaryAction: React.ReactNode = null;\n const shouldCollapse = useShouldCollapseActionGroup(mobileMenuBreakpoint);\n\n childNodes.forEach((child) => {\n if (!React.isValidElement(child)) {\n desktopChildren.push(child);\n return;\n }\n\n const childElement = child as React.ReactElement<{ children?: React.ReactNode }>;\n\n if (childElement.type === PageHeaderActionGroupMobileMenu) {\n mobileMenu = childElement;\n return;\n }\n\n if (childElement.type === PageHeaderActionGroupPrimary) {\n primaryAction = childElement;\n desktopChildren.push(childElement);\n return;\n }\n\n desktopChildren.push(childElement);\n });\n\n if (!mobileMenu) {\n return (\n <HeaderTooltipProvider>\n <Inline\n align=\"center\"\n className={className}\n data-page-header=\"action-group\"\n gap={gap}\n justify=\"end\"\n >\n {children}\n </Inline>\n </HeaderTooltipProvider>\n );\n }\n\n if (!shouldCollapse) {\n return (\n <HeaderTooltipProvider>\n <Inline\n align=\"center\"\n className={className}\n data-page-header=\"action-group\"\n gap={gap}\n justify=\"end\"\n >\n <Inline align=\"center\" data-page-header=\"action-group-desktop\" gap={gap} justify=\"end\">\n {desktopChildren}\n </Inline>\n </Inline>\n </HeaderTooltipProvider>\n );\n }\n\n return (\n <HeaderTooltipProvider>\n <Inline\n align=\"center\"\n className={className}\n data-page-header=\"action-group\"\n gap={gap}\n justify=\"end\"\n >\n <Inline\n align=\"center\"\n className=\"ml-auto\"\n data-page-header=\"action-group-mobile\"\n gap={gap}\n >\n {mobileMenu}\n {primaryAction}\n </Inline>\n </Inline>\n </HeaderTooltipProvider>\n );\n },\n {\n Primary: PageHeaderActionGroupPrimary,\n MobileMenu: PageHeaderActionGroupMobileMenu,\n MobileMenuTrigger: PageHeaderActionGroupMobileMenuTrigger,\n MobileMenuContent: PageHeaderActionGroupMobileMenuContent,\n },\n);\n\nfunction PageHeaderActions({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <HeaderTooltipProvider>\n <Inline\n align=\"center\"\n className={cn('min-h-(--control-height) shrink-0', className)}\n data-page-header=\"actions\"\n gap=\"lg\"\n >\n {children}\n </Inline>\n </HeaderTooltipProvider>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Root\n// ---------------------------------------------------------------------------\n\ntype PageHeaderComponent = React.FC<PageHeaderProps> & {\n Left: React.FC<PropsWithChildrenAndClassName>;\n Breadcrumb: React.FC<PropsWithChildrenAndClassName>;\n Title: React.FC<PropsWithChildrenAndClassName>;\n Count: React.FC<PropsWithChildrenAndClassName>;\n Description: React.FC<PropsWithChildrenAndClassName>;\n Meta: React.FC<PropsWithChildrenAndClassName>;\n Actions: React.FC<PropsWithChildrenAndClassName>;\n ActionGroup: PageHeaderActionGroupComponent;\n Action: typeof PageHeaderAction;\n FilterTrigger: typeof PageHeaderFilterTrigger;\n SelectTrigger: typeof PageHeaderSelectTrigger;\n Tooltip: typeof PageHeaderTooltip;\n TooltipTrigger: typeof TooltipTrigger;\n};\n\n/**\n * PageHeader is the canonical page-chrome component for Ghost Admin pages.\n *\n * The main row contains `Left` (Breadcrumb + Title) and `Actions`.\n * Compose optional ViewBar and FilterBar rows beside it in ListPage.Header.\n * `Title` accepts an inline `Count` and stacked `Description`/`Meta` children.\n * See the design contract for the action ordering and interaction rules:\n * https://shade.ghost.org/docs/components/patterns/page-header.md (generated from page-header.mdx).\n */\nconst PageHeader: PageHeaderComponent = Object.assign(\n function PageHeader({\n className,\n children,\n sticky = true,\n blurredBackground = true,\n }: PageHeaderProps) {\n return (\n <header\n className={cn(\n 'flex flex-col',\n sticky && 'sticky top-0 z-50',\n blurredBackground &&\n 'bg-gradient-to-b from-background via-background/70 to-background/70 backdrop-blur-md',\n className,\n )}\n data-page-header=\"page-header\"\n >\n <Inline align=\"start\" className=\"w-full\" data-page-header=\"main\" gap=\"lg\" justify=\"between\">\n {children}\n </Inline>\n </header>\n );\n },\n {\n Left: PageHeaderLeft,\n Breadcrumb: PageHeaderBreadcrumb,\n Title: PageHeaderTitle,\n Count: PageHeaderCount,\n Description: PageHeaderDescription,\n Meta: PageHeaderMeta,\n Actions: PageHeaderActions,\n ActionGroup: PageHeaderActionGroup,\n Action: PageHeaderAction,\n FilterTrigger: PageHeaderFilterTrigger,\n SelectTrigger: PageHeaderSelectTrigger,\n Tooltip: PageHeaderTooltip,\n TooltipTrigger,\n },\n);\n\nexport {\n PageHeader,\n PageHeaderLeft,\n PageHeaderBreadcrumb,\n PageHeaderTitle,\n PageHeaderCount,\n PageHeaderDescription,\n PageHeaderMeta,\n PageHeaderActions,\n PageHeaderActionGroup,\n PageHeaderActionGroupPrimary,\n PageHeaderActionGroupMobileMenu,\n PageHeaderActionGroupMobileMenuTrigger,\n PageHeaderActionGroupMobileMenuContent,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiCA,SAAS,kBAAkB,EACzB,UACA,OACA,YACiE;CACjE,OACE,qBAAC,SAAD,EAAA,UAAA,CACG,UACD,oBAAC,gBAAD;EAAgB,MAAK;EAAS,SAAQ;YACpC,qBAAC,QAAD;GAAQ,OAAM;GAAS,KAAI;aAA3B,CACG,OACA,YAAY,oBAAC,KAAD,EAAA,UAAM,SAAc,CAAA,CAC3B;;CACM,CAAA,CACT,EAAA,CAAA;AAEb;AAEA,IAAM,uBAAuB,MAAM,cAAc,KAAK;AAetD,IAAM,mBAAmB,MAAM,YAE3B,EACE,OACA,WAAW,OACX,SAAS,aACT,UACA,UAAU,YAAY,QAAQ,QAAQ,GACtC,WACA,GAAG,SAEL,QACG;CACH,MAAM,iBAAiB,M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BAAC,QAAD;GACE,OAAM;GACN,WAAU;GACV,oBAAiB;GACZ;aAJP,CAMG,YACA,aACK;;CACF,CAAA,EACa,CAAA;AAE3B,GACA;CACE,SAAS;CACT,YAAY;CACZ,mBAAmB;CACnB,mBAAmB;AACrB,CACF;AAEA,SAAS,kBAAkB,EAAE,WAAW,YAA2C;CACjF,OACE,oBAAC,uBAAD,EAAA,UACE,oBAAC,QAAD;EACE,OAAM;EACN,WAAW,GAAG,qCAAqC,SAAS;EAC5D,oBAAiB;EACjB,KAAI;EAEH;CACK,CAAA,EACa,CAAA;AAE3B;;;;;;;;;;AA+BA,IAAM,aAAkC,OAAO,OAC7C,SAAS,WAAW,EAClB,WACA,UACA,SAAS,MACT,oBAAoB,QACF;CAClB,OACE,oBAAC,UAAD;EACE,WAAW,GACT,iBACA,UAAU,qBACV,qBACE,wFACF,SACF;EACA,oBAAiB;YAEjB,oBAAC,QAAD;GAAQ,OAAM;GAAQ,WAAU;GAAS,oBAAiB;GAAO,KAAI;GAAK,SAAQ;GAC/E;EACK,CAAA;CACF,CAAA;AAEZ,GACA;CACE,MAAM;CACN,YAAY;CACZ,OAAO;CACP,OAAO;CACP,aAAa;CACb,MAAM;CACN,SAAS;CACT,aAAa;CACb,QAAQ;CACR,eAAe;CACf,eAAe;CACf,SAAS;CACT;AACF,CACF"}
|
|
1
|
+
{"version":3,"file":"page-header.js","names":[],"sources":["../../../src/components/patterns/page-header.tsx"],"sourcesContent":["import { HeaderTooltipProvider } from '@/providers/header-tooltip-provider';\nimport { useShade } from '@/providers/shade-context';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuTrigger,\n} from '@/components/ui/dropdown-menu';\nimport { Button, type ButtonProps } from '@/components/ui/button';\nimport { SelectTrigger } from '@/components/ui/select';\nimport { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';\nimport { Kbd } from '@/components/ui/kbd';\nimport { H1 } from '@/components/layout/heading';\nimport { Inline, Stack, Text } from '@/components/primitives';\nimport { cn } from '@/lib/utils';\n\nimport React from 'react';\nimport { createPortal } from 'react-dom';\nimport { ListFilter } from 'lucide-react';\nimport { PageHeaderLargeTitleContext } from './page-header-large-title';\n\ntype PropsWithChildrenAndClassName = React.PropsWithChildren & {\n className?: string;\n};\n\ntype PageHeaderProps = PropsWithChildrenAndClassName & {\n sticky?: boolean;\n blurredBackground?: boolean;\n};\n\n/**\n * Header tooltips never belong on primary actions. A tooltip without a label\n * shows only the shortcut, for a control whose text already names it.\n */\nfunction PageHeaderTooltip({\n children,\n label,\n shortcut,\n}: React.PropsWithChildren<{ label?: string; shortcut?: string }>) {\n return (\n <Tooltip>\n {children}\n <TooltipContent side=\"bottom\" variant=\"white\">\n <Inline align=\"center\" gap=\"sm\">\n {label}\n {shortcut && <Kbd>{shortcut}</Kbd>}\n </Inline>\n </TooltipContent>\n </Tooltip>\n );\n}\n\nconst PrimaryActionContext = React.createContext(false);\n\ntype PageHeaderActionProps = ButtonProps & {\n label: string;\n iconOnly?: boolean;\n primary?: boolean;\n /**\n * A key the screen binds for this action. It shows in the tooltip and sets\n * `aria-keyshortcuts`, so pass it only when the screen handles the key.\n */\n shortcut?: string;\n /** Show an explanation for a changing value; static labels need no tooltip. */\n tooltip?: boolean;\n};\n\nconst PageHeaderAction = React.forwardRef<HTMLButtonElement, PageHeaderActionProps>(\n (\n {\n label,\n iconOnly = false,\n primary: primaryProp,\n shortcut,\n tooltip = iconOnly || Boolean(shortcut),\n className,\n ...props\n },\n ref,\n ) => {\n const primaryContext = React.useContext(PrimaryActionContext);\n const primary = primaryProp ?? primaryContext;\n const button = (\n <Button\n ref={ref}\n aria-keyshortcuts={shortcut}\n aria-label={label}\n className={cn('[&_svg]:stroke-2!', className)}\n size={iconOnly ? 'icon' : undefined}\n variant={primary ? 'default' : 'ghost'}\n {...props}\n />\n );\n // A labelled action already shows its name, so its shortcut tooltip shows the keys alone.\n const tooltipLabel = iconOnly || !shortcut ? label : undefined;\n return primary || !tooltip ? (\n button\n ) : (\n <PageHeaderTooltip label={tooltipLabel} shortcut={shortcut}>\n <TooltipTrigger asChild>{button}</TooltipTrigger>\n </PageHeaderTooltip>\n );\n },\n);\nPageHeaderAction.displayName = 'PageHeaderAction';\n\nconst PageHeaderFilterTrigger = React.forwardRef<\n HTMLButtonElement,\n Omit<PageHeaderActionProps, 'label'>\n>((props, ref) => (\n <PageHeaderAction\n ref={ref}\n data-slot=\"filters-add\"\n label=\"Filter\"\n shortcut=\"F\"\n type=\"button\"\n {...props}\n >\n <ListFilter className=\"size-4\" />\n Filter\n </PageHeaderAction>\n));\nPageHeaderFilterTrigger.displayName = 'PageHeaderFilterTrigger';\n\nconst PageHeaderSelectTrigger = React.forwardRef<\n React.ElementRef<typeof SelectTrigger>,\n React.ComponentPropsWithoutRef<typeof SelectTrigger> & { label: string; tooltip?: boolean }\n>(({ label, tooltip = true, className, ...props }, ref) => {\n const { controlShape } = useShade();\n const trigger = (\n <SelectTrigger\n ref={ref}\n aria-label={label}\n className={cn(\n 'w-auto gap-1.5 font-medium [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2! [&>svg]:mr-0',\n className,\n )}\n shape={controlShape}\n showChevron={false}\n variant=\"ghost\"\n {...props}\n />\n );\n return tooltip ? (\n <PageHeaderTooltip label={label}>\n <TooltipTrigger asChild>{trigger}</TooltipTrigger>\n </PageHeaderTooltip>\n ) : (\n trigger\n );\n});\nPageHeaderSelectTrigger.displayName = 'PageHeaderSelectTrigger';\n\n// ---------------------------------------------------------------------------\n// Title-block primitives\n// ---------------------------------------------------------------------------\n\n// Crumbs truncate rather than wrapping under the title or running under the\n// actions. They render as blocks, since a flex link can't show an ellipsis.\n// Earlier crumbs keep their width up to a cap, so a long one can't crowd out\n// the current page, which shrinks to fit the rest.\nconst breadcrumbFitClassName =\n 'min-w-0 [&_nav]:min-w-0 [&_ol]:flex-nowrap [&_li]:shrink-0 [&_li>*]:block [&_li>*]:truncate [&_li:not(:last-child)>*]:max-w-40 [&_li:last-child]:min-w-0 [&_li:last-child]:shrink';\n\nfunction PageHeaderBreadcrumb({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <Inline\n align=\"center\"\n className={cn('pt-1 text-sm text-muted-foreground', breadcrumbFitClassName, className)}\n data-page-header=\"breadcrumb\"\n gap=\"sm\"\n >\n {children}\n </Inline>\n );\n}\n\nfunction PageHeaderCount({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <Text\n as=\"span\"\n className={cn('ml-1 text-base tabular-nums', className)}\n data-page-header=\"count\"\n tone=\"secondary\"\n weight=\"regular\"\n >\n {children}\n </Text>\n );\n}\n\nfunction PageHeaderDescription({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <Text as=\"p\" className={className} data-page-header=\"description\" size=\"sm\" tone=\"secondary\">\n {children}\n </Text>\n );\n}\n\nfunction PageHeaderMeta({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <Text\n as=\"p\"\n className={cn('mt-0.5', className)}\n data-page-header=\"meta\"\n size=\"sm\"\n tone=\"secondary\"\n >\n {children}\n </Text>\n );\n}\n\n/**\n * `Title` accepts heading text plus optional `Count`, `Description`, and `Meta`\n * children. `Count` flows inline inside the H1; `Description` and `Meta` stack\n * below the heading.\n */\nfunction PageHeaderTitle({ className, children }: PropsWithChildrenAndClassName) {\n const largeTitle = React.useContext(PageHeaderLargeTitleContext);\n const registerLargeTitle = largeTitle?.registerTitle;\n React.useLayoutEffect(() => registerLargeTitle?.(), [registerLargeTitle]);\n\n const headingChildren: React.ReactNode[] = [];\n const subTextChildren: React.ReactNode[] = [];\n\n React.Children.forEach(children, (child) => {\n if (!React.isValidElement(child)) {\n headingChildren.push(child);\n return;\n }\n\n switch (child.type) {\n case PageHeaderDescription:\n case PageHeaderMeta:\n subTextChildren.push(child);\n break;\n default:\n headingChildren.push(child);\n }\n });\n\n // Shown large above the page's header, the title is that heading; the one\n // in the header is a stand-in, fading in as the header takes over\n if (largeTitle) {\n return (\n <>\n <H1\n aria-hidden=\"true\"\n className={cn(\n 'large-title-header-title text-lg font-semibold tracking-[0.1px] whitespace-nowrap',\n className,\n )}\n data-page-header=\"title\"\n >\n {headingChildren}\n </H1>\n {largeTitle.slot &&\n createPortal(\n <Stack data-page-header=\"large-title\" gap=\"none\">\n <H1\n className=\"flex items-baseline gap-3 font-medium tracking-[-0.03em] whitespace-nowrap [&_[data-page-header=count]]:tracking-normal\"\n data-large-title=\"\"\n // Inline, over Text's own line height\n style={{ fontSize: 'var(--large-title-size)', lineHeight: 1.15 }}\n >\n {headingChildren}\n </H1>\n {subTextChildren}\n </Stack>,\n largeTitle.slot,\n )}\n </>\n );\n }\n\n const heading = (\n <H1\n className={cn('text-lg font-semibold tracking-[0.1px] whitespace-nowrap', className)}\n data-page-header=\"title\"\n >\n {headingChildren}\n </H1>\n );\n\n if (subTextChildren.length > 0) {\n return (\n <Stack data-page-header=\"title-body\" gap=\"none\">\n {heading}\n {subTextChildren}\n </Stack>\n );\n }\n\n return heading;\n}\n\n// ---------------------------------------------------------------------------\n// Main row — Left (stack: Breadcrumb + Title) + Actions\n// ---------------------------------------------------------------------------\n\nfunction PageHeaderLeft({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <Stack\n className={cn('h-full min-h-(--control-height) min-w-0', className)}\n data-page-header=\"left\"\n gap=\"xs\"\n justify=\"center\"\n >\n {children}\n </Stack>\n );\n}\n\ntype PageHeaderActionGroupPrimaryProps = PropsWithChildrenAndClassName;\nfunction PageHeaderActionGroupPrimary({ children, className }: PageHeaderActionGroupPrimaryProps) {\n if (React.Children.toArray(children).length === 0) {\n return null;\n }\n return (\n <PrimaryActionContext.Provider value={true}>\n <Inline\n className={cn('ms-3 shrink-0 first:ms-0', className)}\n data-page-header=\"primary\"\n gap=\"none\"\n >\n {children}\n </Inline>\n </PrimaryActionContext.Provider>\n );\n}\n\ntype PageHeaderActionGroupMobileMenuProps = React.PropsWithChildren;\nfunction PageHeaderActionGroupMobileMenu({ children }: PageHeaderActionGroupMobileMenuProps) {\n return <DropdownMenu>{children}</DropdownMenu>;\n}\n\ntype PageHeaderActionGroupMobileMenuTriggerProps = React.ComponentPropsWithoutRef<\n typeof DropdownMenuTrigger\n>;\nfunction PageHeaderActionGroupMobileMenuTrigger({\n children,\n ...props\n}: PageHeaderActionGroupMobileMenuTriggerProps) {\n return (\n <DropdownMenuTrigger asChild {...props}>\n {children}\n </DropdownMenuTrigger>\n );\n}\n\ntype PageHeaderActionGroupMobileMenuContentProps = React.ComponentPropsWithoutRef<\n typeof DropdownMenuContent\n>;\nfunction PageHeaderActionGroupMobileMenuContent({\n children,\n ...props\n}: PageHeaderActionGroupMobileMenuContentProps) {\n return (\n <DropdownMenuContent align=\"end\" sideOffset={8} {...props}>\n {children}\n </DropdownMenuContent>\n );\n}\n\nconst DEFAULT_MOBILE_MENU_BREAKPOINT = 640;\n\nconst isBelowBreakpoint = (breakpoint: number) => {\n if (typeof window === 'undefined') {\n return false;\n }\n\n return window.innerWidth < breakpoint;\n};\n\nconst useShouldCollapseActionGroup = (breakpoint: number) => {\n const [shouldCollapse, setShouldCollapse] = React.useState(() => isBelowBreakpoint(breakpoint));\n\n React.useEffect(() => {\n const onResize = () => {\n setShouldCollapse(isBelowBreakpoint(breakpoint));\n };\n\n onResize();\n window.addEventListener('resize', onResize);\n\n return () => {\n window.removeEventListener('resize', onResize);\n };\n }, [breakpoint]);\n\n return shouldCollapse;\n};\n\ntype PageHeaderActionGroupProps = PropsWithChildrenAndClassName & {\n mobileMenuBreakpoint?: number;\n};\ntype PageHeaderActionGroupComponent = React.FC<PageHeaderActionGroupProps> & {\n Primary: React.FC<PageHeaderActionGroupPrimaryProps>;\n MobileMenu: React.FC<PageHeaderActionGroupMobileMenuProps>;\n MobileMenuTrigger: React.FC<PageHeaderActionGroupMobileMenuTriggerProps>;\n MobileMenuContent: React.FC<PageHeaderActionGroupMobileMenuContentProps>;\n};\n\nconst PageHeaderActionGroup: PageHeaderActionGroupComponent = Object.assign(\n function PageHeaderActionGroup({\n className,\n children,\n mobileMenuBreakpoint = DEFAULT_MOBILE_MENU_BREAKPOINT,\n }: PageHeaderActionGroupProps) {\n const gap = 'sm';\n const childNodes = React.Children.toArray(children);\n const desktopChildren: React.ReactNode[] = [];\n let mobileMenu: React.ReactElement | null = null;\n let primaryAction: React.ReactNode = null;\n const shouldCollapse = useShouldCollapseActionGroup(mobileMenuBreakpoint);\n\n childNodes.forEach((child) => {\n if (!React.isValidElement(child)) {\n desktopChildren.push(child);\n return;\n }\n\n const childElement = child as React.ReactElement<{ children?: React.ReactNode }>;\n\n if (childElement.type === PageHeaderActionGroupMobileMenu) {\n mobileMenu = childElement;\n return;\n }\n\n if (childElement.type === PageHeaderActionGroupPrimary) {\n primaryAction = childElement;\n desktopChildren.push(childElement);\n return;\n }\n\n desktopChildren.push(childElement);\n });\n\n if (!mobileMenu) {\n return (\n <HeaderTooltipProvider>\n <Inline\n align=\"center\"\n className={className}\n data-page-header=\"action-group\"\n gap={gap}\n justify=\"end\"\n >\n {children}\n </Inline>\n </HeaderTooltipProvider>\n );\n }\n\n if (!shouldCollapse) {\n return (\n <HeaderTooltipProvider>\n <Inline\n align=\"center\"\n className={className}\n data-page-header=\"action-group\"\n gap={gap}\n justify=\"end\"\n >\n <Inline align=\"center\" data-page-header=\"action-group-desktop\" gap={gap} justify=\"end\">\n {desktopChildren}\n </Inline>\n </Inline>\n </HeaderTooltipProvider>\n );\n }\n\n return (\n <HeaderTooltipProvider>\n <Inline\n align=\"center\"\n className={className}\n data-page-header=\"action-group\"\n gap={gap}\n justify=\"end\"\n >\n <Inline\n align=\"center\"\n className=\"ml-auto\"\n data-page-header=\"action-group-mobile\"\n gap={gap}\n >\n {mobileMenu}\n {primaryAction}\n </Inline>\n </Inline>\n </HeaderTooltipProvider>\n );\n },\n {\n Primary: PageHeaderActionGroupPrimary,\n MobileMenu: PageHeaderActionGroupMobileMenu,\n MobileMenuTrigger: PageHeaderActionGroupMobileMenuTrigger,\n MobileMenuContent: PageHeaderActionGroupMobileMenuContent,\n },\n);\n\nfunction PageHeaderActions({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <HeaderTooltipProvider>\n <Inline\n align=\"center\"\n className={cn('min-h-(--control-height) shrink-0', className)}\n data-page-header=\"actions\"\n gap=\"lg\"\n >\n {children}\n </Inline>\n </HeaderTooltipProvider>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Root\n// ---------------------------------------------------------------------------\n\ntype PageHeaderComponent = React.FC<PageHeaderProps> & {\n Left: React.FC<PropsWithChildrenAndClassName>;\n Breadcrumb: React.FC<PropsWithChildrenAndClassName>;\n Title: React.FC<PropsWithChildrenAndClassName>;\n Count: React.FC<PropsWithChildrenAndClassName>;\n Description: React.FC<PropsWithChildrenAndClassName>;\n Meta: React.FC<PropsWithChildrenAndClassName>;\n Actions: React.FC<PropsWithChildrenAndClassName>;\n ActionGroup: PageHeaderActionGroupComponent;\n Action: typeof PageHeaderAction;\n FilterTrigger: typeof PageHeaderFilterTrigger;\n SelectTrigger: typeof PageHeaderSelectTrigger;\n Tooltip: typeof PageHeaderTooltip;\n TooltipTrigger: typeof TooltipTrigger;\n};\n\n/**\n * PageHeader is the canonical page-chrome component for Ghost Admin pages.\n *\n * The main row contains `Left` (Breadcrumb + Title) and `Actions`.\n * Compose optional ViewBar and FilterBar rows beside it in ListPage.Header.\n * `Title` accepts an inline `Count` and stacked `Description`/`Meta` children.\n * See the design contract for the action ordering and interaction rules:\n * https://shade.ghost.org/docs/components/patterns/page-header.md (generated from page-header.mdx).\n */\nconst PageHeader: PageHeaderComponent = Object.assign(\n function PageHeader({\n className,\n children,\n sticky = true,\n blurredBackground = true,\n }: PageHeaderProps) {\n return (\n <header\n className={cn(\n 'flex flex-col',\n sticky && 'sticky top-[var(--ghost-safe-area-inset-top,0px)] z-50',\n blurredBackground &&\n 'bg-gradient-to-b from-background via-background/70 to-background/70 backdrop-blur-md',\n className,\n )}\n data-page-header=\"page-header\"\n >\n <Inline align=\"start\" className=\"w-full\" data-page-header=\"main\" gap=\"lg\" justify=\"between\">\n {children}\n </Inline>\n </header>\n );\n },\n {\n Left: PageHeaderLeft,\n Breadcrumb: PageHeaderBreadcrumb,\n Title: PageHeaderTitle,\n Count: PageHeaderCount,\n Description: PageHeaderDescription,\n Meta: PageHeaderMeta,\n Actions: PageHeaderActions,\n ActionGroup: PageHeaderActionGroup,\n Action: PageHeaderAction,\n FilterTrigger: PageHeaderFilterTrigger,\n SelectTrigger: PageHeaderSelectTrigger,\n Tooltip: PageHeaderTooltip,\n TooltipTrigger,\n },\n);\n\nexport {\n PageHeader,\n PageHeaderLeft,\n PageHeaderBreadcrumb,\n PageHeaderTitle,\n PageHeaderCount,\n PageHeaderDescription,\n PageHeaderMeta,\n PageHeaderActions,\n PageHeaderActionGroup,\n PageHeaderActionGroupPrimary,\n PageHeaderActionGroupMobileMenu,\n PageHeaderActionGroupMobileMenuTrigger,\n PageHeaderActionGroupMobileMenuContent,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiCA,SAAS,kBAAkB,EACzB,UACA,OACA,YACiE;CACjE,OACE,qBAAC,SAAD,EAAA,UAAA,CACG,UACD,oBAAC,gBAAD;EAAgB,MAAK;EAAS,SAAQ;YACpC,qBAAC,QAAD;GAAQ,OAAM;GAAS,KAAI;aAA3B,CACG,OACA,YAAY,oBAAC,KAAD,EAAA,UAAM,SAAc,CAAA,CAC3B;;CACM,CAAA,CACT,EAAA,CAAA;AAEb;AAEA,IAAM,uBAAuB,MAAM,cAAc,KAAK;AAetD,IAAM,mBAAmB,MAAM,YAE3B,EACE,OACA,WAAW,OACX,SAAS,aACT,UACA,UAAU,YAAY,QAAQ,QAAQ,GACtC,WACA,GAAG,SAEL,QACG;CACH,MAAM,iBAAiB,MAAM,WAAW,oBAAoB;CAC5D,MAAM,UAAU,eAAe;CAC/B,MAAM,SACJ,oBAAC,QAAD;EACO;EACL,qBAAmB;EACnB,cAAY;EACZ,WAAW,GAAG,qBAAqB,SAAS;EAC5C,MAAM,WAAW,SAAS,KAA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F;AAEA,SAAS,kBAAkB,EAAE,WAAW,YAA2C;CACjF,OACE,oBAAC,uBAAD,EAAA,UACE,oBAAC,QAAD;EACE,OAAM;EACN,WAAW,GAAG,qCAAqC,SAAS;EAC5D,oBAAiB;EACjB,KAAI;EAEH;CACK,CAAA,EACa,CAAA;AAE3B;;;;;;;;;;AA+BA,IAAM,aAAkC,OAAO,OAC7C,SAAS,WAAW,EAClB,WACA,UACA,SAAS,MACT,oBAAoB,QACF;CAClB,OACE,oBAAC,UAAD;EACE,WAAW,GACT,iBACA,UAAU,0DACV,qBACE,wFACF,SACF;EACA,oBAAiB;YAEjB,oBAAC,QAAD;GAAQ,OAAM;GAAQ,WAAU;GAAS,oBAAiB;GAAO,KAAI;GAAK,SAAQ;GAC/E;EACK,CAAA;CACF,CAAA;AAEZ,GACA;CACE,MAAM;CACN,YAAY;CACZ,OAAO;CACP,OAAO;CACP,aAAa;CACb,MAAM;CACN,SAAS;CACT,aAAa;CACb,QAAQ;CACR,eAAe;CACf,eAAe;CACf,SAAS;CACT;AACF,CACF"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../../lib/ds-utils.js";
|
|
3
|
-
import { Dialog, DialogContent, DialogTitle } from "./dialog.js";
|
|
4
3
|
import { Check, Search } from "lucide-react";
|
|
5
4
|
import "react";
|
|
6
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -12,18 +11,6 @@ function Command({ className, ...props }) {
|
|
|
12
11
|
...props
|
|
13
12
|
});
|
|
14
13
|
}
|
|
15
|
-
var CommandDialog = ({ children, className, ...props }) => {
|
|
16
|
-
return /* @__PURE__ */ jsx(Dialog, {
|
|
17
|
-
...props,
|
|
18
|
-
children: /* @__PURE__ */ jsxs(DialogContent, {
|
|
19
|
-
className: cn("overflow-hidden p-0 shadow-lg", className),
|
|
20
|
-
children: [/* @__PURE__ */ jsx(DialogTitle, { className: "hidden" }), /* @__PURE__ */ jsx(Command, {
|
|
21
|
-
className: "[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:size-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:size-5",
|
|
22
|
-
children
|
|
23
|
-
})]
|
|
24
|
-
})
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
14
|
function CommandInput({ className, ...props }) {
|
|
28
15
|
return /* @__PURE__ */ jsxs("div", {
|
|
29
16
|
className: "flex items-center border-b border-border px-3",
|
|
@@ -86,6 +73,6 @@ function CommandCheck({ icon: Icon = Check, className, ...props }) {
|
|
|
86
73
|
});
|
|
87
74
|
}
|
|
88
75
|
//#endregion
|
|
89
|
-
export { Command, CommandCheck,
|
|
76
|
+
export { Command, CommandCheck, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut };
|
|
90
77
|
|
|
91
78
|
//# sourceMappingURL=command.js.map
|