@kirana-ui/solid 0.1.0 → 0.1.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/dom/autocomplete.js +2 -0
- package/dom/autosize.js +19 -0
- package/dom/calendar.js +141 -0
- package/dom/carousel.js +83 -0
- package/dom/checkbox.js +2 -1
- package/dom/combobox.js +281 -0
- package/dom/command.js +129 -0
- package/dom/context-menu.js +2 -0
- package/dom/date-field.js +86 -0
- package/dom/date-picker.js +103 -0
- package/dom/dialog.js +28 -0
- package/dom/drawer.js +2 -0
- package/dom/hover-popup.js +17 -2
- package/dom/index.js +26 -1
- package/dom/input.js +26 -0
- package/dom/label.js +18 -0
- package/dom/listbox.js +114 -0
- package/dom/menu.js +261 -0
- package/dom/menubar-context.js +3 -0
- package/dom/menubar.js +33 -0
- package/dom/message-scroller.js +56 -0
- package/dom/navigation-menu.js +150 -0
- package/dom/number-field.js +82 -0
- package/dom/otp.js +95 -0
- package/dom/pagination.js +74 -0
- package/dom/popover.js +2 -0
- package/dom/qr-code.js +48 -0
- package/dom/radio-group.js +2 -1
- package/dom/resizable.js +65 -0
- package/dom/runtime.js +36 -2
- package/dom/scroll-area.js +99 -0
- package/dom/select.js +69 -5
- package/dom/slider.js +1 -1
- package/dom/switch.js +2 -1
- package/dom/toast.js +113 -0
- package/dom/toggle-group.js +37 -0
- package/dom/toggle.js +11 -3
- package/dom/toolbar-context.js +5 -0
- package/dom/toolbar.js +71 -0
- package/llms.txt +1838 -0
- package/package.json +220 -2
- package/server/autocomplete.js +2 -0
- package/server/autosize.js +19 -0
- package/server/calendar.js +140 -0
- package/server/carousel.js +83 -0
- package/server/checkbox.js +2 -1
- package/server/combobox.js +281 -0
- package/server/command.js +129 -0
- package/server/context-menu.js +2 -0
- package/server/date-field.js +86 -0
- package/server/date-picker.js +103 -0
- package/server/dialog.js +28 -0
- package/server/drawer.js +2 -0
- package/server/hover-popup.js +17 -2
- package/server/index.js +26 -1
- package/server/input.js +26 -0
- package/server/label.js +18 -0
- package/server/listbox.js +114 -0
- package/server/menu.js +261 -0
- package/server/menubar-context.js +3 -0
- package/server/menubar.js +33 -0
- package/server/message-scroller.js +56 -0
- package/server/navigation-menu.js +144 -0
- package/server/number-field.js +81 -0
- package/server/otp.js +94 -0
- package/server/pagination.js +74 -0
- package/server/popover.js +2 -0
- package/server/qr-code.js +48 -0
- package/server/radio-group.js +2 -1
- package/server/resizable.js +65 -0
- package/server/runtime.js +35 -1
- package/server/scroll-area.js +99 -0
- package/server/select.js +69 -5
- package/server/slider.js +1 -1
- package/server/switch.js +2 -1
- package/server/toast.js +113 -0
- package/server/toggle-group.js +37 -0
- package/server/toggle.js +11 -3
- package/server/toolbar-context.js +5 -0
- package/server/toolbar.js +71 -0
- package/src/autocomplete.jsx +2 -0
- package/src/autosize.jsx +8 -0
- package/src/calendar.jsx +104 -0
- package/src/carousel.jsx +51 -0
- package/src/checkbox.jsx +2 -0
- package/src/combobox.jsx +179 -0
- package/src/command.jsx +81 -0
- package/src/context-menu.js +2 -0
- package/src/date-field.jsx +67 -0
- package/src/date-picker.jsx +72 -0
- package/src/dialog.jsx +20 -0
- package/src/drawer.js +2 -0
- package/src/hover-popup.jsx +10 -2
- package/src/index.js +26 -1
- package/src/input.jsx +17 -0
- package/src/label.jsx +9 -0
- package/src/listbox.jsx +81 -0
- package/src/menu.jsx +164 -0
- package/src/menubar-context.js +3 -0
- package/src/menubar.jsx +21 -0
- package/src/message-scroller.jsx +27 -0
- package/src/navigation-menu.jsx +95 -0
- package/src/number-field.jsx +75 -0
- package/src/otp.jsx +73 -0
- package/src/pagination.jsx +60 -0
- package/src/popover.jsx +2 -0
- package/src/qr-code.jsx +25 -0
- package/src/radio-group.jsx +2 -0
- package/src/resizable.jsx +46 -0
- package/src/runtime.jsx +33 -2
- package/src/scroll-area.jsx +53 -0
- package/src/select.jsx +49 -5
- package/src/slider.jsx +2 -0
- package/src/switch.jsx +2 -0
- package/src/toast.jsx +58 -0
- package/src/toggle-group.jsx +32 -0
- package/src/toggle.jsx +8 -2
- package/src/toolbar-context.js +5 -0
- package/src/toolbar.jsx +43 -0
- package/types/autocomplete.d.ts +1 -0
- package/types/autosize.d.ts +8 -0
- package/types/calendar.d.ts +40 -0
- package/types/carousel.d.ts +26 -0
- package/types/checkbox.d.ts +1 -0
- package/types/combobox.d.ts +106 -0
- package/types/command.d.ts +45 -0
- package/types/context-menu.d.ts +1 -0
- package/types/date-field.d.ts +23 -0
- package/types/date-picker.d.ts +49 -0
- package/types/dialog.d.ts +21 -0
- package/types/drawer.d.ts +1 -0
- package/types/hover-card.d.ts +4 -1
- package/types/hover-popup.d.ts +4 -1
- package/types/index.d.ts +27 -1
- package/types/input.d.ts +12 -0
- package/types/label.d.ts +4 -0
- package/types/listbox.d.ts +38 -0
- package/types/menu.d.ts +91 -0
- package/types/menubar-context.d.ts +3 -0
- package/types/menubar.d.ts +10 -0
- package/types/message-scroller.d.ts +16 -0
- package/types/navigation-menu.d.ts +44 -0
- package/types/number-field.d.ts +15 -0
- package/types/otp.d.ts +32 -0
- package/types/pagination.d.ts +23 -0
- package/types/popover.d.ts +4 -1
- package/types/qr-code.d.ts +14 -0
- package/types/radio-group.d.ts +1 -0
- package/types/resizable.d.ts +24 -0
- package/types/runtime.d.ts +18 -0
- package/types/scroll-area.d.ts +20 -0
- package/types/select.d.ts +25 -1
- package/types/switch.d.ts +1 -0
- package/types/toast.d.ts +33 -0
- package/types/toggle-group.d.ts +14 -0
- package/types/toggle.d.ts +2 -0
- package/types/toolbar-context.d.ts +6 -0
- package/types/toolbar.d.ts +23 -0
- package/types/tooltip.d.ts +4 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { within } from "@kirana-ui/core";
|
|
2
|
+
import { createScrollArea } from "@kirana-ui/core/scroll-area";
|
|
3
|
+
import { Show, createContext, splitProps, untrack, useContext } from "solid-js";
|
|
4
|
+
import { DirectionContext } from "./direction-context.js";
|
|
5
|
+
import { Part, controller, fromSignal } from "./runtime.jsx";
|
|
6
|
+
const Context = createContext();
|
|
7
|
+
const ScrollbarContext = createContext();
|
|
8
|
+
function useScrollArea() {
|
|
9
|
+
const made = useContext(Context);
|
|
10
|
+
if (!made)
|
|
11
|
+
throw new Error("A ScrollArea part must be inside <ScrollArea.Root>");
|
|
12
|
+
return made;
|
|
13
|
+
}
|
|
14
|
+
function Root(props) {
|
|
15
|
+
const direction = useContext(DirectionContext);
|
|
16
|
+
const made = controller(within(createScrollArea, { direction }), () => ({}));
|
|
17
|
+
return (<Context.Provider value={made}>
|
|
18
|
+
<Part part={made.root} tag="div" {...props}/>
|
|
19
|
+
</Context.Provider>);
|
|
20
|
+
}
|
|
21
|
+
/** `orientation` is which way it scrolls (`vertical` by default). */
|
|
22
|
+
function Scrollbar(props) {
|
|
23
|
+
const [local, rest] = splitProps(props, ["orientation", "keepMounted"]);
|
|
24
|
+
const bar = useScrollArea().scrollbar(untrack(() => local.orientation) ?? "vertical");
|
|
25
|
+
const shown = fromSignal(bar.shown);
|
|
26
|
+
return (<ScrollbarContext.Provider value={bar}>
|
|
27
|
+
<Show when={shown() || local.keepMounted}>
|
|
28
|
+
<Part part={bar.part} tag="div" {...rest}/>
|
|
29
|
+
</Show>
|
|
30
|
+
</ScrollbarContext.Provider>);
|
|
31
|
+
}
|
|
32
|
+
function Thumb(props) {
|
|
33
|
+
const bar = useContext(ScrollbarContext);
|
|
34
|
+
if (!bar)
|
|
35
|
+
throw new Error("A ScrollArea.Thumb must be inside <ScrollArea.Scrollbar>");
|
|
36
|
+
return <Part part={bar.thumb} tag="div" {...props}/>;
|
|
37
|
+
}
|
|
38
|
+
function Corner(props) {
|
|
39
|
+
const { corner } = useScrollArea();
|
|
40
|
+
const shown = fromSignal(corner.shown);
|
|
41
|
+
return (<Show when={shown()}>
|
|
42
|
+
<Part part={corner.part} tag="div" {...props}/>
|
|
43
|
+
</Show>);
|
|
44
|
+
}
|
|
45
|
+
const part = (name) => (props) => (<Part part={useScrollArea()[name]} tag="div" {...props}/>);
|
|
46
|
+
export const ScrollArea = {
|
|
47
|
+
Root,
|
|
48
|
+
Viewport: part("viewport"),
|
|
49
|
+
Content: part("content"),
|
|
50
|
+
Scrollbar,
|
|
51
|
+
Thumb,
|
|
52
|
+
Corner,
|
|
53
|
+
};
|
package/src/select.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defined, within } from "@kirana-ui/core";
|
|
2
2
|
import { createSelect } from "@kirana-ui/core/select";
|
|
3
|
-
import { Show, createContext, createUniqueId, splitProps, untrack, useContext } from "solid-js";
|
|
3
|
+
import { Show, createComputed, createContext, createUniqueId, onCleanup, onMount, splitProps, untrack, useContext, } from "solid-js";
|
|
4
4
|
import { positioned } from "./popover.jsx";
|
|
5
5
|
import { FieldContext } from "./field-context.js";
|
|
6
6
|
import { Part, Portal as BodyPortal, controller, fromSignal, toSignal } from "./runtime.jsx";
|
|
@@ -24,7 +24,9 @@ function Root(props) {
|
|
|
24
24
|
disabled: props.disabled,
|
|
25
25
|
required: props.required,
|
|
26
26
|
name: props.name,
|
|
27
|
+
form: props.form,
|
|
27
28
|
items: props.items,
|
|
29
|
+
virtualized: props.virtualized,
|
|
28
30
|
onValueChange: (value, details) => props.onValueChange?.(value, details),
|
|
29
31
|
onOpenChange: (open, details) => props.onOpenChange?.(open, details),
|
|
30
32
|
}));
|
|
@@ -37,9 +39,15 @@ function Root(props) {
|
|
|
37
39
|
</Context.Provider>);
|
|
38
40
|
}
|
|
39
41
|
const Portal = (props) => (<BodyPortal mounted={useSelect().mounted}>{props.children}</BodyPortal>);
|
|
42
|
+
/**
|
|
43
|
+
* `alignItemWithTrigger`: the list opens over its trigger, the chosen item's text on the
|
|
44
|
+
* trigger's own, where there is room and unless a finger opened it.
|
|
45
|
+
*/
|
|
40
46
|
function Positioner(props) {
|
|
41
47
|
const made = useSelect();
|
|
42
|
-
|
|
48
|
+
const [local, rest] = splitProps(props, ["alignItemWithTrigger"]);
|
|
49
|
+
createComputed(() => made.alignItemWithTrigger.set(Boolean(local.alignItemWithTrigger)));
|
|
50
|
+
return (<Part part={made.positioner} tag="div" {...positioned(rest, made.positioning)}/>);
|
|
43
51
|
}
|
|
44
52
|
/** Shows the chosen value's label, or `placeholder` while nothing is chosen. */
|
|
45
53
|
function Value(props) {
|
|
@@ -52,10 +60,14 @@ function Value(props) {
|
|
|
52
60
|
}
|
|
53
61
|
/** `label` is what typeahead matches and the trigger shows; the item's text when left out. */
|
|
54
62
|
function Item(props) {
|
|
55
|
-
const [local, rest] = splitProps(props, ["value", "disabled", "label"]);
|
|
63
|
+
const [local, rest] = splitProps(props, ["value", "disabled", "label", "index"]);
|
|
56
64
|
// An item is its value for as long as it is in the page.
|
|
57
65
|
const value = untrack(() => local.value);
|
|
58
|
-
const options = toSignal(() => ({
|
|
66
|
+
const options = toSignal(() => ({
|
|
67
|
+
disabled: local.disabled,
|
|
68
|
+
label: local.label,
|
|
69
|
+
index: local.index,
|
|
70
|
+
}));
|
|
59
71
|
const part = useSelect().item(value, () => defined(options.get()));
|
|
60
72
|
return (<ItemContext.Provider value={value}>
|
|
61
73
|
<Part part={part} tag="div" {...rest}/>
|
|
@@ -71,7 +83,29 @@ function ItemIndicator(props) {
|
|
|
71
83
|
<Part part={made.itemIndicator(value)} tag="span" {...rest}/>
|
|
72
84
|
</Show>);
|
|
73
85
|
}
|
|
74
|
-
const
|
|
86
|
+
const GroupContext = createContext();
|
|
87
|
+
/** Items that belong together, named by their `<Select.GroupLabel>`. */
|
|
88
|
+
function Group(props) {
|
|
89
|
+
const [local, rest] = splitProps(props, ["id"]);
|
|
90
|
+
const generated = createUniqueId();
|
|
91
|
+
const group = useSelect().group(untrack(() => local.id) ?? generated);
|
|
92
|
+
return (<GroupContext.Provider value={group}>
|
|
93
|
+
<Part part={group.root} tag="div" {...rest}/>
|
|
94
|
+
</GroupContext.Provider>);
|
|
95
|
+
}
|
|
96
|
+
/** Names the group it is in. With no group around it, it is plain text. */
|
|
97
|
+
const GroupLabel = (props) => (<Part part={useContext(GroupContext)?.label ?? useSelect().groupLabel} tag="div" {...props}/>);
|
|
98
|
+
function scrollArrow(direction) {
|
|
99
|
+
return (props) => {
|
|
100
|
+
const arrow = useSelect().scrollArrow(direction);
|
|
101
|
+
onMount(() => onCleanup(arrow.mount()));
|
|
102
|
+
const mounted = fromSignal(arrow.mounted);
|
|
103
|
+
return (<Show when={mounted()}>
|
|
104
|
+
<Part part={arrow.part} tag="div" {...props}/>
|
|
105
|
+
</Show>);
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const part = (name, tag) => (props) => <Part part={useSelect()[name]} tag={tag} {...props}/>;
|
|
75
109
|
export const Select = {
|
|
76
110
|
Root,
|
|
77
111
|
Portal,
|
|
@@ -82,4 +116,14 @@ export const Select = {
|
|
|
82
116
|
ItemIndicator,
|
|
83
117
|
Trigger: part("trigger", "button"),
|
|
84
118
|
Popup: part("popup", "div"),
|
|
119
|
+
/** The items' own box inside the popup, when the popup also holds scroll arrows. */
|
|
120
|
+
List: part("list", "div"),
|
|
121
|
+
/** In the page while there is more of the list above: it scrolls it under a moving pointer. */
|
|
122
|
+
ScrollUpArrow: scrollArrow("up"),
|
|
123
|
+
/** In the page while there is more of the list below. */
|
|
124
|
+
ScrollDownArrow: scrollArrow("down"),
|
|
125
|
+
Group,
|
|
126
|
+
GroupLabel,
|
|
127
|
+
/** A line between groups. */
|
|
128
|
+
Separator: part("separator", "div"),
|
|
85
129
|
};
|
package/src/slider.jsx
CHANGED
package/src/switch.jsx
CHANGED
|
@@ -19,6 +19,7 @@ function Root(props) {
|
|
|
19
19
|
"readOnly",
|
|
20
20
|
"required",
|
|
21
21
|
"name",
|
|
22
|
+
"form",
|
|
22
23
|
"value",
|
|
23
24
|
"id",
|
|
24
25
|
"children",
|
|
@@ -33,6 +34,7 @@ function Root(props) {
|
|
|
33
34
|
readOnly: local.readOnly,
|
|
34
35
|
required: local.required,
|
|
35
36
|
name: local.name,
|
|
37
|
+
form: local.form,
|
|
36
38
|
value: local.value,
|
|
37
39
|
onCheckedChange: (checked, details) => local.onCheckedChange?.(checked, details),
|
|
38
40
|
}));
|
package/src/toast.jsx
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createToast } from "@kirana-ui/core/toast";
|
|
2
|
+
import { For, createContext, createMemo, createUniqueId, splitProps, useContext } from "solid-js";
|
|
3
|
+
import { Part, controller, fromSignal } from "./runtime.jsx";
|
|
4
|
+
const Context = createContext();
|
|
5
|
+
const ToastContext = createContext();
|
|
6
|
+
function useToast() {
|
|
7
|
+
const made = useContext(Context);
|
|
8
|
+
if (!made)
|
|
9
|
+
throw new Error("A Toast part must be inside <Toast.Viewport>");
|
|
10
|
+
return made;
|
|
11
|
+
}
|
|
12
|
+
function useParts() {
|
|
13
|
+
const parts = useContext(ToastContext);
|
|
14
|
+
if (!parts)
|
|
15
|
+
throw new Error("A toast's part must be inside <Toast.Root>");
|
|
16
|
+
return parts;
|
|
17
|
+
}
|
|
18
|
+
/** Where a toaster's toasts are drawn. Always in the page: put it once, near the root. */
|
|
19
|
+
function Viewport(props) {
|
|
20
|
+
const [local, rest] = splitProps(props, ["toaster", "label", "hotkey", "swipeDirection", "id"]);
|
|
21
|
+
const generated = createUniqueId();
|
|
22
|
+
const made = controller(createToast, () => ({
|
|
23
|
+
id: local.id ?? generated,
|
|
24
|
+
toaster: local.toaster,
|
|
25
|
+
label: local.label,
|
|
26
|
+
hotkey: local.hotkey,
|
|
27
|
+
swipeDirection: local.swipeDirection,
|
|
28
|
+
}));
|
|
29
|
+
return (<Context.Provider value={made}>
|
|
30
|
+
<Part part={made.viewport} tag="div" {...rest}/>
|
|
31
|
+
</Context.Provider>);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Draws its child once for each toast, the newest first. The child is given the toast as an
|
|
35
|
+
* accessor: one that changes is the same toast, drawn again where it stands.
|
|
36
|
+
*/
|
|
37
|
+
function List(props) {
|
|
38
|
+
const toasts = fromSignal(useToast().toasts);
|
|
39
|
+
const ids = createMemo(() => toasts().map((each) => each.id), undefined, {
|
|
40
|
+
equals: (a, b) => a.length === b.length && a.every((each, at) => each === b[at]),
|
|
41
|
+
});
|
|
42
|
+
return (<For each={ids()}>{(id) => props.children(() => toasts().find((each) => each.id === id))}</For>);
|
|
43
|
+
}
|
|
44
|
+
function Root(props) {
|
|
45
|
+
const [local, rest] = splitProps(props, ["toast"]);
|
|
46
|
+
// A root is its toast for as long as it is in the page.
|
|
47
|
+
const parts = useToast().toast(local.toast.id);
|
|
48
|
+
return (<ToastContext.Provider value={parts}>
|
|
49
|
+
<Part part={parts.root} tag="div" {...rest}/>
|
|
50
|
+
</ToastContext.Provider>);
|
|
51
|
+
}
|
|
52
|
+
const Content = (props) => (<Part part={useParts().content} tag="div" {...props}/>);
|
|
53
|
+
const Title = (props) => <Part part={useParts().title} tag="div" {...props}/>;
|
|
54
|
+
const Description = (props) => (<Part part={useParts().description} tag="div" {...props}/>);
|
|
55
|
+
const Close = (props) => (<Part part={useParts().close} tag="button" {...props}/>);
|
|
56
|
+
const Action = (props) => (<Part part={useParts().action} tag="button" {...props}/>);
|
|
57
|
+
export const Toast = { Viewport, List, Root, Content, Title, Description, Close, Action };
|
|
58
|
+
export { createToaster } from "@kirana-ui/core/toast";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { within } from "@kirana-ui/core";
|
|
2
|
+
import { createToggleGroup } from "@kirana-ui/core/toggle-group";
|
|
3
|
+
import { splitProps, useContext } from "solid-js";
|
|
4
|
+
import { DirectionContext } from "./direction-context.js";
|
|
5
|
+
import { Part, controller } from "./runtime.jsx";
|
|
6
|
+
import { ToggleGroupContext, ToolbarContext } from "./toolbar-context.js";
|
|
7
|
+
/** Toggles that are one control. Each `<Toggle value>` inside it is one of its toggles. */
|
|
8
|
+
export function ToggleGroup(props) {
|
|
9
|
+
const [local, rest] = splitProps(props, [
|
|
10
|
+
"value",
|
|
11
|
+
"defaultValue",
|
|
12
|
+
"onValueChange",
|
|
13
|
+
"multiple",
|
|
14
|
+
"disabled",
|
|
15
|
+
"orientation",
|
|
16
|
+
"loop",
|
|
17
|
+
]);
|
|
18
|
+
const direction = useContext(DirectionContext);
|
|
19
|
+
const toolbar = useContext(ToolbarContext) ?? undefined;
|
|
20
|
+
const made = controller(within(createToggleGroup, { direction, toolbar }), () => ({
|
|
21
|
+
value: local.value,
|
|
22
|
+
defaultValue: local.defaultValue,
|
|
23
|
+
multiple: local.multiple,
|
|
24
|
+
disabled: local.disabled,
|
|
25
|
+
orientation: local.orientation,
|
|
26
|
+
loop: local.loop,
|
|
27
|
+
onValueChange: (value, details) => local.onValueChange?.(value, details),
|
|
28
|
+
}));
|
|
29
|
+
return (<ToggleGroupContext.Provider value={made}>
|
|
30
|
+
<Part part={made.root} tag="div" {...rest}/>
|
|
31
|
+
</ToggleGroupContext.Provider>);
|
|
32
|
+
}
|
package/src/toggle.jsx
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
+
import { within } from "@kirana-ui/core";
|
|
1
2
|
import { createToggle } from "@kirana-ui/core/toggle";
|
|
2
|
-
import { splitProps } from "solid-js";
|
|
3
|
+
import { splitProps, useContext } from "solid-js";
|
|
3
4
|
import { Part, controller } from "./runtime.jsx";
|
|
5
|
+
import { ToggleGroupContext, ToolbarContext } from "./toolbar-context.js";
|
|
4
6
|
export function Toggle(props) {
|
|
5
7
|
const [local, rest] = splitProps(props, [
|
|
6
8
|
"pressed",
|
|
7
9
|
"defaultPressed",
|
|
8
10
|
"onPressedChange",
|
|
9
11
|
"disabled",
|
|
12
|
+
"value",
|
|
10
13
|
]);
|
|
11
|
-
const
|
|
14
|
+
const group = useContext(ToggleGroupContext) ?? undefined;
|
|
15
|
+
const toolbar = useContext(ToolbarContext) ?? undefined;
|
|
16
|
+
const made = controller(within(createToggle, { group, toolbar }), () => ({
|
|
12
17
|
pressed: local.pressed,
|
|
13
18
|
defaultPressed: local.defaultPressed,
|
|
14
19
|
disabled: local.disabled,
|
|
20
|
+
value: local.value,
|
|
15
21
|
onPressedChange: (pressed, details) => local.onPressedChange?.(pressed, details),
|
|
16
22
|
}));
|
|
17
23
|
return <Part part={made.root} tag="button" {...rest}/>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createContext } from "solid-js";
|
|
2
|
+
/** The toolbar a control is an item of, if it is in one. */
|
|
3
|
+
export const ToolbarContext = createContext(null);
|
|
4
|
+
/** The group a toggle is one of the toggles of, if it is in one. */
|
|
5
|
+
export const ToggleGroupContext = createContext(null);
|
package/src/toolbar.jsx
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { defined, within } from "@kirana-ui/core";
|
|
2
|
+
import { createToolbar } from "@kirana-ui/core/toolbar";
|
|
3
|
+
import { splitProps, useContext } from "solid-js";
|
|
4
|
+
import { DirectionContext } from "./direction-context.js";
|
|
5
|
+
import { Part, controller, toSignal } from "./runtime.jsx";
|
|
6
|
+
import { ToggleGroupContext, ToolbarContext } from "./toolbar-context.js";
|
|
7
|
+
function useToolbar() {
|
|
8
|
+
const made = useContext(ToolbarContext);
|
|
9
|
+
if (!made)
|
|
10
|
+
throw new Error("A Toolbar part must be inside <Toolbar.Root>");
|
|
11
|
+
return made;
|
|
12
|
+
}
|
|
13
|
+
function Root(props) {
|
|
14
|
+
const [local, rest] = splitProps(props, ["orientation", "loop", "disabled"]);
|
|
15
|
+
const direction = useContext(DirectionContext);
|
|
16
|
+
const made = controller(within(createToolbar, { direction }), () => ({
|
|
17
|
+
orientation: local.orientation,
|
|
18
|
+
loop: local.loop,
|
|
19
|
+
disabled: local.disabled,
|
|
20
|
+
}));
|
|
21
|
+
return (<ToolbarContext.Provider value={made}>
|
|
22
|
+
{/* A toggle group around the toolbar is not the group of the toolbar's toggles. */}
|
|
23
|
+
<ToggleGroupContext.Provider value={null}>
|
|
24
|
+
<Part part={made.root} tag="div" {...rest}/>
|
|
25
|
+
</ToggleGroupContext.Provider>
|
|
26
|
+
</ToolbarContext.Provider>);
|
|
27
|
+
}
|
|
28
|
+
const item = (name, tag) => (props) => {
|
|
29
|
+
const [local, rest] = splitProps(props, ["disabled"]);
|
|
30
|
+
const options = toSignal(() => ({ disabled: local.disabled }));
|
|
31
|
+
const part = useToolbar()[name](() => defined(options.get()));
|
|
32
|
+
return <Part part={part} tag={tag} {...rest}/>;
|
|
33
|
+
};
|
|
34
|
+
const Link = (props) => <Part part={useToolbar().link()} tag="a" {...props}/>;
|
|
35
|
+
const Separator = (props) => (<Part part={useToolbar().separator} tag="div" {...props}/>);
|
|
36
|
+
export const Toolbar = {
|
|
37
|
+
Root,
|
|
38
|
+
Button: item("button", "button"),
|
|
39
|
+
Link,
|
|
40
|
+
Input: item("input", "input"),
|
|
41
|
+
Group: item("group", "div"),
|
|
42
|
+
Separator,
|
|
43
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Autocomplete } from "./combobox.tsx";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { JSX } from "solid-js";
|
|
2
|
+
import type { PartComponentProps } from "./runtime.tsx";
|
|
3
|
+
/** A `<textarea>` as tall as its text. It takes what a `<textarea>` takes. */
|
|
4
|
+
declare function Textarea(props: PartComponentProps): JSX.Element;
|
|
5
|
+
export declare const Autosize: {
|
|
6
|
+
Textarea: typeof Textarea;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Calendar as Controller, CalendarDay, CalendarProps, CalendarWeekday } from "@kirana-ui/core/calendar";
|
|
2
|
+
import type { JSX } from "solid-js";
|
|
3
|
+
import type { PartComponentProps } from "./runtime.tsx";
|
|
4
|
+
declare const Context: import("solid-js").Context<Controller | undefined>;
|
|
5
|
+
/** For a component made of this one's parts: a date picker. */
|
|
6
|
+
export { Context as CalendarContext };
|
|
7
|
+
declare function Root(props: PartComponentProps & Omit<CalendarProps, "id"> & {
|
|
8
|
+
id?: string;
|
|
9
|
+
}): JSX.Element;
|
|
10
|
+
/** Names the month shown, unless it is given something else to say. */
|
|
11
|
+
declare function Heading(props: PartComponentProps): JSX.Element;
|
|
12
|
+
/** Draws its child once for each day of the week, in the locale's order. */
|
|
13
|
+
declare function Weekdays(props: {
|
|
14
|
+
children: (weekday: CalendarWeekday) => JSX.Element;
|
|
15
|
+
}): JSX.Element;
|
|
16
|
+
/** Draws its child once for each week of the month shown. */
|
|
17
|
+
declare function Weeks(props: {
|
|
18
|
+
children: (week: readonly CalendarDay[]) => JSX.Element;
|
|
19
|
+
}): JSX.Element;
|
|
20
|
+
declare function HeadCell(props: PartComponentProps & {
|
|
21
|
+
weekday: CalendarWeekday;
|
|
22
|
+
}): JSX.Element;
|
|
23
|
+
declare function Cell(props: PartComponentProps & {
|
|
24
|
+
date: string;
|
|
25
|
+
}): JSX.Element;
|
|
26
|
+
declare function Day(props: PartComponentProps & {
|
|
27
|
+
date: string;
|
|
28
|
+
}): JSX.Element;
|
|
29
|
+
export declare const Calendar: {
|
|
30
|
+
Root: typeof Root;
|
|
31
|
+
Heading: typeof Heading;
|
|
32
|
+
Previous: (props: PartComponentProps) => JSX.Element;
|
|
33
|
+
Next: (props: PartComponentProps) => JSX.Element;
|
|
34
|
+
Grid: (props: PartComponentProps) => JSX.Element;
|
|
35
|
+
Weekdays: typeof Weekdays;
|
|
36
|
+
HeadCell: typeof HeadCell;
|
|
37
|
+
Weeks: typeof Weeks;
|
|
38
|
+
Cell: typeof Cell;
|
|
39
|
+
Day: typeof Day;
|
|
40
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ChangeDetails, Orientation } from "@kirana-ui/core";
|
|
2
|
+
import type { JSX } from "solid-js";
|
|
3
|
+
import type { PartComponentProps } from "./runtime.tsx";
|
|
4
|
+
declare function Root(props: PartComponentProps & {
|
|
5
|
+
index?: number;
|
|
6
|
+
defaultIndex?: number;
|
|
7
|
+
onIndexChange?: (index: number, details: ChangeDetails) => void;
|
|
8
|
+
orientation?: Orientation;
|
|
9
|
+
loop?: boolean;
|
|
10
|
+
id?: string;
|
|
11
|
+
}): JSX.Element;
|
|
12
|
+
declare function Item(props: PartComponentProps & {
|
|
13
|
+
index: number;
|
|
14
|
+
}): JSX.Element;
|
|
15
|
+
declare function Indicator(props: PartComponentProps & {
|
|
16
|
+
index: number;
|
|
17
|
+
}): JSX.Element;
|
|
18
|
+
export declare const Carousel: {
|
|
19
|
+
Root: typeof Root;
|
|
20
|
+
Viewport: (props: PartComponentProps) => JSX.Element;
|
|
21
|
+
Item: typeof Item;
|
|
22
|
+
Previous: (props: PartComponentProps) => JSX.Element;
|
|
23
|
+
Next: (props: PartComponentProps) => JSX.Element;
|
|
24
|
+
Indicator: typeof Indicator;
|
|
25
|
+
};
|
|
26
|
+
export {};
|
package/types/checkbox.d.ts
CHANGED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { ChangeDetails } from "@kirana-ui/core";
|
|
2
|
+
import type { AutocompleteProps } from "@kirana-ui/core/autocomplete";
|
|
3
|
+
import type { ComboboxProps } from "@kirana-ui/core/combobox";
|
|
4
|
+
import type { JSX } from "solid-js";
|
|
5
|
+
import type { PositionerProps } from "./popover.tsx";
|
|
6
|
+
import type { PartComponentProps } from "./runtime.tsx";
|
|
7
|
+
export type RootProps = {
|
|
8
|
+
value?: unknown;
|
|
9
|
+
defaultValue?: unknown;
|
|
10
|
+
onValueChange?: (value: unknown, details: ChangeDetails) => void;
|
|
11
|
+
inputValue?: string;
|
|
12
|
+
defaultInputValue?: string;
|
|
13
|
+
onInputValueChange?: (value: string, details: ChangeDetails) => void;
|
|
14
|
+
open?: boolean;
|
|
15
|
+
defaultOpen?: boolean;
|
|
16
|
+
onOpenChange?: (open: boolean, details: ChangeDetails) => void;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
multiple?: boolean;
|
|
20
|
+
values?: readonly unknown[];
|
|
21
|
+
defaultValues?: readonly unknown[];
|
|
22
|
+
onValuesChange?: (values: unknown[], details: ChangeDetails) => void;
|
|
23
|
+
inline?: boolean;
|
|
24
|
+
virtualized?: ComboboxProps["virtualized"];
|
|
25
|
+
name?: string;
|
|
26
|
+
form?: string;
|
|
27
|
+
items?: readonly {
|
|
28
|
+
value: unknown;
|
|
29
|
+
label: string;
|
|
30
|
+
}[];
|
|
31
|
+
filter?: ((label: string, query: string) => boolean) | null;
|
|
32
|
+
id?: string;
|
|
33
|
+
children?: JSX.Element;
|
|
34
|
+
};
|
|
35
|
+
declare function Root(props: RootProps): JSX.Element;
|
|
36
|
+
declare function Positioner(props: PositionerProps): JSX.Element;
|
|
37
|
+
/** `label` is what is filtered and what the input shows; the item's text when left out. */
|
|
38
|
+
declare function Item(props: PartComponentProps & {
|
|
39
|
+
value: unknown;
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
label?: string;
|
|
42
|
+
id?: string;
|
|
43
|
+
index?: number;
|
|
44
|
+
}): JSX.Element;
|
|
45
|
+
declare function ItemIndicator(props: PartComponentProps & {
|
|
46
|
+
keepMounted?: boolean;
|
|
47
|
+
}): JSX.Element;
|
|
48
|
+
/** A button that empties the input and the value. Drawn while there is something to clear. */
|
|
49
|
+
declare function Clear(props: PartComponentProps & {
|
|
50
|
+
keepMounted?: boolean;
|
|
51
|
+
}): JSX.Element;
|
|
52
|
+
/** With `multiple`: one chosen value. Its `value` is what its remove button takes away. */
|
|
53
|
+
declare function Chip(props: PartComponentProps & {
|
|
54
|
+
value: unknown;
|
|
55
|
+
}): JSX.Element;
|
|
56
|
+
/** Drawn while no item is shown for what was typed. */
|
|
57
|
+
declare function Empty(props: PartComponentProps): JSX.Element;
|
|
58
|
+
/** Items that belong together, named by their `GroupLabel`. Hidden while none is shown. */
|
|
59
|
+
declare function Group(props: PartComponentProps & {
|
|
60
|
+
id?: string;
|
|
61
|
+
}): JSX.Element;
|
|
62
|
+
export type AutocompleteRootProps = Omit<AutocompleteProps, "id"> & {
|
|
63
|
+
id?: string;
|
|
64
|
+
children?: JSX.Element;
|
|
65
|
+
};
|
|
66
|
+
/** A combobox whose text is the value: the list only suggests. */
|
|
67
|
+
declare function AutocompleteRoot(props: AutocompleteRootProps): JSX.Element;
|
|
68
|
+
export declare const Combobox: {
|
|
69
|
+
Root: typeof Root;
|
|
70
|
+
Input: (props: PartComponentProps) => JSX.Element;
|
|
71
|
+
Trigger: (props: PartComponentProps) => JSX.Element;
|
|
72
|
+
Clear: typeof Clear;
|
|
73
|
+
/** With `multiple`: what holds the chips and the input. */
|
|
74
|
+
Chips: (props: PartComponentProps) => JSX.Element;
|
|
75
|
+
Chip: typeof Chip;
|
|
76
|
+
ChipRemove: (props: PartComponentProps) => JSX.Element;
|
|
77
|
+
Portal: (props: {
|
|
78
|
+
children?: JSX.Element;
|
|
79
|
+
}) => JSX.Element;
|
|
80
|
+
Positioner: typeof Positioner;
|
|
81
|
+
Popup: (props: PartComponentProps) => JSX.Element;
|
|
82
|
+
Group: typeof Group;
|
|
83
|
+
GroupLabel: (props: PartComponentProps) => JSX.Element;
|
|
84
|
+
/** A line between groups. */
|
|
85
|
+
Separator: (props: PartComponentProps) => JSX.Element;
|
|
86
|
+
Item: typeof Item;
|
|
87
|
+
ItemIndicator: typeof ItemIndicator;
|
|
88
|
+
Empty: typeof Empty;
|
|
89
|
+
};
|
|
90
|
+
export declare const Autocomplete: {
|
|
91
|
+
Root: typeof AutocompleteRoot;
|
|
92
|
+
Input: (props: PartComponentProps) => JSX.Element;
|
|
93
|
+
Trigger: (props: PartComponentProps) => JSX.Element;
|
|
94
|
+
Clear: typeof Clear;
|
|
95
|
+
Portal: (props: {
|
|
96
|
+
children?: JSX.Element;
|
|
97
|
+
}) => JSX.Element;
|
|
98
|
+
Positioner: typeof Positioner;
|
|
99
|
+
Popup: (props: PartComponentProps) => JSX.Element;
|
|
100
|
+
Group: typeof Group;
|
|
101
|
+
GroupLabel: (props: PartComponentProps) => JSX.Element;
|
|
102
|
+
Separator: (props: PartComponentProps) => JSX.Element;
|
|
103
|
+
Item: typeof Item;
|
|
104
|
+
Empty: typeof Empty;
|
|
105
|
+
};
|
|
106
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ChangeDetails } from "@kirana-ui/core";
|
|
2
|
+
import type { CommandProps } from "@kirana-ui/core/command";
|
|
3
|
+
import type { JSX } from "solid-js";
|
|
4
|
+
import type { PartComponentProps } from "./runtime.tsx";
|
|
5
|
+
export type RootProps = PartComponentProps & {
|
|
6
|
+
inputValue?: string;
|
|
7
|
+
defaultInputValue?: string;
|
|
8
|
+
onInputValueChange?: (value: string, details: ChangeDetails) => void;
|
|
9
|
+
onSelect?: (value: string, details: ChangeDetails) => void;
|
|
10
|
+
filter?: CommandProps["filter"];
|
|
11
|
+
loop?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
id?: string;
|
|
14
|
+
};
|
|
15
|
+
declare function Root(props: RootProps): JSX.Element;
|
|
16
|
+
/** Drawn while no item is shown for what was typed. */
|
|
17
|
+
declare function Empty(props: PartComponentProps): JSX.Element;
|
|
18
|
+
/** Items under a `<Command.GroupHeading>`. Hidden while none of them is shown. */
|
|
19
|
+
declare function Group(props: PartComponentProps & {
|
|
20
|
+
id?: string;
|
|
21
|
+
}): JSX.Element;
|
|
22
|
+
declare function GroupHeading(props: PartComponentProps): JSX.Element;
|
|
23
|
+
/** `label` is what is filtered, the item's text when left out; `keywords` are other words for it. */
|
|
24
|
+
declare function Item(props: PartComponentProps & {
|
|
25
|
+
value: string;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
label?: string;
|
|
28
|
+
keywords?: readonly string[];
|
|
29
|
+
id?: string;
|
|
30
|
+
}): JSX.Element;
|
|
31
|
+
/** A line between groups: gone while something is typed, unless `alwaysRender`. */
|
|
32
|
+
declare function Separator(props: PartComponentProps & {
|
|
33
|
+
alwaysRender?: boolean;
|
|
34
|
+
}): JSX.Element;
|
|
35
|
+
export declare const Command: {
|
|
36
|
+
Root: typeof Root;
|
|
37
|
+
Input: (props: PartComponentProps) => JSX.Element;
|
|
38
|
+
List: (props: PartComponentProps) => JSX.Element;
|
|
39
|
+
Empty: typeof Empty;
|
|
40
|
+
Group: typeof Group;
|
|
41
|
+
GroupHeading: typeof GroupHeading;
|
|
42
|
+
Item: typeof Item;
|
|
43
|
+
Separator: typeof Separator;
|
|
44
|
+
};
|
|
45
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ContextMenu } from "./menu.tsx";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { DateField as Controller, DateFieldProps, DateFieldSegment } from "@kirana-ui/core/date-field";
|
|
2
|
+
import type { JSX } from "solid-js";
|
|
3
|
+
import type { PartComponentProps } from "./runtime.tsx";
|
|
4
|
+
declare const Context: import("solid-js").Context<Controller | undefined>;
|
|
5
|
+
/** For a component made of this one's parts: a date picker. */
|
|
6
|
+
export { Context as DateFieldContext };
|
|
7
|
+
declare function Root(props: PartComponentProps & Omit<DateFieldProps, "id"> & {
|
|
8
|
+
id?: string;
|
|
9
|
+
}): JSX.Element;
|
|
10
|
+
/** Draws its child once for each piece of the date, in the locale's order. */
|
|
11
|
+
declare function Segments(props: {
|
|
12
|
+
children: (segment: DateFieldSegment) => JSX.Element;
|
|
13
|
+
}): JSX.Element;
|
|
14
|
+
/** One piece: a part that is typed, or what stands between two. It writes its own text. */
|
|
15
|
+
declare function Segment(props: PartComponentProps & {
|
|
16
|
+
segment: DateFieldSegment;
|
|
17
|
+
}): JSX.Element;
|
|
18
|
+
export declare const DateField: {
|
|
19
|
+
Root: typeof Root;
|
|
20
|
+
Segments: typeof Segments;
|
|
21
|
+
Segment: typeof Segment;
|
|
22
|
+
Input: (props: PartComponentProps) => JSX.Element;
|
|
23
|
+
};
|