@crisp-ui-kit/crisp 0.38.0 → 0.40.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/dialog/dialog.js +12 -0
- package/dist/cjs/components/drawer/drawer.js +7 -0
- 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/cjs/core/floating-stack.js +21 -0
- package/dist/cjs/core/index.js +2 -1
- package/dist/cjs/product/recordpanel/recordpanel.js +13 -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/dialog/dialog.js +13 -1
- package/dist/esm/components/drawer/drawer.js +8 -1
- 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/esm/core/floating-stack.js +20 -0
- package/dist/esm/core/index.js +1 -1
- package/dist/esm/product/recordpanel/recordpanel.js +13 -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/dist/types/core/floating-stack.d.ts +18 -0
- package/dist/types/core/index.d.ts +1 -1
- 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: [],
|
|
@@ -72,6 +72,18 @@ function Dialog({ open, onOpenChange, title, icon, width = 640, "aria-label": ar
|
|
|
72
72
|
// search), rather than the close button; fall back to the machine default.
|
|
73
73
|
initialFocusEl: () => document.querySelector(`[data-crisp-dialog="${id}"] .crisp-dialog-body :where(input, textarea, select, [contenteditable]):not([disabled])`),
|
|
74
74
|
"aria-label": typeof title === "string" ? title : ariaLabel,
|
|
75
|
+
// Defer to a nested Menu/Select/Popover/ContextMenu's own Escape
|
|
76
|
+
// handling (#361): none of those five are Zag machines, so this
|
|
77
|
+
// machine's own dismissable-layer stack has no visibility into them --
|
|
78
|
+
// pressing Escape to close one opened from inside this Dialog closed
|
|
79
|
+
// the Dialog too, since both listen for the same keypress independently.
|
|
80
|
+
// Zag only calls its own dismiss when the event isn't already
|
|
81
|
+
// prevented (`@zag-js/dismissable`), so this cleanly defers instead of
|
|
82
|
+
// racing it.
|
|
83
|
+
onEscapeKeyDown(event) {
|
|
84
|
+
if ((0, core_1.hasOpenFloatingLayer)())
|
|
85
|
+
event.preventDefault();
|
|
86
|
+
},
|
|
75
87
|
});
|
|
76
88
|
const api = dialog.connect(service, react_1.normalizeProps);
|
|
77
89
|
if (!api.open)
|
|
@@ -66,6 +66,13 @@ function Drawer({ open, onOpenChange, side = "right", title, icon, "aria-label":
|
|
|
66
66
|
onOpenChange(details.open);
|
|
67
67
|
},
|
|
68
68
|
"aria-label": typeof title === "string" ? title : ariaLabel,
|
|
69
|
+
// Defer to a nested Menu/Select/Popover/ContextMenu's own Escape
|
|
70
|
+
// handling (#361) -- see Dialog's identical comment; this composes the
|
|
71
|
+
// same Zag machine.
|
|
72
|
+
onEscapeKeyDown(event) {
|
|
73
|
+
if ((0, core_1.hasOpenFloatingLayer)())
|
|
74
|
+
event.preventDefault();
|
|
75
|
+
},
|
|
69
76
|
});
|
|
70
77
|
const api = dialog.connect(service, react_1.normalizeProps);
|
|
71
78
|
if (!api.open)
|
|
@@ -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
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.registerFloatingLayer = registerFloatingLayer;
|
|
4
4
|
exports.isInsideLaterFloatingLayer = isInsideLaterFloatingLayer;
|
|
5
|
+
exports.hasOpenFloatingLayer = hasOpenFloatingLayer;
|
|
5
6
|
/**
|
|
6
7
|
* Tracks every currently-open `FloatingPortal` layer, in open order, so a
|
|
7
8
|
* layer's outside-click check can tell "outside me" from "inside a layer I
|
|
@@ -52,3 +53,23 @@ function isInsideLaterFloatingLayer(target, self) {
|
|
|
52
53
|
}
|
|
53
54
|
return false;
|
|
54
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* True when at least one `Select`/`MultiSelect`/`Menu`/`Popover`/
|
|
58
|
+
* `ContextMenu` is currently open, anywhere (#361).
|
|
59
|
+
*
|
|
60
|
+
* A dismissable container that closes on Escape via its OWN raw keydown
|
|
61
|
+
* listener or a library's dismissable-layer machine (`RecordPanel`,
|
|
62
|
+
* `Dialog`, `Drawer`) has no visibility into these five: none of them are
|
|
63
|
+
* built on the same machine, so a Menu opened from inside a `Dialog`
|
|
64
|
+
* registers here, but the Dialog's own Escape handling doesn't know to
|
|
65
|
+
* check for it. Both listeners fire on the same Escape keydown, so both
|
|
66
|
+
* close — the outer container closing was never the point of that
|
|
67
|
+
* keypress, which was meant for the nested layer alone. Call this before
|
|
68
|
+
* closing on Escape (or in a dismissable-layer's `onEscapeKeyDown`, calling
|
|
69
|
+
* `event.preventDefault()` when it's true) to defer instead: the nested
|
|
70
|
+
* layer's own listener still runs and closes it, and the outer container
|
|
71
|
+
* gets its own, uncontested Escape on the next press.
|
|
72
|
+
*/
|
|
73
|
+
function hasOpenFloatingLayer() {
|
|
74
|
+
return stack.length > 0;
|
|
75
|
+
}
|
package/dist/cjs/core/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.usePrefersReducedMotion = exports.useLabelAssociation = exports.useFormReset = exports.useFocusAfterRemoval = exports.specToRecipe = exports.defineSpec = exports.resolveRecipe = exports.Primitive = exports.placeFloating = exports.formValueStyle = exports.registerFloatingLayer = exports.isInsideLaterFloatingLayer = exports.FloatingPortal = exports.isRtlElement = exports.withDescribedBy = exports.defineRecipe = exports.cx = exports.parseCellDate = exports.formatCellDate = void 0;
|
|
17
|
+
exports.usePrefersReducedMotion = exports.useLabelAssociation = exports.useFormReset = exports.useFocusAfterRemoval = exports.specToRecipe = exports.defineSpec = exports.resolveRecipe = exports.Primitive = exports.placeFloating = exports.formValueStyle = exports.registerFloatingLayer = exports.isInsideLaterFloatingLayer = exports.hasOpenFloatingLayer = exports.FloatingPortal = exports.isRtlElement = exports.withDescribedBy = exports.defineRecipe = exports.cx = exports.parseCellDate = exports.formatCellDate = void 0;
|
|
18
18
|
var cell_date_1 = require("./cell-date");
|
|
19
19
|
Object.defineProperty(exports, "formatCellDate", { enumerable: true, get: function () { return cell_date_1.formatCellDate; } });
|
|
20
20
|
Object.defineProperty(exports, "parseCellDate", { enumerable: true, get: function () { return cell_date_1.parseCellDate; } });
|
|
@@ -29,6 +29,7 @@ Object.defineProperty(exports, "isRtlElement", { enumerable: true, get: function
|
|
|
29
29
|
var floating_portal_1 = require("./floating-portal");
|
|
30
30
|
Object.defineProperty(exports, "FloatingPortal", { enumerable: true, get: function () { return floating_portal_1.FloatingPortal; } });
|
|
31
31
|
var floating_stack_1 = require("./floating-stack");
|
|
32
|
+
Object.defineProperty(exports, "hasOpenFloatingLayer", { enumerable: true, get: function () { return floating_stack_1.hasOpenFloatingLayer; } });
|
|
32
33
|
Object.defineProperty(exports, "isInsideLaterFloatingLayer", { enumerable: true, get: function () { return floating_stack_1.isInsideLaterFloatingLayer; } });
|
|
33
34
|
Object.defineProperty(exports, "registerFloatingLayer", { enumerable: true, get: function () { return floating_stack_1.registerFloatingLayer; } });
|
|
34
35
|
var form_value_1 = require("./form-value");
|
|
@@ -38,6 +38,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
38
38
|
const lucide_react_1 = require("lucide-react");
|
|
39
39
|
const React = __importStar(require("react"));
|
|
40
40
|
const avatar_1 = require("../../components/avatar");
|
|
41
|
+
const core_1 = require("../../core");
|
|
41
42
|
const recordstable_1 = require("../recordstable");
|
|
42
43
|
const recordpanel_recipe_1 = require("./recordpanel.recipe");
|
|
43
44
|
function FieldValue({ col, row, emptyLabel, }) {
|
|
@@ -64,11 +65,21 @@ function FieldValue({ col, row, emptyLabel, }) {
|
|
|
64
65
|
*/
|
|
65
66
|
function RecordPanel({ record, columns, onClose, className, closeLabel = "Close panel", title, detailsLabel = "Details", emptyLabel = "Empty", footer, ...rest }) {
|
|
66
67
|
const titleId = React.useId();
|
|
67
|
-
// close on Escape while open
|
|
68
|
+
// close on Escape while open -- but not when a Menu/Select/Popover/
|
|
69
|
+
// ContextMenu opened from inside the panel (e.g. a footer "More actions"
|
|
70
|
+
// menu) is itself open (#361): that Escape belongs to the nested layer,
|
|
71
|
+
// which has its own listener and will close itself. Without this check
|
|
72
|
+
// both close on the same keypress, since neither knows about the other --
|
|
73
|
+
// none of the five are built on this listener or registered anywhere it
|
|
74
|
+
// can see, only on the shared floating-stack this checks instead.
|
|
68
75
|
React.useEffect(() => {
|
|
69
76
|
if (!record)
|
|
70
77
|
return;
|
|
71
|
-
const onKey = (e) =>
|
|
78
|
+
const onKey = (e) => {
|
|
79
|
+
if (e.key !== "Escape" || (0, core_1.hasOpenFloatingLayer)())
|
|
80
|
+
return;
|
|
81
|
+
onClose();
|
|
82
|
+
};
|
|
72
83
|
document.addEventListener("keydown", onKey);
|
|
73
84
|
return () => document.removeEventListener("keydown", onKey);
|
|
74
85
|
}, [record, onClose]);
|