@pyck/react 0.0.1
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/checkmark-CW-yHMvN.js +18 -0
- package/dist/chunk-BYypO7fO.js +18 -0
- package/dist/close-button-BM7ikbYh.js +52 -0
- package/dist/components/absolute-center/index.d.ts +11 -0
- package/dist/components/absolute-center/index.js +9 -0
- package/dist/components/action-bar/index.d.ts +21 -0
- package/dist/components/action-bar/index.js +35 -0
- package/dist/components/avatar/index.d.ts +22 -0
- package/dist/components/avatar/index.js +53 -0
- package/dist/components/badge/index.d.ts +11 -0
- package/dist/components/badge/index.js +9 -0
- package/dist/components/breadcrumb/index.d.ts +19 -0
- package/dist/components/breadcrumb/index.js +31 -0
- package/dist/components/button/index.d.ts +47 -0
- package/dist/components/button/index.js +3 -0
- package/dist/components/card/index.d.ts +19 -0
- package/dist/components/card/index.js +24 -0
- package/dist/components/carousel/index.d.ts +25 -0
- package/dist/components/carousel/index.js +65 -0
- package/dist/components/checkbox/index.d.ts +35 -0
- package/dist/components/checkbox/index.js +67 -0
- package/dist/components/checkmark/index.d.ts +26 -0
- package/dist/components/checkmark/index.js +3 -0
- package/dist/components/clipboard/index.d.ts +21 -0
- package/dist/components/clipboard/index.js +36 -0
- package/dist/components/collapsible/index.d.ts +18 -0
- package/dist/components/collapsible/index.js +23 -0
- package/dist/components/combobox/index.d.ts +32 -0
- package/dist/components/combobox/index.js +62 -0
- package/dist/components/data-list/index.d.ts +26 -0
- package/dist/components/data-list/index.js +39 -0
- package/dist/components/date-picker/index.d.ts +38 -0
- package/dist/components/date-picker/index.js +81 -0
- package/dist/components/dialog/index.d.ts +107 -0
- package/dist/components/dialog/index.js +295 -0
- package/dist/components/display-date-value/index.d.ts +3 -0
- package/dist/components/display-date-value/index.js +4 -0
- package/dist/components/display-value/index.d.ts +2 -0
- package/dist/components/display-value/index.js +3 -0
- package/dist/components/drawer/index.d.ts +28 -0
- package/dist/components/drawer/index.js +50 -0
- package/dist/components/drilldown-menu/index.d.ts +16 -0
- package/dist/components/drilldown-menu/index.js +123 -0
- package/dist/components/field/index.d.ts +21 -0
- package/dist/components/field/index.js +49 -0
- package/dist/components/fieldset/index.d.ts +23 -0
- package/dist/components/fieldset/index.js +32 -0
- package/dist/components/floating-panel/index.d.ts +23 -0
- package/dist/components/floating-panel/index.js +86 -0
- package/dist/components/for/index.d.ts +20 -0
- package/dist/components/for/index.js +9 -0
- package/dist/components/form/index.d.ts +41 -0
- package/dist/components/form/index.js +46 -0
- package/dist/components/format/index.d.ts +2 -0
- package/dist/components/format/index.js +3 -0
- package/dist/components/group/index.d.ts +11 -0
- package/dist/components/group/index.js +9 -0
- package/dist/components/heading/index.d.ts +12 -0
- package/dist/components/heading/index.js +8 -0
- package/dist/components/highlight/index.d.ts +17 -0
- package/dist/components/highlight/index.js +27 -0
- package/dist/components/icon/index.d.ts +19 -0
- package/dist/components/icon/index.js +3 -0
- package/dist/components/image/index.d.ts +22 -0
- package/dist/components/image/index.js +12 -0
- package/dist/components/input/index.d.ts +23 -0
- package/dist/components/input/index.js +21 -0
- package/dist/components/input-addon/index.d.ts +11 -0
- package/dist/components/input-addon/index.js +9 -0
- package/dist/components/input-group/index.d.ts +16 -0
- package/dist/components/input-group/index.js +29 -0
- package/dist/components/json-form-builder/index.d.ts +135 -0
- package/dist/components/json-form-builder/index.js +347 -0
- package/dist/components/kbd/index.d.ts +11 -0
- package/dist/components/kbd/index.js +9 -0
- package/dist/components/link/index.d.ts +11 -0
- package/dist/components/link/index.js +9 -0
- package/dist/components/listbox/index.d.ts +2 -0
- package/dist/components/listbox/index.js +3 -0
- package/dist/components/loader/index.d.ts +28 -0
- package/dist/components/loader/index.js +28 -0
- package/dist/components/locale/index.d.ts +2 -0
- package/dist/components/locale/index.js +3 -0
- package/dist/components/logo/index.d.ts +8 -0
- package/dist/components/logo/index.js +25 -0
- package/dist/components/mark/index.d.ts +11 -0
- package/dist/components/mark/index.js +9 -0
- package/dist/components/menu/index.d.ts +34 -0
- package/dist/components/menu/index.js +69 -0
- package/dist/components/number-input/index.d.ts +34 -0
- package/dist/components/number-input/index.js +51 -0
- package/dist/components/page-header/index.d.ts +18 -0
- package/dist/components/page-header/index.js +22 -0
- package/dist/components/pagination/index.d.ts +29 -0
- package/dist/components/pagination/index.js +45 -0
- package/dist/components/picker/index.d.ts +19 -0
- package/dist/components/picker/index.js +57 -0
- package/dist/components/popover/index.d.ts +30 -0
- package/dist/components/popover/index.js +50 -0
- package/dist/components/portal/index.d.ts +2 -0
- package/dist/components/portal/index.js +3 -0
- package/dist/components/progress/index.d.ts +19 -0
- package/dist/components/progress/index.js +47 -0
- package/dist/components/progress-circle/index.d.ts +19 -0
- package/dist/components/progress-circle/index.js +54 -0
- package/dist/components/radio-card-group/index.d.ts +21 -0
- package/dist/components/radio-card-group/index.js +29 -0
- package/dist/components/radio-group/index.d.ts +22 -0
- package/dist/components/radio-group/index.js +41 -0
- package/dist/components/scroll-area/index.d.ts +23 -0
- package/dist/components/scroll-area/index.js +41 -0
- package/dist/components/segment-group/index.d.ts +32 -0
- package/dist/components/segment-group/index.js +46 -0
- package/dist/components/select/index.d.ts +54 -0
- package/dist/components/select/index.js +93 -0
- package/dist/components/show/index.d.ts +11 -0
- package/dist/components/show/index.js +3 -0
- package/dist/components/skeleton/index.d.ts +23 -0
- package/dist/components/skeleton/index.js +17 -0
- package/dist/components/slider/index.d.ts +31 -0
- package/dist/components/slider/index.js +93 -0
- package/dist/components/span/index.d.ts +8 -0
- package/dist/components/span/index.js +3 -0
- package/dist/components/spinner/index.d.ts +11 -0
- package/dist/components/spinner/index.js +9 -0
- package/dist/components/spotlight/index.d.ts +28 -0
- package/dist/components/spotlight/index.js +165 -0
- package/dist/components/stat/index.d.ts +16 -0
- package/dist/components/stat/index.js +18 -0
- package/dist/components/steps/index.d.ts +36 -0
- package/dist/components/steps/index.js +61 -0
- package/dist/components/switch/index.d.ts +41 -0
- package/dist/components/switch/index.js +80 -0
- package/dist/components/table/index.d.ts +85 -0
- package/dist/components/table/index.js +144 -0
- package/dist/components/tabs/index.d.ts +18 -0
- package/dist/components/tabs/index.js +22 -0
- package/dist/components/tags-input/index.d.ts +29 -0
- package/dist/components/tags-input/index.js +48 -0
- package/dist/components/text/index.d.ts +12 -0
- package/dist/components/text/index.js +8 -0
- package/dist/components/textarea/index.d.ts +24 -0
- package/dist/components/textarea/index.js +22 -0
- package/dist/components/toast/index.d.ts +25 -0
- package/dist/components/toast/index.js +76 -0
- package/dist/components/toggle-group/index.d.ts +16 -0
- package/dist/components/toggle-group/index.js +19 -0
- package/dist/components/tooltip/index.d.ts +26 -0
- package/dist/components/tooltip/index.js +50 -0
- package/dist/components/tree-view/index.d.ts +37 -0
- package/dist/components/tree-view/index.js +63 -0
- package/dist/components/wrap/index.d.ts +15 -0
- package/dist/components/wrap/index.js +5 -0
- package/dist/display-date-value-CdfgVuB7.d.ts +15 -0
- package/dist/display-date-value-gTlidtNz.js +21 -0
- package/dist/display-value-BNKxQ99u.js +37 -0
- package/dist/display-value-IyQT1429.d.ts +11 -0
- package/dist/featured-icon-DPysOpSf.js +35 -0
- package/dist/function-DOGwA2sm.js +7 -0
- package/dist/show-IaI-36v9.js +12 -0
- package/dist/span-DWZSA3mH.js +7 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/index.js +0 -0
- package/dist/utils/index.d.ts +206 -0
- package/dist/utils/index.js +377 -0
- package/package.json +89 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { createListCollection } from "@ark-ui/react/collection";
|
|
2
|
+
import { useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { Box, Center, Grid, HStack } from "@pyck/styled-system/jsx";
|
|
4
|
+
import { ArrowDownIcon, ArrowUpIcon, ChevronRightIcon, CommandIcon, CornerDownLeftIcon, SearchIcon, UserIcon } from "lucide-react";
|
|
5
|
+
import { useDebounce, useHotkey } from "@pyck/react/utils";
|
|
6
|
+
import { Show } from "@pyck/react/show";
|
|
7
|
+
import { Span } from "@pyck/react/span";
|
|
8
|
+
import { Button } from "@pyck/react/button";
|
|
9
|
+
import { Icon } from "@pyck/react/icon";
|
|
10
|
+
import { Combobox } from "@pyck/react/combobox";
|
|
11
|
+
import { Text } from "@pyck/react/text";
|
|
12
|
+
import { ScrollArea } from "@pyck/react/scroll-area";
|
|
13
|
+
import { Dialog } from "@pyck/react/dialog";
|
|
14
|
+
import { InputGroup } from "@pyck/react/input-group";
|
|
15
|
+
import { Kbd } from "@pyck/react/kbd";
|
|
16
|
+
import { Portal } from "@pyck/react/portal";
|
|
17
|
+
import { Breadcrumb } from "@pyck/react/breadcrumb";
|
|
18
|
+
import { Highlight } from "@pyck/react/highlight";
|
|
19
|
+
|
|
20
|
+
//#region src/components/spotlight/keyboard-hints.tsx
|
|
21
|
+
const KeyboardHints = () => {
|
|
22
|
+
return <HStack gap="4">
|
|
23
|
+
<Shortcut label="to navigate">
|
|
24
|
+
<HStack gap="1.5">
|
|
25
|
+
<KeyboardKey>
|
|
26
|
+
<ArrowUpIcon />
|
|
27
|
+
</KeyboardKey>
|
|
28
|
+
<KeyboardKey>
|
|
29
|
+
<ArrowDownIcon />
|
|
30
|
+
</KeyboardKey>
|
|
31
|
+
</HStack>
|
|
32
|
+
</Shortcut>
|
|
33
|
+
|
|
34
|
+
<Shortcut label="to select">
|
|
35
|
+
<KeyboardKey>
|
|
36
|
+
<CornerDownLeftIcon />
|
|
37
|
+
</KeyboardKey>
|
|
38
|
+
</Shortcut>
|
|
39
|
+
|
|
40
|
+
<Shortcut label="to close">
|
|
41
|
+
<Kbd variant="surface" size="2xl" color="fg.muted">
|
|
42
|
+
Esc
|
|
43
|
+
</Kbd>
|
|
44
|
+
</Shortcut>
|
|
45
|
+
</HStack>;
|
|
46
|
+
};
|
|
47
|
+
const Shortcut = ({ children, label }) => <HStack>
|
|
48
|
+
{children}
|
|
49
|
+
<Text color="fg.muted" textStyle="sm" fontWeight="medium">
|
|
50
|
+
{label}
|
|
51
|
+
</Text>
|
|
52
|
+
</HStack>;
|
|
53
|
+
const KeyboardKey = (props) => <Kbd variant="surface" size="2xl">
|
|
54
|
+
<Icon {...props} />
|
|
55
|
+
</Kbd>;
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/components/spotlight/search-result-item.tsx
|
|
59
|
+
const SearchResultItem = (props) => {
|
|
60
|
+
const { item, filterText } = props;
|
|
61
|
+
return <HStack py="2.5" px="3.5" borderRadius="l3" _hover={{ bg: "gray.surface.bg.hover" }}>
|
|
62
|
+
<Center borderWidth="1px" borderRadius="l2" boxSize="10">
|
|
63
|
+
<Icon>
|
|
64
|
+
<UserIcon />
|
|
65
|
+
</Icon>
|
|
66
|
+
</Center>
|
|
67
|
+
<Box textStyle="sm">
|
|
68
|
+
<Text fontWeight="medium">{item.label}</Text>
|
|
69
|
+
<Breadcrumb.Root size="sm">
|
|
70
|
+
<Breadcrumb.List gap="0.5">
|
|
71
|
+
<Breadcrumb.Item>{item.matchReason?.property}</Breadcrumb.Item>
|
|
72
|
+
<Breadcrumb.Separator>
|
|
73
|
+
<ChevronRightIcon />
|
|
74
|
+
</Breadcrumb.Separator>
|
|
75
|
+
<Breadcrumb.Item color="fg.muted">
|
|
76
|
+
<Text>
|
|
77
|
+
<Highlight query={filterText ?? ""} variant="subtle" colorPalette="teal">
|
|
78
|
+
{item.matchReason?.value ?? ""}
|
|
79
|
+
</Highlight>
|
|
80
|
+
</Text>
|
|
81
|
+
</Breadcrumb.Item>
|
|
82
|
+
</Breadcrumb.List>
|
|
83
|
+
</Breadcrumb.Root>
|
|
84
|
+
</Box>
|
|
85
|
+
</HStack>;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/components/spotlight/spotlight.tsx
|
|
90
|
+
const Spotlight = (props) => {
|
|
91
|
+
const { searchList, children, onHighlightChange } = props;
|
|
92
|
+
const [open, setOpen] = useState(false);
|
|
93
|
+
useHotkey(setOpen);
|
|
94
|
+
const [filterText, setFilterText] = useState("");
|
|
95
|
+
const debouncedValue = useDebounce(filterText, { wait: 250 });
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
console.log("Setting filter text to:", debouncedValue);
|
|
98
|
+
searchList.setFilterText(debouncedValue);
|
|
99
|
+
}, [debouncedValue]);
|
|
100
|
+
const collection = useMemo(() => createListCollection({ items: searchList.items }), [searchList.items]);
|
|
101
|
+
const id = "list";
|
|
102
|
+
return <Dialog.Root open={open} onOpenChange={(event) => {
|
|
103
|
+
setOpen(event.open);
|
|
104
|
+
if (!event.open) {
|
|
105
|
+
setFilterText("");
|
|
106
|
+
searchList.setFilterText("");
|
|
107
|
+
}
|
|
108
|
+
}} motionPreset="slide-in-bottom" scrollBehavior="inside">
|
|
109
|
+
<Dialog.Trigger asChild>
|
|
110
|
+
<Button variant="outline" size="sm" minW="56">
|
|
111
|
+
<Icon color="fg.muted" size="sm">
|
|
112
|
+
<SearchIcon />
|
|
113
|
+
</Icon>
|
|
114
|
+
<Span fontWeight="normal" flex="1" minW="0" textAlign="start">
|
|
115
|
+
Find...
|
|
116
|
+
</Span>
|
|
117
|
+
<Kbd variant="surface" size="sm" gap="0.5">
|
|
118
|
+
<Icon boxSize="3">
|
|
119
|
+
<CommandIcon />
|
|
120
|
+
</Icon>
|
|
121
|
+
K
|
|
122
|
+
</Kbd>
|
|
123
|
+
</Button>
|
|
124
|
+
</Dialog.Trigger>
|
|
125
|
+
<Portal>
|
|
126
|
+
<Dialog.Backdrop />
|
|
127
|
+
<Dialog.Positioner>
|
|
128
|
+
<Combobox.Root open disableLayer inputBehavior="autohighlight" placeholder="Search..." selectionBehavior="preserve" collection={collection} loopFocus={false} onInputValueChange={({ inputValue }) => setFilterText(inputValue || "")} onHighlightChange={(e) => onHighlightChange?.(e.highlightedItem)} variant="plain" ids={{ content: id }}>
|
|
129
|
+
<Dialog.Content maxW="4xl" divideY="1px">
|
|
130
|
+
<Dialog.Header px="1" p="2">
|
|
131
|
+
<InputGroup startElement={<SearchIcon />}>
|
|
132
|
+
<Combobox.Input />
|
|
133
|
+
</InputGroup>
|
|
134
|
+
</Dialog.Header>
|
|
135
|
+
<Dialog.Body px="0">
|
|
136
|
+
<Grid columns={2} gridTemplateColumns="2fr 3fr" width="full" h="xl" divideX="1px">
|
|
137
|
+
<ScrollArea size="sm" ids={{ viewport: id }}>
|
|
138
|
+
<Combobox.List gap="1" p="2">
|
|
139
|
+
<Combobox.Empty>No results found.</Combobox.Empty>
|
|
140
|
+
{collection.items.map((item) => <Combobox.Item key={item.value} item={item} persistFocus p="0">
|
|
141
|
+
<SearchResultItem item={item} filterText={debouncedValue} />
|
|
142
|
+
</Combobox.Item>)}
|
|
143
|
+
</Combobox.List>
|
|
144
|
+
</ScrollArea>
|
|
145
|
+
<ScrollArea size="sm" h="full">
|
|
146
|
+
<Box py="4" ps="4" pe="8">
|
|
147
|
+
<Show when={children !== null} fallback={<Center>Placeholder to explain how search works</Center>}>
|
|
148
|
+
{children}
|
|
149
|
+
</Show>
|
|
150
|
+
</Box>
|
|
151
|
+
</ScrollArea>
|
|
152
|
+
</Grid>
|
|
153
|
+
</Dialog.Body>
|
|
154
|
+
<Dialog.Footer py="3.5" px="4" justifyContent="start">
|
|
155
|
+
<KeyboardHints />
|
|
156
|
+
</Dialog.Footer>
|
|
157
|
+
</Dialog.Content>
|
|
158
|
+
</Combobox.Root>
|
|
159
|
+
</Dialog.Positioner>
|
|
160
|
+
</Portal>
|
|
161
|
+
</Dialog.Root>;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
//#endregion
|
|
165
|
+
export { Spotlight };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as react from "react";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
import * as _pyck_styled_system_jsx0 from "@pyck/styled-system/jsx";
|
|
4
|
+
import * as _pyck_styled_system_recipes0 from "@pyck/styled-system/recipes";
|
|
5
|
+
import * as _ark_ui_react0 from "@ark-ui/react";
|
|
6
|
+
|
|
7
|
+
//#region src/components/stat/stat.d.ts
|
|
8
|
+
declare namespace stat_d_exports {
|
|
9
|
+
export { Label, Root, RootProps, ValueText };
|
|
10
|
+
}
|
|
11
|
+
type RootProps = ComponentProps<typeof Root>;
|
|
12
|
+
declare const Root: _pyck_styled_system_jsx0.StyleContextProvider<react.ForwardRefExoticComponent<react.ClassAttributes<HTMLDivElement> & react.HTMLAttributes<HTMLDivElement> & _ark_ui_react0.PolymorphicProps>, _pyck_styled_system_recipes0.StatRecipe>;
|
|
13
|
+
declare const Label: _pyck_styled_system_jsx0.StyleContextConsumer<react.ForwardRefExoticComponent<react.ClassAttributes<HTMLDivElement> & react.HTMLAttributes<HTMLDivElement> & _ark_ui_react0.PolymorphicProps>>;
|
|
14
|
+
declare const ValueText: _pyck_styled_system_jsx0.StyleContextConsumer<react.ForwardRefExoticComponent<react.ClassAttributes<HTMLDivElement> & react.HTMLAttributes<HTMLDivElement> & _ark_ui_react0.PolymorphicProps>>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { stat_d_exports as Stat };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { t as __exportAll } from "../../chunk-BYypO7fO.js";
|
|
2
|
+
import { ark } from "@ark-ui/react/factory";
|
|
3
|
+
import { createStyleContext } from "@pyck/styled-system/jsx";
|
|
4
|
+
import { stat } from "@pyck/styled-system/recipes";
|
|
5
|
+
|
|
6
|
+
//#region src/components/stat/stat.tsx
|
|
7
|
+
var stat_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
+
Label: () => Label,
|
|
9
|
+
Root: () => Root,
|
|
10
|
+
ValueText: () => ValueText
|
|
11
|
+
});
|
|
12
|
+
const { withProvider, withContext } = createStyleContext(stat);
|
|
13
|
+
const Root = withProvider(ark.div, "root");
|
|
14
|
+
const Label = withContext(ark.div, "label");
|
|
15
|
+
const ValueText = withContext(ark.div, "valueText");
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { stat_exports as Stat };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as react from "react";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
import * as _pyck_styled_system_jsx0 from "@pyck/styled-system/jsx";
|
|
4
|
+
import * as _pyck_styled_system_recipes0 from "@pyck/styled-system/recipes";
|
|
5
|
+
import * as _ark_ui_react0 from "@ark-ui/react";
|
|
6
|
+
import { StepChangeDetails, Steps } from "@ark-ui/react/steps";
|
|
7
|
+
|
|
8
|
+
//#region src/components/steps/steps.d.ts
|
|
9
|
+
declare namespace steps_d_exports {
|
|
10
|
+
export { CompletedContent, Content, Context, Description, Indicator, Item, ItemContext, List, NextTrigger, PrevTrigger, Progress, Root, RootProps, RootProvider, Separator, StepChangeDetails, Title, Trigger };
|
|
11
|
+
}
|
|
12
|
+
type RootProps = ComponentProps<typeof Root>;
|
|
13
|
+
declare const Root: _pyck_styled_system_jsx0.StyleContextProvider<react.ForwardRefExoticComponent<Steps.RootProps & react.RefAttributes<HTMLDivElement>>, _pyck_styled_system_recipes0.StepsRecipe>;
|
|
14
|
+
declare const RootProvider: _pyck_styled_system_jsx0.StyleContextProvider<react.ForwardRefExoticComponent<Steps.RootProviderProps & react.RefAttributes<HTMLDivElement>>, _pyck_styled_system_recipes0.StepsRecipe>;
|
|
15
|
+
declare const CompletedContent: _pyck_styled_system_jsx0.StyleContextConsumer<react.ForwardRefExoticComponent<Steps.CompletedContentProps & react.RefAttributes<HTMLDivElement>>>;
|
|
16
|
+
declare const Content: _pyck_styled_system_jsx0.StyleContextConsumer<react.ForwardRefExoticComponent<Steps.ContentProps & react.RefAttributes<HTMLDivElement>>>;
|
|
17
|
+
declare const Item: _pyck_styled_system_jsx0.StyleContextConsumer<react.ForwardRefExoticComponent<Steps.ItemProps & react.RefAttributes<HTMLDivElement>>>;
|
|
18
|
+
declare const List: _pyck_styled_system_jsx0.StyleContextConsumer<react.ForwardRefExoticComponent<Steps.ListProps & react.RefAttributes<HTMLDivElement>>>;
|
|
19
|
+
declare const NextTrigger: _pyck_styled_system_jsx0.StyleContextConsumer<react.ForwardRefExoticComponent<Steps.NextTriggerProps & react.RefAttributes<HTMLButtonElement>>>;
|
|
20
|
+
declare const PrevTrigger: _pyck_styled_system_jsx0.StyleContextConsumer<react.ForwardRefExoticComponent<Steps.PrevTriggerProps & react.RefAttributes<HTMLButtonElement>>>;
|
|
21
|
+
declare const Progress: _pyck_styled_system_jsx0.StyleContextConsumer<react.ForwardRefExoticComponent<Steps.ProgressProps & react.RefAttributes<HTMLDivElement>>>;
|
|
22
|
+
declare const Separator: _pyck_styled_system_jsx0.StyleContextConsumer<react.ForwardRefExoticComponent<Steps.SeparatorProps & react.RefAttributes<HTMLDivElement>>>;
|
|
23
|
+
declare const Trigger: _pyck_styled_system_jsx0.StyleContextConsumer<react.ForwardRefExoticComponent<Steps.TriggerProps & react.RefAttributes<HTMLButtonElement>>>;
|
|
24
|
+
declare const Title: _pyck_styled_system_jsx0.StyleContextConsumer<react.ForwardRefExoticComponent<react.ClassAttributes<HTMLDivElement> & react.HTMLAttributes<HTMLDivElement> & _ark_ui_react0.PolymorphicProps>>;
|
|
25
|
+
declare const Description: _pyck_styled_system_jsx0.StyleContextConsumer<react.ForwardRefExoticComponent<react.ClassAttributes<HTMLDivElement> & react.HTMLAttributes<HTMLDivElement> & _ark_ui_react0.PolymorphicProps>>;
|
|
26
|
+
declare const Indicator: _pyck_styled_system_jsx0.StyleContextConsumer<react.ForwardRefExoticComponent<Steps.IndicatorProps & react.RefAttributes<HTMLDivElement>>>;
|
|
27
|
+
declare const Context: {
|
|
28
|
+
(props: Steps.ContextProps): ReactNode;
|
|
29
|
+
displayName: string;
|
|
30
|
+
};
|
|
31
|
+
declare const ItemContext: {
|
|
32
|
+
(props: Steps.ItemContextProps): ReactNode;
|
|
33
|
+
displayName: string;
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
export { steps_d_exports as Steps };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { t as __exportAll } from "../../chunk-BYypO7fO.js";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { ark } from "@ark-ui/react/factory";
|
|
4
|
+
import { Box, createStyleContext } from "@pyck/styled-system/jsx";
|
|
5
|
+
import { steps } from "@pyck/styled-system/recipes";
|
|
6
|
+
import { CheckIcon } from "lucide-react";
|
|
7
|
+
import { Steps } from "@ark-ui/react/steps";
|
|
8
|
+
|
|
9
|
+
//#region src/components/steps/steps.tsx
|
|
10
|
+
var steps_exports = /* @__PURE__ */ __exportAll({
|
|
11
|
+
CompletedContent: () => CompletedContent,
|
|
12
|
+
Content: () => Content,
|
|
13
|
+
Context: () => Context,
|
|
14
|
+
Description: () => Description,
|
|
15
|
+
Indicator: () => Indicator,
|
|
16
|
+
Item: () => Item,
|
|
17
|
+
ItemContext: () => ItemContext,
|
|
18
|
+
List: () => List,
|
|
19
|
+
NextTrigger: () => NextTrigger,
|
|
20
|
+
PrevTrigger: () => PrevTrigger,
|
|
21
|
+
Progress: () => Progress,
|
|
22
|
+
Root: () => Root,
|
|
23
|
+
RootProvider: () => RootProvider,
|
|
24
|
+
Separator: () => Separator,
|
|
25
|
+
Title: () => Title,
|
|
26
|
+
Trigger: () => Trigger
|
|
27
|
+
});
|
|
28
|
+
const { withProvider, withContext } = createStyleContext(steps);
|
|
29
|
+
const Root = withProvider(Steps.Root, "root", { forwardProps: ["orientation"] });
|
|
30
|
+
const RootProvider = withProvider(Steps.RootProvider, "root");
|
|
31
|
+
const CompletedContent = withContext(Steps.CompletedContent, "content");
|
|
32
|
+
const Content = withContext(Steps.Content, "content");
|
|
33
|
+
const Item = withContext(Steps.Item, "item", { defaultProps: { role: "tab" } });
|
|
34
|
+
const List = withContext(Steps.List, "list");
|
|
35
|
+
const NextTrigger = withContext(Steps.NextTrigger, "trigger");
|
|
36
|
+
const PrevTrigger = withContext(Steps.PrevTrigger, "trigger");
|
|
37
|
+
const Progress = withContext(Steps.Progress, "progress");
|
|
38
|
+
const Separator = withContext(Steps.Separator, "separator");
|
|
39
|
+
const Trigger = withContext(Steps.Trigger, "trigger");
|
|
40
|
+
const Title = withContext(ark.div, "title");
|
|
41
|
+
const Description = withContext(ark.div, "description");
|
|
42
|
+
const Status = (props) => <Steps.ItemContext>
|
|
43
|
+
{(api) => {
|
|
44
|
+
if (api.current) return <>{props.current ?? props.incomplete}</>;
|
|
45
|
+
if (api.completed) return <>{props.complete}</>;
|
|
46
|
+
return <>{props.incomplete ?? props.current}</>;
|
|
47
|
+
}}
|
|
48
|
+
</Steps.ItemContext>;
|
|
49
|
+
const StepNumber = forwardRef(function StepNumber(props, ref) {
|
|
50
|
+
return <Steps.ItemContext>
|
|
51
|
+
{(api) => <Box ref={ref} {...props}>
|
|
52
|
+
{api.index + 1}
|
|
53
|
+
</Box>}
|
|
54
|
+
</Steps.ItemContext>;
|
|
55
|
+
});
|
|
56
|
+
const Indicator = withContext(Steps.Indicator, "indicator", { defaultProps: { children: <Status complete={<CheckIcon />} incomplete={<StepNumber />} /> } });
|
|
57
|
+
const Context = Steps.Context;
|
|
58
|
+
const ItemContext = Steps.ItemContext;
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
export { steps_exports as Steps };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as react from "react";
|
|
2
|
+
import { ComponentProps, ReactNode, RefObject } from "react";
|
|
3
|
+
import * as _pyck_styled_system_jsx0 from "@pyck/styled-system/jsx";
|
|
4
|
+
import * as _pyck_styled_system_recipes0 from "@pyck/styled-system/recipes";
|
|
5
|
+
import { FieldProps } from "@pyck/react/field";
|
|
6
|
+
import { FieldPath, FieldValues } from "react-hook-form";
|
|
7
|
+
import "@ark-ui/react";
|
|
8
|
+
import { Switch as Switch$1 } from "@ark-ui/react/switch";
|
|
9
|
+
import "@pyck/styled-system/types";
|
|
10
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
11
|
+
|
|
12
|
+
//#region src/components/switch/switch.d.ts
|
|
13
|
+
type RootProps = ComponentProps<typeof Root>;
|
|
14
|
+
type HiddenInputProps = ComponentProps<typeof HiddenInput>;
|
|
15
|
+
declare const Root: _pyck_styled_system_jsx0.StyleContextProvider<react.ForwardRefExoticComponent<Switch$1.RootProps & react.RefAttributes<HTMLLabelElement>>, _pyck_styled_system_recipes0.SwitchRecipeRecipe>;
|
|
16
|
+
declare const HiddenInput: react.ForwardRefExoticComponent<Switch$1.HiddenInputProps & react.RefAttributes<HTMLInputElement>>;
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/components/switch/switch.closed.d.ts
|
|
19
|
+
interface SwitchProps extends RootProps {
|
|
20
|
+
inputProps?: HiddenInputProps;
|
|
21
|
+
rootRef?: RefObject<HTMLLabelElement | null>;
|
|
22
|
+
trackLabel?: {
|
|
23
|
+
on: ReactNode;
|
|
24
|
+
off: ReactNode;
|
|
25
|
+
};
|
|
26
|
+
thumbLabel?: {
|
|
27
|
+
on: ReactNode;
|
|
28
|
+
off: ReactNode;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
declare const Switch: react.ForwardRefExoticComponent<Omit<SwitchProps, "ref"> & react.RefAttributes<HTMLInputElement>>;
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/components/switch/switch.field.d.ts
|
|
34
|
+
interface SwitchFieldProps<T extends FieldValues = FieldValues> extends Omit<SwitchProps, 'label'> {
|
|
35
|
+
name: FieldPath<T>;
|
|
36
|
+
label: FieldProps['label'] | undefined;
|
|
37
|
+
helperText?: FieldProps['helperText'];
|
|
38
|
+
}
|
|
39
|
+
declare const SwitchField: <T extends FieldValues>(props: SwitchFieldProps<T>) => react_jsx_runtime0.JSX.Element;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { Switch, SwitchField, type SwitchFieldProps, type SwitchProps };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { t as __exportAll } from "../../chunk-BYypO7fO.js";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { VisuallyHidden, createStyleContext, styled } from "@pyck/styled-system/jsx";
|
|
4
|
+
import { switchRecipe } from "@pyck/styled-system/recipes";
|
|
5
|
+
import { Field } from "@pyck/react/field";
|
|
6
|
+
import { Controller, useFormContext } from "react-hook-form";
|
|
7
|
+
import { ark } from "@ark-ui/react";
|
|
8
|
+
import { Switch as Switch$1, SwitchContext as Context, useSwitchContext } from "@ark-ui/react/switch";
|
|
9
|
+
|
|
10
|
+
//#region src/components/switch/switch.tsx
|
|
11
|
+
var switch_exports = /* @__PURE__ */ __exportAll({
|
|
12
|
+
Context: () => Context,
|
|
13
|
+
Control: () => Control,
|
|
14
|
+
HiddenInput: () => HiddenInput,
|
|
15
|
+
Indicator: () => Indicator,
|
|
16
|
+
Label: () => Label,
|
|
17
|
+
Root: () => Root,
|
|
18
|
+
RootProvider: () => RootProvider,
|
|
19
|
+
Thumb: () => Thumb,
|
|
20
|
+
ThumbIndicator: () => ThumbIndicator
|
|
21
|
+
});
|
|
22
|
+
const { withProvider, withContext } = createStyleContext(switchRecipe);
|
|
23
|
+
const Root = withProvider(Switch$1.Root, "root");
|
|
24
|
+
const RootProvider = withProvider(Switch$1.RootProvider, "root");
|
|
25
|
+
const Label = withContext(Switch$1.Label, "label");
|
|
26
|
+
const Thumb = withContext(Switch$1.Thumb, "thumb");
|
|
27
|
+
const HiddenInput = Switch$1.HiddenInput;
|
|
28
|
+
const Control = withContext(Switch$1.Control, "control", { defaultProps: { children: <Thumb /> } });
|
|
29
|
+
const StyledIndicator = withContext(ark.span, "indicator");
|
|
30
|
+
const Indicator = forwardRef(function Indicator(props, ref) {
|
|
31
|
+
const { fallback, children, ...rest } = props;
|
|
32
|
+
const api = useSwitchContext();
|
|
33
|
+
return <StyledIndicator ref={ref} data-checked={api.checked ? "" : void 0} {...rest}>
|
|
34
|
+
{api.checked ? children : fallback}
|
|
35
|
+
</StyledIndicator>;
|
|
36
|
+
});
|
|
37
|
+
const StyledThumbIndicator = styled(ark.span);
|
|
38
|
+
const ThumbIndicator = forwardRef(function SwitchThumbIndicator(props, ref) {
|
|
39
|
+
const { fallback, children, ...rest } = props;
|
|
40
|
+
const api = useSwitchContext();
|
|
41
|
+
return <StyledThumbIndicator ref={ref} data-checked={api.checked ? "" : void 0} {...rest}>
|
|
42
|
+
{api.checked ? children : fallback}
|
|
43
|
+
</StyledThumbIndicator>;
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/components/switch/switch.closed.tsx
|
|
48
|
+
const Switch = forwardRef(function Switch(props, ref) {
|
|
49
|
+
const { inputProps, children, rootRef = null, trackLabel, thumbLabel, ...rest } = props;
|
|
50
|
+
return <switch_exports.Root ref={rootRef} {...rest}>
|
|
51
|
+
<switch_exports.HiddenInput ref={ref} {...inputProps} />
|
|
52
|
+
<switch_exports.Control>
|
|
53
|
+
<switch_exports.Thumb>
|
|
54
|
+
{thumbLabel && <switch_exports.ThumbIndicator fallback={thumbLabel?.off}>
|
|
55
|
+
{thumbLabel?.on}
|
|
56
|
+
</switch_exports.ThumbIndicator>}
|
|
57
|
+
</switch_exports.Thumb>
|
|
58
|
+
{trackLabel && <switch_exports.Indicator fallback={trackLabel.off}>{trackLabel.on}</switch_exports.Indicator>}
|
|
59
|
+
</switch_exports.Control>
|
|
60
|
+
{children && <switch_exports.Label>{children}</switch_exports.Label>}
|
|
61
|
+
{props["aria-label"] && <switch_exports.Label asChild>
|
|
62
|
+
<VisuallyHidden>{props["aria-label"]}</VisuallyHidden>
|
|
63
|
+
</switch_exports.Label>}
|
|
64
|
+
</switch_exports.Root>;
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/components/switch/switch.field.tsx
|
|
69
|
+
const SwitchField = (props) => {
|
|
70
|
+
const { name, label, helperText, disabled } = props;
|
|
71
|
+
const { control } = useFormContext();
|
|
72
|
+
return <Controller name={name} control={control} render={({ field, fieldState }) => <Field helperText={helperText} disabled={field.disabled || disabled} invalid={!!fieldState.error} errorText={fieldState.error?.message}>
|
|
73
|
+
<Switch name={field.name} checked={field.value} onCheckedChange={({ checked }) => field.onChange(checked)} inputProps={{ onBlur: field.onBlur }}>
|
|
74
|
+
{label}
|
|
75
|
+
</Switch>
|
|
76
|
+
</Field>} />;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
export { Switch, SwitchField };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import * as react from "react";
|
|
2
|
+
import { ComponentProps, ComponentType, ReactNode } from "react";
|
|
3
|
+
import * as _pyck_styled_system_jsx0 from "@pyck/styled-system/jsx";
|
|
4
|
+
import * as _pyck_styled_system_recipes0 from "@pyck/styled-system/recipes";
|
|
5
|
+
import { DateInput, Locale } from "@pyck/react/utils";
|
|
6
|
+
import * as _ark_ui_react0 from "@ark-ui/react";
|
|
7
|
+
import { DisplayValueProps } from "@pyck/react/display-value";
|
|
8
|
+
import { DateFormatType } from "@pyck/react/display-date-value";
|
|
9
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
10
|
+
|
|
11
|
+
//#region src/components/table/cells/table-cell-content.d.ts
|
|
12
|
+
interface TableCellContentProps<IconProps extends object = object> {
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
icon?: ReactNode | ComponentType<IconProps>;
|
|
15
|
+
iconProps?: IconProps;
|
|
16
|
+
tooltip?: ReactNode;
|
|
17
|
+
justifyContent?: 'flex-start' | 'flex-end' | 'space-between';
|
|
18
|
+
}
|
|
19
|
+
type TableCellContentShellProps = Pick<TableCellContentProps, 'icon' | 'tooltip' | 'justifyContent'>;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/components/table/cells/boolean-cell.d.ts
|
|
22
|
+
interface BooleanCellProps extends TableCellContentShellProps {
|
|
23
|
+
value?: boolean | null | undefined;
|
|
24
|
+
trueLabel?: string;
|
|
25
|
+
falseLabel?: string;
|
|
26
|
+
copyable?: DisplayValueProps<boolean>['copyable'];
|
|
27
|
+
}
|
|
28
|
+
declare const BooleanCell: (props: BooleanCellProps) => react_jsx_runtime0.JSX.Element;
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/components/table/cells/date-cell.d.ts
|
|
31
|
+
interface DateCellProps extends TableCellContentShellProps {
|
|
32
|
+
value?: DateInput | null | undefined;
|
|
33
|
+
type?: 'date' | 'datetime' | 'relative';
|
|
34
|
+
format?: DateFormatType;
|
|
35
|
+
locale?: Locale;
|
|
36
|
+
copyable?: boolean;
|
|
37
|
+
}
|
|
38
|
+
declare const DateCell: (props: DateCellProps) => react_jsx_runtime0.JSX.Element;
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/components/table/cells/number-cell.d.ts
|
|
41
|
+
interface NumberCellProps extends TableCellContentShellProps {
|
|
42
|
+
value?: number | null | undefined;
|
|
43
|
+
locale?: Locale;
|
|
44
|
+
minimumFractionDigits?: number;
|
|
45
|
+
maximumFractionDigits?: number;
|
|
46
|
+
useGrouping?: boolean;
|
|
47
|
+
copyable?: DisplayValueProps<number>['copyable'];
|
|
48
|
+
}
|
|
49
|
+
declare const NumberCell: (props: NumberCellProps) => react_jsx_runtime0.JSX.Element;
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/components/table/cells/text-cell.d.ts
|
|
52
|
+
interface TextCellProps<T> extends TableCellContentShellProps {
|
|
53
|
+
value?: T | null | undefined;
|
|
54
|
+
formatValue?: DisplayValueProps<T>['formatValue'];
|
|
55
|
+
copyable?: DisplayValueProps<T>['copyable'];
|
|
56
|
+
}
|
|
57
|
+
declare const TextCell: <T>(props: TextCellProps<T>) => react_jsx_runtime0.JSX.Element;
|
|
58
|
+
declare namespace table_d_exports {
|
|
59
|
+
export { Body, Caption, Cell, Foot, Head, Header, Root, RootProps, Row };
|
|
60
|
+
}
|
|
61
|
+
type RootProps = ComponentProps<typeof Root>;
|
|
62
|
+
declare const Root: _pyck_styled_system_jsx0.StyleContextProvider<react.ForwardRefExoticComponent<react.ClassAttributes<HTMLTableElement> & react.TableHTMLAttributes<HTMLTableElement> & _ark_ui_react0.PolymorphicProps>, _pyck_styled_system_recipes0.TableRecipe>;
|
|
63
|
+
declare const Body: _pyck_styled_system_jsx0.StyleContextConsumer<react.ForwardRefExoticComponent<react.ClassAttributes<HTMLTableSectionElement> & react.HTMLAttributes<HTMLTableSectionElement> & _ark_ui_react0.PolymorphicProps>>;
|
|
64
|
+
declare const Cell: _pyck_styled_system_jsx0.StyleContextConsumer<react.ForwardRefExoticComponent<react.ClassAttributes<HTMLTableDataCellElement> & react.TdHTMLAttributes<HTMLTableDataCellElement> & _ark_ui_react0.PolymorphicProps>>;
|
|
65
|
+
declare const Caption: _pyck_styled_system_jsx0.StyleContextConsumer<react.ForwardRefExoticComponent<react.ClassAttributes<HTMLElement> & react.HTMLAttributes<HTMLElement> & _ark_ui_react0.PolymorphicProps>>;
|
|
66
|
+
declare const Foot: _pyck_styled_system_jsx0.StyleContextConsumer<react.ForwardRefExoticComponent<react.ClassAttributes<HTMLTableSectionElement> & react.HTMLAttributes<HTMLTableSectionElement> & _ark_ui_react0.PolymorphicProps>>;
|
|
67
|
+
declare const Head: _pyck_styled_system_jsx0.StyleContextConsumer<react.ForwardRefExoticComponent<react.ClassAttributes<HTMLTableSectionElement> & react.HTMLAttributes<HTMLTableSectionElement> & _ark_ui_react0.PolymorphicProps>>;
|
|
68
|
+
declare const Header: _pyck_styled_system_jsx0.StyleContextConsumer<react.ForwardRefExoticComponent<react.ClassAttributes<HTMLTableHeaderCellElement> & react.ThHTMLAttributes<HTMLTableHeaderCellElement> & _ark_ui_react0.PolymorphicProps>>;
|
|
69
|
+
declare const Row: _pyck_styled_system_jsx0.StyleContextConsumer<react.ForwardRefExoticComponent<react.ClassAttributes<HTMLTableRowElement> & react.HTMLAttributes<HTMLTableRowElement> & _ark_ui_react0.PolymorphicProps>>;
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/components/table/use-virtualized-table-height.d.ts
|
|
72
|
+
interface UseVirtualizedTableHeightOptions {
|
|
73
|
+
virtualSize: number;
|
|
74
|
+
tableRef: React.RefObject<HTMLTableElement | null>;
|
|
75
|
+
scrollRef: React.RefObject<HTMLDivElement | null>;
|
|
76
|
+
}
|
|
77
|
+
declare const useVirtualizedTableHeight: ({
|
|
78
|
+
virtualSize,
|
|
79
|
+
tableRef,
|
|
80
|
+
scrollRef
|
|
81
|
+
}: UseVirtualizedTableHeightOptions) => {
|
|
82
|
+
isScrollNearBottom: boolean;
|
|
83
|
+
};
|
|
84
|
+
//#endregion
|
|
85
|
+
export { BooleanCell, type BooleanCellProps, DateCell, type DateCellProps, NumberCell, type NumberCellProps, table_d_exports as Table, type TableCellContentShellProps, TextCell, type TextCellProps, type UseVirtualizedTableHeightOptions, useVirtualizedTableHeight };
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { t as __exportAll } from "../../chunk-BYypO7fO.js";
|
|
2
|
+
import { match } from "ts-pattern";
|
|
3
|
+
import { useCallback, useEffect, useState } from "react";
|
|
4
|
+
import { ark } from "@ark-ui/react/factory";
|
|
5
|
+
import { Box, HStack, createStyleContext } from "@pyck/styled-system/jsx";
|
|
6
|
+
import { table } from "@pyck/styled-system/recipes";
|
|
7
|
+
import { Show } from "@pyck/react/show";
|
|
8
|
+
import { Wrap } from "@pyck/react/wrap";
|
|
9
|
+
import { Icon } from "@pyck/react/icon";
|
|
10
|
+
import { DisplayValue } from "@pyck/react/display-value";
|
|
11
|
+
import { Tooltip } from "@pyck/react/tooltip";
|
|
12
|
+
import { DisplayDateValue } from "@pyck/react/display-date-value";
|
|
13
|
+
|
|
14
|
+
//#region src/components/table/cells/table-cell-content.tsx
|
|
15
|
+
const renderIcon = (icon, iconProps) => match(icon).when((x) => typeof x === "function", (Icon) => <Icon {...iconProps} />).otherwise((node) => node ?? null);
|
|
16
|
+
const TableCellContent = (props) => {
|
|
17
|
+
const { children, icon, iconProps, tooltip, justifyContent = "flex-start", ...rest } = props;
|
|
18
|
+
const content = <HStack justifyContent={justifyContent} {...rest}>
|
|
19
|
+
<Wrap when={!!icon} with={(children) => <Icon boxSize="4">{children}</Icon>}>
|
|
20
|
+
{renderIcon(icon, iconProps)}
|
|
21
|
+
</Wrap>
|
|
22
|
+
|
|
23
|
+
<Box overflow="hidden" textOverflow="ellipsis">
|
|
24
|
+
{children}
|
|
25
|
+
</Box>
|
|
26
|
+
</HStack>;
|
|
27
|
+
return <Show when={!!tooltip} fallback={content}>
|
|
28
|
+
<Tooltip content={tooltip} openDelay={100}>
|
|
29
|
+
{content}
|
|
30
|
+
</Tooltip>
|
|
31
|
+
</Show>;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/components/table/cells/boolean-cell.tsx
|
|
36
|
+
const BooleanCell = (props) => {
|
|
37
|
+
const { value: booleanValue, trueLabel = "Yes", falseLabel = "No", copyable, icon, tooltip, ...rest } = props;
|
|
38
|
+
const value = booleanValue ? trueLabel : falseLabel;
|
|
39
|
+
return <TableCellContent tooltip={tooltip} icon={icon} {...rest}>
|
|
40
|
+
<DisplayValue value={value} copyable={copyable} />
|
|
41
|
+
</TableCellContent>;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/components/table/cells/date-cell.tsx
|
|
46
|
+
const DateCell = (props) => {
|
|
47
|
+
const { value, type = "date", format, locale, copyable, icon, tooltip, justifyContent, ...rest } = props;
|
|
48
|
+
return <TableCellContent icon={icon} tooltip={tooltip} justifyContent={justifyContent} {...rest}>
|
|
49
|
+
<DisplayDateValue value={value} type={type} format={format} locale={locale} copyable={copyable} />
|
|
50
|
+
</TableCellContent>;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/components/table/cells/number-cell.tsx
|
|
55
|
+
const NumberCell = (props) => {
|
|
56
|
+
const { value, minimumFractionDigits, maximumFractionDigits, locale: localeProp, useGrouping, copyable, tooltip, icon, ...rest } = props;
|
|
57
|
+
const locale = localeProp ?? "en";
|
|
58
|
+
const formatValue = (n) => {
|
|
59
|
+
if (!Number.isFinite(n)) return null;
|
|
60
|
+
return new Intl.NumberFormat(locale, {
|
|
61
|
+
useGrouping,
|
|
62
|
+
minimumFractionDigits,
|
|
63
|
+
maximumFractionDigits
|
|
64
|
+
}).format(n);
|
|
65
|
+
};
|
|
66
|
+
return <TableCellContent icon={icon} tooltip={tooltip} justifyContent="flex-end" {...rest}>
|
|
67
|
+
<DisplayValue value={value} formatValue={formatValue} copyable={copyable} />
|
|
68
|
+
</TableCellContent>;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/components/table/cells/text-cell.tsx
|
|
73
|
+
const TextCell = (props) => {
|
|
74
|
+
const { value, formatValue, copyable, icon, tooltip, justifyContent = "flex-start", ...rest } = props;
|
|
75
|
+
return <TableCellContent icon={icon} tooltip={tooltip} justifyContent={justifyContent} {...rest}>
|
|
76
|
+
<DisplayValue value={value} formatValue={formatValue} copyable={copyable} />
|
|
77
|
+
</TableCellContent>;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/components/table/table.tsx
|
|
82
|
+
var table_exports = /* @__PURE__ */ __exportAll({
|
|
83
|
+
Body: () => Body,
|
|
84
|
+
Caption: () => Caption,
|
|
85
|
+
Cell: () => Cell,
|
|
86
|
+
Foot: () => Foot,
|
|
87
|
+
Head: () => Head,
|
|
88
|
+
Header: () => Header,
|
|
89
|
+
Root: () => Root,
|
|
90
|
+
Row: () => Row
|
|
91
|
+
});
|
|
92
|
+
const { withProvider, withContext } = createStyleContext(table);
|
|
93
|
+
const Root = withProvider(ark.table, "root");
|
|
94
|
+
const Body = withContext(ark.tbody, "body");
|
|
95
|
+
const Cell = withContext(ark.td, "cell");
|
|
96
|
+
const Caption = withContext(ark.caption, "caption");
|
|
97
|
+
const Foot = withContext(ark.tfoot, "foot");
|
|
98
|
+
const Head = withContext(ark.thead, "head");
|
|
99
|
+
const Header = withContext(ark.th, "header");
|
|
100
|
+
const Row = withContext(ark.tr, "row");
|
|
101
|
+
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/components/table/use-virtualized-table-height.ts
|
|
104
|
+
const SCROLL_THRESHOLD = .95;
|
|
105
|
+
const useVirtualizedTableHeight = ({ virtualSize, tableRef, scrollRef }) => {
|
|
106
|
+
const [isScrollNearBottom, setIsScrollNearBottom] = useState(false);
|
|
107
|
+
const handlePseudoResize = useCallback(() => {
|
|
108
|
+
return adjustTableHeight(tableRef, virtualSize);
|
|
109
|
+
}, [tableRef, virtualSize]);
|
|
110
|
+
const handleScroll = useCallback(() => {
|
|
111
|
+
if (scrollRef.current) {
|
|
112
|
+
const scrollPosition = scrollRef.current.scrollTop;
|
|
113
|
+
const visibleHeight = scrollRef.current.clientHeight;
|
|
114
|
+
setIsScrollNearBottom(scrollPosition > virtualSize * SCROLL_THRESHOLD - visibleHeight);
|
|
115
|
+
}
|
|
116
|
+
}, [scrollRef, virtualSize]);
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
const scrollable = scrollRef.current;
|
|
119
|
+
if (scrollable) scrollable.addEventListener("scroll", handleScroll);
|
|
120
|
+
handlePseudoResize();
|
|
121
|
+
return () => {
|
|
122
|
+
if (scrollable) scrollable.removeEventListener("scroll", handleScroll);
|
|
123
|
+
};
|
|
124
|
+
}, [
|
|
125
|
+
scrollRef,
|
|
126
|
+
handleScroll,
|
|
127
|
+
handlePseudoResize
|
|
128
|
+
]);
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
if (isScrollNearBottom) handlePseudoResize();
|
|
131
|
+
}, [isScrollNearBottom, handlePseudoResize]);
|
|
132
|
+
return { isScrollNearBottom };
|
|
133
|
+
};
|
|
134
|
+
const adjustTableHeight = (tableRef, virtualHeight) => {
|
|
135
|
+
if (!tableRef.current) return;
|
|
136
|
+
const existingPseudoElement = window.getComputedStyle(tableRef.current, "::after");
|
|
137
|
+
const existingPseudoHeight = parseFloat(existingPseudoElement.height) || 0;
|
|
138
|
+
const tableHeight = tableRef.current.clientHeight - existingPseudoHeight;
|
|
139
|
+
const pseudoHeight = Math.max(virtualHeight - tableHeight, 0);
|
|
140
|
+
tableRef.current.style.setProperty("--pseudo-height", `${pseudoHeight}px`);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
//#endregion
|
|
144
|
+
export { BooleanCell, DateCell, NumberCell, table_exports as Table, TextCell, useVirtualizedTableHeight };
|