@crisp-ui-kit/crisp 0.38.0 → 0.39.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/dist/cjs/components/contextmenu/contextmenu.js +1 -1
- package/dist/cjs/components/contextmenu/contextmenu.recipe.js +22 -10
- package/dist/cjs/components/menu/menu.js +1 -1
- package/dist/cjs/components/menu/menu.recipe.js +32 -20
- package/dist/cjs/components/multiselect/multiselect.js +1 -1
- package/dist/cjs/components/multiselect/multiselect.recipe.js +37 -22
- package/dist/cjs/components/popover/popover.js +1 -1
- package/dist/cjs/components/popover/popover.recipe.js +19 -4
- package/dist/cjs/components/select/select.js +1 -1
- package/dist/cjs/components/select/select.recipe.js +28 -15
- package/dist/cjs/core/floating-portal.js +55 -2
- package/dist/contextmenu.css +11 -9
- package/dist/contextmenu.layered.css +11 -9
- package/dist/esm/components/contextmenu/contextmenu.js +1 -1
- package/dist/esm/components/contextmenu/contextmenu.recipe.js +22 -10
- package/dist/esm/components/menu/menu.js +1 -1
- package/dist/esm/components/menu/menu.recipe.js +32 -20
- package/dist/esm/components/multiselect/multiselect.js +1 -1
- package/dist/esm/components/multiselect/multiselect.recipe.js +37 -22
- package/dist/esm/components/popover/popover.js +1 -1
- package/dist/esm/components/popover/popover.recipe.js +19 -4
- package/dist/esm/components/select/select.js +1 -1
- package/dist/esm/components/select/select.recipe.js +28 -15
- package/dist/esm/core/floating-portal.js +22 -2
- package/dist/menu.css +34 -19
- package/dist/menu.layered.css +34 -19
- package/dist/multiselect.css +34 -21
- package/dist/multiselect.layered.css +34 -21
- package/dist/popover.css +5 -3
- package/dist/popover.layered.css +5 -3
- package/dist/select.css +27 -14
- package/dist/select.layered.css +27 -14
- package/dist/styles.css +111 -66
- package/dist/styles.layered.css +111 -66
- package/dist/types/core/floating-portal.d.ts +17 -3
- package/package.json +3 -3
|
@@ -109,7 +109,7 @@ function ContextMenu({ children, items, menuLabel = "Context menu", className, }
|
|
|
109
109
|
document.removeEventListener("keydown", onKey);
|
|
110
110
|
};
|
|
111
111
|
}, [pos, close]);
|
|
112
|
-
return ((0, jsx_runtime_1.jsxs)("div", { ref: rootRef, className: (0, contextmenu_recipe_1.contextmenuRecipe)({ className }), children: [(0, jsx_runtime_1.jsx)("div", { onContextMenu: open, children: children }), pos && ((0, jsx_runtime_1.jsx)(core_1.FloatingPortal, { children: (0, jsx_runtime_1.jsx)("div", { ref: menuRef, className: "crisp-contextmenu-content", role: "menu", "aria-label": menuLabel, style: { left: pos.x, top: pos.y }, onKeyDown: onMenuKeyDown, children: items.map((item, i) => item.separator ? ((0, jsx_runtime_1.jsx)("hr", { className: "crisp-contextmenu-sep" }, i)) : ((0, jsx_runtime_1.jsxs)("button", { type: "button", role: "menuitem", disabled: item.disabled, className: item.danger
|
|
112
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: rootRef, className: (0, contextmenu_recipe_1.contextmenuRecipe)({ className }), children: [(0, jsx_runtime_1.jsx)("div", { onContextMenu: open, children: children }), pos && ((0, jsx_runtime_1.jsx)(core_1.FloatingPortal, { sourceRef: rootRef, children: (0, jsx_runtime_1.jsx)("div", { ref: menuRef, className: "crisp-contextmenu-content", role: "menu", "aria-label": menuLabel, style: { left: pos.x, top: pos.y }, onKeyDown: onMenuKeyDown, children: items.map((item, i) => item.separator ? ((0, jsx_runtime_1.jsx)("hr", { className: "crisp-contextmenu-sep" }, i)) : ((0, jsx_runtime_1.jsxs)("button", { type: "button", role: "menuitem", disabled: item.disabled, className: item.danger
|
|
113
113
|
? "crisp-contextmenu-item crisp-contextmenu-item--danger"
|
|
114
114
|
: "crisp-contextmenu-item", tabIndex: -1, onClick: () => {
|
|
115
115
|
item.onSelect?.();
|
|
@@ -7,18 +7,30 @@ const tokens_1 = require("../../tokens");
|
|
|
7
7
|
// cursor. The content portals to document.body (#339) so no ancestor's
|
|
8
8
|
// transform/backdrop-filter can capture its position: fixed box; z-index 70
|
|
9
9
|
// keeps it above Dialog/Drawer's 60/61.
|
|
10
|
+
//
|
|
11
|
+
// Every content-related selector below lives in `globalCss`, not nested
|
|
12
|
+
// under `&` (#357): nesting compiles to a real descendant combinator scoped
|
|
13
|
+
// to the recipe's root class, which needs actual DOM containment — exactly
|
|
14
|
+
// what the portal to `document.body` breaks. Nested, these rules silently
|
|
15
|
+
// matched nothing and the menu rendered completely unstyled. `font-family`
|
|
16
|
+
// is restated on the content's own rule (items then pick it up via their
|
|
17
|
+
// own `font-family: inherit`, which still works — that inheritance chain is
|
|
18
|
+
// intact WITHIN the portaled subtree, only the link back to the root
|
|
19
|
+
// broke).
|
|
10
20
|
const config = (0, core_1.defineRecipe)({
|
|
11
21
|
name: "contextmenu",
|
|
12
|
-
base: `display: contents; font-family: ${tokens_1.contract.font.sans}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
base: `display: contents; font-family: ${tokens_1.contract.font.sans};`,
|
|
23
|
+
globalCss: `
|
|
24
|
+
.crisp-contextmenu-content { font-family: ${tokens_1.contract.font.sans}; position: fixed; z-index: 70; min-width: 200px; box-sizing: border-box; padding: ${tokens_1.contract.space["1"]}; border-radius: ${tokens_1.contract.radius.xl}; background: ${tokens_1.contract.bgPopover}; box-shadow: ${tokens_1.elevation.floating}; opacity: 1; transform: none; transition: opacity .08s ease, transform .08s ease; transform-origin: top left; @starting-style { opacity: 0; transform: scale(0.97) translateY(-1px); } }
|
|
25
|
+
.crisp-contextmenu-item { display: flex; align-items: center; gap: ${tokens_1.contract.space["2"]}; width: 100%; height: ${tokens_1.contract.size.menuRow}; box-sizing: border-box; padding: 0 ${tokens_1.contract.space["2"]}; margin: 0; border: none; border-radius: ${tokens_1.contract.radius.md}; background: none; color: ${tokens_1.contract.fgPrimary}; font-family: inherit; font-size: ${tokens_1.contract.text.lg}; text-align: start; white-space: nowrap; cursor: pointer; }
|
|
26
|
+
.crisp-contextmenu-item svg { flex-shrink: 0; color: ${tokens_1.contract.fgMuted}; }
|
|
27
|
+
.crisp-contextmenu-item:hover { background: color-mix(in srgb, ${tokens_1.contract.fgPrimary} 6%, transparent); }
|
|
28
|
+
.crisp-contextmenu-item--danger { color: ${tokens_1.contract.bgDanger}; }
|
|
29
|
+
.crisp-contextmenu-item--danger svg { color: ${tokens_1.contract.bgDanger}; }
|
|
30
|
+
.crisp-contextmenu-item--danger:hover { background: color-mix(in srgb, ${tokens_1.contract.bgDanger} 10%, transparent); }
|
|
31
|
+
.crisp-contextmenu-shortcut { margin-inline-start: auto; padding-inline-start: ${tokens_1.contract.space["3"]}; color: ${tokens_1.contract.fgMuted}; font-size: ${tokens_1.contract.text.sm}; }
|
|
32
|
+
.crisp-contextmenu-sep { height: 1px; margin: ${tokens_1.contract.space["1"]} 0; border: none; background: ${tokens_1.contract.borderSubtle}; }
|
|
33
|
+
`,
|
|
22
34
|
variants: {},
|
|
23
35
|
defaultVariants: {},
|
|
24
36
|
compoundVariants: [],
|
|
@@ -145,7 +145,7 @@ function Menu({ trigger, children, align = "start", open: openProp, defaultOpen,
|
|
|
145
145
|
setOpen(!open);
|
|
146
146
|
},
|
|
147
147
|
});
|
|
148
|
-
return ((0, jsx_runtime_1.jsxs)("div", { ref: rootRef, className: (0, menu_recipe_1.menuRecipe)({ className }), children: [triggerEl, open && ((0, jsx_runtime_1.jsx)(core_1.FloatingPortal, {
|
|
148
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: rootRef, className: (0, menu_recipe_1.menuRecipe)({ className }), children: [triggerEl, open && ((0, jsx_runtime_1.jsx)(core_1.FloatingPortal, { sourceRef: rootRef, children: (0, jsx_runtime_1.jsx)("div", { ref: contentRef, className: "crisp-menu-content", role: "menu", id: surfaceId, "aria-label": ariaLabel, "aria-labelledby": ariaLabel ? undefined : triggerId, "data-align": align, "data-up": up ? "" : undefined, style: pos, onKeyDown: onContentKeyDown, children: (0, jsx_runtime_1.jsx)(MenuContext.Provider, { value: { close }, children: children }) }) }))] }));
|
|
149
149
|
}
|
|
150
150
|
Menu.displayName = "Menu";
|
|
151
151
|
function MenuItem({ children, icon, shortcut, danger, disabled, onSelect, closeOnSelect = true, }) {
|
|
@@ -9,43 +9,55 @@ const tokens_1 = require("../../tokens");
|
|
|
9
9
|
// check). The content portals to document.body (#339) so no ancestor's
|
|
10
10
|
// transform/backdrop-filter can capture its position: fixed box; z-index 70
|
|
11
11
|
// keeps it above Dialog/Drawer's 60/61.
|
|
12
|
+
//
|
|
13
|
+
// The menu's floating content and everything inside it live in `globalCss`
|
|
14
|
+
// below, not nested under `&` (#357): nesting compiles to a real descendant
|
|
15
|
+
// combinator scoped to the recipe's root class, which needs actual DOM
|
|
16
|
+
// containment — exactly what the portal to `document.body` breaks. Nested,
|
|
17
|
+
// these rules matched nothing once the content moved and the menu rendered
|
|
18
|
+
// completely unstyled. `font-family`/smoothing are restated on the content's
|
|
19
|
+
// own rule (items then pick font up via their own `font-family: inherit`,
|
|
20
|
+
// which still works — that inheritance is intact WITHIN the portaled
|
|
21
|
+
// subtree, only the link back to the trigger-holding root broke).
|
|
12
22
|
const config = (0, core_1.defineRecipe)({
|
|
13
23
|
name: "menu",
|
|
14
24
|
base: `
|
|
15
25
|
position: relative; display: inline-flex; font-family: ${tokens_1.contract.font.sans};
|
|
16
26
|
-webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
|
|
17
|
-
|
|
18
|
-
|
|
27
|
+
`,
|
|
28
|
+
globalCss: `
|
|
29
|
+
.crisp-menu-content {
|
|
30
|
+
font-family: ${tokens_1.contract.font.sans}; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
|
|
19
31
|
position: fixed; z-index: 70; box-sizing: border-box; display: flex; flex-direction: column; gap: ${tokens_1.contract.space.px};
|
|
20
32
|
min-width: 200px; max-height: 360px; overflow-y: auto; padding: ${tokens_1.contract.space["1"]};
|
|
21
33
|
border-radius: ${tokens_1.contract.radius.xl}; background: ${tokens_1.contract.bgPopover};
|
|
22
34
|
box-shadow: ${tokens_1.elevation.floating};
|
|
23
35
|
transform-origin: top left; opacity: 1; transform: none; transition: opacity .08s ease, transform .08s ease;
|
|
24
36
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
37
|
+
.crisp-menu-content[data-align="end"] { transform-origin: top right; }
|
|
38
|
+
.crisp-menu-content[data-up] { transform-origin: bottom left; }
|
|
39
|
+
.crisp-menu-content[data-up][data-align="end"] { transform-origin: bottom right; }
|
|
40
|
+
.crisp-menu-content { @starting-style { opacity: 0; transform: scale(0.97) translateY(-1px); } }
|
|
29
41
|
|
|
30
|
-
|
|
42
|
+
.crisp-menu-item {
|
|
31
43
|
box-sizing: border-box; display: flex; align-items: center; gap: ${tokens_1.contract.space["1.5"]}; width: 100%; height: ${tokens_1.contract.size.menuRow}; flex-shrink: 0;
|
|
32
44
|
margin: 0; padding: 0 ${tokens_1.contract.space["2"]}; border: none; background: none; border-radius: ${tokens_1.contract.radius.md};
|
|
33
45
|
font-family: inherit; font-size: ${tokens_1.contract.text.lg}; color: ${tokens_1.contract.fgPrimary}; text-align: start; cursor: pointer; white-space: nowrap;
|
|
34
46
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
.crisp-menu-item svg { flex-shrink: 0; color: ${tokens_1.contract.fgMuted}; }
|
|
48
|
+
.crisp-menu-item:focus { outline: none; }
|
|
49
|
+
.crisp-menu-item:hover:not([data-disabled]), .crisp-menu-item:focus-visible:not([data-disabled]), .crisp-menu-item[data-highlighted]:not([data-disabled]) { background: ${tokens_1.contract.bgRaised}; }
|
|
50
|
+
.crisp-menu-item[data-disabled] { opacity: 0.5; cursor: not-allowed; }
|
|
51
|
+
.crisp-menu-item--danger { color: ${tokens_1.contract.bgDanger}; }
|
|
52
|
+
.crisp-menu-item--danger svg { color: ${tokens_1.contract.bgDanger}; }
|
|
53
|
+
.crisp-menu-item--danger:hover, .crisp-menu-item--danger:focus-visible, .crisp-menu-item--danger[data-highlighted] { background: color-mix(in srgb, ${tokens_1.contract.bgDanger} 10%, transparent); }
|
|
54
|
+
.crisp-menu-item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
55
|
+
.crisp-menu-item-shortcut { flex-shrink: 0; margin-inline-start: ${tokens_1.contract.space["3"]}; font-size: ${tokens_1.contract.text.sm}; color: ${tokens_1.contract.fgMuted}; letter-spacing: 0.02em; }
|
|
56
|
+
.crisp-menu-item-check { flex-shrink: 0; color: ${tokens_1.contract.bgBrandSolid}; }
|
|
57
|
+
.crisp-menu-item-check--placeholder { width: 15px; }
|
|
46
58
|
|
|
47
|
-
|
|
48
|
-
|
|
59
|
+
.crisp-menu-sep { height: 1px; flex-shrink: 0; border: none; margin: ${tokens_1.contract.space["1"]} calc(-1 * ${tokens_1.contract.space["1"]}); background: ${tokens_1.contract.borderSubtle}; }
|
|
60
|
+
.crisp-menu-label { padding: ${tokens_1.contract.space["1.5"]} ${tokens_1.contract.space["2"]} ${tokens_1.contract.space["0.5"]}; font-size: ${tokens_1.contract.text.sm}; font-weight: ${tokens_1.contract.weight.medium}; color: ${tokens_1.contract.fgMuted}; }
|
|
49
61
|
`,
|
|
50
62
|
variants: {},
|
|
51
63
|
defaultVariants: {},
|
|
@@ -190,7 +190,7 @@ id, placeholder = "Select…", searchable = true, searchPlaceholder = "Search…
|
|
|
190
190
|
e.preventDefault();
|
|
191
191
|
openMenu();
|
|
192
192
|
}
|
|
193
|
-
}, children: [(0, jsx_runtime_1.jsx)("span", { className: "crisp-multiselect-chips", children: selectedOptions.length === 0 ? ((0, jsx_runtime_1.jsx)("span", { className: "crisp-multiselect-placeholder", children: placeholder })) : (selectedOptions.map((o) => (0, jsx_runtime_1.jsx)(Chip, { opt: o }, o.value))) }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronDown, { className: "crisp-multiselect-chevron", size: 16, strokeWidth: 1.75 })] }), open && ((0, jsx_runtime_1.jsx)(core_1.FloatingPortal, { children: (0, jsx_runtime_1.jsxs)("div", { ref: listboxRef, id: listboxId, className: "crisp-multiselect-listbox", role: "listbox", "aria-multiselectable": "true", "aria-label": ariaLabel, "data-up": up ? "" : undefined, style: pos, children: [searchable && ((0, jsx_runtime_1.jsxs)("div", { className: "crisp-multiselect-search", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Search, { size: 15, strokeWidth: 1.75 }), (0, jsx_runtime_1.jsx)("input", { ref: searchRef, type: "text", placeholder: searchPlaceholder, "aria-label": searchPlaceholder, "aria-controls": listboxId, "aria-activedescendant": activeId, value: query, onChange: (e) => {
|
|
193
|
+
}, children: [(0, jsx_runtime_1.jsx)("span", { className: "crisp-multiselect-chips", children: selectedOptions.length === 0 ? ((0, jsx_runtime_1.jsx)("span", { className: "crisp-multiselect-placeholder", children: placeholder })) : (selectedOptions.map((o) => (0, jsx_runtime_1.jsx)(Chip, { opt: o }, o.value))) }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronDown, { className: "crisp-multiselect-chevron", size: 16, strokeWidth: 1.75 })] }), open && ((0, jsx_runtime_1.jsx)(core_1.FloatingPortal, { sourceRef: rootRef, children: (0, jsx_runtime_1.jsxs)("div", { ref: listboxRef, id: listboxId, className: "crisp-multiselect-listbox", role: "listbox", "aria-multiselectable": "true", "aria-label": ariaLabel, "data-up": up ? "" : undefined, style: pos, children: [searchable && ((0, jsx_runtime_1.jsxs)("div", { className: "crisp-multiselect-search", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Search, { size: 15, strokeWidth: 1.75 }), (0, jsx_runtime_1.jsx)("input", { ref: searchRef, type: "text", placeholder: searchPlaceholder, "aria-label": searchPlaceholder, "aria-controls": listboxId, "aria-activedescendant": activeId, value: query, onChange: (e) => {
|
|
194
194
|
setQuery(e.target.value);
|
|
195
195
|
setHighlight(0);
|
|
196
196
|
}, onKeyDown: onNavKeys })] })), filtered.length === 0 ? ((0, jsx_runtime_1.jsx)("div", { className: "crisp-multiselect-empty", children: emptyLabel })) : (filtered.map((opt, i) => {
|
|
@@ -9,6 +9,19 @@ const tokens_1 = require("../../tokens");
|
|
|
9
9
|
// toggle on click. The popover portals to document.body (#339) so no
|
|
10
10
|
// ancestor's transform/backdrop-filter can capture its position: fixed box;
|
|
11
11
|
// z-index 70 keeps it above Dialog/Drawer's 60/61.
|
|
12
|
+
// The listbox and everything inside it (including the recordstable-tag
|
|
13
|
+
// chips, which render inside listbox option rows as well as the trigger)
|
|
14
|
+
// live in `globalCss` below, not nested under `&` (#357): nesting compiles
|
|
15
|
+
// to a real descendant combinator scoped to the recipe's root class, which
|
|
16
|
+
// needs actual DOM containment — exactly what the portal to `document.body`
|
|
17
|
+
// breaks. Nested, these rules matched nothing once the listbox moved and it
|
|
18
|
+
// rendered completely unstyled. The trigger and its own parts stay nested
|
|
19
|
+
// under `&` — the trigger is NOT portaled. `font-family`/smoothing are
|
|
20
|
+
// restated on the listbox's own rule (its children pick font up via their
|
|
21
|
+
// own `font-family: inherit`, which still works — that inheritance is
|
|
22
|
+
// intact WITHIN the portaled subtree, only the link back to the
|
|
23
|
+
// trigger-holding root broke). A flat recordstable-tag selector also works
|
|
24
|
+
// unchanged wherever it's rendered, portaled or not, so it needs no split.
|
|
12
25
|
const config = (0, core_1.defineRecipe)({
|
|
13
26
|
name: "multiselect",
|
|
14
27
|
base: `
|
|
@@ -29,38 +42,40 @@ const config = (0, core_1.defineRecipe)({
|
|
|
29
42
|
& .crisp-multiselect-placeholder { color: ${tokens_1.contract.fgMuted}; }
|
|
30
43
|
& .crisp-multiselect-chevron { flex-shrink: 0; color: ${tokens_1.contract.fgMuted}; transition: transform .15s ease; }
|
|
31
44
|
& .crisp-multiselect-trigger[data-open] .crisp-multiselect-chevron { transform: rotate(180deg); }
|
|
32
|
-
|
|
33
|
-
|
|
45
|
+
`,
|
|
46
|
+
globalCss: `
|
|
47
|
+
.crisp-multiselect-listbox {
|
|
48
|
+
font-family: ${tokens_1.contract.font.sans}; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
|
|
34
49
|
position: fixed; z-index: 70; box-sizing: border-box; display: flex; flex-direction: column; gap: ${tokens_1.contract.space.px};
|
|
35
50
|
max-height: 300px; overflow-y: auto; padding: ${tokens_1.contract.space["1"]};
|
|
36
51
|
border-radius: ${tokens_1.contract.radius.xl}; background: ${tokens_1.contract.bgPopover};
|
|
37
52
|
box-shadow: ${tokens_1.elevation.floating};
|
|
38
53
|
transform-origin: top left; opacity: 1; transform: none; transition: opacity .08s ease, transform .08s ease;
|
|
39
54
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
55
|
+
.crisp-multiselect-listbox[data-up] { transform-origin: bottom left; }
|
|
56
|
+
.crisp-multiselect-listbox { @starting-style { opacity: 0; transform: scale(0.97) translateY(-1px); } }
|
|
57
|
+
.crisp-multiselect-search { display: flex; align-items: center; gap: ${tokens_1.contract.space["2"]}; height: 34px; flex-shrink: 0; margin: calc(-1 * ${tokens_1.contract.space["1"]}) calc(-1 * ${tokens_1.contract.space["1"]}) ${tokens_1.contract.space["1"]}; padding: 0 ${tokens_1.contract.space["2.5"]}; border-bottom: 1px solid ${tokens_1.contract.borderSubtle}; color: ${tokens_1.contract.fgMuted}; }
|
|
58
|
+
.crisp-multiselect-search svg { flex-shrink: 0; }
|
|
59
|
+
.crisp-multiselect-search input { flex: 1; min-width: 0; border: none; outline: none; background: none; font-family: inherit; font-size: ${tokens_1.contract.text.lg}; color: ${tokens_1.contract.fgPrimary}; }
|
|
60
|
+
.crisp-multiselect-search input::placeholder { color: ${tokens_1.contract.fgMuted}; }
|
|
61
|
+
.crisp-multiselect-option {
|
|
47
62
|
box-sizing: border-box; display: flex; align-items: center; gap: ${tokens_1.contract.space["2"]}; height: ${tokens_1.contract.size.menuRow}; flex-shrink: 0;
|
|
48
63
|
padding: 0 ${tokens_1.contract.space["2"]}; margin: 0; border: none; background: none; border-radius: ${tokens_1.contract.radius.md}; font-family: inherit; cursor: pointer; text-align: start;
|
|
49
64
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
65
|
+
.crisp-multiselect-option[data-highlighted] { background: ${tokens_1.contract.bgRaised}; }
|
|
66
|
+
.crisp-multiselect-option-chip { flex: 0 1 auto; min-width: 0; overflow: hidden; }
|
|
67
|
+
.crisp-multiselect-check { flex-shrink: 0; margin-inline-start: auto; display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: ${tokens_1.contract.radius.sm}; box-shadow: inset 0 0 0 1.5px ${tokens_1.contract.borderDefault}; color: transparent; }
|
|
68
|
+
.crisp-multiselect-option[aria-selected="true"] .crisp-multiselect-check { background: ${tokens_1.contract.bgBrandSolid}; box-shadow: none; color: #fff; }
|
|
69
|
+
.crisp-multiselect-empty { padding: ${tokens_1.contract.space["3"]} ${tokens_1.contract.space["2"]}; text-align: center; font-size: ${tokens_1.contract.text.md}; color: ${tokens_1.contract.fgMuted}; }
|
|
55
70
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
71
|
+
.crisp-recordstable-tag { display: inline-flex; align-items: center; height: ${tokens_1.contract.size.chip}; padding: 0 ${tokens_1.contract.space["1"]}; border-radius: ${tokens_1.contract.radius.chip}; font-size: ${tokens_1.contract.text.lg}; line-height: 20px; font-weight: ${tokens_1.contract.weight.medium}; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: color-mix(in srgb, ${tokens_1.contract.fgPrimary} 6%, transparent); color: color-mix(in srgb, ${tokens_1.contract.fgPrimary} 82%, transparent); }
|
|
72
|
+
.crisp-recordstable-tag[data-tone="brand"] { background: color-mix(in srgb, ${tokens_1.contract.bgBrandSolid} 14%, transparent); color: color-mix(in srgb, ${tokens_1.contract.bgBrandSolid} 82%, ${tokens_1.contract.fgPrimary}); }
|
|
73
|
+
.crisp-recordstable-tag[data-tone="success"] { background: color-mix(in srgb, ${tokens_1.contract.bgSuccess} 16%, transparent); color: color-mix(in srgb, ${tokens_1.contract.bgSuccess} 78%, ${tokens_1.contract.fgPrimary}); }
|
|
74
|
+
.crisp-recordstable-tag[data-tone="warning"] { background: color-mix(in srgb, ${tokens_1.contract.bgWarning} 18%, transparent); color: color-mix(in srgb, ${tokens_1.contract.bgWarning} 82%, ${tokens_1.contract.fgPrimary}); }
|
|
75
|
+
.crisp-recordstable-tag[data-tone="danger"] { background: color-mix(in srgb, ${tokens_1.contract.bgDanger} 15%, transparent); color: color-mix(in srgb, ${tokens_1.contract.bgDanger} 80%, ${tokens_1.contract.fgPrimary}); }
|
|
76
|
+
.crisp-recordstable-tag[data-tone="purple"] { background: color-mix(in srgb, ${tokens_1.contract.bgPurple} 16%, transparent); color: color-mix(in srgb, ${tokens_1.contract.bgPurple} 80%, ${tokens_1.contract.fgPrimary}); }
|
|
77
|
+
.crisp-recordstable-tag[data-tone="cyan"] { background: color-mix(in srgb, ${tokens_1.contract.bgCyan} 18%, transparent); color: color-mix(in srgb, ${tokens_1.contract.bgCyan} 82%, ${tokens_1.contract.fgPrimary}); }
|
|
78
|
+
.crisp-recordstable-tag[data-tone="orange"] { background: color-mix(in srgb, ${tokens_1.contract.bgOrange} 16%, transparent); color: color-mix(in srgb, ${tokens_1.contract.bgOrange} 82%, ${tokens_1.contract.fgPrimary}); }
|
|
64
79
|
`,
|
|
65
80
|
variants: {
|
|
66
81
|
// Same ring Select's `invalid` draws — see that recipe's comment.
|
|
@@ -122,7 +122,7 @@ function Popover({ trigger, children, align = "start", open: openProp, defaultOp
|
|
|
122
122
|
setOpen(!open);
|
|
123
123
|
},
|
|
124
124
|
});
|
|
125
|
-
return ((0, jsx_runtime_1.jsxs)("div", { ref: rootRef, className: (0, popover_recipe_1.popoverRecipe)({ className }), children: [triggerEl, open && ((0, jsx_runtime_1.jsx)(core_1.FloatingPortal, { children: (0, jsx_runtime_1.jsx)("div", { ref: contentRef, className: "crisp-popover-content", role: "dialog", id: surfaceId, "aria-label": ariaLabel, "aria-labelledby": ariaLabel ? undefined : triggerId, "data-align": align, "data-up": up ? "" : undefined, style: pos, onKeyDown: (e) => {
|
|
125
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: rootRef, className: (0, popover_recipe_1.popoverRecipe)({ className }), children: [triggerEl, open && ((0, jsx_runtime_1.jsx)(core_1.FloatingPortal, { sourceRef: rootRef, children: (0, jsx_runtime_1.jsx)("div", { ref: contentRef, className: "crisp-popover-content", role: "dialog", id: surfaceId, "aria-label": ariaLabel, "aria-labelledby": ariaLabel ? undefined : triggerId, "data-align": align, "data-up": up ? "" : undefined, style: pos, onKeyDown: (e) => {
|
|
126
126
|
if (e.key === "Escape") {
|
|
127
127
|
e.preventDefault();
|
|
128
128
|
setOpen(false);
|
|
@@ -9,12 +9,27 @@ const tokens_1 = require("../../tokens");
|
|
|
9
9
|
// ancestor's transform/backdrop-filter can capture its position: fixed box;
|
|
10
10
|
// z-index 70 keeps it above Dialog/Drawer's 60/61. The display:contents root
|
|
11
11
|
// is what's left in place, so a consumer's own styling of it survives.
|
|
12
|
+
//
|
|
13
|
+
// The popover's floating content is declared via `globalCss` below, not
|
|
14
|
+
// nested under `&` (#357): nesting compiles to a genuine descendant
|
|
15
|
+
// combinator scoped to the recipe's root class, and the portal moves the
|
|
16
|
+
// content to a DOM sibling of `document.body`, not a descendant of the root
|
|
17
|
+
// — so a nested rule silently matched nothing and the popover rendered
|
|
18
|
+
// completely unstyled (`position: static`, no background, no shadow).
|
|
19
|
+
// `globalCss` is already the escape hatch for CSS a property can't express
|
|
20
|
+
// (`@keyframes`); a portaled part is the same problem, one selector at a
|
|
21
|
+
// time. Every declaration a portaled selector needs — including ones
|
|
22
|
+
// normally inherited from the root, like `font-family` — has to be restated
|
|
23
|
+
// here, since DOM inheritance from the root is exactly what the portal
|
|
24
|
+
// breaks.
|
|
12
25
|
const config = (0, core_1.defineRecipe)({
|
|
13
26
|
name: "popover",
|
|
14
|
-
base: `display: contents; font-family: ${tokens_1.contract.font.sans}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
27
|
+
base: `display: contents; font-family: ${tokens_1.contract.font.sans};`,
|
|
28
|
+
globalCss: `
|
|
29
|
+
.crisp-popover-content { font-family: ${tokens_1.contract.font.sans}; position: fixed; z-index: 70; box-sizing: border-box; min-width: 200px; max-width: min(360px, 92vw); padding: ${tokens_1.contract.space["1"]}; border-radius: ${tokens_1.contract.radius.xl}; background: ${tokens_1.contract.bgPopover}; color: ${tokens_1.contract.fgPrimary}; box-shadow: ${tokens_1.elevation.floating}; opacity: 1; transform: none; transition: opacity 0.08s ease, transform 0.08s ease; transform-origin: top left; @starting-style { opacity: 0; transform: scale(0.97) translateY(-1px); } }
|
|
30
|
+
.crisp-popover-content[data-align="end"] { transform-origin: top right; }
|
|
31
|
+
.crisp-popover-content[data-up] { transform-origin: bottom left; }
|
|
32
|
+
`,
|
|
18
33
|
variants: {},
|
|
19
34
|
defaultVariants: {},
|
|
20
35
|
compoundVariants: [],
|
|
@@ -180,7 +180,7 @@ function Select({ options, value, defaultValue, onValueChange, name, required, p
|
|
|
180
180
|
return ((0, jsx_runtime_1.jsxs)("div", { ref: rootRef, className: (0, select_recipe_1.selectRecipe)({ variant, width, invalid, className }), ...rest, children: [name && (selected || required) && ((0, jsx_runtime_1.jsx)("input", { className: "crisp-formvalue", style: core_1.formValueStyle, name: name, value: selected ?? "", required: required, tabIndex: -1, "aria-hidden": "true",
|
|
181
181
|
// controlled by the listbox above; `readOnly` would bar it from
|
|
182
182
|
// validation, which is the only reason this input is not hidden
|
|
183
|
-
onChange: () => { } })), (0, jsx_runtime_1.jsxs)("button", { ref: triggerRef, type: "button", id: id, role: "combobox", "aria-haspopup": "listbox", "aria-expanded": open, "aria-controls": open ? listboxId : undefined, "aria-activedescendant": searchable ? undefined : activeId, "aria-label": ariaLabel, "aria-invalid": invalid === true || undefined, disabled: disabled, "data-open": open ? "" : undefined, className: "crisp-select-trigger", onClick: () => (open ? setOpen(false) : openMenu()), onKeyDown: onTriggerKeyDown, children: [(0, jsx_runtime_1.jsx)("span", { className: "crisp-select-value", children: selectedOption ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [selectedOption.color && ((0, jsx_runtime_1.jsx)("span", { className: "crisp-select-option-dot", style: { background: selectedOption.color } })), selectedOption.label] })) : ((0, jsx_runtime_1.jsx)("span", { className: "crisp-select-placeholder", children: placeholder })) }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronDown, { className: "crisp-select-chevron", size: 16, strokeWidth: 1.75 })] }), open && ((0, jsx_runtime_1.jsx)(core_1.FloatingPortal, { children: (0, jsx_runtime_1.jsxs)("div", { ref: listboxRef, id: listboxId, className: "crisp-select-listbox", role: "listbox", "aria-label": ariaLabel, "data-up": up ? "" : undefined, style: pos, children: [searchable && ((0, jsx_runtime_1.jsxs)("div", { className: "crisp-select-search", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Search, { size: 15, strokeWidth: 1.75 }), (0, jsx_runtime_1.jsx)("input", { ref: searchRef, type: "text", placeholder: searchPlaceholder, "aria-label": searchPlaceholder, "aria-controls": listboxId, "aria-activedescendant": activeId, value: query, onChange: (e) => {
|
|
183
|
+
onChange: () => { } })), (0, jsx_runtime_1.jsxs)("button", { ref: triggerRef, type: "button", id: id, role: "combobox", "aria-haspopup": "listbox", "aria-expanded": open, "aria-controls": open ? listboxId : undefined, "aria-activedescendant": searchable ? undefined : activeId, "aria-label": ariaLabel, "aria-invalid": invalid === true || undefined, disabled: disabled, "data-open": open ? "" : undefined, className: "crisp-select-trigger", onClick: () => (open ? setOpen(false) : openMenu()), onKeyDown: onTriggerKeyDown, children: [(0, jsx_runtime_1.jsx)("span", { className: "crisp-select-value", children: selectedOption ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [selectedOption.color && ((0, jsx_runtime_1.jsx)("span", { className: "crisp-select-option-dot", style: { background: selectedOption.color } })), selectedOption.label] })) : ((0, jsx_runtime_1.jsx)("span", { className: "crisp-select-placeholder", children: placeholder })) }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronDown, { className: "crisp-select-chevron", size: 16, strokeWidth: 1.75 })] }), open && ((0, jsx_runtime_1.jsx)(core_1.FloatingPortal, { sourceRef: rootRef, children: (0, jsx_runtime_1.jsxs)("div", { ref: listboxRef, id: listboxId, className: "crisp-select-listbox", role: "listbox", "aria-label": ariaLabel, "data-up": up ? "" : undefined, style: pos, children: [searchable && ((0, jsx_runtime_1.jsxs)("div", { className: "crisp-select-search", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Search, { size: 15, strokeWidth: 1.75 }), (0, jsx_runtime_1.jsx)("input", { ref: searchRef, type: "text", placeholder: searchPlaceholder, "aria-label": searchPlaceholder, "aria-controls": listboxId, "aria-activedescendant": activeId, value: query, onChange: (e) => {
|
|
184
184
|
setQuery(e.target.value);
|
|
185
185
|
setHighlight(0);
|
|
186
186
|
}, onKeyDown: onNavKeys })] })), filtered.length === 0 ? ((0, jsx_runtime_1.jsx)("div", { className: "crisp-select-empty", children: emptyLabel })) : (filtered.map((opt, i) => {
|
|
@@ -11,6 +11,17 @@ const tokens_1 = require("../../tokens");
|
|
|
11
11
|
// (Dialog's own measured surface sets both) can capture its position: fixed
|
|
12
12
|
// box; z-index 70 keeps it above Dialog/Drawer's z-index 60/61 layers, since
|
|
13
13
|
// it's no longer nested inside whichever one opened it.
|
|
14
|
+
// The listbox and everything inside it live in `globalCss` below, not
|
|
15
|
+
// nested under `&` (#357): nesting compiles to a real descendant combinator
|
|
16
|
+
// scoped to the recipe's root class, which needs actual DOM containment —
|
|
17
|
+
// exactly what the portal to `document.body` breaks. Nested, these rules
|
|
18
|
+
// matched nothing once the listbox moved and it rendered completely
|
|
19
|
+
// unstyled. The trigger and its own parts stay nested under `&` — the
|
|
20
|
+
// trigger is NOT portaled, it stays where it was authored. `font-family`/
|
|
21
|
+
// smoothing are restated on the listbox's own rule (its children pick font
|
|
22
|
+
// up via their own `font-family: inherit`, which still works — that
|
|
23
|
+
// inheritance is intact WITHIN the portaled subtree, only the link back to
|
|
24
|
+
// the trigger-holding root broke).
|
|
14
25
|
const config = (0, core_1.defineRecipe)({
|
|
15
26
|
name: "select",
|
|
16
27
|
base: `
|
|
@@ -31,31 +42,33 @@ const config = (0, core_1.defineRecipe)({
|
|
|
31
42
|
& .crisp-select-placeholder { color: ${tokens_1.contract.fgMuted}; }
|
|
32
43
|
& .crisp-select-chevron { flex-shrink: 0; color: ${tokens_1.contract.fgMuted}; transition: transform .15s ease; }
|
|
33
44
|
& .crisp-select-trigger[data-open] .crisp-select-chevron { transform: rotate(180deg); }
|
|
34
|
-
|
|
35
|
-
|
|
45
|
+
`,
|
|
46
|
+
globalCss: `
|
|
47
|
+
.crisp-select-listbox {
|
|
48
|
+
font-family: ${tokens_1.contract.font.sans}; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
|
|
36
49
|
position: fixed; z-index: 70; box-sizing: border-box; display: flex; flex-direction: column; gap: ${tokens_1.contract.space.px};
|
|
37
50
|
max-height: 280px; overflow-y: auto; padding: ${tokens_1.contract.space["1"]};
|
|
38
51
|
border-radius: ${tokens_1.contract.radius.xl}; background: ${tokens_1.contract.bgPopover};
|
|
39
52
|
box-shadow: ${tokens_1.elevation.floating};
|
|
40
53
|
transform-origin: top left; opacity: 1; transform: none; transition: opacity .08s ease, transform .08s ease;
|
|
41
54
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
55
|
+
.crisp-select-listbox[data-up] { transform-origin: bottom; }
|
|
56
|
+
.crisp-select-listbox { @starting-style { opacity: 0; transform: scale(0.97) translateY(-1px); } }
|
|
57
|
+
.crisp-select-search { display: flex; align-items: center; gap: ${tokens_1.contract.space["2"]}; height: 34px; flex-shrink: 0; margin: calc(-1 * ${tokens_1.contract.space["1"]}) calc(-1 * ${tokens_1.contract.space["1"]}) ${tokens_1.contract.space["1"]}; padding: 0 ${tokens_1.contract.space["2.5"]}; border-bottom: 1px solid ${tokens_1.contract.borderSubtle}; color: ${tokens_1.contract.fgMuted}; }
|
|
58
|
+
.crisp-select-search svg { flex-shrink: 0; }
|
|
59
|
+
.crisp-select-search input { flex: 1; min-width: 0; border: none; outline: none; background: none; font-family: inherit; font-size: ${tokens_1.contract.text.lg}; color: ${tokens_1.contract.fgPrimary}; }
|
|
60
|
+
.crisp-select-search input::placeholder { color: ${tokens_1.contract.fgMuted}; }
|
|
61
|
+
.crisp-select-empty { padding: ${tokens_1.contract.space["3"]} ${tokens_1.contract.space["2"]}; text-align: center; font-size: ${tokens_1.contract.text.md}; color: ${tokens_1.contract.fgMuted}; }
|
|
62
|
+
.crisp-select-option {
|
|
50
63
|
box-sizing: border-box; display: flex; align-items: center; gap: ${tokens_1.contract.space["2"]}; height: ${tokens_1.contract.size.menuRow}; flex-shrink: 0;
|
|
51
64
|
padding: 0 ${tokens_1.contract.space["2"]}; margin: 0; border: none; background: none; border-radius: ${tokens_1.contract.radius.md};
|
|
52
65
|
font-family: inherit; font-size: ${tokens_1.contract.text.lg}; color: ${tokens_1.contract.fgPrimary}; text-align: start; cursor: pointer; white-space: nowrap;
|
|
53
66
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
.crisp-select-option[data-highlighted] { background: ${tokens_1.contract.bgRaised}; }
|
|
68
|
+
.crisp-select-option[data-disabled] { opacity: 0.5; cursor: not-allowed; }
|
|
69
|
+
.crisp-select-option-dot { flex-shrink: 0; width: 8px; height: 8px; border-radius: ${tokens_1.contract.radius.full}; }
|
|
70
|
+
.crisp-select-option-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
71
|
+
.crisp-select-option-check { flex-shrink: 0; color: ${tokens_1.contract.bgBrandSolid}; }
|
|
59
72
|
`,
|
|
60
73
|
variants: {
|
|
61
74
|
// ghost: borderless at rest (transparent), reveals a subtle fill on hover —
|
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.FloatingPortal = FloatingPortal;
|
|
37
|
+
const React = __importStar(require("react"));
|
|
4
38
|
const react_dom_1 = require("react-dom");
|
|
5
39
|
/**
|
|
6
40
|
* Portals a floating layer (a `position: fixed` listbox/menu/popover
|
|
@@ -22,7 +56,26 @@ const react_dom_1 = require("react-dom");
|
|
|
22
56
|
* starts `false` and is driven only by client interaction — never a prop a
|
|
23
57
|
* fixture sets true at mount (unlike Dialog/Drawer/Command) — so this never
|
|
24
58
|
* touches `document` during SSR, the same safety Tooltip already had.
|
|
59
|
+
*
|
|
60
|
+
* `sourceRef` is the caller's own root — still in its original DOM position,
|
|
61
|
+
* never portaled — used to carry a `data-theme` set on some ancestor of it
|
|
62
|
+
* onto the portaled content (#357). `[data-theme="dark"]` is a normal
|
|
63
|
+
* attribute selector: it needs the themed element to be an actual DOM
|
|
64
|
+
* ancestor, which a consumer that scopes theming below `<html>`/`<body>`
|
|
65
|
+
* (crisp's own visual-test harness does exactly this, per case) no longer
|
|
66
|
+
* is once the content moves to `document.body` — the popover rendered in
|
|
67
|
+
* the PAGE's theme instead of the SUBTREE's. Re-declaring the attribute
|
|
68
|
+
* directly on the portaled root re-establishes it for CSS attribute
|
|
69
|
+
* selectors AND for `var()` resolution, since a custom property set under
|
|
70
|
+
* `[data-theme="dark"] { --crisp-x: ... }` only reaches descendants of an
|
|
71
|
+
* element carrying that attribute.
|
|
25
72
|
*/
|
|
26
|
-
function FloatingPortal({ children, }) {
|
|
27
|
-
|
|
73
|
+
function FloatingPortal({ children, sourceRef, }) {
|
|
74
|
+
const theme = sourceRef.current
|
|
75
|
+
?.closest("[data-theme]")
|
|
76
|
+
?.getAttribute("data-theme");
|
|
77
|
+
const content = theme
|
|
78
|
+
? React.cloneElement(children, { "data-theme": theme })
|
|
79
|
+
: children;
|
|
80
|
+
return (0, react_dom_1.createPortal)(content, document.body);
|
|
28
81
|
}
|
package/dist/contextmenu.css
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
.crisp-contextmenu-content { font-family: var(--crisp-font-sans); position: fixed; z-index: 70; min-width: 200px; box-sizing: border-box; padding: var(--crisp-space-1); border-radius: var(--crisp-radius-xl); background: var(--crisp-bg-popover); box-shadow: inset 0 0 0 1px var(--crisp-ring-popover), 0 0 0 1px var(--crisp-shadow-popover1), 0 4px 8px -4px var(--crisp-shadow-popover2), 0 4px 12px -2px var(--crisp-shadow-popover3); opacity: 1; transform: none; transition: opacity .08s ease, transform .08s ease; transform-origin: top left; @starting-style { opacity: 0; transform: scale(0.97) translateY(-1px); } }
|
|
3
|
+
.crisp-contextmenu-item { display: flex; align-items: center; gap: var(--crisp-space-2); width: 100%; height: var(--crisp-size-menuRow); box-sizing: border-box; padding: 0 var(--crisp-space-2); margin: 0; border: none; border-radius: var(--crisp-radius-md); background: none; color: var(--crisp-fg-primary); font-family: inherit; font-size: var(--crisp-text-lg); text-align: start; white-space: nowrap; cursor: pointer; }
|
|
4
|
+
.crisp-contextmenu-item svg { flex-shrink: 0; color: var(--crisp-fg-muted); }
|
|
5
|
+
.crisp-contextmenu-item:hover { background: color-mix(in srgb, var(--crisp-fg-primary) 6%, transparent); }
|
|
6
|
+
.crisp-contextmenu-item--danger { color: var(--crisp-bg-danger); }
|
|
7
|
+
.crisp-contextmenu-item--danger svg { color: var(--crisp-bg-danger); }
|
|
8
|
+
.crisp-contextmenu-item--danger:hover { background: color-mix(in srgb, var(--crisp-bg-danger) 10%, transparent); }
|
|
9
|
+
.crisp-contextmenu-shortcut { margin-inline-start: auto; padding-inline-start: var(--crisp-space-3); color: var(--crisp-fg-muted); font-size: var(--crisp-text-sm); }
|
|
10
|
+
.crisp-contextmenu-sep { height: 1px; margin: var(--crisp-space-1) 0; border: none; background: var(--crisp-border-subtle); }
|
|
11
|
+
|
|
1
12
|
.crisp-contextmenu {
|
|
2
13
|
display: contents; font-family: var(--crisp-font-sans);
|
|
3
|
-
& .crisp-contextmenu-content { position: fixed; z-index: 70; min-width: 200px; box-sizing: border-box; padding: var(--crisp-space-1); border-radius: var(--crisp-radius-xl); background: var(--crisp-bg-popover); box-shadow: inset 0 0 0 1px var(--crisp-ring-popover), 0 0 0 1px var(--crisp-shadow-popover1), 0 4px 8px -4px var(--crisp-shadow-popover2), 0 4px 12px -2px var(--crisp-shadow-popover3); opacity: 1; transform: none; transition: opacity .08s ease, transform .08s ease; transform-origin: top left; @starting-style { opacity: 0; transform: scale(0.97) translateY(-1px); } }
|
|
4
|
-
& .crisp-contextmenu-item { display: flex; align-items: center; gap: var(--crisp-space-2); width: 100%; height: var(--crisp-size-menuRow); box-sizing: border-box; padding: 0 var(--crisp-space-2); margin: 0; border: none; border-radius: var(--crisp-radius-md); background: none; color: var(--crisp-fg-primary); font-family: inherit; font-size: var(--crisp-text-lg); text-align: start; white-space: nowrap; cursor: pointer; }
|
|
5
|
-
& .crisp-contextmenu-item svg { flex-shrink: 0; color: var(--crisp-fg-muted); }
|
|
6
|
-
& .crisp-contextmenu-item:hover { background: color-mix(in srgb, var(--crisp-fg-primary) 6%, transparent); }
|
|
7
|
-
& .crisp-contextmenu-item--danger { color: var(--crisp-bg-danger); }
|
|
8
|
-
& .crisp-contextmenu-item--danger svg { color: var(--crisp-bg-danger); }
|
|
9
|
-
& .crisp-contextmenu-item--danger:hover { background: color-mix(in srgb, var(--crisp-bg-danger) 10%, transparent); }
|
|
10
|
-
& .crisp-contextmenu-shortcut { margin-inline-start: auto; padding-inline-start: var(--crisp-space-3); color: var(--crisp-fg-muted); font-size: var(--crisp-text-sm); }
|
|
11
|
-
& .crisp-contextmenu-sep { height: 1px; margin: var(--crisp-space-1) 0; border: none; background: var(--crisp-border-subtle); }
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
@media (prefers-reduced-motion: reduce) {
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
@layer crisp-components {
|
|
2
|
+
|
|
3
|
+
.crisp-contextmenu-content { font-family: var(--crisp-font-sans); position: fixed; z-index: 70; min-width: 200px; box-sizing: border-box; padding: var(--crisp-space-1); border-radius: var(--crisp-radius-xl); background: var(--crisp-bg-popover); box-shadow: inset 0 0 0 1px var(--crisp-ring-popover), 0 0 0 1px var(--crisp-shadow-popover1), 0 4px 8px -4px var(--crisp-shadow-popover2), 0 4px 12px -2px var(--crisp-shadow-popover3); opacity: 1; transform: none; transition: opacity .08s ease, transform .08s ease; transform-origin: top left; @starting-style { opacity: 0; transform: scale(0.97) translateY(-1px); } }
|
|
4
|
+
.crisp-contextmenu-item { display: flex; align-items: center; gap: var(--crisp-space-2); width: 100%; height: var(--crisp-size-menuRow); box-sizing: border-box; padding: 0 var(--crisp-space-2); margin: 0; border: none; border-radius: var(--crisp-radius-md); background: none; color: var(--crisp-fg-primary); font-family: inherit; font-size: var(--crisp-text-lg); text-align: start; white-space: nowrap; cursor: pointer; }
|
|
5
|
+
.crisp-contextmenu-item svg { flex-shrink: 0; color: var(--crisp-fg-muted); }
|
|
6
|
+
.crisp-contextmenu-item:hover { background: color-mix(in srgb, var(--crisp-fg-primary) 6%, transparent); }
|
|
7
|
+
.crisp-contextmenu-item--danger { color: var(--crisp-bg-danger); }
|
|
8
|
+
.crisp-contextmenu-item--danger svg { color: var(--crisp-bg-danger); }
|
|
9
|
+
.crisp-contextmenu-item--danger:hover { background: color-mix(in srgb, var(--crisp-bg-danger) 10%, transparent); }
|
|
10
|
+
.crisp-contextmenu-shortcut { margin-inline-start: auto; padding-inline-start: var(--crisp-space-3); color: var(--crisp-fg-muted); font-size: var(--crisp-text-sm); }
|
|
11
|
+
.crisp-contextmenu-sep { height: 1px; margin: var(--crisp-space-1) 0; border: none; background: var(--crisp-border-subtle); }
|
|
12
|
+
|
|
2
13
|
.crisp-contextmenu {
|
|
3
14
|
display: contents; font-family: var(--crisp-font-sans);
|
|
4
|
-
& .crisp-contextmenu-content { position: fixed; z-index: 70; min-width: 200px; box-sizing: border-box; padding: var(--crisp-space-1); border-radius: var(--crisp-radius-xl); background: var(--crisp-bg-popover); box-shadow: inset 0 0 0 1px var(--crisp-ring-popover), 0 0 0 1px var(--crisp-shadow-popover1), 0 4px 8px -4px var(--crisp-shadow-popover2), 0 4px 12px -2px var(--crisp-shadow-popover3); opacity: 1; transform: none; transition: opacity .08s ease, transform .08s ease; transform-origin: top left; @starting-style { opacity: 0; transform: scale(0.97) translateY(-1px); } }
|
|
5
|
-
& .crisp-contextmenu-item { display: flex; align-items: center; gap: var(--crisp-space-2); width: 100%; height: var(--crisp-size-menuRow); box-sizing: border-box; padding: 0 var(--crisp-space-2); margin: 0; border: none; border-radius: var(--crisp-radius-md); background: none; color: var(--crisp-fg-primary); font-family: inherit; font-size: var(--crisp-text-lg); text-align: start; white-space: nowrap; cursor: pointer; }
|
|
6
|
-
& .crisp-contextmenu-item svg { flex-shrink: 0; color: var(--crisp-fg-muted); }
|
|
7
|
-
& .crisp-contextmenu-item:hover { background: color-mix(in srgb, var(--crisp-fg-primary) 6%, transparent); }
|
|
8
|
-
& .crisp-contextmenu-item--danger { color: var(--crisp-bg-danger); }
|
|
9
|
-
& .crisp-contextmenu-item--danger svg { color: var(--crisp-bg-danger); }
|
|
10
|
-
& .crisp-contextmenu-item--danger:hover { background: color-mix(in srgb, var(--crisp-bg-danger) 10%, transparent); }
|
|
11
|
-
& .crisp-contextmenu-shortcut { margin-inline-start: auto; padding-inline-start: var(--crisp-space-3); color: var(--crisp-fg-muted); font-size: var(--crisp-text-sm); }
|
|
12
|
-
& .crisp-contextmenu-sep { height: 1px; margin: var(--crisp-space-1) 0; border: none; background: var(--crisp-border-subtle); }
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
@media (prefers-reduced-motion: reduce) {
|
|
@@ -73,7 +73,7 @@ export function ContextMenu({ children, items, menuLabel = "Context menu", class
|
|
|
73
73
|
document.removeEventListener("keydown", onKey);
|
|
74
74
|
};
|
|
75
75
|
}, [pos, close]);
|
|
76
|
-
return (_jsxs("div", { ref: rootRef, className: contextmenuRecipe({ className }), children: [_jsx("div", { onContextMenu: open, children: children }), pos && (_jsx(FloatingPortal, { children: _jsx("div", { ref: menuRef, className: "crisp-contextmenu-content", role: "menu", "aria-label": menuLabel, style: { left: pos.x, top: pos.y }, onKeyDown: onMenuKeyDown, children: items.map((item, i) => item.separator ? (_jsx("hr", { className: "crisp-contextmenu-sep" }, i)) : (_jsxs("button", { type: "button", role: "menuitem", disabled: item.disabled, className: item.danger
|
|
76
|
+
return (_jsxs("div", { ref: rootRef, className: contextmenuRecipe({ className }), children: [_jsx("div", { onContextMenu: open, children: children }), pos && (_jsx(FloatingPortal, { sourceRef: rootRef, children: _jsx("div", { ref: menuRef, className: "crisp-contextmenu-content", role: "menu", "aria-label": menuLabel, style: { left: pos.x, top: pos.y }, onKeyDown: onMenuKeyDown, children: items.map((item, i) => item.separator ? (_jsx("hr", { className: "crisp-contextmenu-sep" }, i)) : (_jsxs("button", { type: "button", role: "menuitem", disabled: item.disabled, className: item.danger
|
|
77
77
|
? "crisp-contextmenu-item crisp-contextmenu-item--danger"
|
|
78
78
|
: "crisp-contextmenu-item", tabIndex: -1, onClick: () => {
|
|
79
79
|
item.onSelect?.();
|
|
@@ -4,18 +4,30 @@ import { contract as c, elevation as e } from "../../tokens/index.js";
|
|
|
4
4
|
// cursor. The content portals to document.body (#339) so no ancestor's
|
|
5
5
|
// transform/backdrop-filter can capture its position: fixed box; z-index 70
|
|
6
6
|
// keeps it above Dialog/Drawer's 60/61.
|
|
7
|
+
//
|
|
8
|
+
// Every content-related selector below lives in `globalCss`, not nested
|
|
9
|
+
// under `&` (#357): nesting compiles to a real descendant combinator scoped
|
|
10
|
+
// to the recipe's root class, which needs actual DOM containment — exactly
|
|
11
|
+
// what the portal to `document.body` breaks. Nested, these rules silently
|
|
12
|
+
// matched nothing and the menu rendered completely unstyled. `font-family`
|
|
13
|
+
// is restated on the content's own rule (items then pick it up via their
|
|
14
|
+
// own `font-family: inherit`, which still works — that inheritance chain is
|
|
15
|
+
// intact WITHIN the portaled subtree, only the link back to the root
|
|
16
|
+
// broke).
|
|
7
17
|
const config = defineRecipe({
|
|
8
18
|
name: "contextmenu",
|
|
9
|
-
base: `display: contents; font-family: ${c.font.sans}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
base: `display: contents; font-family: ${c.font.sans};`,
|
|
20
|
+
globalCss: `
|
|
21
|
+
.crisp-contextmenu-content { font-family: ${c.font.sans}; position: fixed; z-index: 70; min-width: 200px; box-sizing: border-box; padding: ${c.space["1"]}; border-radius: ${c.radius.xl}; background: ${c.bgPopover}; box-shadow: ${e.floating}; opacity: 1; transform: none; transition: opacity .08s ease, transform .08s ease; transform-origin: top left; @starting-style { opacity: 0; transform: scale(0.97) translateY(-1px); } }
|
|
22
|
+
.crisp-contextmenu-item { display: flex; align-items: center; gap: ${c.space["2"]}; width: 100%; height: ${c.size.menuRow}; box-sizing: border-box; padding: 0 ${c.space["2"]}; margin: 0; border: none; border-radius: ${c.radius.md}; background: none; color: ${c.fgPrimary}; font-family: inherit; font-size: ${c.text.lg}; text-align: start; white-space: nowrap; cursor: pointer; }
|
|
23
|
+
.crisp-contextmenu-item svg { flex-shrink: 0; color: ${c.fgMuted}; }
|
|
24
|
+
.crisp-contextmenu-item:hover { background: color-mix(in srgb, ${c.fgPrimary} 6%, transparent); }
|
|
25
|
+
.crisp-contextmenu-item--danger { color: ${c.bgDanger}; }
|
|
26
|
+
.crisp-contextmenu-item--danger svg { color: ${c.bgDanger}; }
|
|
27
|
+
.crisp-contextmenu-item--danger:hover { background: color-mix(in srgb, ${c.bgDanger} 10%, transparent); }
|
|
28
|
+
.crisp-contextmenu-shortcut { margin-inline-start: auto; padding-inline-start: ${c.space["3"]}; color: ${c.fgMuted}; font-size: ${c.text.sm}; }
|
|
29
|
+
.crisp-contextmenu-sep { height: 1px; margin: ${c.space["1"]} 0; border: none; background: ${c.borderSubtle}; }
|
|
30
|
+
`,
|
|
19
31
|
variants: {},
|
|
20
32
|
defaultVariants: {},
|
|
21
33
|
compoundVariants: [],
|
|
@@ -105,7 +105,7 @@ export function Menu({ trigger, children, align = "start", open: openProp, defau
|
|
|
105
105
|
setOpen(!open);
|
|
106
106
|
},
|
|
107
107
|
});
|
|
108
|
-
return (_jsxs("div", { ref: rootRef, className: menuRecipe({ className }), children: [triggerEl, open && (_jsx(FloatingPortal, {
|
|
108
|
+
return (_jsxs("div", { ref: rootRef, className: menuRecipe({ className }), children: [triggerEl, open && (_jsx(FloatingPortal, { sourceRef: rootRef, children: _jsx("div", { ref: contentRef, className: "crisp-menu-content", role: "menu", id: surfaceId, "aria-label": ariaLabel, "aria-labelledby": ariaLabel ? undefined : triggerId, "data-align": align, "data-up": up ? "" : undefined, style: pos, onKeyDown: onContentKeyDown, children: _jsx(MenuContext.Provider, { value: { close }, children: children }) }) }))] }));
|
|
109
109
|
}
|
|
110
110
|
Menu.displayName = "Menu";
|
|
111
111
|
export function MenuItem({ children, icon, shortcut, danger, disabled, onSelect, closeOnSelect = true, }) {
|