@g4rcez/components 3.0.0-0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/core/button.d.ts +2 -8
- package/dist/components/core/button.d.ts.map +1 -1
- package/dist/components/core/button.jsx +11 -18
- package/dist/components/core/polymorph.d.ts.map +1 -1
- package/dist/components/core/slot.d.ts +1 -1
- package/dist/components/core/slot.d.ts.map +1 -1
- package/dist/components/core/slot.jsx +28 -35
- package/dist/components/core/tag.d.ts +1 -1
- package/dist/components/core/tag.d.ts.map +1 -1
- package/dist/components/core/tag.jsx +3 -3
- package/dist/components/core/typography.d.ts.map +1 -1
- package/dist/components/core/typography.jsx +16 -20
- package/dist/components/display/alert.d.ts.map +1 -1
- package/dist/components/display/alert.jsx +19 -17
- package/dist/components/display/calendar.d.ts.map +1 -1
- package/dist/components/display/calendar.jsx +6 -8
- package/dist/components/display/card.d.ts.map +1 -1
- package/dist/components/display/card.jsx +6 -6
- package/dist/components/display/empty.jsx +1 -1
- package/dist/components/display/notifications.d.ts +2 -0
- package/dist/components/display/notifications.d.ts.map +1 -1
- package/dist/components/display/notifications.jsx +76 -48
- package/dist/components/display/progress.d.ts.map +1 -1
- package/dist/components/display/progress.jsx +7 -9
- package/dist/components/display/shortcut.jsx +1 -1
- package/dist/components/display/skeleton.d.ts.map +1 -1
- package/dist/components/display/skeleton.jsx +3 -5
- package/dist/components/display/step.d.ts.map +1 -1
- package/dist/components/display/step.jsx +27 -27
- package/dist/components/display/tabs.d.ts.map +1 -1
- package/dist/components/display/tabs.jsx +5 -7
- package/dist/components/display/timeline.jsx +1 -1
- package/dist/components/floating/command-palette.d.ts +1 -0
- package/dist/components/floating/command-palette.d.ts.map +1 -1
- package/dist/components/floating/command-palette.jsx +92 -70
- package/dist/components/floating/dropdown.d.ts.map +1 -1
- package/dist/components/floating/dropdown.jsx +15 -15
- package/dist/components/floating/menu.d.ts +2 -2
- package/dist/components/floating/menu.jsx +2 -2
- package/dist/components/floating/modal.d.ts +20 -53
- package/dist/components/floating/modal.d.ts.map +1 -1
- package/dist/components/floating/modal.jsx +109 -51
- package/dist/components/floating/tooltip.d.ts.map +1 -1
- package/dist/components/floating/tooltip.jsx +2 -8
- package/dist/components/floating/wizard.d.ts +1 -1
- package/dist/components/floating/wizard.d.ts.map +1 -1
- package/dist/components/floating/wizard.jsx +50 -53
- package/dist/components/form/autocomplete.d.ts.map +1 -1
- package/dist/components/form/autocomplete.jsx +42 -38
- package/dist/components/form/checkbox.jsx +3 -3
- package/dist/components/form/date-picker.d.ts.map +1 -1
- package/dist/components/form/date-picker.jsx +14 -14
- package/dist/components/form/file-upload.jsx +13 -13
- package/dist/components/form/free-text.d.ts.map +1 -1
- package/dist/components/form/free-text.jsx +3 -3
- package/dist/components/form/input-field.d.ts +3 -2
- package/dist/components/form/input-field.d.ts.map +1 -1
- package/dist/components/form/input-field.jsx +43 -41
- package/dist/components/form/multi-select.d.ts.map +1 -1
- package/dist/components/form/multi-select.jsx +56 -56
- package/dist/components/form/select.d.ts.map +1 -1
- package/dist/components/form/select.jsx +3 -3
- package/dist/components/form/slider.d.ts.map +1 -1
- package/dist/components/form/slider.jsx +10 -10
- package/dist/components/form/switch.jsx +2 -2
- package/dist/components/form/transfer-list.jsx +3 -3
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -0
- package/dist/components/page-calendar/calendar-header.d.ts +16 -0
- package/dist/components/page-calendar/calendar-header.d.ts.map +1 -0
- package/dist/components/page-calendar/calendar-header.jsx +81 -0
- package/dist/components/page-calendar/day-view.d.ts +12 -0
- package/dist/components/page-calendar/day-view.d.ts.map +1 -0
- package/dist/components/page-calendar/day-view.jsx +87 -0
- package/dist/components/page-calendar/event-pill.d.ts +9 -0
- package/dist/components/page-calendar/event-pill.d.ts.map +1 -0
- package/dist/components/page-calendar/event-pill.jsx +25 -0
- package/dist/components/page-calendar/index.d.ts +4 -0
- package/dist/components/page-calendar/index.d.ts.map +1 -0
- package/dist/components/page-calendar/index.js +2 -0
- package/dist/components/page-calendar/month-view.d.ts +11 -0
- package/dist/components/page-calendar/month-view.d.ts.map +1 -0
- package/dist/components/page-calendar/month-view.jsx +47 -0
- package/dist/components/page-calendar/page-calendar.d.ts +18 -0
- package/dist/components/page-calendar/page-calendar.d.ts.map +1 -0
- package/dist/components/page-calendar/page-calendar.jsx +41 -0
- package/dist/components/page-calendar/page-calendar.types.d.ts +18 -0
- package/dist/components/page-calendar/page-calendar.types.d.ts.map +1 -0
- package/dist/components/page-calendar/page-calendar.types.js +1 -0
- package/dist/components/page-calendar/page-calendar.utils.d.ts +18 -0
- package/dist/components/page-calendar/page-calendar.utils.d.ts.map +1 -0
- package/dist/components/page-calendar/page-calendar.utils.js +71 -0
- package/dist/components/page-calendar/week-view.d.ts +11 -0
- package/dist/components/page-calendar/week-view.d.ts.map +1 -0
- package/dist/components/page-calendar/week-view.jsx +64 -0
- package/dist/components/table/filter.jsx +4 -4
- package/dist/components/table/index.d.ts.map +1 -1
- package/dist/components/table/index.jsx +10 -10
- package/dist/components/table/inner-table.d.ts.map +1 -1
- package/dist/components/table/inner-table.jsx +18 -18
- package/dist/components/table/metadata.d.ts.map +1 -1
- package/dist/components/table/metadata.jsx +29 -30
- package/dist/components/table/pagination.jsx +1 -1
- package/dist/components/table/row.d.ts.map +1 -1
- package/dist/components/table/row.jsx +17 -17
- package/dist/components/table/sort.jsx +1 -1
- package/dist/components/table/table-lib.d.ts.map +1 -1
- package/dist/components/table/table-lib.js +1 -2
- package/dist/components/table/thead.d.ts.map +1 -1
- package/dist/components/table/thead.jsx +6 -6
- package/dist/config/context.d.ts.map +1 -1
- package/dist/config/default-translations.d.ts +17 -0
- package/dist/config/default-translations.d.ts.map +1 -1
- package/dist/config/default-translations.jsx +18 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/hooks/use-components-provider.d.ts.map +1 -1
- package/dist/hooks/use-components-provider.jsx +4 -1
- package/dist/hooks/use-form.d.ts +11 -11
- package/dist/hooks/use-form.d.ts.map +1 -1
- package/dist/hooks/use-form.js +1 -0
- package/dist/hooks/use-input-id.d.ts.map +1 -1
- package/dist/hooks/use-is-coarse-device.js +1 -1
- package/dist/hooks/use-preferences.d.ts.map +1 -1
- package/dist/hooks/use-previous.d.ts.map +1 -1
- package/dist/hooks/use-previous.js +1 -0
- package/dist/hooks/use-reactive.d.ts.map +1 -1
- package/dist/hooks/use-reactive.js +1 -0
- package/dist/hooks/use-resize-observer.d.ts.map +1 -1
- package/dist/hooks/use-stable-ref.d.ts.map +1 -1
- package/dist/hooks/use-stable-ref.js +1 -0
- package/dist/hooks/use-swipe.d.ts.map +1 -1
- package/dist/hooks/use-swipe.js +1 -0
- package/dist/hooks/use-translations.d.ts +17 -0
- package/dist/hooks/use-translations.d.ts.map +1 -1
- package/dist/index.css +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13689 -12344
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +24 -17
- package/dist/index.umd.js.map +1 -1
- package/dist/lib/dom.d.ts +1 -0
- package/dist/lib/dom.d.ts.map +1 -1
- package/dist/lib/dom.js +20 -2
- package/dist/lib/fns.d.ts.map +1 -1
- package/dist/lib/fns.js +2 -2
- package/dist/preset/plugin.tailwind.d.ts +9 -0
- package/dist/preset/plugin.tailwind.d.ts.map +1 -0
- package/dist/preset/plugin.tailwind.js +27 -0
- package/dist/preset/preset.tailwind.d.ts +8 -0
- package/dist/preset/preset.tailwind.d.ts.map +1 -0
- package/dist/preset/preset.tailwind.js +54 -0
- package/dist/preset/src/styles/common.d.ts +2 -14
- package/dist/preset/src/styles/common.d.ts.map +1 -1
- package/dist/preset/src/styles/common.js +1 -0
- package/dist/preset/src/styles/dark.d.ts.map +1 -1
- package/dist/preset/src/styles/dark.js +119 -114
- package/dist/preset/src/styles/light.d.ts.map +1 -1
- package/dist/preset/src/styles/light.js +111 -106
- package/dist/preset/src/styles/theme.types.d.ts +17 -8
- package/dist/preset/src/styles/theme.types.d.ts.map +1 -1
- package/dist/styles/common.d.ts +2 -14
- package/dist/styles/common.d.ts.map +1 -1
- package/dist/styles/common.js +1 -0
- package/dist/styles/dark.d.ts.map +1 -1
- package/dist/styles/dark.js +119 -114
- package/dist/styles/light.d.ts.map +1 -1
- package/dist/styles/light.js +111 -106
- package/dist/styles/theme.types.d.ts +17 -8
- package/dist/styles/theme.types.d.ts.map +1 -1
- package/package.json +299 -301
- package/dist/preset/tailwindcssv4.d.ts +0 -3
- package/dist/preset/tailwindcssv4.d.ts.map +0 -1
- package/dist/preset/tailwindcssv4.js +0 -75
|
@@ -7,31 +7,31 @@ import { useStableRef } from "../../hooks/use-stable-ref";
|
|
|
7
7
|
import { useTranslations } from "../../hooks/use-translations";
|
|
8
8
|
import { CombiKeys } from "../../lib/combi-keys";
|
|
9
9
|
import { Dict } from "../../lib/dict";
|
|
10
|
-
import { css, isReactFC } from "../../lib/dom";
|
|
10
|
+
import { css, isChildVisible, isReactFC } from "../../lib/dom";
|
|
11
11
|
import { fzf } from "../../lib/fzf";
|
|
12
12
|
import { Shortcut } from "../display/shortcut";
|
|
13
13
|
import { SkeletonCell } from "../display/skeleton";
|
|
14
14
|
import { Modal } from "./modal";
|
|
15
|
-
const Group = (props) => (<span className="flex items-center
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const Group = (props) => (<span className="flex h-full items-center text-left text-sm font-medium text-secondary">
|
|
16
|
+
{isReactFC(props.item.title) ? <props.item.title text={props.text}/> : props.item.title}
|
|
17
|
+
</span>);
|
|
18
18
|
const Item = forwardRef((props, ref) => {
|
|
19
19
|
const id = useId();
|
|
20
20
|
const active = props.active;
|
|
21
21
|
const item = props.item;
|
|
22
22
|
if (item.type === "group")
|
|
23
|
-
return (<div id={id} className="
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
return (<div id={id} className="h-10 px-2 pb-1 pt-2">
|
|
24
|
+
<Group text={props.text} item={item}/>
|
|
25
|
+
</div>);
|
|
26
26
|
if (item.type !== "shortcut")
|
|
27
27
|
return <Fragment />;
|
|
28
28
|
return (<button {...props} id={id} ref={ref} role="option" type="button" aria-selected={active} data-component="command-palette-item" className={css("flex h-10 items-center justify-between rounded-lg p-2 hover:bg-floating-hover", active ? "bg-floating-hover" : "")}>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
<span className="flex items-center gap-2">
|
|
30
|
+
{item.Icon ? item.Icon : null}
|
|
31
|
+
<span>{isReactFC(item.title) ? <item.title text={props.text}/> : item.title}</span>
|
|
32
|
+
</span>
|
|
33
|
+
{item.shortcut ? <Shortcut value={item.shortcut}/> : null}
|
|
34
|
+
</button>);
|
|
35
35
|
});
|
|
36
36
|
const getFuzzyData = (commands, value) => {
|
|
37
37
|
if (value.length === 0)
|
|
@@ -53,57 +53,74 @@ const getFuzzyData = (commands, value) => {
|
|
|
53
53
|
return Dict.unique(filter.concat(withEnabled), (x) => x.title);
|
|
54
54
|
};
|
|
55
55
|
const loadingSkeleton = [0, 0, 0, 0, 0];
|
|
56
|
+
const findFirstClickable = (items) => {
|
|
57
|
+
for (let index = 0; index < items.length; index++) {
|
|
58
|
+
const element = items[index];
|
|
59
|
+
if (element.type === "shortcut")
|
|
60
|
+
return element;
|
|
61
|
+
const recursive = findFirstClickable(element.items);
|
|
62
|
+
if (recursive)
|
|
63
|
+
return recursive;
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
};
|
|
56
67
|
export const CommandPalette = (props) => {
|
|
57
|
-
const
|
|
68
|
+
const id = useId();
|
|
69
|
+
const scrollContainerRef = useRef(null);
|
|
70
|
+
const [text, setText] = useState("");
|
|
58
71
|
const listRef = useRef([]);
|
|
59
72
|
const translations = useTranslations();
|
|
60
|
-
const
|
|
61
|
-
const valueRef = useStableRef(value);
|
|
62
|
-
const id = useId();
|
|
63
|
-
const ref = useRef(null);
|
|
73
|
+
const valueRef = useStableRef(text);
|
|
64
74
|
const [activeIndex, setActiveIndex] = useState(null);
|
|
75
|
+
const bindKey = props.bind ?? "Mod + k";
|
|
65
76
|
const root = useFloating({
|
|
66
77
|
open: props.open,
|
|
67
78
|
strategy: "absolute",
|
|
68
79
|
whileElementsMounted: autoUpdate,
|
|
69
80
|
onOpenChange: props.onChangeVisibility,
|
|
70
81
|
});
|
|
82
|
+
const commands = props.commands.flatMap((x) => (x.type === "group" ? [x, ...x.items] : [x]));
|
|
83
|
+
const fuzzy = getFuzzyData(commands, text);
|
|
84
|
+
const displayItems = text === ""
|
|
85
|
+
? commands
|
|
86
|
+
: [
|
|
87
|
+
{
|
|
88
|
+
type: "group",
|
|
89
|
+
title: "Results",
|
|
90
|
+
items: [],
|
|
91
|
+
},
|
|
92
|
+
...fuzzy.filter((x) => x.type !== "group"),
|
|
93
|
+
];
|
|
71
94
|
const listNav = useListNavigation(root.context, {
|
|
72
|
-
cols: 0,
|
|
73
95
|
listRef,
|
|
74
96
|
loop: true,
|
|
75
97
|
activeIndex,
|
|
76
98
|
virtual: true,
|
|
77
|
-
allowEscape:
|
|
78
|
-
|
|
79
|
-
|
|
99
|
+
allowEscape: false,
|
|
100
|
+
focusItemOnOpen: true,
|
|
101
|
+
focusItemOnHover: true,
|
|
80
102
|
openOnArrowKeyDown: true,
|
|
81
103
|
scrollItemIntoView: false,
|
|
82
104
|
selectedIndex: activeIndex,
|
|
105
|
+
disabledIndices: (n) => {
|
|
106
|
+
const item = displayItems[n];
|
|
107
|
+
if (item)
|
|
108
|
+
return item.type === "group";
|
|
109
|
+
return false;
|
|
110
|
+
},
|
|
83
111
|
onNavigate: (n) => {
|
|
84
112
|
if (Is.number(n)) {
|
|
85
|
-
listRef.current[n]
|
|
113
|
+
if (!isChildVisible(scrollContainerRef.current, listRef.current[n]))
|
|
114
|
+
listRef.current[n]?.scrollIntoView({ block: "start", inline: "start" });
|
|
86
115
|
}
|
|
87
116
|
setActiveIndex((prev) => {
|
|
88
117
|
if (Is.number(n))
|
|
89
118
|
return n;
|
|
90
119
|
return props.open ? (prev ?? 0) : null;
|
|
91
120
|
});
|
|
92
|
-
}
|
|
121
|
+
},
|
|
93
122
|
});
|
|
94
|
-
const { getItemProps, getReferenceProps } = useInteractions([listNav]);
|
|
95
|
-
const commands = props.commands.flatMap((x) => (x.type === "group" ? [x, ...x.items] : [x]));
|
|
96
|
-
const fuzzy = getFuzzyData(commands, value);
|
|
97
|
-
const displayItems = value === ""
|
|
98
|
-
? commands
|
|
99
|
-
: [
|
|
100
|
-
{
|
|
101
|
-
type: "group",
|
|
102
|
-
title: "Results",
|
|
103
|
-
items: [],
|
|
104
|
-
},
|
|
105
|
-
...fuzzy.filter((x) => x.type !== "group"),
|
|
106
|
-
];
|
|
123
|
+
const { getItemProps, getReferenceProps, getFloatingProps } = useInteractions([listNav]);
|
|
107
124
|
useEffect(() => {
|
|
108
125
|
const combi = new CombiKeys();
|
|
109
126
|
combi.add(bindKey, () => props.onChangeVisibility?.(true));
|
|
@@ -113,6 +130,7 @@ export const CommandPalette = (props) => {
|
|
|
113
130
|
if (cmd.type === "shortcut" && cmd.shortcut !== undefined)
|
|
114
131
|
combi.add(cmd.shortcut, (event) => cmd.action({
|
|
115
132
|
event,
|
|
133
|
+
setText,
|
|
116
134
|
text: valueRef.current,
|
|
117
135
|
setOpen: props.onChangeVisibility,
|
|
118
136
|
}));
|
|
@@ -121,34 +139,38 @@ export const CommandPalette = (props) => {
|
|
|
121
139
|
}, [bindKey, commands, props, valueRef]);
|
|
122
140
|
const Icon = props.Icon ?? FilterIcon;
|
|
123
141
|
return (<Fragment>
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
<input {...getReferenceProps({
|
|
142
|
+
<Modal {...getFloatingProps()} animated={false} closable={false} open={props.open} overlayClickClose ariaTitle="Command palette" bodyClassName="px-0 py-0 pt-0" data-component="command-palette" onChange={props.onChangeVisibility} className="container relative overflow-clip py-0 md:max-w-screen-sm lg:max-w-screen-md">
|
|
143
|
+
<header className="sticky top-0 isolate z-floating flex h-12 w-full items-center overflow-clip border-b border-floating-border bg-floating-background">
|
|
144
|
+
<div className="flex size-10 items-center justify-center">
|
|
145
|
+
{props.Icon ? <Icon Default={FilterIcon} text={text} size={16}/> : <FilterIcon size={16}/>}
|
|
146
|
+
</div>
|
|
147
|
+
<input {...getReferenceProps({
|
|
131
148
|
ref: root.refs.setReference,
|
|
132
149
|
onKeyDown: (e) => {
|
|
133
150
|
const item = Is.number(activeIndex) ? displayItems[activeIndex] : null;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (
|
|
151
|
+
const key = e.key;
|
|
152
|
+
if (key === "Enter") {
|
|
153
|
+
if (item) {
|
|
137
154
|
if (item.type === "shortcut")
|
|
138
|
-
item.action({ event: e, text:
|
|
155
|
+
item.action({ event: e, text: text, setOpen: props.onChangeVisibility, setText });
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
const item = findFirstClickable(fuzzy);
|
|
159
|
+
if (item?.type === "shortcut")
|
|
160
|
+
item.action({ event: e, text: text, setOpen: props.onChangeVisibility, setText });
|
|
139
161
|
}
|
|
140
162
|
}
|
|
141
|
-
}
|
|
142
|
-
})} autoFocus value={
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
163
|
+
},
|
|
164
|
+
})} autoFocus value={text} data-combikeysbypass="true" placeholder="Search for..." onChange={(e) => setText(e.target.value)} className="h-12 w-full items-center bg-transparent px-2 py-2 pb-2 text-left text-lg outline-none"/>
|
|
165
|
+
</header>
|
|
166
|
+
{props.loading ? (<ul role="listbox" data-component="command-palette-list" className="my-2 flex max-h-96 w-full origin-[top_center] flex-col gap-1 overflow-y-auto px-2">
|
|
167
|
+
<div className="h-10 px-2 pb-1 pt-2">{translations.commandPaletteLoading}</div>
|
|
168
|
+
{loadingSkeleton.map((_, i) => (<li key={`${id}-${i}-skeleton-index`} className={css("flex h-10 items-center justify-between rounded-lg p-2 hover:bg-primary hover:text-primary-foreground")}>
|
|
169
|
+
{SkeletonCell}
|
|
170
|
+
</li>))}
|
|
171
|
+
</ul>) : (<div className="flex min-w-full flex-row flex-nowrap" data-component="command-palette-container">
|
|
172
|
+
<ul role="listbox" ref={scrollContainerRef} data-component="command-palette-list" className="my-2 flex h-fit max-h-96 w-full origin-[top_center] flex-col gap-1 overflow-y-auto px-2">
|
|
173
|
+
{displayItems.map((item, index) => (<Item {...getItemProps({
|
|
152
174
|
onMouseEnter: () => setActiveIndex(index),
|
|
153
175
|
ref(node) {
|
|
154
176
|
listRef.current[index] = node;
|
|
@@ -157,16 +179,16 @@ export const CommandPalette = (props) => {
|
|
|
157
179
|
e.preventDefault();
|
|
158
180
|
props.onChangeVisibility(false);
|
|
159
181
|
if (item.type === "shortcut")
|
|
160
|
-
item.action({ event: e, text:
|
|
182
|
+
item.action({ event: e, text: text, setOpen: props.onChangeVisibility, setText });
|
|
161
183
|
},
|
|
162
|
-
})} item={item} text={
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
184
|
+
})} item={item} text={text} active={activeIndex === index} key={`${id}-${item.type}-${index}`}/>))}
|
|
185
|
+
{displayItems.length === 1 ? (<div className={css("flex items-center justify-between rounded-lg p-2 text-secondary")}>
|
|
186
|
+
{translations.commandPaletteEmpty ?? props.emptyMessage}
|
|
187
|
+
</div>) : null}
|
|
188
|
+
</ul>
|
|
189
|
+
{props.Preview && Is.number(activeIndex) ? <props.Preview command={displayItems[activeIndex]} text={text}/> : null}
|
|
190
|
+
</div>)}
|
|
191
|
+
{props.footer ? (<footer className="flex h-8 items-center rounded-b-lg border-t border-floating-border p-2">{props.footer}</footer>) : null}
|
|
192
|
+
</Modal>
|
|
193
|
+
</Fragment>);
|
|
172
194
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/floating/dropdown.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,EAAY,iBAAiB,EAA+C,MAAM,OAAO,CAAC;AAExG,KAAK,aAAa,GAAG;
|
|
1
|
+
{"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/floating/dropdown.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,EAAY,iBAAiB,EAA+C,MAAM,OAAO,CAAC;AAExG,KAAK,aAAa,GAAG;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACxC,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,OAAO,EAAE,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,SAAS,CAAC;IAC9C,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC;CACzD,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,OAAO,iBAAiB,CAAC,aAAa,CAAC,sBAqE/D,CAAC"}
|
|
@@ -35,19 +35,19 @@ export const Dropdown = (props) => {
|
|
|
35
35
|
const role = useRole(context, { role: "tooltip" });
|
|
36
36
|
const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss, role]);
|
|
37
37
|
return (<Fragment>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
38
|
+
<button ref={refs.setReference} {...getReferenceProps(props.buttonProps)} type="button">
|
|
39
|
+
{props.trigger}
|
|
40
|
+
</button>
|
|
41
|
+
{open && (<FloatingPortal preserveTabOrder id={`${headingId}-portal`}>
|
|
42
|
+
<FloatingFocusManager guards restoreFocus={true} returnFocus={true} visuallyHiddenDismiss context={context} modal={false}>
|
|
43
|
+
<div className="relative isolate z-floating min-w-96 rounded-lg border border-floating-border bg-floating-background p-4 shadow-shadow-floating" ref={refs.setFloating} aria-labelledby={headingId} style={floatingStyles} {...getFloatingProps()}>
|
|
44
|
+
<FloatingArrow ref={arrowRef} context={context} strokeWidth={0.1} className="fill-floating-background stroke-floating-border"/>
|
|
45
|
+
<header className="mb-2">
|
|
46
|
+
<h3 className="text-left text-2xl font-medium leading-snug tracking-wide">{props.title}</h3>
|
|
47
|
+
</header>
|
|
48
|
+
{props.children}
|
|
49
|
+
</div>
|
|
50
|
+
</FloatingFocusManager>
|
|
51
|
+
</FloatingPortal>)}
|
|
52
|
+
</Fragment>);
|
|
53
53
|
};
|
|
@@ -22,7 +22,7 @@ type MenuItemProps = {
|
|
|
22
22
|
Right?: React.FC<LucideProps>;
|
|
23
23
|
};
|
|
24
24
|
export declare const MenuItem: React.ForwardRefExoticComponent<Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof MenuItemProps> & MenuItemProps & React.RefAttributes<HTMLButtonElement>>;
|
|
25
|
-
export declare const Menu: React.ForwardRefExoticComponent<(Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "children" | "hover" | "open" | "
|
|
25
|
+
export declare const Menu: React.ForwardRefExoticComponent<(Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "children" | "hover" | "open" | "asChild" | "restoreFocus" | "nested" | "isParent" | "floatingClassName" | "FloatingComponent"> & Partial<{
|
|
26
26
|
hover: boolean;
|
|
27
27
|
open?: boolean;
|
|
28
28
|
nested: boolean;
|
|
@@ -34,7 +34,7 @@ export declare const Menu: React.ForwardRefExoticComponent<(Omit<Omit<React.Deta
|
|
|
34
34
|
FloatingComponent: React.ElementType;
|
|
35
35
|
} & {
|
|
36
36
|
label: string;
|
|
37
|
-
}>, "ref"> | Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "children" | "hover" | "open" | "
|
|
37
|
+
}>, "ref"> | Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "children" | "hover" | "open" | "asChild" | "restoreFocus" | "nested" | "isParent" | "floatingClassName" | "FloatingComponent"> & Partial<{
|
|
38
38
|
hover: boolean;
|
|
39
39
|
open?: boolean;
|
|
40
40
|
nested: boolean;
|
|
@@ -5,7 +5,7 @@ import { ChevronRightIcon } from "lucide-react";
|
|
|
5
5
|
import React, { createContext, Fragment, useContext, useEffect, useRef, useState } from "react";
|
|
6
6
|
import { FLOATING_DELAY, TYPEAHEAD_RESET_DELAY } from "../../constants";
|
|
7
7
|
import { css, mergeRefs } from "../../lib/dom";
|
|
8
|
-
const menuItemClassName = (highlight = "") => css("w-full min-w-36 outline-
|
|
8
|
+
const menuItemClassName = (highlight = "") => css("w-full min-w-36 outline-none p-2.5 items-center flex justify-between text-left", "hover:bg-primary focus:bg-primary aria-expanded:opacity-80", "focus:text-primary-foreground hover:text-primary-foreground", "first-of-type:rounded-t-lg last-of-type:rounded-b-lg", "disabled:opacity-40 disabled:cursor-not-allowed", highlight);
|
|
9
9
|
const MenuContext = createContext({
|
|
10
10
|
isOpen: false,
|
|
11
11
|
activeIndex: null,
|
|
@@ -111,7 +111,7 @@ const MenuComponent = React.forwardRef(({ children, FloatingComponent = "div", h
|
|
|
111
111
|
<FloatingList elementsRef={elementsRef} labelsRef={labelsRef}>
|
|
112
112
|
{isOpen && (<FloatingPortal>
|
|
113
113
|
<FloatingFocusManager context={context} modal={false} initialFocus={isNested ? -1 : 0} returnFocus={isParent ? restoreFocus : !isNested}>
|
|
114
|
-
<FloatingComponent {...getFloatingProps()} ref={refs.setFloating} style={{ ...props.style, ...floatingStyles }} className={css("isolate z-tooltip flex max-h-80 flex-col items-start overflow-y-auto rounded-lg border border-floating-border bg-floating-background text-left shadow-shadow-floating outline-
|
|
114
|
+
<FloatingComponent {...getFloatingProps()} ref={refs.setFloating} style={{ ...props.style, ...floatingStyles }} className={css("isolate z-tooltip flex max-h-80 flex-col items-start overflow-y-auto rounded-lg border border-floating-border bg-floating-background text-left shadow-shadow-floating outline-none", floatingClassName)}>
|
|
115
115
|
{children}
|
|
116
116
|
</FloatingComponent>
|
|
117
117
|
</FloatingFocusManager>
|
|
@@ -2,6 +2,8 @@ import { type ElementProps } from "@floating-ui/react";
|
|
|
2
2
|
import { HTMLMotionProps } from "motion/react";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { Label, Override } from "../../types";
|
|
5
|
+
import { ButtonProps } from "../core/button";
|
|
6
|
+
export declare const useConfirm: () => (options: ConfirmOptions) => Promise<boolean>;
|
|
5
7
|
export type ModalType = "dialog" | "drawer" | "sheet";
|
|
6
8
|
export type DrawerPosition = "left" | "right";
|
|
7
9
|
export type ModalProps = Override<HTMLMotionProps<"div">, ({
|
|
@@ -32,62 +34,27 @@ export type ModalProps = Override<HTMLMotionProps<"div">, ({
|
|
|
32
34
|
interactions: ElementProps[];
|
|
33
35
|
trigger: Label | React.FC<any>;
|
|
34
36
|
}>>;
|
|
35
|
-
type ModalRef = {
|
|
37
|
+
export type ModalRef = {
|
|
36
38
|
context: any;
|
|
37
39
|
floating: HTMLElement | null;
|
|
38
40
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
asChild: boolean;
|
|
50
|
-
layoutId: string;
|
|
51
|
-
resizer: boolean;
|
|
52
|
-
className: string;
|
|
53
|
-
closable: boolean;
|
|
54
|
-
forceType: boolean;
|
|
55
|
-
bodyClassName: string;
|
|
56
|
-
overlayClassName: string;
|
|
57
|
-
position: DrawerPosition;
|
|
58
|
-
overlayClickClose: boolean;
|
|
59
|
-
closeOnFocusOut: boolean;
|
|
60
|
-
role: "dialog";
|
|
61
|
-
interactions: ElementProps[];
|
|
62
|
-
trigger: Label | React.FC<any>;
|
|
63
|
-
}> & {
|
|
64
|
-
children?: React.ReactNode | undefined;
|
|
65
|
-
}, "ref"> | Omit<Omit<HTMLMotionProps<"div">, "footer" | "title" | "className" | "role" | "onChange" | "position" | "open" | "resizer" | "type" | "layoutId" | "trigger" | "closeOnFocusOut" | "asChild" | "animated" | "closable" | "forceType" | "bodyClassName" | "overlayClassName" | "overlayClickClose" | "interactions" | "ariaTitle"> & {
|
|
66
|
-
ariaTitle: string;
|
|
41
|
+
type ModalComponent = React.FC<ModalProps> & {
|
|
42
|
+
confirm: <T>(options: ConfirmOptions) => Promise<T>;
|
|
43
|
+
};
|
|
44
|
+
export declare const Modal: ModalComponent;
|
|
45
|
+
type ButtonConfirmationAction = {
|
|
46
|
+
value?: any;
|
|
47
|
+
text?: Label;
|
|
48
|
+
theme?: ButtonProps["theme"];
|
|
49
|
+
};
|
|
50
|
+
export type ConfirmOptions = {
|
|
67
51
|
title?: Label;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
asChild: boolean;
|
|
76
|
-
layoutId: string;
|
|
77
|
-
resizer: boolean;
|
|
78
|
-
className: string;
|
|
79
|
-
closable: boolean;
|
|
80
|
-
forceType: boolean;
|
|
81
|
-
bodyClassName: string;
|
|
82
|
-
overlayClassName: string;
|
|
83
|
-
position: DrawerPosition;
|
|
84
|
-
overlayClickClose: boolean;
|
|
85
|
-
closeOnFocusOut: boolean;
|
|
86
|
-
role: "dialog";
|
|
87
|
-
interactions: ElementProps[];
|
|
88
|
-
trigger: Label | React.FC<any>;
|
|
89
|
-
}> & {
|
|
90
|
-
children?: React.ReactNode | undefined;
|
|
91
|
-
}, "ref">) & React.RefAttributes<ModalRef>>;
|
|
52
|
+
description?: Label;
|
|
53
|
+
cancel?: ButtonConfirmationAction;
|
|
54
|
+
confirm?: ButtonConfirmationAction;
|
|
55
|
+
};
|
|
56
|
+
export declare const ModalConfirmProvider: ({ children }: {
|
|
57
|
+
children: React.ReactNode;
|
|
58
|
+
}) => React.JSX.Element;
|
|
92
59
|
export {};
|
|
93
60
|
//# sourceMappingURL=modal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/components/floating/modal.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/components/floating/modal.tsx"],"names":[],"mappings":"AACA,OAAO,EASH,KAAK,YAAY,EACpB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAEH,eAAe,EAQlB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAWN,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,KAAK,EAAO,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAU,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAMrD,eAAO,MAAM,UAAU,kBAF8B,cAAc,KAAK,OAAO,CAAC,OAAO,CAEvB,CAAC;AAEjE,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEtD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,CAAC;AAuD9C,MAAM,MAAM,UAAU,GAAG,QAAQ,CAC7B,eAAe,CAAC,KAAK,CAAC,EACtB,CAAC;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC,GAAG;IAC5E,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1C,GAAG,OAAO,CAAC;IACJ,MAAM,EAAE,KAAK,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,cAAc,CAAC;IACzB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,eAAe,EAAE,OAAO,CAAC;IACzB,IAAI,EAAE,QAAQ,CAAC;IACf,YAAY,EAAE,YAAY,EAAE,CAAC;IAC7B,OAAO,EAAE,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;CAClC,CAAC,CACT,CAAC;AAgFF,MAAM,MAAM,QAAQ,GAAG;IAAE,OAAO,EAAE,GAAG,CAAC;IAAC,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAA;CAAE,CAAC;AAItE,KAAK,cAAc,GAAG,KAAK,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG;IACzC,OAAO,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;CACvD,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,cA8PZ,CAAC;AAET,KAAK,wBAAwB,GAAG;IAC5B,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IACzB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,MAAM,CAAC,EAAE,wBAAwB,CAAC;IAClC,OAAO,CAAC,EAAE,wBAAwB,CAAC;CACtC,CAAC;AAaF,eAAO,MAAM,oBAAoB,GAAI,cAAc;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,sBAuD/E,CAAC"}
|