@gridui/preferences 1.3.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -3
- package/dist/index.js +11 -5
- package/dist/index.js.map +2 -2
- package/dist/preferences-controls/menu.d.ts +3 -1
- package/dist/preferences-controls/types.d.ts +3 -0
- package/dist/styles.css +83 -77
- package/dist/styles.local.css +22 -6
- package/docs/catalog.json +5 -5
- package/docs/reference/preferences-controls.md +12 -2
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @gridui/preferences
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Controls family. Public API: `PreferenceLabels`, `PreferenceLanguage`, `PreferencesControls`, `PreferencesControlsProps`.
|
|
4
4
|
|
|
5
5
|
Import components from `@gridui/preferences` and load these styles in order:
|
|
6
6
|
|
|
@@ -13,7 +13,7 @@ Overlay supplies the selection indicator used by both presentations. The dropdow
|
|
|
13
13
|
presentation also composes DropdownMenu and Tooltip. Applications own routes,
|
|
14
14
|
labels, state persistence, and branding.
|
|
15
15
|
|
|
16
|
-
See [component ownership](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/docs/component-ownership.md) and [release history](https://github.com/sudo-ui/GridUI-React-Monorepo/tree/main/packages-
|
|
16
|
+
See [component ownership](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/docs/component-ownership.md) and [release history](https://github.com/sudo-ui/GridUI-React-Monorepo/tree/main/packages-controls/preferences/.changeset/history).
|
|
17
17
|
|
|
18
18
|
## Styles
|
|
19
19
|
|
|
@@ -55,5 +55,12 @@ GridUI does not translate or infer font assets from a locale.
|
|
|
55
55
|
## Local color scopes
|
|
56
56
|
|
|
57
57
|
Pass `portalContainer` to PreferencesControls to mount its dropdowns and tooltips
|
|
58
|
-
inside a `data-gridui-
|
|
58
|
+
inside a `data-gridui-color-variant` region. The default remains the document body.
|
|
59
59
|
Inline content continues inheriting from its actual DOM parent.
|
|
60
|
+
|
|
61
|
+
## Sizing and density
|
|
62
|
+
|
|
63
|
+
size controls owned inline choices, language links and dropdown triggers; it defaults to medium. density independently controls dropdown option rows and defaults to comfortable. These choices never infer locale policy, persistence or application state.
|
|
64
|
+
|
|
65
|
+
See the [shared sizing contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/docs/usage/sizing.md)
|
|
66
|
+
for native attributes, scope precedence, tokens and target behavior.
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Tooltip, TooltipContent, TooltipTrigger } from "@gridui/tooltip";
|
|
|
5
5
|
import { useState } from "react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
var PreferenceMenu = (props) => {
|
|
8
|
-
const { label, icon, children, selectionAppearance, container } = props;
|
|
8
|
+
const { label, icon, children, selectionAppearance, container, size = "medium", density = "comfortable" } = props;
|
|
9
9
|
const [
|
|
10
10
|
menuOpen,
|
|
11
11
|
setMenuOpen
|
|
@@ -39,7 +39,7 @@ var PreferenceMenu = (props) => {
|
|
|
39
39
|
Button,
|
|
40
40
|
{
|
|
41
41
|
variant: "quiet",
|
|
42
|
-
size
|
|
42
|
+
size,
|
|
43
43
|
layout: "icon",
|
|
44
44
|
"aria-label": label,
|
|
45
45
|
children: icon
|
|
@@ -61,6 +61,7 @@ var PreferenceMenu = (props) => {
|
|
|
61
61
|
/* @__PURE__ */ jsx(
|
|
62
62
|
DropdownMenuContent,
|
|
63
63
|
{
|
|
64
|
+
density,
|
|
64
65
|
container,
|
|
65
66
|
selectionAppearance,
|
|
66
67
|
children
|
|
@@ -90,7 +91,7 @@ var preferencesOptionsStyles = cva(cn(
|
|
|
90
91
|
"gridui-preferences-options",
|
|
91
92
|
"gridui-u-preferences--flex gridui-u-preferences--flex-wrap gridui-u-preferences--items-stretch gridui-u-preferences--gap-px gridui-u-preferences--border gridui-u-preferences--border-solid gridui-u-preferences--border-border gridui-u-preferences--rounded-control gridui-u-preferences--bg-border",
|
|
92
93
|
"gridui-u-preferences--*:flex-[1_1_auto] gridui-u-preferences--*:min-w-0 gridui-u-preferences--*:max-w-full gridui-u-preferences--*:rounded-none gridui-u-preferences--*:border-0 gridui-u-preferences--*:bg-background gridui-u-preferences--*:whitespace-normal gridui-u-preferences--*:wrap-anywhere",
|
|
93
|
-
"gridui-u-preferences--[&_>_a]:inline-flex gridui-u-preferences--[&_>_a]:min-h-gridui-
|
|
94
|
+
"gridui-u-preferences--[&_>_a]:inline-flex gridui-u-preferences--[&_>_a]:min-h-(--gridui-preferences-min) gridui-u-preferences--[&_>_a]:items-center gridui-u-preferences--[&_>_a]:justify-center gridui-u-preferences--[&_>_a]:gap-gridui-4 gridui-u-preferences--[&_>_a]:py-(--gridui-preferences-block) gridui-u-preferences--[&_>_a]:px-(--gridui-preferences-inline) gridui-u-preferences--[&_>_a]:text-foreground gridui-u-preferences--[&_>_a]:no-underline gridui-u-preferences--[&_>_a]:type-ui",
|
|
94
95
|
"gridui-u-preferences--*:aria-[current=page]:text-foreground gridui-u-preferences--*:aria-pressed:text-foreground"
|
|
95
96
|
), {
|
|
96
97
|
variants: {
|
|
@@ -128,6 +129,8 @@ var DropdownPreferences = (props) => {
|
|
|
128
129
|
/* @__PURE__ */ jsxs2(
|
|
129
130
|
PreferenceMenu,
|
|
130
131
|
{
|
|
132
|
+
size: props.size,
|
|
133
|
+
density: props.density,
|
|
131
134
|
container: portalContainer,
|
|
132
135
|
selectionAppearance,
|
|
133
136
|
label: labels.language,
|
|
@@ -155,6 +158,8 @@ var DropdownPreferences = (props) => {
|
|
|
155
158
|
/* @__PURE__ */ jsxs2(
|
|
156
159
|
PreferenceMenu,
|
|
157
160
|
{
|
|
161
|
+
size: props.size,
|
|
162
|
+
density: props.density,
|
|
158
163
|
container: portalContainer,
|
|
159
164
|
selectionAppearance,
|
|
160
165
|
label: labels.appearance,
|
|
@@ -216,10 +221,11 @@ import { THEME as THEME2 } from "@gridui/theme/theme";
|
|
|
216
221
|
import { Check } from "lucide-react";
|
|
217
222
|
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
218
223
|
var InlinePreferences = (props) => {
|
|
219
|
-
const { labels, theme, onThemeChange, languageLinks, selectionAppearance } = props;
|
|
224
|
+
const { labels, theme, onThemeChange, languageLinks, selectionAppearance, size = "medium" } = props;
|
|
220
225
|
return /* @__PURE__ */ jsxs3(
|
|
221
226
|
"div",
|
|
222
227
|
{
|
|
228
|
+
"data-size": size,
|
|
223
229
|
className: cn3(preferencesInlineStyles()),
|
|
224
230
|
children: [
|
|
225
231
|
/* @__PURE__ */ jsxs3(
|
|
@@ -270,7 +276,7 @@ var InlinePreferences = (props) => {
|
|
|
270
276
|
return /* @__PURE__ */ jsx3(
|
|
271
277
|
Button2,
|
|
272
278
|
{
|
|
273
|
-
size
|
|
279
|
+
size,
|
|
274
280
|
variant: "quiet",
|
|
275
281
|
"aria-pressed": theme === value,
|
|
276
282
|
endIcon: /* @__PURE__ */ jsx3(
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/preferences-controls/menu.tsx", "../src/preferences-controls/style.ts", "../src/preferences-controls/dropdown.tsx", "../src/preferences-controls/inline.tsx", "../src/preferences-controls/preferences-controls.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * @author WMXPY\n * @package Preferences\n * @namespace PreferencesControls\n * @description Menu\n */\n\nimport { Button } from \"@gridui/button\";\nimport { DropdownMenu, DropdownMenuContent, type DropdownMenuContentProps, DropdownMenuTrigger } from \"@gridui/dropdown-menu\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"@gridui/tooltip\";\nimport { type FC, type ReactNode, useState } from \"react\";\n\nexport type PreferenceMenuProps = Pick<DropdownMenuContentProps, \"selectionAppearance\" | \"container\"> & {\n readonly label: string;\n readonly icon: ReactNode;\n readonly children: ReactNode;\n};\n\nexport const PreferenceMenu: FC<PreferenceMenuProps> = (props: PreferenceMenuProps) => {\n const { label, icon, children, selectionAppearance, container } = props;\n const [\n menuOpen,\n setMenuOpen,\n ] = useState(false);\n const [\n hintOpen,\n setHintOpen,\n ] = useState(false);\n return (<DropdownMenu\n open={menuOpen}\n onOpenChange={(open) => {\n setMenuOpen(open);\n if (open) {\n setHintOpen(false);\n }\n }}\n >\n <Tooltip\n open={hintOpen && !menuOpen}\n onOpenChange={setHintOpen}\n >\n <TooltipTrigger>\n <DropdownMenuTrigger\n asChild\n >\n <Button\n variant=\"quiet\"\n size=\"small\"\n layout=\"icon\"\n aria-label={label}\n >\n {icon}\n </Button>\n </DropdownMenuTrigger>\n </TooltipTrigger>\n <TooltipContent\n container={container}\n align=\"end\"\n >\n {label}\n </TooltipContent>\n </Tooltip>\n <DropdownMenuContent\n container={container}\n selectionAppearance={selectionAppearance}\n >\n {children}\n </DropdownMenuContent>\n </DropdownMenu>);\n};\n", "/**\n * @author WMXPY\n * @package Preferences\n * @namespace PreferencesControls\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const preferencesStyles = cva(cn(\n \"gridui-preferences\",\n \"gridui-u-preferences--flex gridui-u-preferences--flex-wrap gridui-u-preferences--gap-gridui-8\",\n));\n\nexport const preferencesInlineStyles = cva(cn(\n \"gridui-preferences-inline\",\n \"gridui-u-preferences--grid gridui-u-preferences--gap-gridui-24\",\n));\n\nexport const preferencesLabelStyles = cva(cn(\n \"gridui-preferences-label\",\n \"gridui-u-preferences--m-0 gridui-u-preferences--text-muted gridui-u-preferences--type-caption\",\n));\n\nexport const preferencesOptionsStyles = cva(cn(\n \"gridui-preferences-options\",\n \"gridui-u-preferences--flex gridui-u-preferences--flex-wrap gridui-u-preferences--items-stretch gridui-u-preferences--gap-px gridui-u-preferences--border gridui-u-preferences--border-solid gridui-u-preferences--border-border gridui-u-preferences--rounded-control gridui-u-preferences--bg-border\",\n \"gridui-u-preferences--*:flex-[1_1_auto] gridui-u-preferences--*:min-w-0 gridui-u-preferences--*:max-w-full gridui-u-preferences--*:rounded-none gridui-u-preferences--*:border-0 gridui-u-preferences--*:bg-background gridui-u-preferences--*:whitespace-normal gridui-u-preferences--*:wrap-anywhere\",\n \"gridui-u-preferences--[&_>_a]:inline-flex gridui-u-preferences--[&_>_a]:min-h-gridui-control-small gridui-u-preferences--[&_>_a]:items-center gridui-u-preferences--[&_>_a]:justify-center gridui-u-preferences--[&_>_a]:gap-gridui-4 gridui-u-preferences--[&_>_a]:py-gridui-4 gridui-u-preferences--[&_>_a]:px-gridui-8 gridui-u-preferences--[&_>_a]:text-foreground gridui-u-preferences--[&_>_a]:no-underline gridui-u-preferences--[&_>_a]:type-ui\",\n \"gridui-u-preferences--*:aria-[current=page]:text-foreground gridui-u-preferences--*:aria-pressed:text-foreground\",\n), {\n variants: {\n selectionAppearance: {\n filled: \"gridui-u-preferences--*:aria-[current=page]:bg-selection-background gridui-u-preferences--*:aria-pressed:bg-selection-background\",\n indicator: \"\",\n },\n },\n defaultVariants: {\n selectionAppearance: \"filled\",\n },\n});\n", "/**\n * @author WMXPY\n * @package Preferences\n * @namespace PreferencesControls\n * @description Dropdown\n */\n\nimport { PreferenceMenu } from \"./menu\";\nimport { preferencesStyles } from \"./style\";\nimport type { PreferencesViewOptions } from \"./types\";\nimport { DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem } from \"@gridui/dropdown-menu\";\nimport { cn } from \"@gridui/style-utils\";\nimport { isTheme } from \"@gridui/theme/preference\";\nimport { THEME } from \"@gridui/theme/theme\";\nimport { TooltipProvider } from \"@gridui/tooltip\";\nimport { Globe, Laptop, Moon, Sun } from \"lucide-react\";\nimport type { FC } from \"react\";\n\nexport type DropdownPreferencesProps = PreferencesViewOptions;\n\nexport const DropdownPreferences: FC<DropdownPreferencesProps> = (props: DropdownPreferencesProps) => {\n const { labels, theme, onThemeChange, languageLinks, selectionAppearance, portalContainer } = props;\n const themeIcons = {\n system: Laptop,\n dark: Moon,\n light: Sun,\n };\n const ThemeIcon = themeIcons[theme];\n return (<TooltipProvider>\n <div\n className={cn(preferencesStyles())}\n >\n <PreferenceMenu\n container={portalContainer}\n selectionAppearance={selectionAppearance}\n label={labels.language}\n icon={(<Globe\n aria-hidden=\"true\"\n />)}\n >\n <DropdownMenuLabel>\n {labels.language}\n </DropdownMenuLabel>\n {languageLinks.map((link) => {\n return (<DropdownMenuItem\n key={link.key}\n asChild\n >\n {link}\n </DropdownMenuItem>);\n })}\n </PreferenceMenu>\n <PreferenceMenu\n container={portalContainer}\n selectionAppearance={selectionAppearance}\n label={labels.appearance}\n icon={(<ThemeIcon\n aria-hidden=\"true\"\n />)}\n >\n <DropdownMenuLabel>\n {labels.appearance}\n </DropdownMenuLabel>\n <DropdownMenuRadioGroup\n value={theme}\n onValueChange={(value) => {\n if (isTheme(value)) {\n onThemeChange(value);\n }\n }}\n >\n <DropdownMenuRadioItem\n value={THEME.SYSTEM}\n >\n {labels.system}\n </DropdownMenuRadioItem>\n <DropdownMenuRadioItem\n value={THEME.LIGHT}\n >\n {labels.light}\n </DropdownMenuRadioItem>\n <DropdownMenuRadioItem\n value={THEME.DARK}\n >\n {labels.dark}\n </DropdownMenuRadioItem>\n </DropdownMenuRadioGroup>\n </PreferenceMenu>\n </div>\n </TooltipProvider>);\n};\n", "/**\n * @author WMXPY\n * @package Preferences\n * @namespace PreferencesControls\n * @description Inline\n */\n\nimport { preferencesInlineStyles, preferencesLabelStyles, preferencesOptionsStyles } from \"./style\";\nimport type { PreferencesViewOptions } from \"./types\";\nimport { Button } from \"@gridui/button\";\nimport { overlayListIndicatorStyles } from \"@gridui/overlay\";\nimport { cn } from \"@gridui/style-utils\";\nimport { THEME } from \"@gridui/theme/theme\";\nimport { Check } from \"lucide-react\";\nimport type { FC } from \"react\";\n\nexport type InlinePreferencesProps = PreferencesViewOptions;\n\nexport const InlinePreferences: FC<InlinePreferencesProps> = (props: InlinePreferencesProps) => {\n const { labels, theme, onThemeChange, languageLinks, selectionAppearance } = props;\n return (<div\n className={cn(preferencesInlineStyles())}\n >\n <div\n role=\"group\"\n aria-label={labels.language}\n >\n <p\n className={cn(preferencesLabelStyles())}\n >\n {labels.language}\n </p>\n <div\n className={cn(preferencesOptionsStyles({ selectionAppearance }))}\n >\n {languageLinks}\n </div>\n </div>\n <div\n role=\"group\"\n aria-label={labels.appearance}\n >\n <p\n className={cn(preferencesLabelStyles())}\n >\n {labels.appearance}\n </p>\n <div\n className={cn(preferencesOptionsStyles({ selectionAppearance }))}\n >\n {([\n THEME.SYSTEM,\n THEME.LIGHT,\n THEME.DARK,\n ] as const).map((value) => {\n return (<Button\n key={value}\n size=\"small\"\n variant=\"quiet\"\n aria-pressed={theme === value}\n endIcon={(<span\n className={overlayListIndicatorStyles()}\n >\n {theme === value ? (<Check\n size={16}\n />) : null}\n </span>)}\n onClick={() => {\n return void onThemeChange(value);\n }}\n >\n {labels[value]}\n </Button>);\n })}\n </div>\n </div>\n </div>);\n};\n", "/**\n * @author WMXPY\n * @package Preferences\n * @namespace PreferencesControls\n * @description Preferences Controls\n */\n\nimport { DropdownPreferences } from \"./dropdown\";\nimport { InlinePreferences } from \"./inline\";\nimport type { PreferenceLanguage } from \"./language\";\nimport type { PreferencesOptions } from \"./types\";\nimport { overlayListIndicatorStyles } from \"@gridui/overlay\";\nimport { Check } from \"lucide-react\";\nimport type { FC } from \"react\";\n\nexport type PreferencesControlsProps = PreferencesOptions & {\n readonly presentation?: \"dropdown\" | \"inline\";\n readonly languages: readonly PreferenceLanguage[];\n};\n\nexport const PreferencesControls: FC<PreferencesControlsProps> = (props: PreferencesControlsProps) => {\n const { presentation = \"dropdown\", languages, ...options } = props;\n const languageLinks = languages.map((language) => {\n return (<a\n key={language.locale}\n href={language.href}\n hrefLang={language.locale}\n lang={language.locale}\n dir={language.dir ?? \"auto\"}\n aria-current={language.current ? \"page\" : undefined}\n onClick={language.onSelect}\n >\n <span\n className=\"gridui-u-preferences--min-w-0 gridui-u-preferences--flex-1\"\n >\n {language.label}\n </span>\n <span\n className={overlayListIndicatorStyles()}\n aria-hidden=\"true\"\n >\n {language.current ? (<Check\n size={16}\n />) : null}\n </span>\n </a>);\n });\n\n if (presentation === \"inline\") {\n return (<InlinePreferences\n {...options}\n languageLinks={languageLinks}\n />);\n }\n return (<DropdownPreferences\n {...options}\n languageLinks={languageLinks}\n />);\n};\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["/**\n * @author WMXPY\n * @package Preferences\n * @namespace PreferencesControls\n * @description Menu\n */\n\nimport type { Size } from \"@gridui/theme\";\nimport { Button } from \"@gridui/button\";\nimport { DropdownMenu, DropdownMenuContent, type DropdownMenuContentProps, DropdownMenuTrigger } from \"@gridui/dropdown-menu\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"@gridui/tooltip\";\nimport { type FC, type ReactNode, useState } from \"react\";\n\nexport type PreferenceMenuProps = Pick<DropdownMenuContentProps, \"selectionAppearance\" | \"container\" | \"density\"> & {\n readonly size?: Size | undefined;\n readonly label: string;\n readonly icon: ReactNode;\n readonly children: ReactNode;\n};\n\nexport const PreferenceMenu: FC<PreferenceMenuProps> = (props: PreferenceMenuProps) => {\n const { label, icon, children, selectionAppearance, container, size = \"medium\", density = \"comfortable\" } = props;\n const [\n menuOpen,\n setMenuOpen,\n ] = useState(false);\n const [\n hintOpen,\n setHintOpen,\n ] = useState(false);\n return (<DropdownMenu\n open={menuOpen}\n onOpenChange={(open) => {\n setMenuOpen(open);\n if (open) {\n setHintOpen(false);\n }\n }}\n >\n <Tooltip\n open={hintOpen && !menuOpen}\n onOpenChange={setHintOpen}\n >\n <TooltipTrigger>\n <DropdownMenuTrigger\n asChild\n >\n <Button\n variant=\"quiet\"\n size={size}\n layout=\"icon\"\n aria-label={label}\n >\n {icon}\n </Button>\n </DropdownMenuTrigger>\n </TooltipTrigger>\n <TooltipContent\n container={container}\n align=\"end\"\n >\n {label}\n </TooltipContent>\n </Tooltip>\n <DropdownMenuContent\n density={density}\n container={container}\n selectionAppearance={selectionAppearance}\n >\n {children}\n </DropdownMenuContent>\n </DropdownMenu>);\n};\n", "/**\n * @author WMXPY\n * @package Preferences\n * @namespace PreferencesControls\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const preferencesStyles = cva(cn(\n \"gridui-preferences\",\n \"gridui-u-preferences--flex gridui-u-preferences--flex-wrap gridui-u-preferences--gap-gridui-8\",\n));\n\nexport const preferencesInlineStyles = cva(cn(\n \"gridui-preferences-inline\",\n \"gridui-u-preferences--grid gridui-u-preferences--gap-gridui-24\",\n));\n\nexport const preferencesLabelStyles = cva(cn(\n \"gridui-preferences-label\",\n \"gridui-u-preferences--m-0 gridui-u-preferences--text-muted gridui-u-preferences--type-caption\",\n));\n\nexport const preferencesOptionsStyles = cva(cn(\n \"gridui-preferences-options\",\n \"gridui-u-preferences--flex gridui-u-preferences--flex-wrap gridui-u-preferences--items-stretch gridui-u-preferences--gap-px gridui-u-preferences--border gridui-u-preferences--border-solid gridui-u-preferences--border-border gridui-u-preferences--rounded-control gridui-u-preferences--bg-border\",\n \"gridui-u-preferences--*:flex-[1_1_auto] gridui-u-preferences--*:min-w-0 gridui-u-preferences--*:max-w-full gridui-u-preferences--*:rounded-none gridui-u-preferences--*:border-0 gridui-u-preferences--*:bg-background gridui-u-preferences--*:whitespace-normal gridui-u-preferences--*:wrap-anywhere\",\n \"gridui-u-preferences--[&_>_a]:inline-flex gridui-u-preferences--[&_>_a]:min-h-(--gridui-preferences-min) gridui-u-preferences--[&_>_a]:items-center gridui-u-preferences--[&_>_a]:justify-center gridui-u-preferences--[&_>_a]:gap-gridui-4 gridui-u-preferences--[&_>_a]:py-(--gridui-preferences-block) gridui-u-preferences--[&_>_a]:px-(--gridui-preferences-inline) gridui-u-preferences--[&_>_a]:text-foreground gridui-u-preferences--[&_>_a]:no-underline gridui-u-preferences--[&_>_a]:type-ui\",\n \"gridui-u-preferences--*:aria-[current=page]:text-foreground gridui-u-preferences--*:aria-pressed:text-foreground\",\n), {\n variants: {\n selectionAppearance: {\n filled: \"gridui-u-preferences--*:aria-[current=page]:bg-selection-background gridui-u-preferences--*:aria-pressed:bg-selection-background\",\n indicator: \"\",\n },\n },\n defaultVariants: {\n selectionAppearance: \"filled\",\n },\n});\n", "/**\n * @author WMXPY\n * @package Preferences\n * @namespace PreferencesControls\n * @description Dropdown\n */\n\nimport { PreferenceMenu } from \"./menu\";\nimport { preferencesStyles } from \"./style\";\nimport type { PreferencesViewOptions } from \"./types\";\nimport { DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem } from \"@gridui/dropdown-menu\";\nimport { cn } from \"@gridui/style-utils\";\nimport { isTheme } from \"@gridui/theme/preference\";\nimport { THEME } from \"@gridui/theme/theme\";\nimport { TooltipProvider } from \"@gridui/tooltip\";\nimport { Globe, Laptop, Moon, Sun } from \"lucide-react\";\nimport type { FC } from \"react\";\n\nexport type DropdownPreferencesProps = PreferencesViewOptions;\n\nexport const DropdownPreferences: FC<DropdownPreferencesProps> = (props: DropdownPreferencesProps) => {\n const { labels, theme, onThemeChange, languageLinks, selectionAppearance, portalContainer } = props;\n const themeIcons = {\n system: Laptop,\n dark: Moon,\n light: Sun,\n };\n const ThemeIcon = themeIcons[theme];\n return (<TooltipProvider>\n <div\n className={cn(preferencesStyles())}\n >\n <PreferenceMenu\n size={props.size}\n density={props.density}\n container={portalContainer}\n selectionAppearance={selectionAppearance}\n label={labels.language}\n icon={(<Globe\n aria-hidden=\"true\"\n />)}\n >\n <DropdownMenuLabel>\n {labels.language}\n </DropdownMenuLabel>\n {languageLinks.map((link) => {\n return (<DropdownMenuItem\n key={link.key}\n asChild\n >\n {link}\n </DropdownMenuItem>);\n })}\n </PreferenceMenu>\n <PreferenceMenu\n size={props.size}\n density={props.density}\n container={portalContainer}\n selectionAppearance={selectionAppearance}\n label={labels.appearance}\n icon={(<ThemeIcon\n aria-hidden=\"true\"\n />)}\n >\n <DropdownMenuLabel>\n {labels.appearance}\n </DropdownMenuLabel>\n <DropdownMenuRadioGroup\n value={theme}\n onValueChange={(value) => {\n if (isTheme(value)) {\n onThemeChange(value);\n }\n }}\n >\n <DropdownMenuRadioItem\n value={THEME.SYSTEM}\n >\n {labels.system}\n </DropdownMenuRadioItem>\n <DropdownMenuRadioItem\n value={THEME.LIGHT}\n >\n {labels.light}\n </DropdownMenuRadioItem>\n <DropdownMenuRadioItem\n value={THEME.DARK}\n >\n {labels.dark}\n </DropdownMenuRadioItem>\n </DropdownMenuRadioGroup>\n </PreferenceMenu>\n </div>\n </TooltipProvider>);\n};\n", "/**\n * @author WMXPY\n * @package Preferences\n * @namespace PreferencesControls\n * @description Inline\n */\n\nimport { preferencesInlineStyles, preferencesLabelStyles, preferencesOptionsStyles } from \"./style\";\nimport type { PreferencesViewOptions } from \"./types\";\nimport { Button } from \"@gridui/button\";\nimport { overlayListIndicatorStyles } from \"@gridui/overlay\";\nimport { cn } from \"@gridui/style-utils\";\nimport { THEME } from \"@gridui/theme/theme\";\nimport { Check } from \"lucide-react\";\nimport type { FC } from \"react\";\n\nexport type InlinePreferencesProps = PreferencesViewOptions;\n\nexport const InlinePreferences: FC<InlinePreferencesProps> = (props: InlinePreferencesProps) => {\n const { labels, theme, onThemeChange, languageLinks, selectionAppearance, size = \"medium\" } = props;\n return (<div\n data-size={size}\n className={cn(preferencesInlineStyles())}\n >\n <div\n role=\"group\"\n aria-label={labels.language}\n >\n <p\n className={cn(preferencesLabelStyles())}\n >\n {labels.language}\n </p>\n <div\n className={cn(preferencesOptionsStyles({ selectionAppearance }))}\n >\n {languageLinks}\n </div>\n </div>\n <div\n role=\"group\"\n aria-label={labels.appearance}\n >\n <p\n className={cn(preferencesLabelStyles())}\n >\n {labels.appearance}\n </p>\n <div\n className={cn(preferencesOptionsStyles({ selectionAppearance }))}\n >\n {([\n THEME.SYSTEM,\n THEME.LIGHT,\n THEME.DARK,\n ] as const).map((value) => {\n return (<Button\n key={value}\n size={size}\n variant=\"quiet\"\n aria-pressed={theme === value}\n endIcon={(<span\n className={overlayListIndicatorStyles()}\n >\n {theme === value ? (<Check\n size={16}\n />) : null}\n </span>)}\n onClick={() => {\n return void onThemeChange(value);\n }}\n >\n {labels[value]}\n </Button>);\n })}\n </div>\n </div>\n </div>);\n};\n", "/**\n * @author WMXPY\n * @package Preferences\n * @namespace PreferencesControls\n * @description Preferences Controls\n */\n\nimport { DropdownPreferences } from \"./dropdown\";\nimport { InlinePreferences } from \"./inline\";\nimport type { PreferenceLanguage } from \"./language\";\nimport type { PreferencesOptions } from \"./types\";\nimport { overlayListIndicatorStyles } from \"@gridui/overlay\";\nimport { Check } from \"lucide-react\";\nimport type { FC } from \"react\";\n\nexport type PreferencesControlsProps = PreferencesOptions & {\n readonly presentation?: \"dropdown\" | \"inline\";\n readonly languages: readonly PreferenceLanguage[];\n};\n\nexport const PreferencesControls: FC<PreferencesControlsProps> = (props: PreferencesControlsProps) => {\n const { presentation = \"dropdown\", languages, ...options } = props;\n const languageLinks = languages.map((language) => {\n return (<a\n key={language.locale}\n href={language.href}\n hrefLang={language.locale}\n lang={language.locale}\n dir={language.dir ?? \"auto\"}\n aria-current={language.current ? \"page\" : undefined}\n onClick={language.onSelect}\n >\n <span\n className=\"gridui-u-preferences--min-w-0 gridui-u-preferences--flex-1\"\n >\n {language.label}\n </span>\n <span\n className={overlayListIndicatorStyles()}\n aria-hidden=\"true\"\n >\n {language.current ? (<Check\n size={16}\n />) : null}\n </span>\n </a>);\n });\n\n if (presentation === \"inline\") {\n return (<InlinePreferences\n {...options}\n languageLinks={languageLinks}\n />);\n }\n return (<DropdownPreferences\n {...options}\n languageLinks={languageLinks}\n />);\n};\n"],
|
|
5
|
+
"mappings": ";AAQA,SAAS,cAAc;AACvB,SAAS,cAAc,qBAAoD,2BAA2B;AACtG,SAAS,SAAS,gBAAgB,sBAAsB;AACxD,SAAkC,gBAAgB;AA4B1C,S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C,SAAS,SAAAC,cAAa;AAWN,SASJ,OAAAC,MATI,QAAAC,aAAA;AAHT,IAAM,sBAAoD,CAAC,UAAoC;AAClG,QAAM,EAAE,eAAe,YAAY,WAAW,GAAG,QAAQ,IAAI;AAC7D,QAAM,gBAAgB,UAAU,IAAI,CAAC,aAAa;AAC9C,WAAQ,gBAAAA;AAAA,MAAC;AAAA;AAAA,QAEL,MAAM,SAAS;AAAA,QACf,UAAU,SAAS;AAAA,QACnB,MAAM,SAAS;AAAA,QACf,KAAK,SAAS,OAAO;AAAA,QACrB,gBAAc,SAAS,UAAU,SAAS;AAAA,QAC1C,SAAS,SAAS;AAAA,QAElB;AAAA,0BAAAD;AAAA,YAAC;AAAA;AAAA,cACG,WAAU;AAAA,cAET,mBAAS;AAAA;AAAA,UACd;AAAA,UACA,gBAAAA;AAAA,YAAC;AAAA;AAAA,cACG,WAAWF,4BAA2B;AAAA,cACtC,eAAY;AAAA,cAEX,mBAAS,UAAW,gBAAAE;AAAA,gBAACD;AAAA,gBAAA;AAAA,kBAClB,MAAM;AAAA;AAAA,cACV,IAAM;AAAA;AAAA,UACV;AAAA;AAAA;AAAA,MApBK,SAAS;AAAA,IAqBlB;AAAA,EACJ,CAAC;AAED,MAAI,iBAAiB,UAAU;AAC3B,WAAQ,gBAAAC;AAAA,MAAC;AAAA;AAAA,QACJ,GAAG;AAAA,QACJ;AAAA;AAAA,IACJ;AAAA,EACJ;AACA,SAAQ,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACJ,GAAG;AAAA,MACJ;AAAA;AAAA,EACJ;AACJ;",
|
|
6
6
|
"names": ["cn", "jsx", "jsxs", "Button", "cn", "THEME", "jsx", "jsxs", "overlayListIndicatorStyles", "Check", "jsx", "jsxs"]
|
|
7
7
|
}
|
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
* @namespace PreferencesControls
|
|
5
5
|
* @description Menu
|
|
6
6
|
*/
|
|
7
|
+
import type { Size } from "@gridui/theme";
|
|
7
8
|
import { type DropdownMenuContentProps } from "@gridui/dropdown-menu";
|
|
8
9
|
import { type FC, type ReactNode } from "react";
|
|
9
|
-
export type PreferenceMenuProps = Pick<DropdownMenuContentProps, "selectionAppearance" | "container"> & {
|
|
10
|
+
export type PreferenceMenuProps = Pick<DropdownMenuContentProps, "selectionAppearance" | "container" | "density"> & {
|
|
11
|
+
readonly size?: Size | undefined;
|
|
10
12
|
readonly label: string;
|
|
11
13
|
readonly icon: ReactNode;
|
|
12
14
|
readonly children: ReactNode;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* @namespace PreferencesControls
|
|
5
5
|
* @description Types
|
|
6
6
|
*/
|
|
7
|
+
import type { Size, Density } from "@gridui/theme";
|
|
7
8
|
import type { DropdownMenuContentProps } from "@gridui/dropdown-menu";
|
|
8
9
|
import type { THEME } from "@gridui/theme/theme";
|
|
9
10
|
import type { ReactElement } from "react";
|
|
@@ -15,6 +16,8 @@ export type PreferenceLabels = {
|
|
|
15
16
|
readonly dark: string;
|
|
16
17
|
};
|
|
17
18
|
export type PreferencesOptions = {
|
|
19
|
+
readonly size?: Size | undefined;
|
|
20
|
+
readonly density?: Density | undefined;
|
|
18
21
|
readonly portalContainer?: DropdownMenuContentProps["container"];
|
|
19
22
|
/** Selection presentation for language and theme options in both dropdown and inline layouts. */
|
|
20
23
|
readonly selectionAppearance?: DropdownMenuContentProps["selectionAppearance"];
|
package/dist/styles.css
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
/*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */
|
|
2
2
|
@layer properties;
|
|
3
3
|
@layer theme, base, components, utilities;
|
|
4
|
-
@layer theme {
|
|
5
|
-
:root, :host {
|
|
6
|
-
--spacing: 0.25rem;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
4
|
@layer utilities {
|
|
10
5
|
.gridui-u-button--pointer-events-none {
|
|
11
6
|
pointer-events: none;
|
|
@@ -13,24 +8,13 @@
|
|
|
13
8
|
.gridui-u-button--inline-flex {
|
|
14
9
|
display: inline-flex;
|
|
15
10
|
}
|
|
11
|
+
.gridui-u-button--size-\(--_gridui-button-min\) {
|
|
12
|
+
width: var(--_gridui-button-min);
|
|
13
|
+
height: var(--_gridui-button-min);
|
|
14
|
+
}
|
|
16
15
|
.gridui-u-button--h-full {
|
|
17
16
|
height: 100%;
|
|
18
17
|
}
|
|
19
|
-
.gridui-u-button--h-gridui-control {
|
|
20
|
-
height: var(--gridui-control-min-height);
|
|
21
|
-
}
|
|
22
|
-
.gridui-u-button--min-h-18 {
|
|
23
|
-
min-height: calc(var(--spacing) * 18);
|
|
24
|
-
}
|
|
25
|
-
.gridui-u-button--min-h-gridui-control {
|
|
26
|
-
min-height: var(--gridui-control-min-height);
|
|
27
|
-
}
|
|
28
|
-
.gridui-u-button--min-h-gridui-control-large {
|
|
29
|
-
min-height: var(--gridui-control-min-height-large);
|
|
30
|
-
}
|
|
31
|
-
.gridui-u-button--min-h-gridui-control-small {
|
|
32
|
-
min-height: var(--gridui-control-min-height-small);
|
|
33
|
-
}
|
|
34
18
|
.gridui-u-button--w-fit {
|
|
35
19
|
width: fit-content;
|
|
36
20
|
}
|
|
@@ -40,14 +24,14 @@
|
|
|
40
24
|
.gridui-u-button--w-gridui-64 {
|
|
41
25
|
width: var(--gridui-space-64);
|
|
42
26
|
}
|
|
43
|
-
.gridui-u-button--w-gridui-control {
|
|
44
|
-
width: var(--gridui-control-min-height);
|
|
45
|
-
}
|
|
46
27
|
.gridui-u-button--w-gridui-control-large {
|
|
47
|
-
width: var(--gridui-control-min-height-large);
|
|
28
|
+
width: max(var(--gridui-control-min-height-large), var(--gridui-target-min-size));
|
|
29
|
+
}
|
|
30
|
+
.gridui-u-button--w-gridui-control-medium {
|
|
31
|
+
width: max(var(--gridui-control-min-height-medium), var(--gridui-target-min-size));
|
|
48
32
|
}
|
|
49
33
|
.gridui-u-button--w-gridui-control-small {
|
|
50
|
-
width: var(--gridui-control-min-height-small);
|
|
34
|
+
width: max(var(--gridui-control-min-height-small), var(--gridui-target-min-size));
|
|
51
35
|
}
|
|
52
36
|
.gridui-u-button--max-w-full {
|
|
53
37
|
max-width: 100%;
|
|
@@ -253,35 +237,10 @@
|
|
|
253
237
|
.gridui-u-button--\[\&_svg\]\:shrink-0 svg {
|
|
254
238
|
flex-shrink: 0;
|
|
255
239
|
}
|
|
256
|
-
.gridui-u-button--\[\&\.gridui-button-extra-large\]\:h-18.gridui-button-extra-large {
|
|
257
|
-
height: calc(var(--spacing) * 18);
|
|
258
|
-
}
|
|
259
|
-
.gridui-u-button--\[\&\.gridui-button-extra-large\]\:w-18.gridui-button-extra-large {
|
|
260
|
-
width: calc(var(--spacing) * 18);
|
|
261
|
-
}
|
|
262
|
-
.gridui-u-button--\[\&\.gridui-button-large\]\:h-gridui-control-large.gridui-button-large {
|
|
263
|
-
height: var(--gridui-control-min-height-large);
|
|
264
|
-
}
|
|
265
|
-
.gridui-u-button--\[\&\.gridui-button-large\]\:w-gridui-control-large.gridui-button-large {
|
|
266
|
-
width: var(--gridui-control-min-height-large);
|
|
267
|
-
}
|
|
268
|
-
.gridui-u-button--\[\&\.gridui-button-small\]\:h-gridui-control-small.gridui-button-small {
|
|
269
|
-
height: var(--gridui-control-min-height-small);
|
|
270
|
-
}
|
|
271
|
-
.gridui-u-button--\[\&\.gridui-button-small\]\:w-gridui-control-small.gridui-button-small {
|
|
272
|
-
width: var(--gridui-control-min-height-small);
|
|
273
|
-
}
|
|
274
|
-
@media (pointer: coarse) {
|
|
275
|
-
.gridui-u-button--pointer-coarse\:\[\&\.gridui-button-small\]\:h-gridui-control.gridui-button-small {
|
|
276
|
-
height: var(--gridui-control-min-height);
|
|
277
|
-
}
|
|
278
|
-
.gridui-u-button--pointer-coarse\:\[\&\.gridui-button-small\]\:w-gridui-control.gridui-button-small {
|
|
279
|
-
width: var(--gridui-control-min-height);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
240
|
}
|
|
283
241
|
@layer components {
|
|
284
242
|
.gridui-button {
|
|
243
|
+
min-height: var(--_gridui-button-min);
|
|
285
244
|
border: 1px solid transparent;
|
|
286
245
|
}
|
|
287
246
|
.gridui-button-cell {
|
|
@@ -327,8 +286,27 @@
|
|
|
327
286
|
transform: var(--gridui-motion-transform, translate(calc(-1 * var(--gridui-space-4)), calc(-1 * var(--gridui-space-4))));
|
|
328
287
|
}
|
|
329
288
|
}
|
|
289
|
+
.gridui-button-medium {
|
|
290
|
+
--_gridui-button-min: max(var(--gridui-control-min-height-medium), var(--gridui-target-min-size));
|
|
291
|
+
padding-block: var(--gridui-space-8);
|
|
292
|
+
padding-inline: var(--gridui-space-16);
|
|
293
|
+
}
|
|
294
|
+
.gridui-button-small {
|
|
295
|
+
--_gridui-button-min: max(var(--gridui-control-min-height-small), var(--gridui-target-min-size));
|
|
296
|
+
padding-block: var(--gridui-space-4);
|
|
297
|
+
padding-inline: var(--gridui-space-8);
|
|
298
|
+
}
|
|
299
|
+
.gridui-button-large {
|
|
300
|
+
--_gridui-button-min: max(var(--gridui-control-min-height-large), var(--gridui-target-min-size));
|
|
301
|
+
padding-block: var(--gridui-space-8);
|
|
302
|
+
padding-inline: var(--gridui-space-24);
|
|
303
|
+
}
|
|
304
|
+
.gridui-button-extra-large {
|
|
305
|
+
--_gridui-button-min: max(var(--gridui-control-min-height-extra-large), var(--gridui-target-min-size));
|
|
306
|
+
padding-block: var(--gridui-space-16);
|
|
307
|
+
padding-inline: var(--gridui-space-24);
|
|
308
|
+
}
|
|
330
309
|
.gridui-button-group {
|
|
331
|
-
--gridui-button-group-padding-block: var(--gridui-space-24);
|
|
332
310
|
container: gridui-button-group / inline-size;
|
|
333
311
|
min-width: 0;
|
|
334
312
|
}
|
|
@@ -371,12 +349,19 @@
|
|
|
371
349
|
min-width: 0;
|
|
372
350
|
}
|
|
373
351
|
.gridui-button-group-items[data-layout="cells"] > [data-gridui-button-group-item] {
|
|
374
|
-
|
|
375
|
-
padding: var(--gridui-button-group-padding-block) var(--gridui-space-24);
|
|
352
|
+
padding-block: var(--gridui-button-group-padding-block, var(--_gridui-button-group-block, var(--gridui-space-8)));
|
|
376
353
|
border: 0;
|
|
377
354
|
border-radius: 0;
|
|
378
355
|
}
|
|
379
356
|
}
|
|
357
|
+
@layer components {
|
|
358
|
+
.gridui-button-group-items > [data-size="small"] {
|
|
359
|
+
--_gridui-button-group-block: var(--gridui-space-4);
|
|
360
|
+
}
|
|
361
|
+
.gridui-button-group-items > [data-size="extra-large"] {
|
|
362
|
+
--_gridui-button-group-block: var(--gridui-space-16);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
380
365
|
@property --tw-border-style {
|
|
381
366
|
syntax: "*";
|
|
382
367
|
inherits: false;
|
|
@@ -403,11 +388,6 @@
|
|
|
403
388
|
/*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */
|
|
404
389
|
@layer properties;
|
|
405
390
|
@layer theme, base, components, utilities;
|
|
406
|
-
@layer theme {
|
|
407
|
-
:root, :host {
|
|
408
|
-
--spacing: 0.25rem;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
391
|
@layer utilities {
|
|
412
392
|
.gridui-u-overlay--z-\(--gridui-z-popover\) {
|
|
413
393
|
z-index: var(--gridui-z-popover);
|
|
@@ -422,9 +402,6 @@
|
|
|
422
402
|
width: var(--gridui-space-16);
|
|
423
403
|
height: var(--gridui-space-16);
|
|
424
404
|
}
|
|
425
|
-
.gridui-u-overlay--min-h-10 {
|
|
426
|
-
min-height: calc(var(--spacing) * 10);
|
|
427
|
-
}
|
|
428
405
|
.gridui-u-overlay--min-w-0 {
|
|
429
406
|
min-width: 0px;
|
|
430
407
|
}
|
|
@@ -463,15 +440,9 @@
|
|
|
463
440
|
.gridui-u-overlay--p-0 {
|
|
464
441
|
padding: 0px;
|
|
465
442
|
}
|
|
466
|
-
.gridui-u-overlay--p-gridui-8 {
|
|
467
|
-
padding: var(--gridui-space-8);
|
|
468
|
-
}
|
|
469
443
|
.gridui-u-overlay--px-gridui-8 {
|
|
470
444
|
padding-inline: var(--gridui-space-8);
|
|
471
445
|
}
|
|
472
|
-
.gridui-u-overlay--py-gridui-8 {
|
|
473
|
-
padding-block: var(--gridui-space-8);
|
|
474
|
-
}
|
|
475
446
|
.gridui-u-overlay--type-data {
|
|
476
447
|
font: var(--gridui-type-data);
|
|
477
448
|
font-family: var(--gridui-font-body);
|
|
@@ -578,6 +549,25 @@
|
|
|
578
549
|
animation: none;
|
|
579
550
|
}
|
|
580
551
|
}
|
|
552
|
+
.gridui-overlay-list {
|
|
553
|
+
--gridui-overlay-row-min: var(--gridui-control-min-height-medium);
|
|
554
|
+
--gridui-overlay-row-padding: var(--gridui-space-8);
|
|
555
|
+
}
|
|
556
|
+
.gridui-overlay-density-compact {
|
|
557
|
+
--gridui-overlay-row-min: var(--gridui-control-min-height-small);
|
|
558
|
+
--gridui-overlay-row-padding: var(--gridui-space-4);
|
|
559
|
+
}
|
|
560
|
+
.gridui-overlay-density-comfortable {
|
|
561
|
+
--gridui-overlay-row-min: var(--gridui-control-min-height-medium);
|
|
562
|
+
--gridui-overlay-row-padding: var(--gridui-space-8);
|
|
563
|
+
}
|
|
564
|
+
.gridui-overlay-list-item {
|
|
565
|
+
min-block-size: max(var(--gridui-overlay-row-min, var(--gridui-control-min-height-medium)), var(--gridui-target-min-size));
|
|
566
|
+
padding-block: var(--gridui-overlay-row-padding, var(--gridui-space-8));
|
|
567
|
+
}
|
|
568
|
+
.gridui-overlay-list-label {
|
|
569
|
+
padding-block: var(--gridui-overlay-row-padding, var(--gridui-space-8));
|
|
570
|
+
}
|
|
581
571
|
}
|
|
582
572
|
@property --tw-border-style {
|
|
583
573
|
syntax: "*";
|
|
@@ -632,16 +622,16 @@
|
|
|
632
622
|
.gridui-dropdown-content {
|
|
633
623
|
--gridui-overlay-origin: var(--radix-dropdown-menu-content-transform-origin);
|
|
634
624
|
}
|
|
635
|
-
.gridui-dropdown-content[data-morph-measuring][data-state="open"] {
|
|
625
|
+
.gridui-dropdown-content[data-morph-measuring][data-state="open"][data-side] {
|
|
636
626
|
animation: none;
|
|
637
627
|
}
|
|
638
628
|
@supports (clip-path: inset(0)) {
|
|
639
|
-
.gridui-dropdown-content[data-morph-ready][data-state="open"] {
|
|
629
|
+
.gridui-dropdown-content[data-morph-ready][data-state="open"][data-side] {
|
|
640
630
|
animation: var(--gridui-motion-animation, gridui-menu-morph calc(var(--gridui-motion-duration-normal) * var(--gridui-motion-factor, 1)) var(--gridui-motion-ease-out));
|
|
641
631
|
}
|
|
642
632
|
}
|
|
643
633
|
@media (prefers-reduced-motion: reduce) {
|
|
644
|
-
.gridui-dropdown-content[data-morph-ready][data-state="open"] {
|
|
634
|
+
.gridui-dropdown-content[data-morph-ready][data-state="open"][data-side] {
|
|
645
635
|
animation: none;
|
|
646
636
|
}
|
|
647
637
|
}
|
|
@@ -791,8 +781,8 @@
|
|
|
791
781
|
.gridui-u-preferences--\[\&_\>_a\]\:inline-flex > a {
|
|
792
782
|
display: inline-flex;
|
|
793
783
|
}
|
|
794
|
-
.gridui-u-preferences--\[\&_\>_a\]\:min-h
|
|
795
|
-
min-height: var(--gridui-
|
|
784
|
+
.gridui-u-preferences--\[\&_\>_a\]\:min-h-\(--gridui-preferences-min\) > a {
|
|
785
|
+
min-height: var(--gridui-preferences-min);
|
|
796
786
|
}
|
|
797
787
|
.gridui-u-preferences--\[\&_\>_a\]\:items-center > a {
|
|
798
788
|
align-items: center;
|
|
@@ -803,11 +793,11 @@
|
|
|
803
793
|
.gridui-u-preferences--\[\&_\>_a\]\:gap-gridui-4 > a {
|
|
804
794
|
gap: var(--gridui-space-4);
|
|
805
795
|
}
|
|
806
|
-
.gridui-u-preferences--\[\&_\>_a\]\:px
|
|
807
|
-
padding-inline: var(--gridui-
|
|
796
|
+
.gridui-u-preferences--\[\&_\>_a\]\:px-\(--gridui-preferences-inline\) > a {
|
|
797
|
+
padding-inline: var(--gridui-preferences-inline);
|
|
808
798
|
}
|
|
809
|
-
.gridui-u-preferences--\[\&_\>_a\]\:py
|
|
810
|
-
padding-block: var(--gridui-
|
|
799
|
+
.gridui-u-preferences--\[\&_\>_a\]\:py-\(--gridui-preferences-block\) > a {
|
|
800
|
+
padding-block: var(--gridui-preferences-block);
|
|
811
801
|
}
|
|
812
802
|
.gridui-u-preferences--\[\&_\>_a\]\:type-ui > a {
|
|
813
803
|
font: var(--gridui-type-ui);
|
|
@@ -821,6 +811,22 @@
|
|
|
821
811
|
text-decoration-line: none;
|
|
822
812
|
}
|
|
823
813
|
}
|
|
814
|
+
@layer components {
|
|
815
|
+
[data-size].gridui-preferences-inline {
|
|
816
|
+
--gridui-preferences-min: max(var(--gridui-control-min-height-medium), var(--gridui-target-min-size));
|
|
817
|
+
--gridui-preferences-block: var(--gridui-space-8);
|
|
818
|
+
--gridui-preferences-inline: var(--gridui-space-16);
|
|
819
|
+
}
|
|
820
|
+
[data-size="small"].gridui-preferences-inline {
|
|
821
|
+
--gridui-preferences-min: max(var(--gridui-control-min-height-small), var(--gridui-target-min-size));
|
|
822
|
+
--gridui-preferences-block: var(--gridui-space-4);
|
|
823
|
+
--gridui-preferences-inline: var(--gridui-space-8);
|
|
824
|
+
}
|
|
825
|
+
[data-size="large"].gridui-preferences-inline {
|
|
826
|
+
--gridui-preferences-min: max(var(--gridui-control-min-height-large), var(--gridui-target-min-size));
|
|
827
|
+
--gridui-preferences-inline: var(--gridui-space-24);
|
|
828
|
+
}
|
|
829
|
+
}
|
|
824
830
|
@property --tw-border-style {
|
|
825
831
|
syntax: "*";
|
|
826
832
|
inherits: false;
|
package/dist/styles.local.css
CHANGED
|
@@ -97,8 +97,8 @@
|
|
|
97
97
|
.gridui-u-preferences--\[\&_\>_a\]\:inline-flex > a {
|
|
98
98
|
display: inline-flex;
|
|
99
99
|
}
|
|
100
|
-
.gridui-u-preferences--\[\&_\>_a\]\:min-h
|
|
101
|
-
min-height: var(--gridui-
|
|
100
|
+
.gridui-u-preferences--\[\&_\>_a\]\:min-h-\(--gridui-preferences-min\) > a {
|
|
101
|
+
min-height: var(--gridui-preferences-min);
|
|
102
102
|
}
|
|
103
103
|
.gridui-u-preferences--\[\&_\>_a\]\:items-center > a {
|
|
104
104
|
align-items: center;
|
|
@@ -109,11 +109,11 @@
|
|
|
109
109
|
.gridui-u-preferences--\[\&_\>_a\]\:gap-gridui-4 > a {
|
|
110
110
|
gap: var(--gridui-space-4);
|
|
111
111
|
}
|
|
112
|
-
.gridui-u-preferences--\[\&_\>_a\]\:px
|
|
113
|
-
padding-inline: var(--gridui-
|
|
112
|
+
.gridui-u-preferences--\[\&_\>_a\]\:px-\(--gridui-preferences-inline\) > a {
|
|
113
|
+
padding-inline: var(--gridui-preferences-inline);
|
|
114
114
|
}
|
|
115
|
-
.gridui-u-preferences--\[\&_\>_a\]\:py
|
|
116
|
-
padding-block: var(--gridui-
|
|
115
|
+
.gridui-u-preferences--\[\&_\>_a\]\:py-\(--gridui-preferences-block\) > a {
|
|
116
|
+
padding-block: var(--gridui-preferences-block);
|
|
117
117
|
}
|
|
118
118
|
.gridui-u-preferences--\[\&_\>_a\]\:type-ui > a {
|
|
119
119
|
font: var(--gridui-type-ui);
|
|
@@ -127,6 +127,22 @@
|
|
|
127
127
|
text-decoration-line: none;
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
+
@layer components {
|
|
131
|
+
[data-size].gridui-preferences-inline {
|
|
132
|
+
--gridui-preferences-min: max(var(--gridui-control-min-height-medium), var(--gridui-target-min-size));
|
|
133
|
+
--gridui-preferences-block: var(--gridui-space-8);
|
|
134
|
+
--gridui-preferences-inline: var(--gridui-space-16);
|
|
135
|
+
}
|
|
136
|
+
[data-size="small"].gridui-preferences-inline {
|
|
137
|
+
--gridui-preferences-min: max(var(--gridui-control-min-height-small), var(--gridui-target-min-size));
|
|
138
|
+
--gridui-preferences-block: var(--gridui-space-4);
|
|
139
|
+
--gridui-preferences-inline: var(--gridui-space-8);
|
|
140
|
+
}
|
|
141
|
+
[data-size="large"].gridui-preferences-inline {
|
|
142
|
+
--gridui-preferences-min: max(var(--gridui-control-min-height-large), var(--gridui-target-min-size));
|
|
143
|
+
--gridui-preferences-inline: var(--gridui-space-24);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
130
146
|
@property --tw-border-style {
|
|
131
147
|
syntax: "*";
|
|
132
148
|
inherits: false;
|
package/docs/catalog.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"name": "@gridui/preferences",
|
|
4
|
-
"version": "
|
|
5
|
-
"category": "
|
|
4
|
+
"version": "2.0.0",
|
|
5
|
+
"category": "controls",
|
|
6
6
|
"description": "GridUI React preferences",
|
|
7
7
|
"usage": "Overlay supplies the selection indicator used by both presentations. The dropdown presentation also composes DropdownMenu and Tooltip. Applications own routes, labels, state persistence, and branding.",
|
|
8
8
|
"documentation": [
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
],
|
|
43
43
|
"styledImport": "@gridui/preferences/styled",
|
|
44
44
|
"examples": [
|
|
45
|
-
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
46
|
-
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
47
|
-
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
45
|
+
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/preferences/stories/getting-started.mdx",
|
|
46
|
+
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/preferences/stories/preferences.mdx",
|
|
47
|
+
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/preferences/stories/preferences.stories.tsx"
|
|
48
48
|
]
|
|
49
49
|
}
|
|
@@ -11,14 +11,24 @@ import "@gridui/theme/styles.css";
|
|
|
11
11
|
import "@gridui/preferences/styles.css";
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
14
|
+
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/preferences/README.md) for shared behavior and stylesheet dependencies.
|
|
15
15
|
|
|
16
|
-
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-
|
|
16
|
+
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-controls/preferences/stories/preferences.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
|
|
17
17
|
|
|
18
18
|
## API
|
|
19
19
|
|
|
20
20
|
The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
|
|
21
21
|
|
|
22
|
+
### size
|
|
23
|
+
|
|
24
|
+
``Size | undefined`` · Optional
|
|
25
|
+
|
|
26
|
+
Component size preset.
|
|
27
|
+
|
|
28
|
+
### density
|
|
29
|
+
|
|
30
|
+
``Density | undefined`` · Optional
|
|
31
|
+
|
|
22
32
|
### portalContainer
|
|
23
33
|
|
|
24
34
|
``Element | DocumentFragment | null | undefined`` · Optional
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gridui/preferences",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "GridUI React preferences",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"react-dom": "^19.2.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@gridui/button": "^
|
|
36
|
-
"@gridui/dropdown-menu": "^
|
|
37
|
-
"@gridui/overlay": "^2.
|
|
38
|
-
"@gridui/style-utils": "^4.
|
|
39
|
-
"@gridui/theme": "^
|
|
40
|
-
"@gridui/tooltip": "^1.2.
|
|
35
|
+
"@gridui/button": "^6.0.0",
|
|
36
|
+
"@gridui/dropdown-menu": "^4.0.0",
|
|
37
|
+
"@gridui/overlay": "^2.5.0",
|
|
38
|
+
"@gridui/style-utils": "^4.1.0",
|
|
39
|
+
"@gridui/theme": "^5.0.0",
|
|
40
|
+
"@gridui/tooltip": "^1.2.1",
|
|
41
41
|
"class-variance-authority": "0.7.1",
|
|
42
|
-
"lucide-react": "1.
|
|
42
|
+
"lucide-react": "1.73.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@gridui-internal/configuration": "0.0.0-internal",
|