@stll/ui 0.87.0 → 0.89.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/components/document-mark.shared.d.ts +2 -0
- package/dist/components/document-mark.shared.js +18 -0
- package/dist/components/entity-actions.d.ts +8 -1
- package/dist/components/entity-actions.js +33 -21
- package/dist/components/switch.d.ts +7 -2
- package/dist/components/switch.js +21 -11
- package/package.json +1 -1
|
@@ -24,6 +24,8 @@ export declare const DOCUMENT_MARKS: {
|
|
|
24
24
|
readonly asicS: DocumentMarkArtwork;
|
|
25
25
|
readonly bdoc: DocumentMarkArtwork;
|
|
26
26
|
readonly cades: DocumentMarkArtwork;
|
|
27
|
+
readonly cadesDetached: DocumentMarkArtwork;
|
|
28
|
+
readonly xades: DocumentMarkArtwork;
|
|
27
29
|
readonly fatturaPA: DocumentMarkArtwork;
|
|
28
30
|
readonly isdoc: DocumentMarkArtwork;
|
|
29
31
|
readonly isdocx: DocumentMarkArtwork;
|
|
@@ -496,6 +496,24 @@ const DOCUMENT_MARKS = {
|
|
|
496
496
|
"M"
|
|
497
497
|
]]
|
|
498
498
|
}),
|
|
499
|
+
cadesDetached: taggedFormatMark({
|
|
500
|
+
color: "#57418a",
|
|
501
|
+
lines: [[
|
|
502
|
+
"P",
|
|
503
|
+
"7",
|
|
504
|
+
"S"
|
|
505
|
+
]]
|
|
506
|
+
}),
|
|
507
|
+
xades: taggedFormatMark({
|
|
508
|
+
color: "#4b4f8f",
|
|
509
|
+
lines: [[
|
|
510
|
+
"X",
|
|
511
|
+
"A",
|
|
512
|
+
"D",
|
|
513
|
+
"E",
|
|
514
|
+
"S"
|
|
515
|
+
]]
|
|
516
|
+
}),
|
|
499
517
|
fatturaPA: taggedFormatMark({
|
|
500
518
|
color: "#1d6f42",
|
|
501
519
|
lines: [[
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ContextMenuAction } from "./context-menu.js";
|
|
2
2
|
import { ReactNode, Ref } from "react";
|
|
3
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
3
4
|
/** One action of an object: the same shape `ContextMenu` renders. */
|
|
4
5
|
export type EntityAction = ContextMenuAction;
|
|
5
6
|
export type EntityActionsProps = {
|
|
@@ -14,12 +15,18 @@ export type EntityActionsProps = {
|
|
|
14
15
|
heading?: ReactNode;
|
|
15
16
|
/** The accessible name of the "…" button, e.g. "Actions". */
|
|
16
17
|
label: string;
|
|
18
|
+
/**
|
|
19
|
+
* Optional host element to attach the right-click listener to directly
|
|
20
|
+
* (for example `<TableRow />`, where a wrapping `<div className="contents">`
|
|
21
|
+
* would be invalid HTML inside `<tbody>`).
|
|
22
|
+
*/
|
|
23
|
+
render?: useRender.RenderProp;
|
|
17
24
|
};
|
|
18
25
|
/**
|
|
19
26
|
* An object's actions: the right-click menu over `children`, and the list
|
|
20
27
|
* an `EntityActionsButton` inside them opens.
|
|
21
28
|
*/
|
|
22
|
-
export declare const EntityActions: ({ actions, children, heading, label }: EntityActionsProps) => import("react").JSX.Element;
|
|
29
|
+
export declare const EntityActions: ({ actions, children, heading, label, render }: EntityActionsProps) => import("react").JSX.Element;
|
|
23
30
|
export type EntityActionsButtonProps = {
|
|
24
31
|
/** Popup alignment against the button. */
|
|
25
32
|
align?: "center" | "end" | "start";
|
|
@@ -6,7 +6,9 @@ import { ContextMenuActionItems } from "./context-menu.js";
|
|
|
6
6
|
import { DropdownMenu as Menu, DropdownMenuContent as MenuPopup, DropdownMenuGroup as MenuGroup, DropdownMenuLabel as MenuGroupLabel, DropdownMenuSeparator as MenuSeparator, DropdownMenuTrigger as MenuTrigger, MenuAnchor } from "./menu.js";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { createContext, use, useRef, useState } from "react";
|
|
9
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
9
10
|
import { panic } from "better-result";
|
|
11
|
+
import { createPortal } from "react-dom";
|
|
10
12
|
// src/components/entity-actions.tsx
|
|
11
13
|
const EntityActionsContext = createContext(null);
|
|
12
14
|
const isContextMenuKey = (event) => event.key === "ContextMenu" || event.shiftKey && event.key === "F10";
|
|
@@ -39,8 +41,9 @@ const EntityActionItems = ({ actions, heading }) => /* @__PURE__ */ jsxs(Fragmen
|
|
|
39
41
|
* An object's actions: the right-click menu over `children`, and the list
|
|
40
42
|
* an `EntityActionsButton` inside them opens.
|
|
41
43
|
*/
|
|
42
|
-
const EntityActions = ({ actions, children, heading, label }) => {
|
|
44
|
+
const EntityActions = ({ actions, children, heading, label, render }) => {
|
|
43
45
|
const [open, setOpen] = useState(false);
|
|
46
|
+
const [hasOpened, setHasOpened] = useState(false);
|
|
44
47
|
const [anchor, setAnchor] = useState(null);
|
|
45
48
|
const returnFocus = useRef(null);
|
|
46
49
|
const context = {
|
|
@@ -53,6 +56,7 @@ const EntityActions = ({ actions, children, heading, label }) => {
|
|
|
53
56
|
event.preventDefault();
|
|
54
57
|
event.stopPropagation();
|
|
55
58
|
returnFocus.current = focusReturnTarget(event.currentTarget, event.target);
|
|
59
|
+
setHasOpened(true);
|
|
56
60
|
setAnchor(anchorRect);
|
|
57
61
|
setOpen(true);
|
|
58
62
|
};
|
|
@@ -71,32 +75,40 @@ const EntityActions = ({ actions, children, heading, label }) => {
|
|
|
71
75
|
}) !== null) return;
|
|
72
76
|
openAt(event, { getBoundingClientRect: () => target.getBoundingClientRect() });
|
|
73
77
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
const target = useRender({
|
|
79
|
+
defaultTagName: "div",
|
|
80
|
+
render,
|
|
81
|
+
props: {
|
|
82
|
+
...render === void 0 ? {
|
|
83
|
+
className: "contents",
|
|
84
|
+
role: "presentation"
|
|
85
|
+
} : {},
|
|
78
86
|
"data-context-menu-target": "",
|
|
79
87
|
"data-slot": "entity-actions",
|
|
80
88
|
onContextMenu: handleContextMenu,
|
|
81
89
|
onKeyDown: handleKeyDown,
|
|
82
|
-
role: "presentation",
|
|
83
90
|
children
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
const contextMenu = hasActions && hasOpened ? /* @__PURE__ */ jsxs(Menu, {
|
|
94
|
+
onOpenChange: (nextOpen) => {
|
|
95
|
+
setOpen(nextOpen);
|
|
96
|
+
if (!nextOpen) setAnchor(null);
|
|
97
|
+
},
|
|
98
|
+
open,
|
|
99
|
+
children: [/* @__PURE__ */ jsx(MenuAnchor, {}), /* @__PURE__ */ jsx(MenuPopup, {
|
|
100
|
+
anchor: anchor ?? void 0,
|
|
101
|
+
"data-slot": "entity-actions-context-popup",
|
|
102
|
+
finalFocus: () => returnFocus.current ?? false,
|
|
103
|
+
children: /* @__PURE__ */ jsx(EntityActionItems, {
|
|
104
|
+
actions,
|
|
105
|
+
heading
|
|
106
|
+
})
|
|
99
107
|
})]
|
|
108
|
+
}) : null;
|
|
109
|
+
return /* @__PURE__ */ jsxs(EntityActionsContext, {
|
|
110
|
+
value: context,
|
|
111
|
+
children: [target, contextMenu !== null && typeof document !== "undefined" && createPortal(contextMenu, document.body)]
|
|
100
112
|
});
|
|
101
113
|
};
|
|
102
114
|
/**
|
|
@@ -3,15 +3,20 @@ import { Switch as Switch$1 } from "@base-ui/react/switch";
|
|
|
3
3
|
import { SwitchSize } from "./toggle-classes.js";
|
|
4
4
|
type SwitchProps = Switch$1.Root.Props & {
|
|
5
5
|
size?: SwitchSize | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Why the switch cannot be toggled right now, in the reader's terms.
|
|
8
|
+
* Shown as a tooltip while `disabled` is true.
|
|
9
|
+
*/
|
|
10
|
+
disabledReason?: React.ReactNode;
|
|
6
11
|
};
|
|
7
|
-
declare const Switch: ({ className, size, ...props }: SwitchProps) => React.JSX.Element;
|
|
12
|
+
declare const Switch: ({ className, disabled, disabledReason, size, ...props }: SwitchProps) => React.JSX.Element;
|
|
8
13
|
/**
|
|
9
14
|
* A setting row: its label and an optional description at the start, the
|
|
10
15
|
* switch at the end. The whole row is the label, so a click anywhere on it
|
|
11
16
|
* flips the switch, and the row is at least 44px tall for touch. The
|
|
12
17
|
* description is linked to the switch, so it is read after the name.
|
|
13
18
|
*/
|
|
14
|
-
declare const SwitchField: ({ className, description, label, size, ...props }: SwitchProps & {
|
|
19
|
+
declare const SwitchField: ({ className, description, disabledReason, label, size, ...props }: SwitchProps & {
|
|
15
20
|
label: React.ReactNode;
|
|
16
21
|
description?: React.ReactNode;
|
|
17
22
|
}) => React.JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../lib/utils.js";
|
|
3
3
|
import { SWITCH_ROOT_CLASS_NAME, SWITCH_ROOT_SIZE_CLASS_NAME } from "./toggle-classes.js";
|
|
4
|
+
import { renderTooltipTrigger } from "./tooltip-trigger-helper.js";
|
|
4
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
6
|
import { useId } from "react";
|
|
6
7
|
import { Switch as Switch$1 } from "@base-ui/react/switch";
|
|
@@ -9,23 +10,31 @@ const SWITCH_THUMB_SIZE_CLASS_NAME = {
|
|
|
9
10
|
default: "size-4 ltr:data-checked:translate-x-4.5 ltr:data-unchecked:translate-x-0.5 rtl:data-checked:-translate-x-4.5 rtl:data-unchecked:-translate-x-0.5",
|
|
10
11
|
sm: "size-3 ltr:data-checked:translate-x-3.5 ltr:data-unchecked:translate-x-0.5 rtl:data-checked:-translate-x-3.5 rtl:data-unchecked:-translate-x-0.5"
|
|
11
12
|
};
|
|
12
|
-
const Switch = ({ className, size = "default", ...props }) =>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
const Switch = ({ className, disabled, disabledReason, size = "default", ...props }) => {
|
|
14
|
+
const trigger = /* @__PURE__ */ jsx(Switch$1.Root, {
|
|
15
|
+
className: cn(SWITCH_ROOT_CLASS_NAME, SWITCH_ROOT_SIZE_CLASS_NAME[size], className),
|
|
16
|
+
"data-size": size,
|
|
17
|
+
"data-slot": "switch",
|
|
18
|
+
disabled,
|
|
19
|
+
...props,
|
|
20
|
+
children: /* @__PURE__ */ jsx(Switch$1.Thumb, {
|
|
21
|
+
className: cn("bg-background pointer-events-none block rounded-full shadow-xs transition-transform", SWITCH_THUMB_SIZE_CLASS_NAME[size]),
|
|
22
|
+
"data-slot": "switch-thumb"
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
return renderTooltipTrigger({
|
|
26
|
+
keepTriggerMounted: disabledReason !== void 0,
|
|
27
|
+
tooltip: disabled ? disabledReason : void 0,
|
|
28
|
+
trigger
|
|
29
|
+
});
|
|
30
|
+
};
|
|
22
31
|
/**
|
|
23
32
|
* A setting row: its label and an optional description at the start, the
|
|
24
33
|
* switch at the end. The whole row is the label, so a click anywhere on it
|
|
25
34
|
* flips the switch, and the row is at least 44px tall for touch. The
|
|
26
35
|
* description is linked to the switch, so it is read after the name.
|
|
27
36
|
*/
|
|
28
|
-
const SwitchField = ({ className, description, label, size, ...props }) => {
|
|
37
|
+
const SwitchField = ({ className, description, disabledReason, label, size, ...props }) => {
|
|
29
38
|
const descriptionId = useId();
|
|
30
39
|
return /* @__PURE__ */ jsxs("label", {
|
|
31
40
|
className: cn("flex min-h-11 cursor-pointer items-center justify-between gap-4 py-2 has-data-disabled:cursor-not-allowed", className),
|
|
@@ -43,6 +52,7 @@ const SwitchField = ({ className, description, label, size, ...props }) => {
|
|
|
43
52
|
})]
|
|
44
53
|
}), /* @__PURE__ */ jsx(Switch, {
|
|
45
54
|
"aria-describedby": description === void 0 ? void 0 : descriptionId,
|
|
55
|
+
disabledReason,
|
|
46
56
|
size,
|
|
47
57
|
...props
|
|
48
58
|
})]
|
package/package.json
CHANGED