@setsquare/ui 0.9.1 → 0.11.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/CHANGELOG.md +107 -0
- package/README.md +5 -2
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/cn.d.ts.map +1 -1
- package/dist/lib/cn.js +1 -0
- package/dist/lib/cn.js.map +1 -1
- package/dist/lib/english.d.ts.map +1 -1
- package/dist/lib/english.js +2 -0
- package/dist/lib/english.js.map +1 -1
- package/dist/lib/locale.d.ts +3 -0
- package/dist/lib/locale.d.ts.map +1 -1
- package/dist/lib/locale.js.map +1 -1
- package/dist/lib/timeline-scale.d.ts +106 -0
- package/dist/lib/timeline-scale.d.ts.map +1 -0
- package/dist/lib/timeline-scale.js +221 -0
- package/dist/lib/timeline-scale.js.map +1 -0
- package/dist/lib/use-scroll-tab-stop.d.ts +9 -0
- package/dist/lib/use-scroll-tab-stop.d.ts.map +1 -0
- package/dist/lib/use-scroll-tab-stop.js +46 -0
- package/dist/lib/use-scroll-tab-stop.js.map +1 -0
- package/dist/shell/dashboard-shell.d.ts +1 -0
- package/dist/shell/dashboard-shell.d.ts.map +1 -1
- package/dist/shell/dashboard-shell.js +2 -34
- package/dist/shell/dashboard-shell.js.map +1 -1
- package/dist/shell/page-header.d.ts +7 -1
- package/dist/shell/page-header.d.ts.map +1 -1
- package/dist/shell/page-header.js +3 -2
- package/dist/shell/page-header.js.map +1 -1
- package/dist/shell/right-panel.d.ts +29 -1
- package/dist/shell/right-panel.d.ts.map +1 -1
- package/dist/shell/right-panel.js +14 -5
- package/dist/shell/right-panel.js.map +1 -1
- package/dist/styles/theme.css +16 -0
- package/dist/styles/tokens.css +23 -0
- package/dist/tokens.json +95 -0
- package/dist/ui/button.d.ts +2 -1
- package/dist/ui/button.d.ts.map +1 -1
- package/dist/ui/button.js +9 -3
- package/dist/ui/button.js.map +1 -1
- package/dist/ui/dialog.d.ts +14 -2
- package/dist/ui/dialog.d.ts.map +1 -1
- package/dist/ui/dialog.js +19 -4
- package/dist/ui/dialog.js.map +1 -1
- package/dist/ui/disabled-reason.d.ts +36 -0
- package/dist/ui/disabled-reason.d.ts.map +1 -0
- package/dist/ui/disabled-reason.js +27 -0
- package/dist/ui/disabled-reason.js.map +1 -0
- package/dist/ui/icon-button.d.ts.map +1 -1
- package/dist/ui/icon-button.js +10 -6
- package/dist/ui/icon-button.js.map +1 -1
- package/dist/ui/menu.d.ts +9 -3
- package/dist/ui/menu.d.ts.map +1 -1
- package/dist/ui/menu.js +22 -4
- package/dist/ui/menu.js.map +1 -1
- package/dist/ui/timeline.d.ts +231 -0
- package/dist/ui/timeline.d.ts.map +1 -0
- package/dist/ui/timeline.js +539 -0
- package/dist/ui/timeline.js.map +1 -0
- package/package.json +2 -2
package/dist/styles/tokens.css
CHANGED
|
@@ -31,6 +31,8 @@
|
|
|
31
31
|
--control-gap-aaa: 12px;
|
|
32
32
|
--nav-item-height-aa: 36px;
|
|
33
33
|
--nav-item-height-aaa: 36px;
|
|
34
|
+
--lane-height-aa: 32px;
|
|
35
|
+
--lane-height-aaa: 44px;
|
|
34
36
|
--nav-item-gap-aa: 2px;
|
|
35
37
|
--nav-item-gap-aaa: 4px;
|
|
36
38
|
--choice-size-aa: 20px;
|
|
@@ -48,6 +50,15 @@
|
|
|
48
50
|
--measure-aaa: 64ch;
|
|
49
51
|
--motion-distance-aa: 8px;
|
|
50
52
|
--motion-distance-aaa: 0px;
|
|
53
|
+
--control-height-compact: 28px;
|
|
54
|
+
--control-height-sm-compact: 24px;
|
|
55
|
+
--control-height-lg-compact: 36px;
|
|
56
|
+
--control-pad-x-compact: 8px;
|
|
57
|
+
--control-gap-compact: 4px;
|
|
58
|
+
--nav-item-height-compact: 28px;
|
|
59
|
+
--lane-height-compact: 24px;
|
|
60
|
+
--field-gap-compact: 12px;
|
|
61
|
+
--text-sm-compact: 13px;
|
|
51
62
|
--header-height-aa: 56px;
|
|
52
63
|
--header-height-aaa: 56px;
|
|
53
64
|
--sidebar-width-aa: 256px;
|
|
@@ -61,6 +72,14 @@
|
|
|
61
72
|
--subnav-width-aaa: 240px;
|
|
62
73
|
--panel-width-aa: 320px;
|
|
63
74
|
--panel-width-aaa: 360px;
|
|
75
|
+
--panel-width-wide-aa: 512px;
|
|
76
|
+
--panel-width-wide-aaa: 560px;
|
|
77
|
+
--panel-width-max: 720px;
|
|
78
|
+
--dialog-width-sm: 26rem;
|
|
79
|
+
--dialog-width-md: 32rem;
|
|
80
|
+
--dialog-width-lg: 44rem;
|
|
81
|
+
--dialog-width-xl: 60rem;
|
|
82
|
+
--dialog-width-2xl: 77.5rem;
|
|
64
83
|
--gutter: 24px;
|
|
65
84
|
--content-max: 1440px;
|
|
66
85
|
--site-max: 1180px;
|
|
@@ -92,6 +111,7 @@
|
|
|
92
111
|
--control-pad-x: var(--control-pad-x-aa);
|
|
93
112
|
--control-gap: var(--control-gap-aa);
|
|
94
113
|
--nav-item-height: var(--nav-item-height-aa);
|
|
114
|
+
--lane-height: var(--lane-height-aa);
|
|
95
115
|
--nav-item-gap: var(--nav-item-gap-aa);
|
|
96
116
|
--choice-size: var(--choice-size-aa);
|
|
97
117
|
--field-gap: var(--field-gap-aa);
|
|
@@ -106,6 +126,7 @@
|
|
|
106
126
|
--rail-width: var(--rail-width-aa);
|
|
107
127
|
--subnav-width: var(--subnav-width-aa);
|
|
108
128
|
--panel-width: var(--panel-width-aa);
|
|
129
|
+
--panel-width-wide: var(--panel-width-wide-aa);
|
|
109
130
|
}
|
|
110
131
|
:root[data-conformance="aaa"] {
|
|
111
132
|
--target-min: var(--target-min-aaa);
|
|
@@ -115,6 +136,7 @@
|
|
|
115
136
|
--control-pad-x: var(--control-pad-x-aaa);
|
|
116
137
|
--control-gap: var(--control-gap-aaa);
|
|
117
138
|
--nav-item-height: var(--nav-item-height-aaa);
|
|
139
|
+
--lane-height: var(--lane-height-aaa);
|
|
118
140
|
--nav-item-gap: var(--nav-item-gap-aaa);
|
|
119
141
|
--choice-size: var(--choice-size-aaa);
|
|
120
142
|
--field-gap: var(--field-gap-aaa);
|
|
@@ -129,6 +151,7 @@
|
|
|
129
151
|
--rail-width: var(--rail-width-aaa);
|
|
130
152
|
--subnav-width: var(--subnav-width-aaa);
|
|
131
153
|
--panel-width: var(--panel-width-aaa);
|
|
154
|
+
--panel-width-wide: var(--panel-width-wide-aaa);
|
|
132
155
|
}
|
|
133
156
|
@media (prefers-reduced-motion: reduce) { :root { --motion-distance: 0px; } }
|
|
134
157
|
|
package/dist/tokens.json
CHANGED
|
@@ -753,6 +753,16 @@
|
|
|
753
753
|
"value": "36px",
|
|
754
754
|
"usage": "Equal to AA by default: at AAA the 36px highlight sits in a 44px row."
|
|
755
755
|
},
|
|
756
|
+
{
|
|
757
|
+
"name": "lane-height-aa",
|
|
758
|
+
"value": "32px",
|
|
759
|
+
"usage": "A timeline lane's height, and its ruler's and marker bands' tiers (resolved as --lane-height). An item on a lane is the lane's height, so it is a target at least --target-min tall."
|
|
760
|
+
},
|
|
761
|
+
{
|
|
762
|
+
"name": "lane-height-aaa",
|
|
763
|
+
"value": "44px",
|
|
764
|
+
"usage": "At AAA a lane is the 44px target size (2.5.5), so seven lanes are 308px."
|
|
765
|
+
},
|
|
756
766
|
{
|
|
757
767
|
"name": "nav-item-gap-aa",
|
|
758
768
|
"value": "2px",
|
|
@@ -837,6 +847,51 @@
|
|
|
837
847
|
"name": "motion-distance-aaa",
|
|
838
848
|
"value": "0px",
|
|
839
849
|
"usage": "WCAG 2.3.3: at AAA transitions fade only — opacity is not motion — so no interaction moves content."
|
|
850
|
+
},
|
|
851
|
+
{
|
|
852
|
+
"name": "control-height-compact",
|
|
853
|
+
"value": "28px",
|
|
854
|
+
"usage": "data-density=\"compact\", at AA only: a control's painted height (resolved as --control-height). Its target stays at least --target-min."
|
|
855
|
+
},
|
|
856
|
+
{
|
|
857
|
+
"name": "control-height-sm-compact",
|
|
858
|
+
"value": "24px",
|
|
859
|
+
"usage": "Compact density's small controls: the AA target floor, so paint and target are one."
|
|
860
|
+
},
|
|
861
|
+
{
|
|
862
|
+
"name": "control-height-lg-compact",
|
|
863
|
+
"value": "36px",
|
|
864
|
+
"usage": "Compact density's large controls."
|
|
865
|
+
},
|
|
866
|
+
{
|
|
867
|
+
"name": "control-pad-x-compact",
|
|
868
|
+
"value": "8px",
|
|
869
|
+
"usage": "Compact density's padding either side of a control's content."
|
|
870
|
+
},
|
|
871
|
+
{
|
|
872
|
+
"name": "control-gap-compact",
|
|
873
|
+
"value": "4px",
|
|
874
|
+
"usage": "Compact density's gap between controls. Targets don't overlap: a control's target is its own box."
|
|
875
|
+
},
|
|
876
|
+
{
|
|
877
|
+
"name": "nav-item-height-compact",
|
|
878
|
+
"value": "28px",
|
|
879
|
+
"usage": "Compact density's menu and list rows."
|
|
880
|
+
},
|
|
881
|
+
{
|
|
882
|
+
"name": "lane-height-compact",
|
|
883
|
+
"value": "24px",
|
|
884
|
+
"usage": "Compact density's timeline lanes: the AA target floor (2.5.8), the smallest lane whose items are targets without leaning on the spacing exception. Holds 13px text at a line height of 1.5."
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
"name": "field-gap-compact",
|
|
888
|
+
"value": "12px",
|
|
889
|
+
"usage": "Compact density's space between fields."
|
|
890
|
+
},
|
|
891
|
+
{
|
|
892
|
+
"name": "text-sm-compact",
|
|
893
|
+
"value": "13px",
|
|
894
|
+
"usage": "Compact density's interface text (Tailwind's text-sm): the system's 13px floor, never smaller."
|
|
840
895
|
}
|
|
841
896
|
]
|
|
842
897
|
},
|
|
@@ -908,6 +963,46 @@
|
|
|
908
963
|
"value": "360px",
|
|
909
964
|
"usage": "Right panel at AAA."
|
|
910
965
|
},
|
|
966
|
+
{
|
|
967
|
+
"name": "panel-width-wide-aa",
|
|
968
|
+
"value": "512px",
|
|
969
|
+
"usage": "RightPanel width=\"wide\": a panel that is a working surface, such as a chat (resolved as --panel-width-wide)."
|
|
970
|
+
},
|
|
971
|
+
{
|
|
972
|
+
"name": "panel-width-wide-aaa",
|
|
973
|
+
"value": "560px",
|
|
974
|
+
"usage": "RightPanel width=\"wide\" at AAA."
|
|
975
|
+
},
|
|
976
|
+
{
|
|
977
|
+
"name": "panel-width-max",
|
|
978
|
+
"value": "720px",
|
|
979
|
+
"usage": "The widest a resizable RightPanel can be dragged; never more than half the shell either."
|
|
980
|
+
},
|
|
981
|
+
{
|
|
982
|
+
"name": "dialog-width-sm",
|
|
983
|
+
"value": "26rem",
|
|
984
|
+
"usage": "Dialog size=\"sm\": a confirmation."
|
|
985
|
+
},
|
|
986
|
+
{
|
|
987
|
+
"name": "dialog-width-md",
|
|
988
|
+
"value": "32rem",
|
|
989
|
+
"usage": "Dialog size=\"md\", the default: a short form."
|
|
990
|
+
},
|
|
991
|
+
{
|
|
992
|
+
"name": "dialog-width-lg",
|
|
993
|
+
"value": "44rem",
|
|
994
|
+
"usage": "Dialog size=\"lg\": a longer form, two columns."
|
|
995
|
+
},
|
|
996
|
+
{
|
|
997
|
+
"name": "dialog-width-xl",
|
|
998
|
+
"value": "60rem",
|
|
999
|
+
"usage": "Dialog size=\"xl\": a gallery of cards, a picker with a preview."
|
|
1000
|
+
},
|
|
1001
|
+
{
|
|
1002
|
+
"name": "dialog-width-2xl",
|
|
1003
|
+
"value": "77.5rem",
|
|
1004
|
+
"usage": "Dialog size=\"2xl\": a library or a board, 1240px. size=\"full\" fills the viewport but its margins."
|
|
1005
|
+
},
|
|
911
1006
|
{
|
|
912
1007
|
"name": "gutter",
|
|
913
1008
|
"value": "24px",
|
package/dist/ui/button.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { composeRenderProps, type ButtonProps as RACButtonProps, type LinkProps as RACLinkProps } from 'react-aria-components';
|
|
2
2
|
import { type ButtonVariant, type ButtonVisualSize } from './button-styles.js';
|
|
3
3
|
import { type KeyshortcutsProps } from '../lib/keyshortcuts.js';
|
|
4
|
+
import { type DisabledReasonProps } from './disabled-reason.js';
|
|
4
5
|
export type { ButtonVariant, ButtonVisualSize };
|
|
5
6
|
interface LayerProps {
|
|
6
7
|
variant?: ButtonVariant;
|
|
@@ -13,7 +14,7 @@ interface LayerProps {
|
|
|
13
14
|
/** Layer 2, the painted box. */
|
|
14
15
|
visualClassName?: string;
|
|
15
16
|
}
|
|
16
|
-
export interface ButtonProps extends Omit<RACButtonProps, 'className'>, LayerProps, KeyshortcutsProps {
|
|
17
|
+
export interface ButtonProps extends Omit<RACButtonProps, 'className'>, LayerProps, KeyshortcutsProps, DisabledReasonProps {
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
19
20
|
* React Aria Button. One `primary` per view; `outline` is the default.
|
package/dist/ui/button.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/ui/button.tsx"],"names":[],"mappings":"AAGA,OAAO,EAGL,kBAAkB,EAClB,KAAK,WAAW,IAAI,cAAc,EAClC,KAAK,SAAS,IAAI,YAAY,EAC/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEjF,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,CAAC;AAEhD,UAAU,UAAU;IAClB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,mGAAmG;IACnG,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,oDAAoD;IACpD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,oGAAoG;IACpG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gCAAgC;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,WACf,SAAQ,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,EAAE,UAAU,EAAE,iBAAiB;CAAG;
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/ui/button.tsx"],"names":[],"mappings":"AAGA,OAAO,EAGL,kBAAkB,EAClB,KAAK,WAAW,IAAI,cAAc,EAClC,KAAK,SAAS,IAAI,YAAY,EAC/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEjF,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,CAAC;AAEhD,UAAU,UAAU;IAClB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,mGAAmG;IACnG,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,oDAAoD;IACpD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,oGAAoG;IACpG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gCAAgC;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,WACf,SAAQ,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,EAAE,UAAU,EAAE,iBAAiB,EAAE,mBAAmB;CAAG;AAElG;;;GAGG;AACH,eAAO,MAAM,MAAM,2GAuDjB,CAAC;AAEH,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,EAAE,UAAU,EAAE,iBAAiB;CAAG;AAE3E,wGAAwG;AACxG,eAAO,MAAM,UAAU,+GA8BrB,CAAC;AAEH,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/ui/button.js
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { forwardRef } from 'react';
|
|
3
|
+
import { forwardRef, useId } from 'react';
|
|
4
4
|
import { Button as RACButton, Link as RACLink, composeRenderProps, } from 'react-aria-components';
|
|
5
5
|
import { buttonTargetStyles, buttonVisualStyles, } from './button-styles.js';
|
|
6
6
|
import { SpinnerIcon } from './spinner.js';
|
|
7
7
|
import { useKeyshortcuts } from '../lib/keyshortcuts.js';
|
|
8
|
+
import { Tooltip, TooltipTrigger } from './tooltip.js';
|
|
9
|
+
import { DisabledReasonText, disabledReasonProps, } from './disabled-reason.js';
|
|
8
10
|
/**
|
|
9
11
|
* React Aria Button. One `primary` per view; `outline` is the default.
|
|
10
12
|
* `isPending` keeps it focusable, announces the wait and swaps any leading icon for a spinner.
|
|
11
13
|
*/
|
|
12
|
-
export const Button = forwardRef(function Button({ variant = 'outline', visualSize = 'default', fullWidth, className, visualClassName, children, 'aria-keyshortcuts': keys, ...props }, ref) {
|
|
14
|
+
export const Button = forwardRef(function Button({ variant = 'outline', visualSize = 'default', fullWidth, className, visualClassName, children, 'aria-keyshortcuts': keys, disabledReason, ...props }, ref) {
|
|
13
15
|
const iconOnly = visualSize === 'icon' || visualSize === 'icon-sm';
|
|
14
16
|
const target = useKeyshortcuts(keys, ref);
|
|
15
|
-
|
|
17
|
+
const reasonId = useId();
|
|
18
|
+
const button = (_jsx(RACButton, { ref: target, ...props, ...disabledReasonProps(disabledReason, props['aria-describedby'], reasonId), className: buttonTargetStyles({ fullWidth, className }), children: composeRenderProps(children, (kids, { isPending }) => (_jsx("span", { className: buttonVisualStyles({
|
|
16
19
|
variant,
|
|
17
20
|
visualSize,
|
|
18
21
|
fullWidth,
|
|
19
22
|
className: visualClassName,
|
|
20
23
|
}), children: isPending && iconOnly ? (_jsx(SpinnerIcon, {})) : (_jsxs(_Fragment, { children: [isPending && _jsx(SpinnerIcon, {}), kids] })) }))) }));
|
|
24
|
+
if (!disabledReason)
|
|
25
|
+
return button;
|
|
26
|
+
return (_jsxs(_Fragment, { children: [_jsxs(TooltipTrigger, { delay: 500, children: [button, _jsx(Tooltip, { children: disabledReason })] }), _jsx(DisabledReasonText, { reason: disabledReason, id: reasonId })] }));
|
|
21
27
|
});
|
|
22
28
|
/** A link that looks like a button — for navigation, never for actions. Same three layers as Button. */
|
|
23
29
|
export const LinkButton = forwardRef(function LinkButton({ variant = 'outline', visualSize = 'default', fullWidth, className, visualClassName, children, 'aria-keyshortcuts': keys, ...props }, ref) {
|
package/dist/ui/button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../src/ui/button.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../src/ui/button.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EACL,MAAM,IAAI,SAAS,EACnB,IAAI,IAAI,OAAO,EACf,kBAAkB,GAGnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GAGnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,eAAe,EAA0B,MAAM,wBAAwB,CAAC;AACjF,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EACL,kBAAkB,EAClB,mBAAmB,GAEpB,MAAM,sBAAsB,CAAC;AAmB9B;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,UAAU,CAAiC,SAAS,MAAM,CAC9E,EACE,OAAO,GAAG,SAAS,EACnB,UAAU,GAAG,SAAS,EACtB,SAAS,EACT,SAAS,EACT,eAAe,EACf,QAAQ,EACR,mBAAmB,EAAE,IA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B,UAAU,GAAG,SAAS,EACtB,SAAS,EACT,SAAS,EACT,eAAe,EACf,QAAQ,EACR,mBAAmB,EAAE,IAAI,EACzB,GAAG,KAAK,EACT,EACD,GAAG;IAEH,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC1C,OAAO,CACL,KAAC,OAAO,IAAC,GAAG,EAAE,MAAM,KAAM,KAAK,EAAE,SAAS,EAAE,kBAAkB,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,YACrF,kBAAkB,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CACtC,eACE,SAAS,EAAE,kBAAkB,CAAC;gBAC5B,OAAO;gBACP,UAAU;gBACV,SAAS;gBACT,SAAS,EAAE,eAAe;aAC3B,CAAC,YAED,IAAI,GACA,CACR,CAAC,GACM,CACX,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/ui/dialog.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
+
import { type IconProp } from './icon.js';
|
|
2
3
|
/** A Dialog's words, for the `labels` prop. */
|
|
3
4
|
export interface DialogLabels {
|
|
4
5
|
close: string;
|
|
@@ -8,20 +9,31 @@ export interface DialogProps {
|
|
|
8
9
|
isOpen: boolean;
|
|
9
10
|
onOpenChange: (open: boolean) => void;
|
|
10
11
|
title: string;
|
|
12
|
+
/**
|
|
13
|
+
* An icon before the title, in `muted-foreground` and hidden from assistive technology, so the dialog is named by
|
|
14
|
+
* the title's words alone.
|
|
15
|
+
*/
|
|
16
|
+
icon?: IconProp;
|
|
11
17
|
/** One or two sentences under the title; read as the dialog's description. */
|
|
12
18
|
description?: ReactNode;
|
|
13
19
|
children?: ReactNode;
|
|
20
|
+
/** Pinned to the bottom: only the content between the title and the footer scrolls. */
|
|
14
21
|
footer?: ReactNode;
|
|
15
22
|
/** 'alertdialog' for confirmations that interrupt. */
|
|
16
23
|
role?: 'dialog' | 'alertdialog';
|
|
17
24
|
/** Backdrop click and the × close it. Default true; false for confirmations. Escape always closes. */
|
|
18
25
|
isDismissable?: boolean;
|
|
19
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Its widest, from the `dialog-width-*` tokens: sm 26rem, md 32rem (the default), lg 44rem, xl 60rem, 2xl 77.5rem
|
|
28
|
+
* (1240px). `full` fills the viewport but its margins. Never wider than the viewport.
|
|
29
|
+
*/
|
|
30
|
+
size?: DialogSize;
|
|
20
31
|
labels?: Partial<DialogLabels>;
|
|
21
32
|
className?: string;
|
|
22
33
|
}
|
|
34
|
+
export type DialogSize = 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full';
|
|
23
35
|
/** A centred modal: focus moves in and is trapped, Escape closes, focus returns to what opened it. */
|
|
24
|
-
export declare function Dialog({ isOpen, onOpenChange, title, description, children, footer, role, isDismissable, size, labels, className, }: DialogProps): import("react").JSX.Element;
|
|
36
|
+
export declare function Dialog({ isOpen, onOpenChange, title, icon, description, children, footer, role, isDismissable, size, labels, className, }: DialogProps): import("react").JSX.Element;
|
|
25
37
|
/** A ConfirmDialog's words, for the `labels` prop. */
|
|
26
38
|
export interface ConfirmDialogLabels {
|
|
27
39
|
/** The button that closes it without acting. */
|
package/dist/ui/dialog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/ui/dialog.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/ui/dialog.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA2B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAQhE,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAItD,+CAA+C;AAC/C,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;CACf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mBAAmB,EAAE,mBAMjC,CAAC;AAEF,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,QAAQ,EAAE,SAAS,CAAC;IACpB,qFAAqF;IACrF,YAAY,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC5B,+FAA+F;IAC/F,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qGAAqG;IACrG,SAAS,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACvC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,IAAe,EACf,WAAW,EACX,SAAS,EACT,MAAM,EAAE,KAAK,GACd,EAAE,kBAAkB,+BAwFpB"}
|
package/dist/ui/dialog.js
CHANGED
|
@@ -1,21 +1,36 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useId, useState } from 'react';
|
|
3
|
+
import { useId, useRef, useState } from 'react';
|
|
4
4
|
import { Dialog as RACDialog, Heading, Modal, ModalOverlay } from 'react-aria-components';
|
|
5
5
|
import { X } from 'lucide-react';
|
|
6
6
|
import { cn } from '../lib/cn.js';
|
|
7
7
|
import { useLabels } from '../lib/locale.js';
|
|
8
|
+
import { useScrollTabStop } from '../lib/use-scroll-tab-stop.js';
|
|
8
9
|
import { Alert } from './alert.js';
|
|
9
10
|
import { Button } from './button.js';
|
|
11
|
+
import { renderIcon } from './icon.js';
|
|
10
12
|
import { IconButton } from './icon-button.js';
|
|
11
13
|
import { TextField } from './text-field.js';
|
|
12
14
|
export const dialogLabels = { close: 'Close' };
|
|
13
|
-
const widths = {
|
|
15
|
+
const widths = {
|
|
16
|
+
sm: 'max-w-(--dialog-width-sm)',
|
|
17
|
+
md: 'max-w-(--dialog-width-md)',
|
|
18
|
+
lg: 'max-w-(--dialog-width-lg)',
|
|
19
|
+
xl: 'max-w-(--dialog-width-xl)',
|
|
20
|
+
'2xl': 'max-w-(--dialog-width-2xl)',
|
|
21
|
+
full: 'max-w-none',
|
|
22
|
+
};
|
|
14
23
|
/** A centred modal: focus moves in and is trapped, Escape closes, focus returns to what opened it. */
|
|
15
|
-
export function Dialog({ isOpen, onOpenChange, title, description, children, footer, role = 'dialog', isDismissable = true, size = 'md', labels, className, }) {
|
|
24
|
+
export function Dialog({ isOpen, onOpenChange, title, icon, description, children, footer, role = 'dialog', isDismissable = true, size = 'md', labels, className, }) {
|
|
16
25
|
const t = useLabels('dialog', dialogLabels, labels);
|
|
17
26
|
const descId = useId();
|
|
18
|
-
|
|
27
|
+
const body = useRef(null);
|
|
28
|
+
const bodyTabbable = useScrollTabStop(body);
|
|
29
|
+
return (_jsx(ModalOverlay, { isOpen: isOpen, onOpenChange: onOpenChange, isDismissable: isDismissable, "data-overlay": true, className: "fixed inset-0 z-(--z-sheet) flex items-center justify-center bg-overlay p-4", children: _jsx(Modal, { "data-sheet": "top", className: cn(
|
|
30
|
+
// A column the viewport's height at most: the title and the footer stay, and only the body scrolls.
|
|
31
|
+
'relative flex max-h-[calc(100dvh-2rem)] w-full flex-col overflow-hidden rounded-xl border border-border bg-popover text-popover-foreground shadow-(--shadow-lg) outline-none', widths[size], className), children: _jsxs(RACDialog, { role: role, "aria-describedby": description ? descId : undefined, className: "flex min-h-0 flex-1 flex-col outline-none", children: [_jsxs("div", { className: "flex shrink-0 items-start justify-between gap-3 px-5 pt-5", children: [_jsxs(Heading, { slot: "title", className: cn('text-heading', icon && 'flex items-center gap-2'), children: [icon && renderIcon(icon, 'size-5 shrink-0 text-muted-foreground'), icon ? _jsx("span", { className: "min-w-0", children: title }) : title] }), isDismissable && (_jsx(IconButton, { label: t('close'), icon: X, visualSize: "icon-sm", slot: "close", tooltip: false, className: "-mt-1 -mr-2 items-start justify-end" }))] }), _jsxs("div", { ref: body,
|
|
32
|
+
// oxlint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
33
|
+
tabIndex: bodyTabbable ? 0 : undefined, "data-tabbable": bodyTabbable || undefined, className: "relative flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-5 pt-2 pb-5 text-sm leading-6 outline-none data-tabbable:focus-visible:focus-ring-inset", children: [description && (_jsx("div", { id: descId, className: "max-w-(--measure) text-muted-foreground", children: description })), children] }), footer && (_jsx("div", { className: "flex shrink-0 flex-wrap items-center justify-end gap-(--control-gap) border-t border-border px-5 py-4", children: footer }))] }) }) }));
|
|
19
34
|
}
|
|
20
35
|
export const confirmDialogLabels = {
|
|
21
36
|
cancel: 'Cancel',
|
package/dist/ui/dialog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/ui/dialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/ui/dialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AACjC,OAAO,EAAE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IACR,aAGJ,WAAW,IAAI,CACd,KAAC,SAAS,IACR,EAAE,EAAE,OAAO,EACX,KAAK,EAAE,CAAC,CAAC,eAAe,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,EAChD,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;oBACd,QAAQ,CAAC,CAAC,CAAC,CAAC;oBACZ,WAAW,CAAC,KAAK,CAAC,CAAC;gBACrB,CAAC;gBACD,kGAAkG;gBAClG,iDAAiD;gBACjD,SAAS,QACT,YAAY,EAAC,KAAK,EAClB,UAAU,EAAC,OAAO,EAClB,SAAS,EAAE,QAAQ,EACnB,YAAY,EAAE,CAAC,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,GACrD,CACH,EACA,KAAK,IAAI,CACR,KAAC,KAAK,IAAC,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAC,WAAW,EAAC,KAAK,EAAE,CAAC,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,YACpF,KAAK,GACA,CACT,IACM,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A button that can't act right now and says why: it keeps focus and hover (`aria-disabled`, not `disabled`), so the
|
|
4
|
+
* reason is reachable. The reason is its description, read when it's focused, and its tooltip. Pressing it does
|
|
5
|
+
* nothing, and it can't submit a form.
|
|
6
|
+
*/
|
|
7
|
+
export interface DisabledReasonProps {
|
|
8
|
+
/**
|
|
9
|
+
* Why it can't be used right now ("Claude is working on this scene"). Use it instead of `isDisabled` when the
|
|
10
|
+
* reason isn't obvious from the page: `isDisabled` takes the button out of reach, so it can't explain itself.
|
|
11
|
+
*/
|
|
12
|
+
disabledReason?: string;
|
|
13
|
+
}
|
|
14
|
+
/** What a button with a reason passes on: focusable but inert, described by the element `id` names. */
|
|
15
|
+
export interface DisabledReasonButtonProps {
|
|
16
|
+
isDisabled?: false;
|
|
17
|
+
type?: 'button';
|
|
18
|
+
'aria-disabled'?: true;
|
|
19
|
+
'aria-describedby'?: string;
|
|
20
|
+
onPress?: undefined;
|
|
21
|
+
onPressStart?: undefined;
|
|
22
|
+
onPressEnd?: undefined;
|
|
23
|
+
onPressUp?: undefined;
|
|
24
|
+
onPressChange?: undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The props for a button with `reason`, given the id of the element holding it (useId: no hook here, so a server
|
|
28
|
+
* component can call this, as IconButton does). None without a reason.
|
|
29
|
+
*/
|
|
30
|
+
export declare function disabledReasonProps(reason: string | undefined, describedBy: string | undefined, id: string): DisabledReasonButtonProps;
|
|
31
|
+
/** The hidden element holding the reason, for the button's description. Hidden content still describes. */
|
|
32
|
+
export declare function DisabledReasonText({ reason, id }: {
|
|
33
|
+
reason?: string;
|
|
34
|
+
id: string;
|
|
35
|
+
}): ReactNode;
|
|
36
|
+
//# sourceMappingURL=disabled-reason.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disabled-reason.d.ts","sourceRoot":"","sources":["../../src/ui/disabled-reason.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,uGAAuG;AACvG,MAAM,WAAW,yBAAyB;IACxC,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,eAAe,CAAC,EAAE,IAAI,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,aAAa,CAAC,EAAE,SAAS,CAAC;CAC3B;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,EAAE,EAAE,MAAM,GACT,yBAAyB,CAa3B;AAED,2GAA2G;AAC3G,wBAAgB,kBAAkB,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAO7F"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* The props for a button with `reason`, given the id of the element holding it (useId: no hook here, so a server
|
|
4
|
+
* component can call this, as IconButton does). None without a reason.
|
|
5
|
+
*/
|
|
6
|
+
export function disabledReasonProps(reason, describedBy, id) {
|
|
7
|
+
if (!reason)
|
|
8
|
+
return {};
|
|
9
|
+
return {
|
|
10
|
+
isDisabled: false,
|
|
11
|
+
type: 'button',
|
|
12
|
+
'aria-disabled': true,
|
|
13
|
+
'aria-describedby': describedBy ? `${describedBy} ${id}` : id,
|
|
14
|
+
onPress: undefined,
|
|
15
|
+
onPressStart: undefined,
|
|
16
|
+
onPressEnd: undefined,
|
|
17
|
+
onPressUp: undefined,
|
|
18
|
+
onPressChange: undefined,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** The hidden element holding the reason, for the button's description. Hidden content still describes. */
|
|
22
|
+
export function DisabledReasonText({ reason, id }) {
|
|
23
|
+
if (!reason)
|
|
24
|
+
return null;
|
|
25
|
+
return (_jsx("span", { id: id, hidden: true, children: reason }));
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=disabled-reason.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disabled-reason.js","sourceRoot":"","sources":["../../src/ui/disabled-reason.tsx"],"names":[],"mappings":";AA4BA;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAA0B,EAC1B,WAA+B,EAC/B,EAAU;IAEV,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IACvB,OAAO;QACL,UAAU,EAAE,KAAK;QACjB,IAAI,EAAE,QAAQ;QACd,eAAe,EAAE,IAAI;QACrB,kBAAkB,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE;QAC7D,OAAO,EAAE,SAAS;QAClB,YAAY,EAAE,SAAS;QACvB,UAAU,EAAE,SAAS;QACrB,SAAS,EAAE,SAAS;QACpB,aAAa,EAAE,SAAS;KACzB,CAAC;AACJ,CAAC;AAED,2GAA2G;AAC3G,MAAM,UAAU,kBAAkB,CAAC,EAAE,MAAM,EAAE,EAAE,EAAmC;IAChF,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,OAAO,CACL,eAAM,EAAE,EAAE,EAAE,EAAE,MAAM,kBACjB,MAAM,GACF,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-button.d.ts","sourceRoot":"","sources":["../../src/ui/icon-button.tsx"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"icon-button.d.ts","sourceRoot":"","sources":["../../src/ui/icon-button.tsx"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGtD,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEzD,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,YAAY,CAAC;IACnF,gGAAgG;IAChG,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;IACf,gGAAgG;IAChG,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;CACxD;AAED,6EAA6E;AAC7E,eAAO,MAAM,UAAU,+GAyDrB,CAAC"}
|
package/dist/ui/icon-button.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from 'react';
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useId } from 'react';
|
|
3
3
|
import { Button } from './button.js';
|
|
4
|
+
import { DisabledReasonText, disabledReasonProps } from './disabled-reason.js';
|
|
4
5
|
import { renderIcon } from './icon.js';
|
|
5
6
|
import { Tooltip, TooltipTrigger } from './tooltip.js';
|
|
6
7
|
/** Icon-only button that always carries an accessible name and a tooltip. */
|
|
7
|
-
export const IconButton = forwardRef(function IconButton({ label, icon, visualSize = 'icon', variant = 'ghost', count, tooltip = true, tooltipPlacement = 'bottom', ...props }, ref) {
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
export const IconButton = forwardRef(function IconButton({ label, icon, visualSize = 'icon', variant = 'ghost', count, tooltip = true, tooltipPlacement = 'bottom', disabledReason, ...props }, ref) {
|
|
9
|
+
const reasonId = useId();
|
|
10
|
+
const button = (_jsxs(Button, { ref: ref, variant: variant, visualSize: visualSize, "aria-label": label, ...props, ...disabledReasonProps(disabledReason, props['aria-describedby'], reasonId), children: [renderIcon(icon), count ? (_jsx("span", { "aria-hidden": "true", className: "absolute top-0.5 right-0.5 min-w-[18px] rounded-full bg-destructive px-[5px] text-center text-[11px] leading-[18px] font-bold text-destructive-foreground ring-2 ring-background", children: count > 99 ? '99+' : count })) : null] }));
|
|
11
|
+
const tip = typeof tooltip === 'string' ? tooltip : label;
|
|
12
|
+
// With a reason, the tooltip shows even when `tooltip` is false: it's where a pointer finds out why.
|
|
13
|
+
if (!tooltip && !disabledReason)
|
|
10
14
|
return button;
|
|
11
|
-
return (_jsxs(TooltipTrigger, { delay: 500, children: [button, _jsx(Tooltip, { placement: tooltipPlacement, children:
|
|
15
|
+
return (_jsxs(_Fragment, { children: [_jsxs(TooltipTrigger, { delay: 500, children: [button, _jsx(Tooltip, { placement: tooltipPlacement, children: disabledReason ? (_jsxs("span", { className: "flex flex-col", children: [tooltip !== false && _jsx("span", { children: tip }), _jsx("span", { className: "font-normal", children: disabledReason })] })) : (tip) })] }), _jsx(DisabledReasonText, { reason: disabledReason, id: reasonId })] }));
|
|
12
16
|
});
|
|
13
17
|
//# sourceMappingURL=icon-button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-button.js","sourceRoot":"","sources":["../../src/ui/icon-button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"icon-button.js","sourceRoot":"","sources":["../../src/ui/icon-button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAoB,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAiB,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAiBvD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAqC,SAA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cAAc,EAAE,EAAE,EAAE,QAAQ,GAAI,IAC3D,CACJ,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/dist/ui/menu.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
1
|
+
import type { ReactNode, Ref } from 'react';
|
|
2
2
|
import { MenuTrigger, type MenuItemProps as RACMenuItemProps, type MenuProps as RACMenuProps, type PopoverProps as RACPopoverProps } from 'react-aria-components';
|
|
3
3
|
import { type IconProp } from './icon.js';
|
|
4
4
|
export interface PopoverProps extends Omit<RACPopoverProps, 'className'> {
|
|
5
5
|
className?: string;
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Floating surface for menus and listboxes: popover ground, border and shadow-lg. It renders at the end of the
|
|
9
|
+
* page, outside its trigger's container, so it takes the trigger's `data-density` with it: a menu opened from a
|
|
10
|
+
* compact toolbar is compact too.
|
|
11
|
+
*/
|
|
12
|
+
export declare function Popover({ className, offset, ref, ...props }: PopoverProps & {
|
|
13
|
+
ref?: Ref<HTMLElement>;
|
|
14
|
+
}): import("react").JSX.Element;
|
|
9
15
|
export declare function Menu<T extends object>({ className, ...props }: Omit<RACMenuProps<T>, 'className'> & {
|
|
10
16
|
className?: string;
|
|
11
17
|
}): import("react").JSX.Element;
|
package/dist/ui/menu.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../src/ui/menu.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../src/ui/menu.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAKL,WAAW,EAKX,KAAK,aAAa,IAAI,gBAAgB,E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M,CAAC;IACf,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,+BAgBA;AAED,wBAAgB,aAAa,gCAE5B;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
package/dist/ui/menu.js
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Header, Menu as RACMenu, MenuItem as RACMenuItem, MenuSection as RACMenuSection, MenuTrigger, Popover as RACPopover, Separator, } from 'react-aria-components';
|
|
3
|
+
import { Header, Menu as RACMenu, MenuItem as RACMenuItem, MenuSection as RACMenuSection, MenuTrigger, Popover as RACPopover, PopoverContext, Separator, useSlottedContext, } from 'react-aria-components';
|
|
4
4
|
import { Check } from 'lucide-react';
|
|
5
5
|
import { cn } from '../lib/cn.js';
|
|
6
6
|
import { renderIcon } from './icon.js';
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Floating surface for menus and listboxes: popover ground, border and shadow-lg. It renders at the end of the
|
|
9
|
+
* page, outside its trigger's container, so it takes the trigger's `data-density` with it: a menu opened from a
|
|
10
|
+
* compact toolbar is compact too.
|
|
11
|
+
*/
|
|
12
|
+
export function Popover({ className, offset = 6, ref, ...props }) {
|
|
13
|
+
const context = useSlottedContext(PopoverContext);
|
|
14
|
+
const triggerRef = props.triggerRef ?? context?.triggerRef;
|
|
15
|
+
// Read when the surface mounts: the trigger is in the page by then.
|
|
16
|
+
const surface = (el) => {
|
|
17
|
+
if (el) {
|
|
18
|
+
const density = triggerRef?.current?.closest('[data-density]')?.getAttribute('data-density');
|
|
19
|
+
if (density)
|
|
20
|
+
el.setAttribute('data-density', density);
|
|
21
|
+
else
|
|
22
|
+
el.removeAttribute('data-density');
|
|
23
|
+
}
|
|
24
|
+
if (typeof ref === 'function')
|
|
25
|
+
return ref(el);
|
|
26
|
+
};
|
|
27
|
+
return (_jsx(RACPopover, { offset: offset, ref: typeof ref === 'function' || !ref ? surface : ref, ...props, className: cn(
|
|
10
28
|
// React Aria positions the popover inline (style="position: absolute"), which the lint rule can't see.
|
|
11
29
|
// oxlint-disable-next-line setsquare-ui/positioned-scroll-container
|
|
12
30
|
'z-(--z-popover) min-w-(--trigger-width) overflow-auto rounded-lg border border-border bg-popover text-popover-foreground shadow-(--shadow-lg) outline-none', className) }));
|
package/dist/ui/menu.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.js","sourceRoot":"","sources":["../../src/ui/menu.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EACL,MAAM,EACN,IAAI,IAAI,OAAO,EACf,QAAQ,IAAI,WAAW,EACvB,WAAW,IAAI,cAAc,EAC7B,WAAW,EACX,OAAO,IAAI,UAAU,EACrB,SAAS,
|
|
1
|
+
{"version":3,"file":"menu.js","sourceRoot":"","sources":["../../src/ui/menu.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EACL,MAAM,EACN,IAAI,IAAI,OAAO,EACf,QAAQ,IAAI,WAAW,EACvB,WAAW,IAAI,cAAc,EAC7B,WAAW,EACX,OAAO,IAAI,UAAU,EACrB,cAAc,EACd,SAAS,EACT,iBAAiB,GAIlB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,UAAU,EAAiB,MAAM,WAAW,CAAC;AAMtD;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,EACtB,SAAS,EACT,MAAM,GAAG,CAAC,EACV,GAAG,EACH,GAAG,KAAK,EACkC;IAC1C,MAAM,OAAO,GAAG,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,IAAI,OAAO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