@g4rcez/components 2.0.32 → 2.0.34
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.js → button.jsx} +5 -3
- package/dist/components/core/heading.d.ts +1 -1
- package/dist/components/core/heading.d.ts.map +1 -1
- package/dist/components/core/heading.jsx +4 -0
- package/dist/components/core/{polymorph.js → polymorph.jsx} +1 -2
- package/dist/components/core/render-on-view.d.ts +1 -1
- package/dist/components/core/render-on-view.d.ts.map +1 -1
- package/dist/components/core/{render-on-view.js → render-on-view.jsx} +4 -3
- package/dist/components/core/resizable.d.ts +1 -1
- package/dist/components/core/resizable.d.ts.map +1 -1
- package/dist/components/core/{resizable.js → resizable.jsx} +4 -3
- package/dist/components/core/{slot.js → slot.jsx} +8 -5
- package/dist/components/core/{tag.js → tag.jsx} +6 -3
- package/dist/components/core/typography.d.ts +5 -5
- package/dist/components/core/typography.d.ts.map +1 -1
- package/dist/components/core/typography.jsx +26 -0
- package/dist/components/display/alert.d.ts +1 -1
- package/dist/components/display/alert.d.ts.map +1 -1
- package/dist/components/display/alert.jsx +56 -0
- package/dist/components/display/calendar.d.ts +1 -1
- package/dist/components/display/calendar.d.ts.map +1 -1
- package/dist/components/display/{calendar.js → calendar.jsx} +83 -21
- package/dist/components/display/card.d.ts +3 -3
- package/dist/components/display/card.d.ts.map +1 -1
- package/dist/components/display/card.jsx +43 -0
- package/dist/components/display/empty.d.ts +1 -1
- package/dist/components/display/empty.d.ts.map +1 -1
- package/dist/components/display/empty.jsx +11 -0
- package/dist/components/display/list.d.ts +2 -2
- package/dist/components/display/list.d.ts.map +1 -1
- package/dist/components/display/list.jsx +81 -0
- package/dist/components/display/notifications.d.ts +1 -1
- package/dist/components/display/notifications.d.ts.map +1 -1
- package/dist/components/display/{notifications.js → notifications.jsx} +34 -10
- package/dist/components/display/progress.d.ts +1 -1
- package/dist/components/display/progress.d.ts.map +1 -1
- package/dist/components/display/progress.jsx +13 -0
- package/dist/components/display/shortcut.d.ts +1 -1
- package/dist/components/display/shortcut.d.ts.map +1 -1
- package/dist/components/display/shortcut.jsx +23 -0
- package/dist/components/display/skeleton.d.ts +4 -4
- package/dist/components/display/skeleton.d.ts.map +1 -1
- package/dist/components/display/skeleton.jsx +14 -0
- package/dist/components/display/spinner.d.ts +2 -2
- package/dist/components/display/spinner.d.ts.map +1 -1
- package/dist/components/display/spinner.jsx +7 -0
- package/dist/components/display/stats.d.ts +1 -1
- package/dist/components/display/stats.d.ts.map +1 -1
- package/dist/components/display/stats.jsx +20 -0
- package/dist/components/display/step.d.ts +2 -2
- package/dist/components/display/step.d.ts.map +1 -1
- package/dist/components/display/step.jsx +133 -0
- package/dist/components/display/tabs.d.ts +3 -3
- package/dist/components/display/tabs.d.ts.map +1 -1
- package/dist/components/display/{tabs.js → tabs.jsx} +21 -7
- package/dist/components/display/timeline.d.ts +6 -6
- package/dist/components/display/timeline.d.ts.map +1 -1
- package/dist/components/display/timeline.jsx +25 -0
- package/dist/components/floating/command-palette.d.ts +1 -1
- package/dist/components/floating/command-palette.d.ts.map +1 -1
- package/dist/components/floating/command-palette.jsx +187 -0
- package/dist/components/floating/dropdown.d.ts +1 -1
- package/dist/components/floating/dropdown.d.ts.map +1 -1
- package/dist/components/floating/{dropdown.js → dropdown.jsx} +17 -3
- package/dist/components/floating/expand.d.ts +1 -1
- package/dist/components/floating/expand.d.ts.map +1 -1
- package/dist/components/floating/{expand.js → expand.jsx} +14 -2
- package/dist/components/floating/{menu.js → menu.jsx} +52 -27
- package/dist/components/floating/modal.d.ts +10 -2
- package/dist/components/floating/modal.d.ts.map +1 -1
- package/dist/components/floating/modal.jsx +240 -0
- package/dist/components/floating/toolbar.d.ts +1 -1
- package/dist/components/floating/toolbar.d.ts.map +1 -1
- package/dist/components/floating/toolbar.jsx +5 -0
- package/dist/components/floating/{tooltip.js → tooltip.jsx} +12 -3
- package/dist/components/floating/wizard.d.ts +1 -1
- package/dist/components/floating/wizard.d.ts.map +1 -1
- package/dist/components/floating/{wizard.js → wizard.jsx} +64 -19
- package/dist/components/form/autocomplete.jsx +276 -0
- package/dist/components/form/checkbox.jsx +12 -0
- package/dist/components/form/{date-picker.js → date-picker.jsx} +15 -4
- package/dist/components/form/file-upload.d.ts +1 -1
- package/dist/components/form/file-upload.d.ts.map +1 -1
- package/dist/components/form/file-upload.jsx +133 -0
- package/dist/components/form/form.d.ts +1 -1
- package/dist/components/form/form.d.ts.map +1 -1
- package/dist/components/form/{form.js → form.jsx} +2 -2
- package/dist/components/form/{free-text.js → free-text.jsx} +4 -3
- package/dist/components/form/input-field.d.ts +1 -1
- package/dist/components/form/input-field.d.ts.map +1 -1
- package/dist/components/form/input-field.jsx +54 -0
- package/dist/components/form/multi-select.jsx +328 -0
- package/dist/components/form/radiobox.d.ts +1 -1
- package/dist/components/form/radiobox.d.ts.map +1 -1
- package/dist/components/form/radiobox.jsx +6 -0
- package/dist/components/form/select.jsx +42 -0
- package/dist/components/form/slider.d.ts +1 -1
- package/dist/components/form/slider.d.ts.map +1 -1
- package/dist/components/form/{slider.js → slider.jsx} +11 -3
- package/dist/components/form/switch.jsx +46 -0
- package/dist/components/form/task-list.d.ts +1 -1
- package/dist/components/form/task-list.d.ts.map +1 -1
- package/dist/components/form/{task-list.js → task-list.jsx} +1 -2
- package/dist/components/form/transfer-list.d.ts +1 -1
- package/dist/components/form/transfer-list.d.ts.map +1 -1
- package/dist/components/form/transfer-list.jsx +39 -0
- package/dist/components/table/filter.d.ts +2 -2
- package/dist/components/table/filter.d.ts.map +1 -1
- package/dist/components/table/{filter.js → filter.jsx} +35 -7
- package/dist/components/table/group.d.ts +1 -1
- package/dist/components/table/group.d.ts.map +1 -1
- package/dist/components/table/group.jsx +68 -0
- package/dist/components/table/index.d.ts +1 -1
- package/dist/components/table/index.d.ts.map +1 -1
- package/dist/components/table/{index.js → index.jsx} +10 -2
- package/dist/components/table/inner-table.d.ts +1 -1
- package/dist/components/table/inner-table.d.ts.map +1 -1
- package/dist/components/table/{inner-table.js → inner-table.jsx} +21 -9
- package/dist/components/table/metadata.d.ts +1 -1
- package/dist/components/table/metadata.d.ts.map +1 -1
- package/dist/components/table/metadata.jsx +37 -0
- package/dist/components/table/pagination.d.ts +1 -1
- package/dist/components/table/pagination.d.ts.map +1 -1
- package/dist/components/table/pagination.jsx +73 -0
- package/dist/components/table/row.d.ts +1 -1
- package/dist/components/table/row.d.ts.map +1 -1
- package/dist/components/table/row.jsx +58 -0
- package/dist/components/table/sort.d.ts +2 -2
- package/dist/components/table/sort.d.ts.map +1 -1
- package/dist/components/table/{sort.js → sort.jsx} +32 -6
- package/dist/components/table/thead.d.ts +2 -1
- package/dist/components/table/thead.d.ts.map +1 -1
- package/dist/components/table/thead.jsx +103 -0
- package/dist/config/default-translations.d.ts +1 -1
- package/dist/config/{default-translations.js → default-translations.jsx} +5 -3
- package/dist/flow/flow.d.ts +1 -1
- package/dist/flow/flow.d.ts.map +1 -1
- package/dist/flow/flow.jsx +111 -0
- package/dist/hooks/use-components-provider.d.ts +2 -2
- package/dist/hooks/use-components-provider.d.ts.map +1 -1
- package/dist/hooks/{use-components-provider.js → use-components-provider.jsx} +2 -3
- package/dist/hooks/use-translations.d.ts +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13463 -16070
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +14 -31
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/core/heading.js +0 -5
- package/dist/components/core/typography.js +0 -10
- package/dist/components/display/alert.js +0 -37
- package/dist/components/display/card.js +0 -18
- package/dist/components/display/empty.js +0 -8
- package/dist/components/display/list.js +0 -32
- package/dist/components/display/progress.js +0 -9
- package/dist/components/display/shortcut.js +0 -19
- package/dist/components/display/skeleton.js +0 -13
- package/dist/components/display/spinner.js +0 -6
- package/dist/components/display/stats.js +0 -5
- package/dist/components/display/step.js +0 -122
- package/dist/components/display/timeline.js +0 -14
- package/dist/components/floating/command-palette.js +0 -155
- package/dist/components/floating/modal.js +0 -195
- package/dist/components/floating/toolbar.js +0 -4
- package/dist/components/form/autocomplete.js +0 -247
- package/dist/components/form/checkbox.js +0 -7
- package/dist/components/form/file-upload.js +0 -88
- package/dist/components/form/input-field.js +0 -17
- package/dist/components/form/multi-select.js +0 -277
- package/dist/components/form/radiobox.js +0 -3
- package/dist/components/form/select.js +0 -31
- package/dist/components/form/switch.js +0 -36
- package/dist/components/form/transfer-list.js +0 -22
- package/dist/components/table/group.js +0 -41
- package/dist/components/table/metadata.js +0 -10
- package/dist/components/table/pagination.js +0 -42
- package/dist/components/table/row.js +0 -47
- package/dist/components/table/thead.js +0 -71
- package/dist/flow/flow.js +0 -77
- /package/dist/components/form/{formReset.js → formReset.jsx} +0 -0
- /package/dist/components/form/{input.js → input.jsx} +0 -0
- /package/dist/components/form/{textarea.js → textarea.jsx} +0 -0
- /package/dist/components/table/{table.context.js → table.context.jsx} +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { css } from "../../lib/dom";
|
|
3
|
+
import { Polymorph } from "../core/polymorph";
|
|
4
|
+
export const TimelineItem = (props) => (<li data-component="timeline-item" className="relative pb-12" role="listitem">
|
|
5
|
+
<span aria-hidden="true" className="absolute left-6 top-8 -ml-px h-full w-0.5 bg-card-border"/>
|
|
6
|
+
<div className="relative flex items-stretch justify-start space-x-3">{props.children}</div>
|
|
7
|
+
</li>);
|
|
8
|
+
TimelineItem.Icon = function TimelineIcon(props) {
|
|
9
|
+
return (<header {...props} className={css("flex size-12 items-center justify-center rounded-full bg-primary p-2 text-primary-foreground", props.className)}>
|
|
10
|
+
{props.children}
|
|
11
|
+
</header>);
|
|
12
|
+
};
|
|
13
|
+
TimelineItem.Body = function TimelineItemBody(props) {
|
|
14
|
+
return (<Polymorph {...props} className={css("min-w-0 flex-1", props.className)}>
|
|
15
|
+
{props.children}
|
|
16
|
+
</Polymorph>);
|
|
17
|
+
};
|
|
18
|
+
TimelineItem.Right = function TimelineItemRight(props) {
|
|
19
|
+
return (<footer className="flex gap-6 self-stretch px-4 align-baseline">
|
|
20
|
+
<Polymorph {...props} type="button"/>
|
|
21
|
+
</footer>);
|
|
22
|
+
};
|
|
23
|
+
export const Timeline = (props) => (<ul data-component="timeline" role="list" className="flow-root [&>li:last-child>span[aria-hidden=true]]:hidden">
|
|
24
|
+
{props.children}
|
|
25
|
+
</ul>);
|
|
@@ -43,6 +43,6 @@ export type CommandPaletteProps = {
|
|
|
43
43
|
Default: React.FC<LucideProps>;
|
|
44
44
|
}>;
|
|
45
45
|
};
|
|
46
|
-
export declare const CommandPalette: (props: CommandPaletteProps) =>
|
|
46
|
+
export declare const CommandPalette: (props: CommandPaletteProps) => React.JSX.Element;
|
|
47
47
|
export {};
|
|
48
48
|
//# sourceMappingURL=command-palette.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-palette.d.ts","sourceRoot":"","sources":["../../../src/components/floating/command-palette.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAc,WAAW,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAmE,MAAM,OAAO,CAAC;AAQxF,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAKpC,KAAK,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAElC,KAAK,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI;IACnD,IAAI,EAAE,CAAC,CAAC;IACR,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,IAAI,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;IAC1B,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC,GAAG,OAAO,CAAC;CACvD,GAAG,CAAC,CAAC;AAEN,KAAK,IAAI,GAAG,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,SAAS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KAAK,gBAAgB,GAAG,WAAW,CAAC,OAAO,EAAE;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,gBAAgB,EAAE,CAAA;CAAE,CAAC,CAAC;AAEzF,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,GAAG,mBAAmB,CAAC;AA8CtE,MAAM,MAAM,mBAAmB,GAAG;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,MAAM,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;IAC5B,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,kBAAkB,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC5C,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,OAAO,EAAE,gBAAgB,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChE,IAAI,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;KAAE,CAAC,CAAC;CACnF,CAAC;AAsBF,eAAO,MAAM,cAAc,GAAI,OAAO,mBAAmB,sBA6LxD,CAAC"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { autoUpdate, useFloating, useInteractions, useListNavigation } from "@floating-ui/react";
|
|
3
|
+
import { FilterIcon } from "lucide-react";
|
|
4
|
+
import React, { forwardRef, Fragment, useEffect, useId, useRef, useState } from "react";
|
|
5
|
+
import { Is } from "sidekicker";
|
|
6
|
+
import { useStableRef } from "../../hooks/use-stable-ref";
|
|
7
|
+
import { useTranslations } from "../../hooks/use-translations";
|
|
8
|
+
import { CombiKeys } from "../../lib/combi-keys";
|
|
9
|
+
import { Dict } from "../../lib/dict";
|
|
10
|
+
import { css, isReactFC } from "../../lib/dom";
|
|
11
|
+
import { fzf } from "../../lib/fzf";
|
|
12
|
+
import { Shortcut } from "../display/shortcut";
|
|
13
|
+
import { SkeletonCell } from "../display/skeleton";
|
|
14
|
+
import { Modal } from "./modal";
|
|
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
|
+
const Item = forwardRef((props, ref) => {
|
|
19
|
+
const id = useId();
|
|
20
|
+
const active = props.active;
|
|
21
|
+
const item = props.item;
|
|
22
|
+
if (item.type === "group")
|
|
23
|
+
return (<div id={id} className="h-10 px-2 pb-1 pt-2">
|
|
24
|
+
<Group text={props.text} item={item}/>
|
|
25
|
+
</div>);
|
|
26
|
+
if (item.type !== "shortcut")
|
|
27
|
+
return <Fragment />;
|
|
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
|
+
<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
|
+
});
|
|
36
|
+
const getFuzzyData = (commands, value) => {
|
|
37
|
+
if (value.length === 0)
|
|
38
|
+
return commands;
|
|
39
|
+
const rules = [
|
|
40
|
+
{ key: "title", value },
|
|
41
|
+
{ key: "shortcut", value },
|
|
42
|
+
{ key: "hint", value },
|
|
43
|
+
];
|
|
44
|
+
const normalize = commands.map((x) => ({ ...x, title: Is.function(x.title) ? x.title({ text: value }) : x.title }));
|
|
45
|
+
const target = normalize.reduce((acc, x) => {
|
|
46
|
+
const enabled = Is.function(x.enabled) ? x.enabled({ text: value }) : (x.enabled ?? true);
|
|
47
|
+
if (enabled)
|
|
48
|
+
acc.push({ ...x, enabled: enabled });
|
|
49
|
+
return acc;
|
|
50
|
+
}, []);
|
|
51
|
+
const filter = fzf(target, "title", rules);
|
|
52
|
+
const withEnabled = normalize.filter((x) => (Is.function(x.enabled) ? x.enabled({ text: value }) : false));
|
|
53
|
+
return Dict.unique(filter.concat(withEnabled), (x) => x.title);
|
|
54
|
+
};
|
|
55
|
+
const loadingSkeleton = [0, 0, 0, 0, 0];
|
|
56
|
+
export const CommandPalette = (props) => {
|
|
57
|
+
const bindKey = props.bind ?? "Mod + k";
|
|
58
|
+
const listRef = useRef([]);
|
|
59
|
+
const translations = useTranslations();
|
|
60
|
+
const [value, setValue] = useState("");
|
|
61
|
+
const valueRef = useStableRef(value);
|
|
62
|
+
const id = useId();
|
|
63
|
+
const ref = useRef(null);
|
|
64
|
+
const [activeIndex, setActiveIndex] = useState(null);
|
|
65
|
+
const floating = useFloating({
|
|
66
|
+
open: props.open,
|
|
67
|
+
strategy: "absolute",
|
|
68
|
+
onOpenChange: props.onChangeVisibility,
|
|
69
|
+
whileElementsMounted: autoUpdate,
|
|
70
|
+
});
|
|
71
|
+
const listNav = useListNavigation(floating.context, {
|
|
72
|
+
listRef,
|
|
73
|
+
loop: true,
|
|
74
|
+
activeIndex,
|
|
75
|
+
virtual: true,
|
|
76
|
+
allowEscape: true,
|
|
77
|
+
scrollItemIntoView: true,
|
|
78
|
+
onNavigate: (n) => setActiveIndex((prev) => {
|
|
79
|
+
if (Is.number(n))
|
|
80
|
+
return n;
|
|
81
|
+
return props.open ? (prev ?? 0) : null;
|
|
82
|
+
}),
|
|
83
|
+
});
|
|
84
|
+
const { getItemProps } = useInteractions([listNav]);
|
|
85
|
+
const commands = props.commands.flatMap((x) => (x.type === "group" ? [x, ...x.items] : [x]));
|
|
86
|
+
const fuzzy = getFuzzyData(commands, value);
|
|
87
|
+
const displayItems = value === ""
|
|
88
|
+
? commands
|
|
89
|
+
: [
|
|
90
|
+
{
|
|
91
|
+
type: "group",
|
|
92
|
+
title: "Results",
|
|
93
|
+
items: [],
|
|
94
|
+
},
|
|
95
|
+
...fuzzy.filter((x) => x.type !== "group"),
|
|
96
|
+
];
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
const combi = new CombiKeys();
|
|
99
|
+
combi.add(bindKey, () => props.onChangeVisibility?.(true));
|
|
100
|
+
commands.forEach((cmd) => {
|
|
101
|
+
if (cmd.type === "group")
|
|
102
|
+
return;
|
|
103
|
+
if (cmd.type === "shortcut" && cmd.shortcut !== undefined)
|
|
104
|
+
combi.add(cmd.shortcut, (event) => cmd.action({
|
|
105
|
+
event,
|
|
106
|
+
text: valueRef.current,
|
|
107
|
+
setOpen: props.onChangeVisibility,
|
|
108
|
+
}));
|
|
109
|
+
});
|
|
110
|
+
return combi.register();
|
|
111
|
+
}, [bindKey]);
|
|
112
|
+
const Icon = props.Icon ?? FilterIcon;
|
|
113
|
+
return (<Fragment>
|
|
114
|
+
<Modal ref={ref} animated={false} closable={false} open={props.open} overlayClickClose ariaTitle="Command palette" bodyClassName="px-0 py-0 pt-2" data-component="command-palette" onChange={props.onChangeVisibility} className="container relative py-0 md:max-w-screen-sm lg:max-w-screen-md">
|
|
115
|
+
<header className="sticky top-0 isolate z-floating flex h-12 w-full items-center border-b border-floating-border bg-floating-background px-4">
|
|
116
|
+
<div className="flex size-10 items-center justify-center">
|
|
117
|
+
<Icon Default={FilterIcon} text={value} size={16}/>
|
|
118
|
+
</div>
|
|
119
|
+
<input autoFocus value={value} data-combikeysbypass="true" placeholder="Search for..." onChange={(e) => setValue(e.target.value)} className="h-12 w-full items-center bg-transparent px-2 py-2 pb-2 text-left text-lg outline-none" onKeyDown={(e) => {
|
|
120
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
121
|
+
if (activeIndex !== null) {
|
|
122
|
+
listRef.current[activeIndex]?.scrollIntoView({
|
|
123
|
+
block: "start",
|
|
124
|
+
inline: "start",
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (e.key === "Enter") {
|
|
129
|
+
if (activeIndex !== null && displayItems[activeIndex]) {
|
|
130
|
+
e.preventDefault();
|
|
131
|
+
const x = displayItems[activeIndex];
|
|
132
|
+
const text = e.currentTarget.value;
|
|
133
|
+
if (x.type === "shortcut")
|
|
134
|
+
return x.action({
|
|
135
|
+
event: e,
|
|
136
|
+
setOpen: props.onChangeVisibility,
|
|
137
|
+
text,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
if (displayItems.length === 1) {
|
|
141
|
+
e.preventDefault();
|
|
142
|
+
const x = displayItems[0];
|
|
143
|
+
const text = e.currentTarget.value;
|
|
144
|
+
if (x.type === "shortcut")
|
|
145
|
+
return x.action({
|
|
146
|
+
event: e,
|
|
147
|
+
setOpen: props.onChangeVisibility,
|
|
148
|
+
text,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}}/>
|
|
153
|
+
</header>
|
|
154
|
+
{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">
|
|
155
|
+
<div className="h-10 px-2 pb-1 pt-2">{translations.commandPaletteLoading}</div>
|
|
156
|
+
{loadingSkeleton.map((x, 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")}>
|
|
157
|
+
{SkeletonCell}
|
|
158
|
+
</li>))}
|
|
159
|
+
</ul>) : (<div className="flex min-w-full flex-row flex-nowrap" data-component="command-palette-container">
|
|
160
|
+
<ul role="listbox" 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">
|
|
161
|
+
{displayItems.map((item, index) => (<Item {...getItemProps({
|
|
162
|
+
onMouseEnter: () => setActiveIndex(index),
|
|
163
|
+
ref(node) {
|
|
164
|
+
listRef.current[index] = node;
|
|
165
|
+
},
|
|
166
|
+
onClick(e) {
|
|
167
|
+
e.preventDefault();
|
|
168
|
+
props.onChangeVisibility(false);
|
|
169
|
+
floating.refs.domReference.current?.focus();
|
|
170
|
+
if (item.type === "shortcut")
|
|
171
|
+
item.action({
|
|
172
|
+
event: e,
|
|
173
|
+
setOpen: props.onChangeVisibility,
|
|
174
|
+
text: value,
|
|
175
|
+
});
|
|
176
|
+
},
|
|
177
|
+
})} item={item} text={value} active={activeIndex === index} key={`${id}-${item.type}-${index}`}/>))}
|
|
178
|
+
{displayItems.length === 1 ? (<div className={css("flex items-center justify-between rounded-lg p-2 text-secondary")}>
|
|
179
|
+
{translations.commandPaletteEmpty ?? props.emptyMessage}
|
|
180
|
+
</div>) : null}
|
|
181
|
+
</ul>
|
|
182
|
+
{props.Preview && Is.number(activeIndex) ? <props.Preview command={displayItems[activeIndex]} text={value}/> : null}
|
|
183
|
+
</div>)}
|
|
184
|
+
{props.footer ? <footer className="flex h-8 items-center rounded-b-lg bg-background p-2">{props.footer}</footer> : null}
|
|
185
|
+
</Modal>
|
|
186
|
+
</Fragment>);
|
|
187
|
+
};
|
|
@@ -9,6 +9,6 @@ type DropdownProps = {
|
|
|
9
9
|
trigger: React.ReactElement | React.ReactNode;
|
|
10
10
|
title?: React.ReactNode | React.ReactElement | string;
|
|
11
11
|
};
|
|
12
|
-
export declare const Dropdown: (props: PropsWithChildren<DropdownProps>) =>
|
|
12
|
+
export declare const Dropdown: (props: PropsWithChildren<DropdownProps>) => React.JSX.Element;
|
|
13
13
|
export {};
|
|
14
14
|
//# sourceMappingURL=dropdown.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/floating/d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,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,OAAO,iBAAiB,CAAC,aAAa,CAAC,sBAqE/D,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { arrow, autoUpdate, flip, FloatingArrow, FloatingFocusManager, FloatingPortal, offset, shift, useClick, useDismiss, useFloating, useInteractions, useRole, } from "@floating-ui/react";
|
|
4
|
-
import { Fragment, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
3
|
+
import React, { Fragment, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
5
4
|
export const Dropdown = (props) => {
|
|
6
5
|
const headingId = useId();
|
|
7
6
|
const [open, setOpen] = useState(props.open);
|
|
@@ -35,5 +34,20 @@ export const Dropdown = (props) => {
|
|
|
35
34
|
const dismiss = useDismiss(context);
|
|
36
35
|
const role = useRole(context, { role: "tooltip" });
|
|
37
36
|
const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss, role]);
|
|
38
|
-
return (
|
|
37
|
+
return (<Fragment>
|
|
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 p-4 rounded-lg border isolate z-floating min-w-96 border-floating-border bg-floating-background 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-2xl font-medium tracking-wide leading-snug text-left">{props.title}</h3>
|
|
47
|
+
</header>
|
|
48
|
+
{props.children}
|
|
49
|
+
</div>
|
|
50
|
+
</FloatingFocusManager>
|
|
51
|
+
</FloatingPortal>)}
|
|
52
|
+
</Fragment>);
|
|
39
53
|
};
|
|
@@ -7,5 +7,5 @@ export type ExpandProps = Override<ButtonProps<typeof motion.button>, {
|
|
|
7
7
|
open?: boolean;
|
|
8
8
|
disabled?: boolean;
|
|
9
9
|
}>;
|
|
10
|
-
export declare const Expand: (props: PropsWithChildren<ExpandProps>) => import("react
|
|
10
|
+
export declare const Expand: (props: PropsWithChildren<ExpandProps>) => import("react").JSX.Element;
|
|
11
11
|
//# sourceMappingURL=expand.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expand.d.ts","sourceRoot":"","sources":["../../../src/components/floating/expand.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAmB,MAAM,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAsC,MAAM,OAAO,CAAC;AAC9E,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAU,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,MAAM,WAAW,GAAG,QAAQ,CAC9B,WAAW,CAAC,OAAO,MAAM,CAAC,MAAM,CAAC,EACjC;IACI,OAAO,EAAE,KAAK,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB,CACJ,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,OAAO,iBAAiB,CAAC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"expand.d.ts","sourceRoot":"","sources":["../../../src/components/floating/expand.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAmB,MAAM,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAsC,MAAM,OAAO,CAAC;AAC9E,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAU,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,MAAM,WAAW,GAAG,QAAQ,CAC9B,WAAW,CAAC,OAAO,MAAM,CAAC,MAAM,CAAC,EACjC;IACI,OAAO,EAAE,KAAK,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB,CACJ,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,OAAO,iBAAiB,CAAC,WAAW,CAAC,gCAmD3D,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { FloatingFocusManager, FloatingPortal, useClick, useDismiss, useFloating, useInteractions, useRole } from "@floating-ui/react";
|
|
4
3
|
import { AnimatePresence, motion } from "motion/react";
|
|
5
4
|
import { useEffect, useId, useRef, useState } from "react";
|
|
@@ -28,5 +27,18 @@ export const Expand = (props) => {
|
|
|
28
27
|
outsidePress: true,
|
|
29
28
|
});
|
|
30
29
|
const { getFloatingProps, getReferenceProps } = useInteractions([click, role, dismiss]);
|
|
31
|
-
return (
|
|
30
|
+
return (<div className="relative inline-flex items-center justify-center" ref={root}>
|
|
31
|
+
<Button {...getReferenceProps(props)} as={motion.button} layoutId={wrapperId} ref={refs.setReference} size="small" onClick={() => setOpen(true)}>
|
|
32
|
+
<motion.span layoutId={titleId}>{props.trigger}</motion.span>
|
|
33
|
+
</Button>
|
|
34
|
+
<AnimatePresence>
|
|
35
|
+
{open ? (<FloatingPortal root={root}>
|
|
36
|
+
<FloatingFocusManager visuallyHiddenDismiss modal closeOnFocusOut context={context}>
|
|
37
|
+
<motion.div {...getFloatingProps()} ref={refs.setFloating} layoutId={wrapperId} className="absolute -left-1/4 -top-3/4">
|
|
38
|
+
{props.children}
|
|
39
|
+
</motion.div>
|
|
40
|
+
</FloatingFocusManager>
|
|
41
|
+
</FloatingPortal>) : null}
|
|
42
|
+
</AnimatePresence>
|
|
43
|
+
</div>);
|
|
32
44
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { autoUpdate, flip, FloatingFocusManager, FloatingList, FloatingNode, FloatingPortal, FloatingTree, offset, safePolygon, shift, useClick, useDismiss, useFloating, useFloatingNodeId, useFloatingParentNodeId, useFloatingTree, useHover, useInteractions, useListItem, useListNavigation, useRole, useTypeahead, } from "@floating-ui/react";
|
|
4
3
|
import { Slot } from "../core/slot";
|
|
5
4
|
import { ChevronRightIcon } from "lucide-react";
|
|
@@ -84,39 +83,65 @@ const MenuComponent = React.forwardRef(({ children, FloatingComponent = "div", h
|
|
|
84
83
|
tree.events.emit("menuopen", { parentId, nodeId });
|
|
85
84
|
}, [tree, isOpen, nodeId, parentId]);
|
|
86
85
|
const className = isParent ? props.className : css(menuItemClassName(props.className));
|
|
87
|
-
return (
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
86
|
+
return (<FloatingNode id={nodeId}>
|
|
87
|
+
<Fragment>
|
|
88
|
+
{props.asChild ? (<Slot {...getReferenceProps(parent.getItemProps({
|
|
89
|
+
...props,
|
|
90
|
+
onFocus(event) {
|
|
91
|
+
props.onFocus?.(event);
|
|
92
|
+
setHasFocusInside(false);
|
|
93
|
+
parent.setHasFocusInside(true);
|
|
94
|
+
},
|
|
95
|
+
}))} children={label} className={className} data-open={isOpen ? "" : undefined} data-nested={isNested ? "" : undefined} role={isNested ? "menuitem" : undefined} data-focus-inside={hasFocusInside ? "" : undefined} ref={mergeRefs(refs.setReference, item.ref, forwardedRef)} tabIndex={!isNested ? undefined : parent.activeIndex === item.index ? 0 : -1}/>) : (<button type="button" className={className} data-open={isOpen ? "" : undefined} data-nested={isNested ? "" : undefined} role={isNested ? "menuitem" : undefined} data-focus-inside={hasFocusInside ? "" : undefined} ref={mergeRefs(refs.setReference, item.ref, forwardedRef)} tabIndex={!isNested ? undefined : parent.activeIndex === item.index ? 0 : -1} {...getReferenceProps(parent.getItemProps({
|
|
96
|
+
...props,
|
|
97
|
+
onFocus(event) {
|
|
98
|
+
props.onFocus?.(event);
|
|
99
|
+
setHasFocusInside(false);
|
|
100
|
+
parent.setHasFocusInside(true);
|
|
101
|
+
},
|
|
102
|
+
}))}>
|
|
103
|
+
{label}
|
|
104
|
+
{isNested && (<span style={{ marginLeft: 10, fontSize: 10 }}>
|
|
105
|
+
<span className="sr-only">Next menu</span>
|
|
106
|
+
<ChevronRightIcon size={14}/>
|
|
107
|
+
</span>)}
|
|
108
|
+
</button>)}
|
|
109
|
+
</Fragment>
|
|
110
|
+
<MenuContext.Provider value={{ activeIndex, setActiveIndex, getItemProps, setHasFocusInside, isOpen }}>
|
|
111
|
+
<FloatingList elementsRef={elementsRef} labelsRef={labelsRef}>
|
|
112
|
+
{isOpen && (<FloatingPortal>
|
|
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-none", floatingClassName)}>
|
|
115
|
+
{children}
|
|
116
|
+
</FloatingComponent>
|
|
117
|
+
</FloatingFocusManager>
|
|
118
|
+
</FloatingPortal>)}
|
|
119
|
+
</FloatingList>
|
|
120
|
+
</MenuContext.Provider>
|
|
121
|
+
</FloatingNode>);
|
|
102
122
|
});
|
|
103
123
|
export const MenuItem = React.forwardRef(({ title, Right, disabled, children, ...props }, forwardedRef) => {
|
|
104
124
|
const menu = useContext(MenuContext);
|
|
105
125
|
const item = useListItem({ label: disabled ? null : title });
|
|
106
126
|
const tree = useFloatingTree();
|
|
107
127
|
const isActive = item.index === menu.activeIndex;
|
|
108
|
-
return (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
128
|
+
return (<button {...props} title={title} type="button" role="menuitem" disabled={disabled} data-active={isActive} data-open={menu.isOpen} tabIndex={isActive ? 0 : -1} ref={mergeRefs(item.ref, forwardedRef)} className={menuItemClassName(`${props.className ?? ""} ${isActive ? "bg-primary text-primary-foreground" : ""}`)} {...menu.getItemProps({
|
|
129
|
+
onClick(event) {
|
|
130
|
+
props.onClick?.(event);
|
|
131
|
+
tree?.events.emit("click");
|
|
132
|
+
},
|
|
133
|
+
onFocus(event) {
|
|
134
|
+
props.onFocus?.(event);
|
|
135
|
+
menu.setHasFocusInside(true);
|
|
136
|
+
},
|
|
137
|
+
})}>
|
|
138
|
+
{children}
|
|
139
|
+
{Right ? <Right size={16}/> : null}
|
|
140
|
+
</button>);
|
|
118
141
|
});
|
|
119
142
|
export const Menu = React.forwardRef((props, ref) => {
|
|
120
143
|
const parentId = useFloatingParentNodeId();
|
|
121
|
-
return parentId === null ? (
|
|
144
|
+
return parentId === null ? (<FloatingTree>
|
|
145
|
+
<MenuComponent {...props} isParent ref={ref}/>
|
|
146
|
+
</FloatingTree>) : (<MenuComponent {...props} isParent={false} ref={ref}/>);
|
|
122
147
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ElementProps } from "@floating-ui/react";
|
|
1
2
|
import { HTMLMotionProps } from "motion/react";
|
|
2
3
|
import React from "react";
|
|
3
4
|
import { Label, Override } from "../../types";
|
|
@@ -26,12 +27,15 @@ export type ModalProps = Override<HTMLMotionProps<"div">, ({
|
|
|
26
27
|
overlayClassName: string;
|
|
27
28
|
position: DrawerPosition;
|
|
28
29
|
overlayClickClose: boolean;
|
|
30
|
+
role: "dialog" | "listbox";
|
|
31
|
+
interactions: ElementProps[];
|
|
29
32
|
trigger: Label | React.FC<any>;
|
|
30
33
|
}>>;
|
|
31
34
|
type ModalRef = {
|
|
35
|
+
context: any;
|
|
32
36
|
floating: HTMLElement | null;
|
|
33
37
|
};
|
|
34
|
-
export declare const Modal: React.ForwardRefExoticComponent<(Omit<Omit<HTMLMotionProps<"div">, "footer" | "title" | "className" | "onChange" | "position" | "open" | "resizer" | "type" | "layoutId" | "trigger" | "asChild" | "animated" | "closable" | "forceType" | "bodyClassName" | "overlayClassName" | "overlayClickClose" | "ariaTitle"> & {
|
|
38
|
+
export declare const Modal: React.ForwardRefExoticComponent<(Omit<Omit<HTMLMotionProps<"div">, "footer" | "title" | "className" | "role" | "onChange" | "position" | "open" | "resizer" | "type" | "layoutId" | "trigger" | "asChild" | "animated" | "closable" | "forceType" | "bodyClassName" | "overlayClassName" | "overlayClickClose" | "interactions" | "ariaTitle"> & {
|
|
35
39
|
title: Label;
|
|
36
40
|
ariaTitle?: string;
|
|
37
41
|
} & {
|
|
@@ -51,10 +55,12 @@ export declare const Modal: React.ForwardRefExoticComponent<(Omit<Omit<HTMLMotio
|
|
|
51
55
|
overlayClassName: string;
|
|
52
56
|
position: DrawerPosition;
|
|
53
57
|
overlayClickClose: boolean;
|
|
58
|
+
role: "dialog" | "listbox";
|
|
59
|
+
interactions: ElementProps[];
|
|
54
60
|
trigger: Label | React.FC<any>;
|
|
55
61
|
}> & {
|
|
56
62
|
children?: React.ReactNode | undefined;
|
|
57
|
-
}, "ref"> | Omit<Omit<HTMLMotionProps<"div">, "footer" | "title" | "className" | "onChange" | "position" | "open" | "resizer" | "type" | "layoutId" | "trigger" | "asChild" | "animated" | "closable" | "forceType" | "bodyClassName" | "overlayClassName" | "overlayClickClose" | "ariaTitle"> & {
|
|
63
|
+
}, "ref"> | Omit<Omit<HTMLMotionProps<"div">, "footer" | "title" | "className" | "role" | "onChange" | "position" | "open" | "resizer" | "type" | "layoutId" | "trigger" | "asChild" | "animated" | "closable" | "forceType" | "bodyClassName" | "overlayClassName" | "overlayClickClose" | "interactions" | "ariaTitle"> & {
|
|
58
64
|
ariaTitle: string;
|
|
59
65
|
title?: Label;
|
|
60
66
|
} & {
|
|
@@ -74,6 +80,8 @@ export declare const Modal: React.ForwardRefExoticComponent<(Omit<Omit<HTMLMotio
|
|
|
74
80
|
overlayClassName: string;
|
|
75
81
|
position: DrawerPosition;
|
|
76
82
|
overlayClickClose: boolean;
|
|
83
|
+
role: "dialog" | "listbox";
|
|
84
|
+
interactions: ElementProps[];
|
|
77
85
|
trigger: Label | React.FC<any>;
|
|
78
86
|
}> & {
|
|
79
87
|
children?: React.ReactNode | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/components/floating/modal.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/components/floating/modal.tsx"],"names":[],"mappings":"AACA,OAAO,EASL,KAAK,YAAY,EAClB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAmB,eAAe,EAAmF,MAAM,cAAc,CAAC;AAEjJ,OAAO,KAA+G,MAAM,OAAO,CAAC;AAGpI,OAAO,EAAE,KAAK,EAAO,QAAQ,EAAE,MAAM,aAAa,CAAC;AAInD,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,CAC/B,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,C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