@techsio/ui-kit 0.45.0 → 0.47.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/atoms/hotkeys.js +52 -0
- package/dist/hotkeys.js +108 -0
- package/dist/internal/molecules/command.context.js +14 -0
- package/dist/molecules/command.js +177 -0
- package/dist/organisms/data-table.js +51 -46
- package/dist/src/atoms/hotkeys.d.ts +29 -0
- package/dist/src/atoms/hotkeys.d.ts.map +1 -0
- package/dist/src/hotkeys.d.ts +19 -0
- package/dist/src/hotkeys.d.ts.map +1 -0
- package/dist/src/internal/molecules/command.context.d.ts +6 -0
- package/dist/src/internal/molecules/command.context.d.ts.map +1 -0
- package/dist/src/molecules/command.d.ts +51 -0
- package/dist/src/molecules/command.d.ts.map +1 -0
- package/dist/src/molecules/toast.d.ts +9 -9
- package/dist/src/organisms/data-table.d.ts.map +1 -1
- package/dist/src/types/zag.d.ts +1 -0
- package/dist/src/types/zag.d.ts.map +1 -1
- package/dist/stories/atoms/hotkeys-hydration.fixture.d.ts +6 -0
- package/dist/stories/atoms/hotkeys-hydration.fixture.d.ts.map +1 -0
- package/dist/stories/atoms/hotkeys.stories.d.ts +336 -0
- package/dist/stories/atoms/hotkeys.stories.d.ts.map +1 -0
- package/dist/stories/changelog/changelog.stories.d.ts.map +1 -1
- package/dist/stories/molecules/command-hotkeys.stories.d.ts +38 -0
- package/dist/stories/molecules/command-hotkeys.stories.d.ts.map +1 -0
- package/dist/stories/molecules/command.stories.d.ts +74 -0
- package/dist/stories/molecules/command.stories.d.ts.map +1 -0
- package/dist/test/command-hotkeys.spec.d.ts +2 -0
- package/dist/test/command-hotkeys.spec.d.ts.map +1 -0
- package/dist/test/command.spec.d.ts +2 -0
- package/dist/test/command.spec.d.ts.map +1 -0
- package/dist/test/hotkeys.spec.d.ts +2 -0
- package/dist/test/hotkeys.spec.d.ts.map +1 -0
- package/package.json +6 -1
- package/src/tokens/components/atoms/_hotkeys.css +36 -0
- package/src/tokens/components/components.css +2 -0
- package/src/tokens/components/molecules/_command.css +43 -0
- package/src/tokens/components/organisms/_data-table.css +30 -7
- package/src/tokens/components/organisms/_table.css +0 -17
- package/src/tokens/figma/akros/variables.css +438 -0
- package/src/tokens/figma/brand-overrides.css +1 -1
- package/src/tokens/figma/business/variables.css +2 -2
- package/src/tokens/figma/dark/variables.css +39 -1
- package/src/tokens/figma/light/variables.css +431 -6
- package/src/tokens/figma/neo/variables.css +2 -2
- package/src/tokens/figma/neo-dark/variables.css +1 -1
- package/src/tokens/figma/variables.css +430 -5
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useFormatHotkey } from "../hotkeys.js";
|
|
3
|
+
import { tv } from "../utils.js";
|
|
4
|
+
const hotkeysStyles = tv({
|
|
5
|
+
slots: {
|
|
6
|
+
root: "inline-flex items-center gap-hotkeys whitespace-nowrap font-hotkeys text-hotkeys-sm",
|
|
7
|
+
key: "hotkeys-key-border-width inline-flex items-center justify-center rounded-hotkeys-key border-hotkeys-key-border bg-hotkeys-key-bg px-hotkeys-key-x py-hotkeys-key-y text-hotkeys-key-fg",
|
|
8
|
+
separator: "text-hotkeys-separator-fg"
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
function Hotkeys({ hotkey, formatOptions, children, className, ref, ...props }) {
|
|
12
|
+
const format = useFormatHotkey();
|
|
13
|
+
return /*#__PURE__*/ jsx("span", {
|
|
14
|
+
...props,
|
|
15
|
+
className: hotkeysStyles().root({
|
|
16
|
+
className
|
|
17
|
+
}),
|
|
18
|
+
"data-part": "root",
|
|
19
|
+
"data-scope": "hotkeys",
|
|
20
|
+
ref: ref,
|
|
21
|
+
children: children ?? (void 0 !== hotkey ? /*#__PURE__*/ jsx(Hotkeys.Key, {
|
|
22
|
+
children: format(hotkey, formatOptions)
|
|
23
|
+
}) : null)
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
Hotkeys.Key = function({ className, ref, ...props }) {
|
|
27
|
+
return /*#__PURE__*/ jsx("kbd", {
|
|
28
|
+
...props,
|
|
29
|
+
className: hotkeysStyles().key({
|
|
30
|
+
className
|
|
31
|
+
}),
|
|
32
|
+
"data-part": "key",
|
|
33
|
+
"data-scope": "hotkeys",
|
|
34
|
+
ref: ref
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
Hotkeys.Separator = function({ children = "+", className, ref, ...props }) {
|
|
38
|
+
return /*#__PURE__*/ jsx("span", {
|
|
39
|
+
...props,
|
|
40
|
+
"aria-hidden": "true",
|
|
41
|
+
className: hotkeysStyles().separator({
|
|
42
|
+
className
|
|
43
|
+
}),
|
|
44
|
+
"data-part": "separator",
|
|
45
|
+
"data-scope": "hotkeys",
|
|
46
|
+
ref: ref,
|
|
47
|
+
children: children
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
Hotkeys.Root = Hotkeys;
|
|
51
|
+
Hotkeys.displayName = "Hotkeys";
|
|
52
|
+
export { Hotkeys };
|
package/dist/hotkeys.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { createHotkeyStore, formatHotkey } from "@zag-js/hotkeys";
|
|
2
|
+
import { useEffect, useId, useLayoutEffect, useMemo, useRef, useSyncExternalStore } from "react";
|
|
3
|
+
function useHotkey({ store, id, ...command }) {
|
|
4
|
+
const generatedId = useId();
|
|
5
|
+
useHotkeys({
|
|
6
|
+
store,
|
|
7
|
+
commands: [
|
|
8
|
+
{
|
|
9
|
+
...command,
|
|
10
|
+
id: id ?? generatedId
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function sameValues(left, right) {
|
|
16
|
+
if (Object.is(left, right)) return true;
|
|
17
|
+
return Array.isArray(left) && Array.isArray(right) && left.length === right.length && left.every((value, index)=>Object.is(value, right[index]));
|
|
18
|
+
}
|
|
19
|
+
function sameOptions(left, right) {
|
|
20
|
+
return left?.capture === right?.capture && left?.eventType === right?.eventType && left?.preventDefault === right?.preventDefault && left?.stopPropagation === right?.stopPropagation && left?.requireReset === right?.requireReset && left?.enableOnContentEditable === right?.enableOnContentEditable && sameValues(left?.enableOnFormTags, right?.enableOnFormTags) && left?.target === right?.target;
|
|
21
|
+
}
|
|
22
|
+
function sameRegistration(left, right) {
|
|
23
|
+
return left.hotkey === right.hotkey && left.label === right.label && left.description === right.description && left.category === right.category && sameValues(left.scopes, right.scopes) && sameValues(left.keywords, right.keywords) && sameOptions(left.options, right.options);
|
|
24
|
+
}
|
|
25
|
+
function readEnabled(command) {
|
|
26
|
+
const value = command?.enabled;
|
|
27
|
+
return "function" == typeof value ? value() : value ?? false;
|
|
28
|
+
}
|
|
29
|
+
function syncCommand(store, command, previous, getCurrent) {
|
|
30
|
+
const enabled = "function" == typeof command.enabled ? ()=>readEnabled(getCurrent()) : command.enabled ?? true;
|
|
31
|
+
const enabledUnchanged = previous?.enabled === command.enabled || "function" == typeof previous?.enabled && "function" == typeof command.enabled;
|
|
32
|
+
if (previous && sameRegistration(previous, command)) {
|
|
33
|
+
if (!enabledUnchanged) store.setEnabled(command.id, enabled);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (previous) store.unregister(command.id);
|
|
37
|
+
store.register({
|
|
38
|
+
...command,
|
|
39
|
+
action: (event)=>getCurrent()?.action(event),
|
|
40
|
+
enabled
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function useHotkeys({ store, commands }) {
|
|
44
|
+
const current = useRef(commands);
|
|
45
|
+
const registered = useRef(new Map());
|
|
46
|
+
useLayoutEffect(()=>{
|
|
47
|
+
current.current = commands;
|
|
48
|
+
});
|
|
49
|
+
useEffect(()=>{
|
|
50
|
+
const owned = registered.current;
|
|
51
|
+
return ()=>{
|
|
52
|
+
for (const id of owned.keys())store.unregister(id);
|
|
53
|
+
owned.clear();
|
|
54
|
+
};
|
|
55
|
+
}, [
|
|
56
|
+
store
|
|
57
|
+
]);
|
|
58
|
+
useEffect(()=>{
|
|
59
|
+
const owned = registered.current;
|
|
60
|
+
for (const id of owned.keys())if (!commands.some((command)=>command.id === id)) {
|
|
61
|
+
owned.delete(id);
|
|
62
|
+
store.unregister(id);
|
|
63
|
+
}
|
|
64
|
+
for (const command of commands){
|
|
65
|
+
const previous = owned.get(command.id);
|
|
66
|
+
owned.set(command.id, command);
|
|
67
|
+
syncCommand(store, command, previous, ()=>current.current.find((item)=>item.id === command.id));
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
const emptyRegistrations = [];
|
|
72
|
+
const getServerRegistrations = ()=>emptyRegistrations;
|
|
73
|
+
function useHotkeyRegistrations({ store }) {
|
|
74
|
+
const subscription = useMemo(()=>{
|
|
75
|
+
let snapshot = [];
|
|
76
|
+
const getSnapshot = ()=>{
|
|
77
|
+
const commands = [
|
|
78
|
+
...store.getState().commands.values()
|
|
79
|
+
];
|
|
80
|
+
if (commands.length !== snapshot.length || commands.some((command, index)=>{
|
|
81
|
+
const previous = snapshot[index];
|
|
82
|
+
return !previous || command._registrationOrder !== previous._registrationOrder || command.enabled !== previous.enabled || command.options !== previous.options || command._parsed !== previous._parsed;
|
|
83
|
+
})) snapshot = commands.map((command)=>({
|
|
84
|
+
...command
|
|
85
|
+
}));
|
|
86
|
+
return snapshot;
|
|
87
|
+
};
|
|
88
|
+
return {
|
|
89
|
+
getSnapshot,
|
|
90
|
+
subscribe: (notify)=>store.subscribe(getSnapshot, notify)
|
|
91
|
+
};
|
|
92
|
+
}, [
|
|
93
|
+
store
|
|
94
|
+
]);
|
|
95
|
+
return useSyncExternalStore(subscription.subscribe, subscription.getSnapshot, getServerRegistrations);
|
|
96
|
+
}
|
|
97
|
+
const subscribeToHydration = ()=>()=>{};
|
|
98
|
+
const getClientHydration = ()=>true;
|
|
99
|
+
const getServerHydration = ()=>false;
|
|
100
|
+
function useFormatHotkey() {
|
|
101
|
+
const hydrated = useSyncExternalStore(subscribeToHydration, getClientHydration, getServerHydration);
|
|
102
|
+
const defaultPlatform = hydrated ? "auto" : "windows";
|
|
103
|
+
return (hotkey, options)=>formatHotkey(hotkey, {
|
|
104
|
+
...options,
|
|
105
|
+
platform: options?.platform && "auto" !== options.platform ? options.platform : defaultPlatform
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
export { createHotkeyStore, useFormatHotkey, useHotkey, useHotkeyRegistrations, useHotkeys };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
const CommandContext = createContext(null);
|
|
3
|
+
const CommandItemContext = createContext(null);
|
|
4
|
+
function useCommandContext() {
|
|
5
|
+
const api = useContext(CommandContext);
|
|
6
|
+
if (!api) throw new Error("Command components must be used within Command.Root");
|
|
7
|
+
return api;
|
|
8
|
+
}
|
|
9
|
+
function useCommandItemContext() {
|
|
10
|
+
const item = useContext(CommandItemContext);
|
|
11
|
+
if (!item) throw new Error("Command.ItemText must be used within Command.Item");
|
|
12
|
+
return item;
|
|
13
|
+
}
|
|
14
|
+
export { CommandContext, CommandItemContext, useCommandContext, useCommandItemContext };
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createFilter } from "@zag-js/i18n-utils";
|
|
3
|
+
import { mergeProps, normalizeProps, useMachine } from "@zag-js/react";
|
|
4
|
+
import { useEffect, useId, useMemo, useState } from "react";
|
|
5
|
+
import { Input } from "../atoms/input.js";
|
|
6
|
+
import { Label } from "../atoms/label.js";
|
|
7
|
+
import { CommandContext, CommandItemContext, useCommandContext, useCommandItemContext } from "../internal/molecules/command.context.js";
|
|
8
|
+
import { tv } from "../utils.js";
|
|
9
|
+
import * as __rspack_external__zag_js_combobox_6371d768 from "@zag-js/combobox";
|
|
10
|
+
const commandVariants = tv({
|
|
11
|
+
slots: {
|
|
12
|
+
root: "command-border-width flex w-full flex-col gap-command-gap rounded-command border-command-border bg-command-bg p-command text-command-fg text-command-md",
|
|
13
|
+
control: "relative flex items-center",
|
|
14
|
+
list: "max-h-command-list-max overflow-y-auto overscroll-contain p-command-list",
|
|
15
|
+
item: "flex w-full cursor-pointer select-none items-center gap-command-item-gap rounded-command-item px-command-item-x py-command-item-y data-disabled:cursor-not-allowed data-highlighted:bg-command-item-bg-highlighted data-disabled:text-command-item-fg-disabled",
|
|
16
|
+
itemText: "min-w-0 flex-1",
|
|
17
|
+
itemGroup: "",
|
|
18
|
+
itemGroupLabel: "px-command-item-x py-command-item-y font-command-group-label text-command-group-label-fg",
|
|
19
|
+
empty: "text-center text-command-empty-fg data-empty:p-command-empty"
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
function Command({ items, children, id, className, ref, disabled, loopFocus = true, onSelect, locale, inputValue, defaultInputValue = "", onInputValueChange, onEscape }) {
|
|
23
|
+
const generatedId = useId();
|
|
24
|
+
const [uncontrolledQuery, setUncontrolledQuery] = useState(defaultInputValue);
|
|
25
|
+
const query = inputValue ?? uncontrolledQuery;
|
|
26
|
+
const collection = useMemo(()=>{
|
|
27
|
+
const filter = createFilter({
|
|
28
|
+
sensitivity: "base",
|
|
29
|
+
locale
|
|
30
|
+
});
|
|
31
|
+
return __rspack_external__zag_js_combobox_6371d768.collection({
|
|
32
|
+
items: items.filter((item)=>filter.contains(item.label, query) || item.keywords?.some((keyword)=>filter.contains(keyword, query))),
|
|
33
|
+
itemToValue: (item)=>item.value,
|
|
34
|
+
itemToString: (item)=>item.label,
|
|
35
|
+
isItemDisabled: (item)=>!!item.disabled
|
|
36
|
+
});
|
|
37
|
+
}, [
|
|
38
|
+
items,
|
|
39
|
+
query,
|
|
40
|
+
locale
|
|
41
|
+
]);
|
|
42
|
+
const service = useMachine(__rspack_external__zag_js_combobox_6371d768.machine, {
|
|
43
|
+
id: id ?? generatedId,
|
|
44
|
+
collection,
|
|
45
|
+
disabled,
|
|
46
|
+
loopFocus,
|
|
47
|
+
onSelect,
|
|
48
|
+
inputValue: query,
|
|
49
|
+
onInputValueChange (details) {
|
|
50
|
+
if (void 0 === inputValue) setUncontrolledQuery(details.inputValue);
|
|
51
|
+
onInputValueChange?.(details);
|
|
52
|
+
},
|
|
53
|
+
onOpenChange (details) {
|
|
54
|
+
if (!details.open && "escape-key" === details.reason) onEscape?.();
|
|
55
|
+
},
|
|
56
|
+
open: true,
|
|
57
|
+
disableLayer: true,
|
|
58
|
+
inputBehavior: "autohighlight",
|
|
59
|
+
selectionBehavior: "preserve",
|
|
60
|
+
closeOnSelect: false
|
|
61
|
+
});
|
|
62
|
+
const api = __rspack_external__zag_js_combobox_6371d768.connect(service, normalizeProps);
|
|
63
|
+
useEffect(()=>{
|
|
64
|
+
if (api.collection.find(api.highlightedValue)?.disabled) api.clearHighlightValue();
|
|
65
|
+
}, [
|
|
66
|
+
api
|
|
67
|
+
]);
|
|
68
|
+
return /*#__PURE__*/ jsx(CommandContext.Provider, {
|
|
69
|
+
value: api,
|
|
70
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
71
|
+
...api.getRootProps(),
|
|
72
|
+
className: commandVariants().root({
|
|
73
|
+
className
|
|
74
|
+
}),
|
|
75
|
+
ref: ref,
|
|
76
|
+
children: children
|
|
77
|
+
})
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
Command.Root = Command;
|
|
81
|
+
Command.Label = function({ children, ...props }) {
|
|
82
|
+
const api = useCommandContext();
|
|
83
|
+
return /*#__PURE__*/ jsx(Label, {
|
|
84
|
+
...mergeProps(props, api.getLabelProps()),
|
|
85
|
+
children: children
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
Command.Control = function({ className, ...props }) {
|
|
89
|
+
const api = useCommandContext();
|
|
90
|
+
return /*#__PURE__*/ jsx("div", {
|
|
91
|
+
...mergeProps(props, api.getControlProps()),
|
|
92
|
+
className: commandVariants().control({
|
|
93
|
+
className
|
|
94
|
+
})
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
Command.Input = function({ size, ...props }) {
|
|
98
|
+
const api = useCommandContext();
|
|
99
|
+
return /*#__PURE__*/ jsx(Input, {
|
|
100
|
+
...mergeProps(props, api.getInputProps()),
|
|
101
|
+
size: size
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
Command.List = function({ className, ...props }) {
|
|
105
|
+
const api = useCommandContext();
|
|
106
|
+
return /*#__PURE__*/ jsx("div", {
|
|
107
|
+
...mergeProps(props, api.getContentProps()),
|
|
108
|
+
className: commandVariants().list({
|
|
109
|
+
className
|
|
110
|
+
})
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
Command.ItemGroup = function({ id, className, ...props }) {
|
|
114
|
+
const api = useCommandContext();
|
|
115
|
+
return /*#__PURE__*/ jsx("div", {
|
|
116
|
+
...mergeProps(props, api.getItemGroupProps({
|
|
117
|
+
id
|
|
118
|
+
})),
|
|
119
|
+
className: commandVariants().itemGroup({
|
|
120
|
+
className
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
Command.ItemGroupLabel = function({ htmlFor, className, ...props }) {
|
|
125
|
+
const api = useCommandContext();
|
|
126
|
+
return /*#__PURE__*/ jsx("div", {
|
|
127
|
+
...mergeProps(props, api.getItemGroupLabelProps({
|
|
128
|
+
htmlFor
|
|
129
|
+
})),
|
|
130
|
+
className: commandVariants().itemGroupLabel({
|
|
131
|
+
className
|
|
132
|
+
})
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
Command.Item = function({ item, className, ...props }) {
|
|
136
|
+
const api = useCommandContext();
|
|
137
|
+
return /*#__PURE__*/ jsx(CommandItemContext.Provider, {
|
|
138
|
+
value: item,
|
|
139
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
140
|
+
...mergeProps(props, api.getItemProps({
|
|
141
|
+
item
|
|
142
|
+
})),
|
|
143
|
+
className: commandVariants().item({
|
|
144
|
+
className
|
|
145
|
+
})
|
|
146
|
+
})
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
Command.ItemText = function({ className, children, ...props }) {
|
|
150
|
+
const api = useCommandContext();
|
|
151
|
+
const item = useCommandItemContext();
|
|
152
|
+
return /*#__PURE__*/ jsx("span", {
|
|
153
|
+
...mergeProps(props, api.getItemTextProps({
|
|
154
|
+
item
|
|
155
|
+
})),
|
|
156
|
+
className: commandVariants().itemText({
|
|
157
|
+
className
|
|
158
|
+
}),
|
|
159
|
+
children: children ?? item.label
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
Command.Context = function({ children }) {
|
|
163
|
+
return children(useCommandContext());
|
|
164
|
+
};
|
|
165
|
+
Command.Empty = function({ children, className, ...props }) {
|
|
166
|
+
const api = useCommandContext();
|
|
167
|
+
const empty = 0 === api.collection.size;
|
|
168
|
+
return /*#__PURE__*/ jsx("output", {
|
|
169
|
+
...props,
|
|
170
|
+
className: commandVariants().empty({
|
|
171
|
+
className
|
|
172
|
+
}),
|
|
173
|
+
"data-empty": empty || void 0,
|
|
174
|
+
children: empty ? children : null
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
export { Command };
|
|
@@ -21,20 +21,20 @@ import { Table } from "./table.js";
|
|
|
21
21
|
const dataTableVariants = tv({
|
|
22
22
|
slots: {
|
|
23
23
|
wrapper: [
|
|
24
|
-
"flex w-full flex-col overflow-hidden rounded-table",
|
|
25
|
-
"border-(length:--border-table
|
|
24
|
+
"flex w-full flex-col overflow-hidden rounded-data-table",
|
|
25
|
+
"border-(length:--border-width-data-table) border-data-table-border"
|
|
26
26
|
],
|
|
27
27
|
toolbar: [
|
|
28
|
-
"flex items-center justify-between gap-
|
|
29
|
-
"bg-table-
|
|
30
|
-
"
|
|
31
|
-
"border-b-(length:--border-table
|
|
28
|
+
"flex items-center justify-between gap-data-table-toolbar",
|
|
29
|
+
"bg-data-table-toolbar-bg text-data-table-toolbar-fg",
|
|
30
|
+
"p-data-table-toolbar",
|
|
31
|
+
"border-b-(length:--border-width-data-table) border-data-table-border"
|
|
32
32
|
],
|
|
33
33
|
toolbarSearch: [
|
|
34
34
|
"min-w-0 flex-1"
|
|
35
35
|
],
|
|
36
36
|
toolbarActions: [
|
|
37
|
-
"flex shrink-0 items-center gap-
|
|
37
|
+
"flex shrink-0 items-center gap-data-table-toolbar"
|
|
38
38
|
],
|
|
39
39
|
scroll: [
|
|
40
40
|
"relative w-full overflow-auto"
|
|
@@ -48,68 +48,68 @@ const dataTableVariants = tv({
|
|
|
48
48
|
"data-[disabled=true]:cursor-default"
|
|
49
49
|
],
|
|
50
50
|
sortIcon: [
|
|
51
|
-
"text-fg
|
|
52
|
-
"data-[active=true]:text-fg-
|
|
51
|
+
"text-data-table-sort-icon-fg",
|
|
52
|
+
"data-[active=true]:text-data-table-sort-icon-fg-active"
|
|
53
53
|
],
|
|
54
54
|
dragHandle: [
|
|
55
|
-
"inline-flex cursor-grab items-center rounded-table text-fg
|
|
55
|
+
"inline-flex cursor-grab items-center rounded-data-table text-data-table-drag-handle-fg",
|
|
56
56
|
"opacity-0 transition-opacity duration-200 motion-reduce:transition-none",
|
|
57
|
-
"hover:bg-table-row-bg-hover hover:opacity-100 focus-visible:opacity-100",
|
|
57
|
+
"hover:bg-data-table-row-bg-hover hover:opacity-100 focus-visible:opacity-100",
|
|
58
58
|
"group-hover/header:opacity-100 group-hover/row:opacity-100",
|
|
59
59
|
"group-focus-within/header:opacity-100 group-focus-within/row:opacity-100",
|
|
60
60
|
"group-data-dragging/header:opacity-100 group-data-dragging/row:opacity-100",
|
|
61
61
|
"active:cursor-grabbing"
|
|
62
62
|
],
|
|
63
63
|
resizeHandle: [
|
|
64
|
-
"absolute end-0 top-0 h-full
|
|
64
|
+
"w-(length:--size-data-table-resize-handle) absolute end-0 top-0 h-full cursor-col-resize touch-none select-none",
|
|
65
65
|
"opacity-0 transition-opacity duration-200 motion-reduce:transition-none",
|
|
66
|
-
"bg-table-
|
|
66
|
+
"bg-data-table-resize-handle-bg hover:opacity-100 focus-visible:opacity-100",
|
|
67
67
|
"group-hover/header:opacity-100"
|
|
68
68
|
],
|
|
69
69
|
filterRow: [
|
|
70
|
-
"bg-table-
|
|
70
|
+
"bg-data-table-filter-row-bg"
|
|
71
71
|
],
|
|
72
72
|
filterCell: [
|
|
73
|
-
"
|
|
73
|
+
"p-data-table-filter-cell",
|
|
74
74
|
"min-w-fit",
|
|
75
|
-
"border-b-(length:--border-table
|
|
75
|
+
"border-b-(length:--border-width-data-table) border-data-table-border"
|
|
76
76
|
],
|
|
77
77
|
filterControl: [
|
|
78
|
-
"flex flex-wrap items-center gap-
|
|
78
|
+
"flex flex-wrap items-center gap-data-table-filter-control"
|
|
79
79
|
],
|
|
80
80
|
editorControl: [
|
|
81
|
-
"flex flex-col gap-
|
|
81
|
+
"flex flex-col gap-data-table-editor"
|
|
82
82
|
],
|
|
83
83
|
editorError: [
|
|
84
|
-
"text-
|
|
84
|
+
"text-data-table-editor-error-fg text-data-table-sm"
|
|
85
85
|
],
|
|
86
86
|
actionsCell: [
|
|
87
87
|
"flex items-center justify-end gap-100"
|
|
88
88
|
],
|
|
89
89
|
empty: [
|
|
90
90
|
"flex flex-col items-center justify-center gap-200",
|
|
91
|
-
"p-
|
|
91
|
+
"p-data-table-empty text-center text-data-table-empty-fg"
|
|
92
92
|
],
|
|
93
93
|
paginationBar: [
|
|
94
|
-
"flex flex-wrap items-center justify-between gap-
|
|
95
|
-
"bg-table-
|
|
96
|
-
"
|
|
97
|
-
"border-t-(length:--border-table
|
|
94
|
+
"flex flex-wrap items-center justify-between gap-data-table-pagination",
|
|
95
|
+
"bg-data-table-pagination-bg text-data-table-pagination-fg",
|
|
96
|
+
"p-data-table-pagination",
|
|
97
|
+
"border-t-(length:--border-width-data-table) border-data-table-border"
|
|
98
98
|
],
|
|
99
99
|
detailBox: [
|
|
100
|
-
"w-full p-
|
|
100
|
+
"w-full p-data-table-detail"
|
|
101
101
|
],
|
|
102
102
|
paginationInfo: [
|
|
103
|
-
"whitespace-nowrap text-table-sm"
|
|
103
|
+
"whitespace-nowrap text-data-table-sm"
|
|
104
104
|
],
|
|
105
105
|
paginationControls: [
|
|
106
|
-
"flex items-center gap-
|
|
106
|
+
"flex items-center gap-data-table-pagination"
|
|
107
107
|
]
|
|
108
108
|
},
|
|
109
109
|
variants: {
|
|
110
110
|
outlined: {
|
|
111
111
|
true: {
|
|
112
|
-
wrapper: "shadow-table-outline"
|
|
112
|
+
wrapper: "shadow-data-table-outline"
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
}
|
|
@@ -245,9 +245,9 @@ const BUILTIN_COLUMN_IDS = new Set([
|
|
|
245
245
|
function pinClass(column, kind) {
|
|
246
246
|
if (!column.getIsPinned()) return;
|
|
247
247
|
return [
|
|
248
|
-
"header" === kind ? "bg-table-header-bg" : "data-table-frozen-cell",
|
|
249
|
-
isLastStartPinned(column) ? "border-e-(length:--border-table
|
|
250
|
-
isFirstEndPinned(column) ? "border-s-(length:--border-table
|
|
248
|
+
"header" === kind ? "bg-data-table-header-bg" : "data-table-frozen-cell",
|
|
249
|
+
isLastStartPinned(column) ? "border-e-(length:--border-width-data-table) border-data-table-border" : "",
|
|
250
|
+
isFirstEndPinned(column) ? "border-s-(length:--border-width-data-table) border-data-table-border" : ""
|
|
251
251
|
].join(" ");
|
|
252
252
|
}
|
|
253
253
|
function HeaderDragHandle({ styles, setActivatorNodeRef, listeners, attributes, label }) {
|
|
@@ -392,21 +392,26 @@ function rowDragClass(dnd, opts) {
|
|
|
392
392
|
return [
|
|
393
393
|
"group/row",
|
|
394
394
|
"focus-visible:outline-(style:--default-ring-style) focus-visible:outline-(length:--default-ring-width) focus-visible:outline-primary",
|
|
395
|
-
"data-[selected=true]:[--dt-row-tint:var(--color-table-row-bg-selected)]",
|
|
396
|
-
"group-hover/row:[--dt-row-tint:var(--color-table-row-bg-hover)]",
|
|
397
|
-
"hover:[--dt-row-tint:var(--color-table-row-bg-hover)]",
|
|
398
|
-
striped ? `${(rowIndex ?? 0) % 2 === 0 ? "bg-table-row-striped-primary [--dt-row-tint:var(--color-table-row-striped-primary)]" : "bg-table-row-striped-secondary [--dt-row-tint:var(--color-table-row-striped-secondary)]"} border-b-0` : "",
|
|
395
|
+
"data-[selected=true]:[--dt-row-tint:var(--color-data-table-row-bg-selected)]",
|
|
396
|
+
"group-hover/row:[--dt-row-tint:var(--color-data-table-row-bg-hover)]",
|
|
397
|
+
"hover:[--dt-row-tint:var(--color-data-table-row-bg-hover)]",
|
|
398
|
+
striped ? `${(rowIndex ?? 0) % 2 === 0 ? "bg-data-table-row-bg-striped-primary [--dt-row-tint:var(--color-data-table-row-bg-striped-primary)]" : "bg-data-table-row-bg-striped-secondary [--dt-row-tint:var(--color-data-table-row-bg-striped-secondary)]"} border-b-0` : "",
|
|
399
399
|
tintNestedRows ? "data-[depth]:data-table-row-nested-tint" : "",
|
|
400
|
-
dnd?.isDragging ? "shadow-table-outline" : "",
|
|
400
|
+
dnd?.isDragging ? "shadow-data-table-outline" : "",
|
|
401
401
|
dnd?.dropSide === "top" ? "border-primary border-t-2" : "",
|
|
402
402
|
dnd?.dropSide === "bottom" ? "border-primary border-b-2" : "",
|
|
403
403
|
className ?? ""
|
|
404
404
|
].filter(Boolean).join(" ");
|
|
405
405
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
}
|
|
406
|
+
function opaqueSurface(tint) {
|
|
407
|
+
return {
|
|
408
|
+
backgroundColor: "var(--color-data-table-bg)",
|
|
409
|
+
backgroundImage: `linear-gradient(var(${tint}), var(${tint}))`
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
const OPAQUE_HEADER_BG = opaqueSurface("--color-data-table-header-bg");
|
|
413
|
+
const OPAQUE_FILTER_ROW_BG = opaqueSurface("--color-data-table-filter-row-bg");
|
|
414
|
+
const OPAQUE_PAGINATION_BG = opaqueSurface("--color-data-table-pagination-bg");
|
|
410
415
|
function sortState(column, enableSorting) {
|
|
411
416
|
if (!(enableSorting && column.getCanSort())) return;
|
|
412
417
|
const sorted = column.getIsSorted();
|
|
@@ -1094,7 +1099,7 @@ function DataTable(props) {
|
|
|
1094
1099
|
className: `${styles.filterCell()} ${pinClass(column, "header") ?? ""}`,
|
|
1095
1100
|
"data-pinned": column.getIsPinned() || void 0,
|
|
1096
1101
|
style: {
|
|
1097
|
-
...
|
|
1102
|
+
...OPAQUE_FILTER_ROW_BG,
|
|
1098
1103
|
...getPinningStyles(column, "header"),
|
|
1099
1104
|
...stickyHeader ? {
|
|
1100
1105
|
position: "sticky",
|
|
@@ -1111,9 +1116,9 @@ function DataTable(props) {
|
|
|
1111
1116
|
})
|
|
1112
1117
|
}, column.id)),
|
|
1113
1118
|
hasActionsColumn && /*#__PURE__*/ jsx("td", {
|
|
1114
|
-
className: stickyActions ? `${styles.filterCell()} sticky end-0 bg-table-
|
|
1119
|
+
className: stickyActions ? `${styles.filterCell()} sticky end-0 bg-data-table-filter-row-bg` : styles.filterCell(),
|
|
1115
1120
|
style: {
|
|
1116
|
-
...
|
|
1121
|
+
...OPAQUE_FILTER_ROW_BG,
|
|
1117
1122
|
...stickyHeader ? {
|
|
1118
1123
|
position: "sticky",
|
|
1119
1124
|
top: headerHeight
|
|
@@ -1368,7 +1373,7 @@ function DataTable(props) {
|
|
|
1368
1373
|
children: translations.emptyTitle
|
|
1369
1374
|
}),
|
|
1370
1375
|
/*#__PURE__*/ jsx("p", {
|
|
1371
|
-
className: "text-table-sm",
|
|
1376
|
+
className: "text-data-table-sm",
|
|
1372
1377
|
children: translations.emptyDescription
|
|
1373
1378
|
})
|
|
1374
1379
|
]
|
|
@@ -1424,7 +1429,7 @@ function DataTable(props) {
|
|
|
1424
1429
|
children: header.isPlaceholder ? null : flexRender(header.column.columnDef.footer, header.getContext())
|
|
1425
1430
|
}, header.id)),
|
|
1426
1431
|
hasActionsColumn && /*#__PURE__*/ jsx(Table.Cell, {
|
|
1427
|
-
className: stickyActions ? "sticky end-0 bg-table-footer-bg" : void 0,
|
|
1432
|
+
className: stickyActions ? "sticky end-0 bg-data-table-footer-bg" : void 0,
|
|
1428
1433
|
numeric: true,
|
|
1429
1434
|
style: stickyActions ? {
|
|
1430
1435
|
zIndex: DATA_TABLE_Z.stickyActionsCell
|
|
@@ -1686,7 +1691,7 @@ DataTable.Pagination = function() {
|
|
|
1686
1691
|
}));
|
|
1687
1692
|
return /*#__PURE__*/ jsxs("div", {
|
|
1688
1693
|
className: styles.paginationBar(),
|
|
1689
|
-
style:
|
|
1694
|
+
style: OPAQUE_PAGINATION_BG,
|
|
1690
1695
|
children: [
|
|
1691
1696
|
/*#__PURE__*/ jsx("span", {
|
|
1692
1697
|
className: styles.paginationInfo(),
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hotkeys — @techsio/ui-kit atom.
|
|
3
|
+
*
|
|
4
|
+
* @component Hotkeys
|
|
5
|
+
* @componentVersion v1.0.1
|
|
6
|
+
* @skill hotkeys-usage
|
|
7
|
+
* @changelog libs/ui/stories/changelog/changelog.stories.tsx
|
|
8
|
+
*/
|
|
9
|
+
import type { ComponentPropsWithoutRef, Ref } from "react";
|
|
10
|
+
import { type HotkeyFormatOptions } from "../hotkeys.js";
|
|
11
|
+
export type HotkeysProps = ComponentPropsWithoutRef<"span"> & {
|
|
12
|
+
hotkey?: string;
|
|
13
|
+
formatOptions?: HotkeyFormatOptions;
|
|
14
|
+
ref?: Ref<HTMLSpanElement>;
|
|
15
|
+
};
|
|
16
|
+
export declare function Hotkeys({ hotkey, formatOptions, children, className, ref, ...props }: HotkeysProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare namespace Hotkeys {
|
|
18
|
+
var Key: ({ className, ref, ...props }: HotkeysKeyProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
var Separator: ({ children, className, ref, ...props }: HotkeysSeparatorProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
var Root: typeof Hotkeys;
|
|
21
|
+
var displayName: string;
|
|
22
|
+
}
|
|
23
|
+
export type HotkeysKeyProps = ComponentPropsWithoutRef<"kbd"> & {
|
|
24
|
+
ref?: Ref<HTMLElement>;
|
|
25
|
+
};
|
|
26
|
+
export type HotkeysSeparatorProps = ComponentPropsWithoutRef<"span"> & {
|
|
27
|
+
ref?: Ref<HTMLSpanElement>;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=hotkeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hotkeys.d.ts","sourceRoot":"","sources":["../../../src/atoms/hotkeys.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,wBAAwB,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC1D,OAAO,EAAE,KAAK,mBAAmB,EAAmB,MAAM,YAAY,CAAA;AAWtE,MAAM,MAAM,YAAY,GAAG,wBAAwB,CAAC,MAAM,CAAC,GAAG;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,aAAa,CAAC,EAAE,mBAAmB,CAAA;IACnC,GAAG,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC,CAAA;CAC3B,CAAA;AAED,wBAAgB,OAAO,CAAC,EACtB,MAAM,EACN,aAAa,EACb,QAAQ,EACR,SAAS,EACT,GAAG,EACH,GAAG,KAAK,EACT,EAAE,YAAY,2CAgBd;yBAvBe,OAAO;4CAiCpB,eAAe;4DAqBf,qBAAqB;;;;AA7BxB,MAAM,MAAM,eAAe,GAAG,wBAAwB,CAAC,KAAK,CAAC,GAAG;IAC9D,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAA;CACvB,CAAA;AAkBD,MAAM,MAAM,qBAAqB,GAAG,wBAAwB,CAAC,MAAM,CAAC,GAAG;IACrE,GAAG,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC,CAAA;CAC3B,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type CommandDefinition, type HotkeyCommand, type HotkeyFormatOptions, type HotkeyStore } from "@zag-js/hotkeys";
|
|
2
|
+
export { createHotkeyStore } from "@zag-js/hotkeys";
|
|
3
|
+
export type { CommandDefinition, HotkeyAction, HotkeyCommand, HotkeyFormatOptions, HotkeyOptions, HotkeyStore, HotkeyStoreOptions, } from "@zag-js/hotkeys";
|
|
4
|
+
export type UseHotkeyProps = Omit<CommandDefinition, "id"> & {
|
|
5
|
+
store: HotkeyStore;
|
|
6
|
+
id?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function useHotkey({ store, id, ...command }: UseHotkeyProps): void;
|
|
9
|
+
export type UseHotkeysProps = {
|
|
10
|
+
store: HotkeyStore;
|
|
11
|
+
commands: CommandDefinition[];
|
|
12
|
+
};
|
|
13
|
+
export declare function useHotkeys({ store, commands }: UseHotkeysProps): void;
|
|
14
|
+
export type UseHotkeyRegistrationsProps = {
|
|
15
|
+
store: HotkeyStore;
|
|
16
|
+
};
|
|
17
|
+
export declare function useHotkeyRegistrations({ store }: UseHotkeyRegistrationsProps): HotkeyCommand[];
|
|
18
|
+
export declare function useFormatHotkey(): (hotkey: string, options?: HotkeyFormatOptions) => string;
|
|
19
|
+
//# sourceMappingURL=hotkeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hotkeys.d.ts","sourceRoot":"","sources":["../../src/hotkeys.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EAExB,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAA;AAWxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,YAAY,EACV,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,kBAAkB,GACnB,MAAM,iBAAiB,CAAA;AAExB,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,GAAG;IAC3D,KAAK,EAAE,WAAW,CAAA;IAClB,EAAE,CAAC,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,OAAO,EAAE,EAAE,cAAc,QAGlE;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,WAAW,CAAA;IAClB,QAAQ,EAAE,iBAAiB,EAAE,CAAA;CAC9B,CAAA;AA4ED,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,eAAe,QAmC9D;AAED,MAAM,MAAM,2BAA2B,GAAG;IAAE,KAAK,EAAE,WAAW,CAAA;CAAE,CAAA;AAKhE,wBAAgB,sBAAsB,CAAC,EAAE,KAAK,EAAE,EAAE,2BAA2B,mBAiC5E;AAQD,wBAAgB,eAAe,KAOrB,QAAQ,MAAM,EAAE,UAAU,mBAAmB,YAQtD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CommandApi, CommandItem } from "../../molecules/command.js";
|
|
2
|
+
export declare const CommandContext: import("react").Context<CommandApi | null>;
|
|
3
|
+
export declare const CommandItemContext: import("react").Context<CommandItem | null>;
|
|
4
|
+
export declare function useCommandContext(): CommandApi;
|
|
5
|
+
export declare function useCommandItemContext(): CommandItem;
|
|
6
|
+
//# sourceMappingURL=command.context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.context.d.ts","sourceRoot":"","sources":["../../../../src/internal/molecules/command.context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAEtE,eAAO,MAAM,cAAc,4CAAyC,CAAA;AACpE,eAAO,MAAM,kBAAkB,6CAA0C,CAAA;AAEzE,wBAAgB,iBAAiB,eAMhC;AAED,wBAAgB,qBAAqB,gBAMpC"}
|