@tryghost/shade 0.1.0-alpha.2 → 0.1.0-alpha.20
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 +30 -64
- package/es/components/page-templates/list-page.js +2 -1
- package/es/components/page-templates/list-page.js.map +1 -1
- package/es/components/patterns/filter-bar.js +4 -6
- package/es/components/patterns/filter-bar.js.map +1 -1
- package/es/components/patterns/filters.js +35 -22
- package/es/components/patterns/filters.js.map +1 -1
- package/es/components/patterns/gh-chart.js +6 -3
- package/es/components/patterns/gh-chart.js.map +1 -1
- package/es/components/patterns/image-upload.js +1 -3
- package/es/components/patterns/image-upload.js.map +1 -1
- package/es/components/patterns/page-header.js +18 -43
- package/es/components/patterns/page-header.js.map +1 -1
- package/es/components/patterns/share-modal.js +3 -15
- package/es/components/patterns/share-modal.js.map +1 -1
- package/es/components/ui/alert-dialog.js +2 -4
- package/es/components/ui/alert-dialog.js.map +1 -1
- package/es/components/ui/avatar.js +8 -4
- package/es/components/ui/avatar.js.map +1 -1
- package/es/components/ui/badge-variants.js +1 -1
- package/es/components/ui/badge-variants.js.map +1 -1
- package/es/components/ui/banner-variants.js +4 -4
- package/es/components/ui/banner-variants.js.map +1 -1
- package/es/components/ui/button-variants.js +2 -33
- package/es/components/ui/button-variants.js.map +1 -1
- package/es/components/ui/button.js +1 -2
- package/es/components/ui/button.js.map +1 -1
- package/es/components/ui/calendar.js +5 -6
- package/es/components/ui/calendar.js.map +1 -1
- package/es/components/ui/chart.js +2 -29
- package/es/components/ui/chart.js.map +1 -1
- package/es/components/ui/combobox.js +2 -2
- package/es/components/ui/combobox.js.map +1 -1
- package/es/components/ui/copy-field.js +1 -3
- package/es/components/ui/copy-field.js.map +1 -1
- package/es/components/ui/data-list.js +1 -3
- package/es/components/ui/data-list.js.map +1 -1
- package/es/components/ui/dialog.js +32 -8
- package/es/components/ui/dialog.js.map +1 -1
- package/es/components/ui/dropzone-variants.js +1 -3
- package/es/components/ui/dropzone-variants.js.map +1 -1
- package/es/components/ui/dropzone.js +2 -2
- package/es/components/ui/dropzone.js.map +1 -1
- package/es/components/ui/floating-sidebar.js +4 -4
- package/es/components/ui/floating-sidebar.js.map +1 -1
- package/es/components/ui/image-overlay-button.js +2 -2
- package/es/components/ui/image-overlay-button.js.map +1 -1
- package/es/components/ui/input-group.js +2 -5
- package/es/components/ui/input-group.js.map +1 -1
- package/es/components/ui/navbar.js +1 -3
- package/es/components/ui/navbar.js.map +1 -1
- package/es/components/ui/pagemenu.js +33 -9
- package/es/components/ui/pagemenu.js.map +1 -1
- package/es/components/ui/select-variants.js +2 -10
- package/es/components/ui/select-variants.js.map +1 -1
- package/es/components/ui/select.js +1 -4
- package/es/components/ui/select.js.map +1 -1
- package/es/components/ui/simple-pagination.js +4 -7
- package/es/components/ui/simple-pagination.js.map +1 -1
- package/es/components/ui/sticky-footer.js +1 -1
- package/es/components/ui/sticky-footer.js.map +1 -1
- package/es/components/ui/toast.js +2 -0
- package/es/components/ui/toggle-group.js +1 -3
- package/es/components/ui/toggle-group.js.map +1 -1
- package/es/components/ui/toggle-variants.js +1 -7
- package/es/components/ui/toggle-variants.js.map +1 -1
- package/es/components/ui/toggle.js +1 -2
- package/es/components/ui/toggle.js.map +1 -1
- package/es/components/ui/token-field.js +2 -2
- package/es/components/ui/token-field.js.map +1 -1
- package/es/components/ui/tooltip.js +8 -17
- package/es/components/ui/tooltip.js.map +1 -1
- package/es/components.js +3 -2
- package/es/index.js +3 -2
- package/es/lib/date-utils.js +151 -0
- package/es/lib/date-utils.js.map +1 -0
- package/es/lib/ds-utils.js +16 -72
- package/es/lib/ds-utils.js.map +1 -1
- package/es/lib/utils.js +3 -2
- package/es/providers/header-tooltip-provider.js +1 -4
- package/es/providers/header-tooltip-provider.js.map +1 -1
- package/es/providers/shade-context.js +1 -1
- package/es/providers/shade-context.js.map +1 -1
- package/es/providers/shade-provider.js +3 -3
- package/es/providers/shade-provider.js.map +1 -1
- package/es/shade-app.js +3 -3
- package/es/shade-app.js.map +1 -1
- package/es/shade-scope.js +2 -2
- package/es/shade-scope.js.map +1 -1
- package/es/tokens.js +0 -8
- package/es/tokens.js.map +1 -1
- package/es/utils.js +3 -2
- package/package.json +6 -6
- package/styles.css +6 -0
- package/tailwind.theme.css +201 -187
- package/theme-variables.css +289 -42
- package/types/components/page-templates/list-page.d.ts +2 -1
- package/types/components/page-templates/list-page.d.ts.map +1 -1
- package/types/components/patterns/filter-bar.d.ts.map +1 -1
- package/types/components/patterns/filters.d.ts +2 -4
- package/types/components/patterns/filters.d.ts.map +1 -1
- package/types/components/patterns/gh-chart.d.ts.map +1 -1
- package/types/components/patterns/image-upload.d.ts.map +1 -1
- package/types/components/patterns/page-header.d.ts +6 -11
- package/types/components/patterns/page-header.d.ts.map +1 -1
- package/types/components/patterns/share-modal.d.ts +1 -1
- package/types/components/patterns/share-modal.d.ts.map +1 -1
- package/types/components/ui/avatar.d.ts.map +1 -1
- package/types/components/ui/button-variants.d.ts +0 -1
- package/types/components/ui/button-variants.d.ts.map +1 -1
- package/types/components/ui/button.d.ts +1 -1
- package/types/components/ui/button.d.ts.map +1 -1
- package/types/components/ui/calendar.d.ts.map +1 -1
- package/types/components/ui/chart.d.ts +1 -17
- package/types/components/ui/chart.d.ts.map +1 -1
- package/types/components/ui/combobox.d.ts.map +1 -1
- package/types/components/ui/copy-field.d.ts.map +1 -1
- package/types/components/ui/data-list.d.ts.map +1 -1
- package/types/components/ui/dialog.d.ts +11 -2
- package/types/components/ui/dialog.d.ts.map +1 -1
- package/types/components/ui/dropzone-variants.d.ts +1 -1
- package/types/components/ui/dropzone-variants.d.ts.map +1 -1
- package/types/components/ui/image-overlay-button.d.ts +1 -1
- package/types/components/ui/image-overlay-button.d.ts.map +1 -1
- package/types/components/ui/input-group.d.ts.map +1 -1
- package/types/components/ui/navbar.d.ts.map +1 -1
- package/types/components/ui/pagemenu.d.ts +3 -0
- package/types/components/ui/pagemenu.d.ts.map +1 -1
- package/types/components/ui/select-variants.d.ts +0 -1
- package/types/components/ui/select-variants.d.ts.map +1 -1
- package/types/components/ui/select.d.ts +1 -1
- package/types/components/ui/select.d.ts.map +1 -1
- package/types/components/ui/simple-pagination.d.ts.map +1 -1
- package/types/components/ui/toast.d.ts +2 -0
- package/types/components/ui/toast.d.ts.map +1 -0
- package/types/components/ui/toggle-group.d.ts +4 -6
- package/types/components/ui/toggle-group.d.ts.map +1 -1
- package/types/components/ui/toggle-variants.d.ts +0 -1
- package/types/components/ui/toggle-variants.d.ts.map +1 -1
- package/types/components/ui/toggle.d.ts +2 -3
- package/types/components/ui/toggle.d.ts.map +1 -1
- package/types/components/ui/token-field.d.ts +2 -2
- package/types/components/ui/token-field.d.ts.map +1 -1
- package/types/components/ui/tooltip.d.ts.map +1 -1
- package/types/components.d.ts +1 -0
- package/types/components.d.ts.map +1 -1
- package/types/lib/date-utils.d.ts +17 -0
- package/types/lib/date-utils.d.ts.map +1 -0
- package/types/lib/ds-utils.d.ts +2 -16
- package/types/lib/ds-utils.d.ts.map +1 -1
- package/types/lib/utils.d.ts +1 -0
- package/types/lib/utils.d.ts.map +1 -1
- package/types/providers/header-tooltip-provider.d.ts.map +1 -1
- package/types/providers/shade-context.d.ts +2 -1
- package/types/providers/shade-context.d.ts.map +1 -1
- package/types/providers/shade-provider.d.ts +1 -1
- package/types/providers/shade-provider.d.ts.map +1 -1
- package/types/shade-app.d.ts +5 -2
- package/types/shade-app.d.ts.map +1 -1
- package/types/tokens.d.ts +1 -1
- package/types/tokens.d.ts.map +1 -1
- package/types/utils.d.ts +2 -1
- package/types/utils.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
# Shade
|
|
2
2
|
|
|
3
|
-
Ghost
|
|
3
|
+
Shade is Ghost's design system for React apps: the tokens, layout primitives,
|
|
4
|
+
components, patterns and page templates that Ghost Admin is built with.
|
|
4
5
|
|
|
5
|
-
##
|
|
6
|
+
## Install in an app
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
`@tryghost/shade/styles.css` or add another `ShadeApp` wrapper. Import
|
|
10
|
-
components from their layer-specific subpaths:
|
|
8
|
+
These steps are for a standalone surface: an app that owns its page, rather
|
|
9
|
+
than one bundled into Ghost Admin.
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import {Button} from '@tryghost/shade/components';
|
|
16
|
-
|
|
17
|
-
export function Example() {
|
|
18
|
-
return <Button>Continue</Button>;
|
|
19
|
-
}
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## Usage in standalone surfaces
|
|
11
|
+
Building a Ghost app, which runs framed inside Admin? Follow
|
|
12
|
+
[Using Shade in a Ghost app](https://github.com/TryGhost/Ghost/blob/main/apps/shade/src/docs/ghost-apps.mdx)
|
|
13
|
+
instead: it also covers fonts, Admin's theme and the page frame.
|
|
23
14
|
|
|
24
15
|
Shade requires React 18 and Tailwind CSS 4.1+. The app compiles Shade's
|
|
25
16
|
`styles.css` together with its own styles using Tailwind's Vite or PostCSS
|
|
@@ -85,59 +76,34 @@ createRoot(document.getElementById('root')!).render(
|
|
|
85
76
|
`.dark` to `document.documentElement` and pass the same state to `ShadeApp` so
|
|
86
77
|
portalled menus and dialogs receive the theme too.
|
|
87
78
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
Admin's stylesheet and application wrapper instead.
|
|
79
|
+
Import from the layer subpaths, such as `@tryghost/shade/components` and
|
|
80
|
+
`@tryghost/shade/primitives`, never the root `@tryghost/shade`.
|
|
91
81
|
|
|
92
|
-
##
|
|
82
|
+
## Inside Ghost Admin
|
|
93
83
|
|
|
94
|
-
|
|
84
|
+
Shade is already set up. Ghost Admin provides Shade's CSS and the `ShadeApp`
|
|
85
|
+
wrapper centrally, so embedded Admin apps, including `apps/admin` and
|
|
86
|
+
`apps/activitypub`, must not import `@tryghost/shade/styles.css` or add another
|
|
87
|
+
`ShadeApp`. They only import components:
|
|
95
88
|
|
|
96
|
-
|
|
97
|
-
|
|
89
|
+
```tsx
|
|
90
|
+
import {Button} from '@tryghost/shade/components';
|
|
98
91
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
92
|
+
export function Example() {
|
|
93
|
+
return <Button>Continue</Button>;
|
|
94
|
+
}
|
|
102
95
|
```
|
|
103
96
|
|
|
104
|
-
|
|
105
|
-
`pnpm --filter @tryghost/shade <command>`.
|
|
106
|
-
|
|
107
|
-
Local docs with Storybook:
|
|
108
|
-
|
|
109
|
-
- `pnpm storybook` — run Storybook and view docs under `src/docs/`
|
|
110
|
-
- `pnpm build-storybook` — build a static export
|
|
111
|
-
- `pnpm build` — build the JavaScript and type declarations
|
|
112
|
-
|
|
113
|
-
### Source exports
|
|
114
|
-
|
|
115
|
-
Admin’s Vite development, production and test configurations select the `source`
|
|
116
|
-
export condition to load this package directly from `src/`. Changes reach Vite
|
|
117
|
-
without waiting for the library build. Consumers without that condition keep
|
|
118
|
-
using the compiled exports; TypeScript continues using the generated declarations.
|
|
119
|
-
The library build remains required for those consumers. Published exports only
|
|
120
|
-
refer to compiled modules and declarations; the workspace-only `source`
|
|
121
|
-
conditions are removed when packing.
|
|
122
|
-
|
|
123
|
-
## Test
|
|
124
|
-
|
|
125
|
-
- `pnpm test` — type-checks and runs Vitest with coverage
|
|
126
|
-
- `pnpm test:unit` — runs Vitest
|
|
127
|
-
- `pnpm test:types` — TypeScript only
|
|
128
|
-
- `pnpm lint` — ESLint for `src/` and `test/`
|
|
129
|
-
|
|
130
|
-
## Publishing
|
|
97
|
+
## Docs
|
|
131
98
|
|
|
132
|
-
Shade
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
`
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
release gates and the unchanged-package check.
|
|
99
|
+
Shade's docs are its Storybook: how to use tokens, primitives, components,
|
|
100
|
+
patterns and page templates, with live examples. Browse it at
|
|
101
|
+
[shade.ghost.org](https://shade.ghost.org), read the sources in
|
|
102
|
+
[`src/docs/`](https://github.com/TryGhost/Ghost/tree/main/apps/shade/src/docs)
|
|
103
|
+
on GitHub, or run it from a Ghost checkout with `pnpm storybook` in
|
|
104
|
+
`apps/shade`.
|
|
139
105
|
|
|
140
|
-
##
|
|
106
|
+
## Working on Shade?
|
|
141
107
|
|
|
142
|
-
|
|
143
|
-
|
|
108
|
+
See [CONTRIBUTING.md](https://github.com/TryGhost/Ghost/blob/main/apps/shade/CONTRIBUTING.md)
|
|
109
|
+
for development, layers, conventions, tests and publishing.
|
|
@@ -90,7 +90,8 @@ function ListPageBody({ className, children, ...rest }) {
|
|
|
90
90
|
* Composition:
|
|
91
91
|
* - `<ListPage.Header>` — sticky, blurred, full-bleed chrome band. Place
|
|
92
92
|
* `PageHeader`, `ViewBar`, and/or `FilterBar` directly inside as siblings.
|
|
93
|
-
* `FilterBar`
|
|
93
|
+
* `FilterBar` hides itself only when it has no children, so mount it
|
|
94
|
+
* while filters are active (`hasFilters && <FilterBar>…</FilterBar>`).
|
|
94
95
|
* - `<ListPage.Body>` — grows to fill remaining space. Use `flex-1 flex items-center justify-center`
|
|
95
96
|
* on the immediate child to vertically center empty/loading states.
|
|
96
97
|
*
|
|
@@ -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` auto-collapses when it has no active filters.\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: List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;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-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;IAC1B,eAAY;IACZ,WAAU;IACV,2BAAwB;IACxB,OAAO;KACL,QAAQ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,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"}
|
|
@@ -21,13 +21,13 @@ import { jsx } from "react/jsx-runtime";
|
|
|
21
21
|
* </FilterBar>
|
|
22
22
|
*/
|
|
23
23
|
function FilterBarRoot({ className, children }) {
|
|
24
|
-
const { controlShape
|
|
24
|
+
const { controlShape } = useShade();
|
|
25
25
|
if (React.Children.count(children) === 0) return null;
|
|
26
26
|
return /* @__PURE__ */ jsx(FilterBarContext.Provider, {
|
|
27
27
|
value: true,
|
|
28
28
|
children: /* @__PURE__ */ jsx(Inline, {
|
|
29
29
|
align: "start",
|
|
30
|
-
className: cn("relative w-full [&>[data-slot=filter-bar-actions]]:static",
|
|
30
|
+
className: cn("relative w-full [&>[data-slot=filter-bar-actions]]:static", "-mt-1 rounded-control bg-filter-bar-background p-2 [&_[data-slot=filter-item]>*]:bg-background! [&_[data-slot=filter-item]>*:hover]:bg-filter-bar-item-hover! [&_[data-slot=filter-item]>*[data-state=open]]:bg-filter-bar-item-hover! [&_[data-slot=filters-add]]:bg-transparent! [&_[data-slot=filters-add]:hover]:bg-tab-active!", className),
|
|
31
31
|
"data-control-shape": controlShape,
|
|
32
32
|
"data-slot": "filter-bar",
|
|
33
33
|
gap: "sm",
|
|
@@ -46,12 +46,10 @@ var FilterBarActions = React.forwardRef(({ className, gap = "sm", ...props }, re
|
|
|
46
46
|
FilterBarActions.displayName = "FilterBar.Actions";
|
|
47
47
|
var FilterBarAction = React.forwardRef(({ className, size, variant, ...props }, ref) => {
|
|
48
48
|
const isInFilterBar = useFilterBarContext();
|
|
49
|
-
const { isAdmin7 } = useShade();
|
|
50
|
-
const usePillFilterBarStyle = isInFilterBar && isAdmin7;
|
|
51
49
|
return /* @__PURE__ */ jsx(Button, {
|
|
52
50
|
ref,
|
|
53
|
-
className: cn(
|
|
54
|
-
size: size ?? (
|
|
51
|
+
className: cn(isInFilterBar && variant === "outline" && "bg-background", isInFilterBar && variant === "ghost" && "hover:bg-tab-active enabled:active:bg-tab-active", className),
|
|
52
|
+
size: size ?? (isInFilterBar ? "sm" : void 0),
|
|
55
53
|
variant,
|
|
56
54
|
...props
|
|
57
55
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-bar.js","names":[],"sources":["../../../src/components/patterns/filter-bar.tsx"],"sourcesContent":["import React from 'react';\nimport { Button, type ButtonProps } from '@/components/ui/button';\nimport { Inline, type InlineProps } from '@/components/primitives/inline';\nimport { FilterBarContext, useFilterBarContext } from '@/components/patterns/filter-bar-context';\nimport { cn } from '@/lib/utils';\nimport { useShade } from '@/providers/shade-context';\n\ntype FilterBarProps = React.PropsWithChildren & {\n className?: string;\n};\n\n/**\n * FilterBar is a full-width horizontal row for active filters and related\n * controls (clear, save view, etc.). It renders null when it has no children,\n * so consumers can always mount it without conditional wrapping.\n *\n * Typical usage:\n * <FilterBar>\n * <Filters ... />\n * <FilterBar.Actions>\n * <FilterBar.Action variant=\"ghost\">Clear</FilterBar.Action>\n * <FilterBar.Action variant=\"outline\">Save view</FilterBar.Action>\n * </FilterBar.Actions>\n * </FilterBar>\n */\nfunction FilterBarRoot({ className, children }: FilterBarProps) {\n const { controlShape
|
|
1
|
+
{"version":3,"file":"filter-bar.js","names":[],"sources":["../../../src/components/patterns/filter-bar.tsx"],"sourcesContent":["import React from 'react';\nimport { Button, type ButtonProps } from '@/components/ui/button';\nimport { Inline, type InlineProps } from '@/components/primitives/inline';\nimport { FilterBarContext, useFilterBarContext } from '@/components/patterns/filter-bar-context';\nimport { cn } from '@/lib/utils';\nimport { useShade } from '@/providers/shade-context';\n\ntype FilterBarProps = React.PropsWithChildren & {\n className?: string;\n};\n\n/**\n * FilterBar is a full-width horizontal row for active filters and related\n * controls (clear, save view, etc.). It renders null when it has no children,\n * so consumers can always mount it without conditional wrapping.\n *\n * Typical usage:\n * <FilterBar>\n * <Filters ... />\n * <FilterBar.Actions>\n * <FilterBar.Action variant=\"ghost\">Clear</FilterBar.Action>\n * <FilterBar.Action variant=\"outline\">Save view</FilterBar.Action>\n * </FilterBar.Actions>\n * </FilterBar>\n */\nfunction FilterBarRoot({ className, children }: FilterBarProps) {\n const { controlShape } = useShade();\n\n if (React.Children.count(children) === 0) {\n return null;\n }\n\n return (\n <FilterBarContext.Provider value={true}>\n <Inline\n align=\"start\"\n className={cn(\n 'relative w-full [&>[data-slot=filter-bar-actions]]:static',\n '-mt-1 rounded-control bg-filter-bar-background p-2 [&_[data-slot=filter-item]>*]:bg-background! [&_[data-slot=filter-item]>*:hover]:bg-filter-bar-item-hover! [&_[data-slot=filter-item]>*[data-state=open]]:bg-filter-bar-item-hover! [&_[data-slot=filters-add]]:bg-transparent! [&_[data-slot=filters-add]:hover]:bg-tab-active!',\n className,\n )}\n data-control-shape={controlShape}\n data-slot=\"filter-bar\"\n gap=\"sm\"\n justify=\"between\"\n >\n {children}\n </Inline>\n </FilterBarContext.Provider>\n );\n}\n\nconst FilterBarActions = React.forwardRef<HTMLElement, InlineProps>(\n ({ className, gap = 'sm', ...props }, ref) => (\n <Inline\n ref={ref}\n className={cn('shrink-0 sm:absolute sm:top-0 sm:right-0', className)}\n data-slot=\"filter-bar-actions\"\n gap={gap}\n {...props}\n />\n ),\n);\nFilterBarActions.displayName = 'FilterBar.Actions';\n\nconst FilterBarAction = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, size, variant, ...props }, ref) => {\n const isInFilterBar = useFilterBarContext();\n\n return (\n <Button\n ref={ref}\n className={cn(\n isInFilterBar && variant === 'outline' && 'bg-background',\n isInFilterBar &&\n variant === 'ghost' &&\n 'hover:bg-tab-active enabled:active:bg-tab-active',\n className,\n )}\n size={size ?? (isInFilterBar ? 'sm' : undefined)}\n variant={variant}\n {...props}\n />\n );\n },\n);\nFilterBarAction.displayName = 'FilterBar.Action';\n\nconst FilterBar = Object.assign(FilterBarRoot, {\n Actions: FilterBarActions,\n Action: FilterBarAction,\n});\n\nexport { FilterBar };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAS,cAAc,EAAE,WAAW,YAA4B;CAC9D,MAAM,EAAE,iBAAiB,SAAS;CAElC,IAAI,MAAM,SAAS,MAAM,QAAQ,MAAM,GACrC,OAAO;CAGT,OACE,oBAAC,iBAAiB,UAAlB;EAA2B,OAAO;YAChC,oBAAC,QAAD;GACE,OAAM;GACN,WAAW,GACT,6DACA,uUACA,SACF;GACA,sBAAoB;GACpB,aAAU;GACV,KAAI;GACJ,SAAQ;GAEP;EACK,CAAA;CACiB,CAAA;AAE/B;AAEA,IAAM,mBAAmB,MAAM,YAC5B,EAAE,WAAW,MAAM,MAAM,GAAG,SAAS,QACpC,oBAAC,QAAD;CACO;CACL,WAAW,GAAG,4CAA4C,SAAS;CACnE,aAAU;CACL;CACL,GAAI;AACL,CAAA,CAEL;AACA,iBAAiB,cAAc;AAE/B,IAAM,kBAAkB,MAAM,YAC3B,EAAE,WAAW,MAAM,SAAS,GAAG,SAAS,QAAQ;CAC/C,MAAM,gBAAgB,oBAAoB;CAE1C,OACE,oBAAC,QAAD;EACO;EACL,WAAW,GACT,iBAAiB,YAAY,aAAa,iBAC1C,iBACE,YAAY,WACZ,oDACF,SACF;EACA,MAAM,SAAS,gBAAgB,OAAO,KAAA;EAC7B;EACT,GAAI;CACL,CAAA;AAEL,CACF;AACA,gBAAgB,cAAc;AAE9B,IAAM,YAAY,OAAO,OAAO,eAAe;CAC7C,SAAS;CACT,QAAQ;AACV,CAAC"}
|
|
@@ -11,7 +11,7 @@ import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, Command
|
|
|
11
11
|
import { MultiSelectCombobox } from "../ui/multi-select-combobox.js";
|
|
12
12
|
import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover.js";
|
|
13
13
|
import { Switch } from "../ui/switch.js";
|
|
14
|
-
import { AlertCircle, Calendar, Check,
|
|
14
|
+
import { AlertCircle, Calendar, Check, FunnelPlus, ListFilterPlus, Loader2, Plus, X } from "lucide-react";
|
|
15
15
|
import { createContext, forwardRef, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
16
16
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
17
17
|
import { cva } from "class-variance-authority";
|
|
@@ -560,6 +560,14 @@ var flattenFields = (fields) => {
|
|
|
560
560
|
return [...acc, item];
|
|
561
561
|
}, []);
|
|
562
562
|
};
|
|
563
|
+
/**
|
|
564
|
+
* Whether a field's operator takes no value: `empty` and `not_empty` never do, nor do the
|
|
565
|
+
* operators a field lists as valueless, unless the field renders its operator inside its value.
|
|
566
|
+
*/
|
|
567
|
+
function takesNoValue(field, operator) {
|
|
568
|
+
if (operator === "empty" || operator === "not_empty") return true;
|
|
569
|
+
return field !== void 0 && !field.renderOperatorInValue && (field.valuelessOperators?.includes(operator) ?? false);
|
|
570
|
+
}
|
|
563
571
|
var getFieldsMap = (fields) => {
|
|
564
572
|
return flattenFields(fields).reduce((acc, field) => {
|
|
565
573
|
if (field.key) acc[field.key] = field;
|
|
@@ -1010,7 +1018,7 @@ function FilterValueSelector({ field, values, onChange, operator, onOperatorChan
|
|
|
1010
1018
|
useEffect(() => {
|
|
1011
1019
|
if (autoFocus) valueInputRef.current?.focus();
|
|
1012
1020
|
}, [autoFocus]);
|
|
1013
|
-
if (
|
|
1021
|
+
if (takesNoValue(field, operator)) return null;
|
|
1014
1022
|
if (field.customRenderer) {
|
|
1015
1023
|
if (field.renderOperatorInValue) return /* @__PURE__ */ jsx(Fragment$1, { children: field.customRenderer({
|
|
1016
1024
|
field,
|
|
@@ -1397,12 +1405,16 @@ var FiltersContent = ({ filters, fields, onChange }) => {
|
|
|
1397
1405
|
...filter,
|
|
1398
1406
|
...updates
|
|
1399
1407
|
};
|
|
1400
|
-
if (updates.operator
|
|
1408
|
+
if (updates.operator !== void 0 && takesNoValue(fieldsMap[filter.field], updates.operator)) updatedFilter.values = [];
|
|
1401
1409
|
return updatedFilter;
|
|
1402
1410
|
}
|
|
1403
1411
|
return filter;
|
|
1404
1412
|
}));
|
|
1405
|
-
}, [
|
|
1413
|
+
}, [
|
|
1414
|
+
filters,
|
|
1415
|
+
onChange,
|
|
1416
|
+
fieldsMap
|
|
1417
|
+
]);
|
|
1406
1418
|
const removeFilter = useCallback((filterId) => {
|
|
1407
1419
|
onChange(filters.filter((filter) => filter.id !== filterId));
|
|
1408
1420
|
}, [filters, onChange]);
|
|
@@ -1448,10 +1460,9 @@ var FiltersContent = ({ filters, fields, onChange }) => {
|
|
|
1448
1460
|
};
|
|
1449
1461
|
var FilterAddButton = forwardRef(({ className, label, icon, ...props }, ref) => {
|
|
1450
1462
|
const context = useFilterContext();
|
|
1451
|
-
const { controlShape
|
|
1463
|
+
const { controlShape } = useShade();
|
|
1452
1464
|
const isInFilterBar = useFilterBarContext();
|
|
1453
|
-
const
|
|
1454
|
-
const iconOnly = isPillFilterBar && context.hasFilters;
|
|
1465
|
+
const iconOnly = isInFilterBar && context.hasFilters;
|
|
1455
1466
|
const buttonLabel = label ?? context.addButtonText ?? context.i18n.addFilter;
|
|
1456
1467
|
return /* @__PURE__ */ jsxs("button", {
|
|
1457
1468
|
ref,
|
|
@@ -1461,7 +1472,7 @@ var FilterAddButton = forwardRef(({ className, label, icon, ...props }, ref) =>
|
|
|
1461
1472
|
size: context.size,
|
|
1462
1473
|
cursorPointer: context.cursorPointer,
|
|
1463
1474
|
radius: context.controlRadius
|
|
1464
|
-
}),
|
|
1475
|
+
}), isInFilterBar && "h-7 text-sm! [&_svg]:size-3", !isInFilterBar && "font-medium", iconOnly ? "aspect-square border-0 !px-0 shadow-none" : context.addButtonVariant === "ghost" || context.addButtonVariant === "secondary" ? "border-0 px-3 shadow-none active:shadow-none" : "border-0 px-3 shadow-control-outline active:shadow-control-outline-pressed", context.addButtonClassName, className),
|
|
1465
1476
|
"data-control-shape": controlShape,
|
|
1466
1477
|
"data-slot": "filters-add",
|
|
1467
1478
|
title: context.i18n.addFilterTitle,
|
|
@@ -1471,28 +1482,26 @@ var FilterAddButton = forwardRef(({ className, label, icon, ...props }, ref) =>
|
|
|
1471
1482
|
});
|
|
1472
1483
|
});
|
|
1473
1484
|
FilterAddButton.displayName = "FilterAddButton";
|
|
1474
|
-
var FiltersTrigger = forwardRef(({
|
|
1485
|
+
var FiltersTrigger = forwardRef(({ fallbackStyle = "list", className, ...props }, ref) => {
|
|
1475
1486
|
const { hasFilters, keyboardShortcut } = useFilterContext();
|
|
1476
|
-
|
|
1477
|
-
if (isAdmin7 && !hasFilters) return /* @__PURE__ */ jsx(PageHeader.FilterTrigger, {
|
|
1487
|
+
if (!hasFilters) return /* @__PURE__ */ jsx(PageHeader.FilterTrigger, {
|
|
1478
1488
|
ref,
|
|
1479
1489
|
className,
|
|
1480
1490
|
shortcut: keyboardShortcut?.toUpperCase(),
|
|
1481
1491
|
...props
|
|
1482
1492
|
});
|
|
1483
|
-
const iconStyle =
|
|
1484
|
-
const Icon = iconStyle === "list" ? hasFilters ? ListFilterPlus : ListFilter : hasFilters || fallbackStyle === "funnel-plus" ? FunnelPlus : Funnel;
|
|
1493
|
+
const iconStyle = fallbackStyle === "funnel-plus" ? "funnel-plus" : "list";
|
|
1485
1494
|
return /* @__PURE__ */ jsx(FilterAddButton, {
|
|
1486
1495
|
ref,
|
|
1487
|
-
className
|
|
1488
|
-
icon: /* @__PURE__ */ jsx(
|
|
1489
|
-
label:
|
|
1496
|
+
className,
|
|
1497
|
+
icon: /* @__PURE__ */ jsx(iconStyle === "list" ? ListFilterPlus : FunnelPlus, { className: iconStyle === "list" ? "size-4" : void 0 }),
|
|
1498
|
+
label: "Add filter",
|
|
1490
1499
|
...props
|
|
1491
1500
|
});
|
|
1492
1501
|
});
|
|
1493
1502
|
FiltersTrigger.displayName = "Filters.Trigger";
|
|
1494
1503
|
function Filters({ filters, fields, onChange, className, showAddButton = true, addButtonText, addButtonIcon, addButtonClassName, addButtonVariant, addButton, showClearButton = false, clearButtonText, clearButtonIcon, clearButtonClassName, clearButton, onClear, variant = "outline", size = "md", radius, i18n, showSearchInput = true, cursorPointer = true, trigger, allowMultiple = true, popoverContentClassName, popoverAlign = "start", keyboardShortcut, onActiveFieldChange }) {
|
|
1495
|
-
const { controlShape
|
|
1504
|
+
const { controlShape } = useShade();
|
|
1496
1505
|
const [addFilterOpen, setAddFilterOpen] = useState(false);
|
|
1497
1506
|
const [selectedFieldKeyForOptions, setSelectedFieldKeyForOptions] = useState(null);
|
|
1498
1507
|
const [tempSelectedValues, setTempSelectedValues] = useState([]);
|
|
@@ -1500,7 +1509,7 @@ function Filters({ filters, fields, onChange, className, showAddButton = true, a
|
|
|
1500
1509
|
const [fieldSearch, setFieldSearch] = useState("");
|
|
1501
1510
|
const [expandedGroups, setExpandedGroups] = useState(/* @__PURE__ */ new Set());
|
|
1502
1511
|
const filterRadius = radius ?? "md";
|
|
1503
|
-
const controlRadius = radius ??
|
|
1512
|
+
const controlRadius = radius ?? "full";
|
|
1504
1513
|
useEffect(() => {
|
|
1505
1514
|
onActiveFieldChange?.(selectedFieldKeyForOptions);
|
|
1506
1515
|
}, [selectedFieldKeyForOptions, onActiveFieldChange]);
|
|
@@ -1556,12 +1565,16 @@ function Filters({ filters, fields, onChange, className, showAddButton = true, a
|
|
|
1556
1565
|
...filter,
|
|
1557
1566
|
...updates
|
|
1558
1567
|
};
|
|
1559
|
-
if (updates.operator
|
|
1568
|
+
if (updates.operator !== void 0 && takesNoValue(fieldsMap[filter.field], updates.operator)) updatedFilter.values = [];
|
|
1560
1569
|
return updatedFilter;
|
|
1561
1570
|
}
|
|
1562
1571
|
return filter;
|
|
1563
1572
|
}));
|
|
1564
|
-
}, [
|
|
1573
|
+
}, [
|
|
1574
|
+
filters,
|
|
1575
|
+
onChange,
|
|
1576
|
+
fieldsMap
|
|
1577
|
+
]);
|
|
1565
1578
|
const removeFilter = useCallback((filterId) => {
|
|
1566
1579
|
onChange(filters.filter((filter) => filter.id !== filterId));
|
|
1567
1580
|
}, [filters, onChange]);
|
|
@@ -1693,7 +1706,7 @@ function Filters({ filters, fields, onChange, className, showAddButton = true, a
|
|
|
1693
1706
|
const field = fieldsMap[filter.field];
|
|
1694
1707
|
if (!field) return null;
|
|
1695
1708
|
return /* @__PURE__ */ jsxs("div", {
|
|
1696
|
-
className: cn(filterItemVariants({ variant }),
|
|
1709
|
+
className: cn(filterItemVariants({ variant }), "text-sm [--control-height:calc(var(--spacing)*7)] [&_*]:text-sm!"),
|
|
1697
1710
|
"data-slot": "filter-item",
|
|
1698
1711
|
children: [
|
|
1699
1712
|
/* @__PURE__ */ jsxs("div", {
|
|
@@ -1796,7 +1809,7 @@ function Filters({ filters, fields, onChange, className, showAddButton = true, a
|
|
|
1796
1809
|
size,
|
|
1797
1810
|
cursorPointer,
|
|
1798
1811
|
radius: controlRadius
|
|
1799
|
-
}),
|
|
1812
|
+
}), "h-7 text-sm! [&_svg]:size-3", "border-0 bg-transparent hover:bg-transparent hover:text-foreground", "px-3 shadow-control-outline active:shadow-control-outline-pressed", "sm:absolute sm:top-0 sm:right-0", clearButtonClassName),
|
|
1800
1813
|
"data-control-shape": controlShape,
|
|
1801
1814
|
type: "button",
|
|
1802
1815
|
onClick: () => {
|