@kirana-ui/solid 0.2.0 → 0.3.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/dom/avatar.js +36 -11
- package/dom/calendar.js +66 -11
- package/dom/checkbox-group-context.js +3 -0
- package/dom/checkbox-group.js +38 -0
- package/dom/checkbox.js +6 -2
- package/dom/combobox.js +53 -3
- package/dom/command.js +2 -1
- package/dom/date-picker.js +7 -1
- package/dom/dialog.js +8 -1
- package/dom/index.js +1 -0
- package/dom/number-field.js +36 -3
- package/dom/otp.js +2 -1
- package/dom/popover.js +18 -2
- package/dom/primitive.js +92 -0
- package/dom/radio-group.js +3 -2
- package/dom/select.js +1 -0
- package/dom/slider.js +1 -1
- package/llms.txt +312 -82
- package/package.json +18 -2
- package/server/avatar.js +36 -11
- package/server/calendar.js +66 -11
- package/server/checkbox-group-context.js +3 -0
- package/server/checkbox-group.js +38 -0
- package/server/checkbox.js +6 -2
- package/server/combobox.js +53 -3
- package/server/command.js +2 -1
- package/server/date-picker.js +7 -1
- package/server/dialog.js +8 -1
- package/server/index.js +1 -0
- package/server/number-field.js +36 -3
- package/server/otp.js +2 -1
- package/server/popover.js +18 -2
- package/server/primitive.js +92 -0
- package/server/radio-group.js +3 -2
- package/server/select.js +1 -0
- package/server/slider.js +1 -1
- package/skills/kirana-ui-primitives/SKILL.md +29 -8
- package/src/avatar.jsx +16 -9
- package/src/calendar.jsx +62 -10
- package/src/checkbox-group-context.js +3 -0
- package/src/checkbox-group.jsx +33 -0
- package/src/checkbox.jsx +5 -1
- package/src/combobox.jsx +50 -1
- package/src/command.jsx +2 -0
- package/src/date-picker.jsx +6 -0
- package/src/dialog.jsx +5 -1
- package/src/index.js +1 -0
- package/src/number-field.jsx +23 -3
- package/src/otp.jsx +2 -0
- package/src/popover.jsx +15 -1
- package/src/primitive.jsx +81 -0
- package/src/radio-group.jsx +2 -2
- package/src/select.jsx +1 -0
- package/src/slider.jsx +1 -0
- package/types/alert-dialog.d.ts +1 -1
- package/types/autocomplete.d.ts +1 -1
- package/types/avatar.d.ts +5 -4
- package/types/calendar.d.ts +15 -3
- package/types/checkbox-group-context.d.ts +3 -0
- package/types/checkbox-group.d.ts +13 -0
- package/types/checkbox.d.ts +1 -0
- package/types/combobox.d.ts +41 -2
- package/types/command.d.ts +2 -0
- package/types/date-picker.d.ts +2 -1
- package/types/dialog.d.ts +5 -0
- package/types/index.d.ts +5 -2
- package/types/number-field.d.ts +9 -1
- package/types/otp.d.ts +1 -0
- package/types/popover.d.ts +17 -3
- package/types/primitive.d.ts +50 -0
- package/types/radio-group.d.ts +3 -0
package/src/number-field.jsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { within } from "@kirana-ui/core";
|
|
1
|
+
import { defined, within } from "@kirana-ui/core";
|
|
2
2
|
import { createNumberField } from "@kirana-ui/core/number-field";
|
|
3
|
-
import { Show, createContext, createUniqueId, splitProps, useContext } from "solid-js";
|
|
3
|
+
import { Show, createComputed, createContext, createUniqueId, splitProps, useContext, } from "solid-js";
|
|
4
4
|
import { FieldContext } from "./field-context.js";
|
|
5
|
-
import { Part, controller, fromSignal } from "./runtime.jsx";
|
|
5
|
+
import { Part, Portal, controller, fromSignal } from "./runtime.jsx";
|
|
6
6
|
const Context = createContext();
|
|
7
7
|
function useNumberField() {
|
|
8
8
|
const made = useContext(Context);
|
|
@@ -66,8 +66,28 @@ function Root(props) {
|
|
|
66
66
|
</Context.Provider>);
|
|
67
67
|
}
|
|
68
68
|
const part = (name, tag) => (props) => <Part of={useNumberField()[name]} tag={tag} {...props}/>;
|
|
69
|
+
/** Pressed and dragged to change the number; `direction`, `pixelSensitivity`, `teleportDistance`. */
|
|
70
|
+
function ScrubArea(props) {
|
|
71
|
+
const [local, rest] = splitProps(props, [
|
|
72
|
+
"direction",
|
|
73
|
+
"pixelSensitivity",
|
|
74
|
+
"teleportDistance",
|
|
75
|
+
]);
|
|
76
|
+
const made = useNumberField();
|
|
77
|
+
createComputed(() => made.scrub.set(defined({ ...local })));
|
|
78
|
+
return <Part of={made.scrubArea} tag="span" {...rest}/>;
|
|
79
|
+
}
|
|
80
|
+
/** Drawn in place of the pointer while it is locked for a drag, at the end of `<body>`. */
|
|
81
|
+
function ScrubAreaCursor(props) {
|
|
82
|
+
const made = useNumberField();
|
|
83
|
+
return (<Portal mounted={made.scrubAreaCursor.mounted}>
|
|
84
|
+
<Part of={made.scrubAreaCursor.part} tag="span" {...props}/>
|
|
85
|
+
</Portal>);
|
|
86
|
+
}
|
|
69
87
|
export const NumberField = {
|
|
70
88
|
Root,
|
|
89
|
+
ScrubArea,
|
|
90
|
+
ScrubAreaCursor,
|
|
71
91
|
Group: part("group", "div"),
|
|
72
92
|
Input: part("input", "input"),
|
|
73
93
|
Increment: part("increment", "button"),
|
package/src/otp.jsx
CHANGED
|
@@ -17,6 +17,7 @@ function Root(props) {
|
|
|
17
17
|
"onValueChange",
|
|
18
18
|
"onComplete",
|
|
19
19
|
"mode",
|
|
20
|
+
"pattern",
|
|
20
21
|
"disabled",
|
|
21
22
|
"name",
|
|
22
23
|
"form",
|
|
@@ -29,6 +30,7 @@ function Root(props) {
|
|
|
29
30
|
value: local.value,
|
|
30
31
|
defaultValue: local.defaultValue,
|
|
31
32
|
mode: local.mode,
|
|
33
|
+
pattern: local.pattern,
|
|
32
34
|
disabled: local.disabled,
|
|
33
35
|
name: local.name,
|
|
34
36
|
form: local.form,
|
package/src/popover.jsx
CHANGED
|
@@ -20,6 +20,7 @@ function Root(props) {
|
|
|
20
20
|
const made = controller(createPopover, () => ({
|
|
21
21
|
id: props.id ?? generated,
|
|
22
22
|
open: props.open,
|
|
23
|
+
modal: props.modal,
|
|
23
24
|
defaultOpen: props.defaultOpen,
|
|
24
25
|
onOpenChange: (open, details) => props.onOpenChange?.(open, details),
|
|
25
26
|
}));
|
|
@@ -37,6 +38,11 @@ export function positioned(props, positioning) {
|
|
|
37
38
|
"sideOffset",
|
|
38
39
|
"alignOffset",
|
|
39
40
|
"collisionPadding",
|
|
41
|
+
"collisionBoundary",
|
|
42
|
+
"collisionAvoidance",
|
|
43
|
+
"sticky",
|
|
44
|
+
"arrowPadding",
|
|
45
|
+
"positionMethod",
|
|
40
46
|
"anchor",
|
|
41
47
|
]);
|
|
42
48
|
createComputed(() => {
|
|
@@ -55,12 +61,20 @@ function Positioner(props) {
|
|
|
55
61
|
return <Part of={made.positioner} tag="div" {...positioned(props, made.positioning)}/>;
|
|
56
62
|
}
|
|
57
63
|
const part = (name, tag) => (props) => <Part of={usePopover()[name]} tag={tag} {...props}/>;
|
|
64
|
+
function Trigger(props) {
|
|
65
|
+
const [local, rest] = splitProps(props, ["openOnHover", "delay", "closeDelay"]);
|
|
66
|
+
const made = usePopover();
|
|
67
|
+
createComputed(() => made.hovering.set(defined({ ...local })));
|
|
68
|
+
return <Part of={made.trigger} tag="button" {...rest}/>;
|
|
69
|
+
}
|
|
58
70
|
export const Popover = {
|
|
59
71
|
Root,
|
|
60
72
|
Portal,
|
|
73
|
+
Backdrop: part("backdrop", "div"),
|
|
61
74
|
Positioner,
|
|
62
|
-
Trigger
|
|
75
|
+
Trigger,
|
|
63
76
|
Popup: part("popup", "div"),
|
|
77
|
+
Arrow: part("arrow", "div"),
|
|
64
78
|
Title: part("title", "h2"),
|
|
65
79
|
Description: part("description", "p"),
|
|
66
80
|
Close: part("close", "button"),
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { mergeProps as layer, stateAttributes } from "@kirana-ui/core";
|
|
2
|
+
import { Show, children, createMemo, splitProps } from "solid-js";
|
|
3
|
+
import { Dynamic } from "solid-js/web";
|
|
4
|
+
/**
|
|
5
|
+
* A plain element of one's own (a badge, a breadcrumb's link) with the composition a part has:
|
|
6
|
+
* `as` for another tag (a `div` unless said), or `render` for the caller's own element, given the
|
|
7
|
+
* props to spread and the state. `state` is written as `data-*` attributes under the attributes
|
|
8
|
+
* given. Merge the component's own props with its caller's through `mergeProps`, as a part's
|
|
9
|
+
* are merged.
|
|
10
|
+
*/
|
|
11
|
+
export function Primitive(props) {
|
|
12
|
+
const [local, rest] = splitProps(props, [
|
|
13
|
+
"as",
|
|
14
|
+
"render",
|
|
15
|
+
"state",
|
|
16
|
+
"children",
|
|
17
|
+
]);
|
|
18
|
+
const marks = () => stateAttributes(local.state ?? {});
|
|
19
|
+
return (<Show when={local.render} fallback={<Dynamic component={local.as ?? "div"} {...marks()} {...rest}>
|
|
20
|
+
{local.children}
|
|
21
|
+
</Dynamic>}>
|
|
22
|
+
{(render) => {
|
|
23
|
+
// Resolved once, as a part's are: a change of the props hands the same nodes over again.
|
|
24
|
+
const held = children(() => local.children);
|
|
25
|
+
const handed = createMemo(() => {
|
|
26
|
+
const given = { ...marks() };
|
|
27
|
+
for (const key of Object.keys(rest))
|
|
28
|
+
given[key] = rest[key];
|
|
29
|
+
return { ...given, children: held() };
|
|
30
|
+
});
|
|
31
|
+
return render()(handed, () => local.state ?? {});
|
|
32
|
+
}}
|
|
33
|
+
</Show>);
|
|
34
|
+
}
|
|
35
|
+
/** One key of several sets, by a part's rule. */
|
|
36
|
+
function mergedValue(sets, key) {
|
|
37
|
+
if (key === "ref") {
|
|
38
|
+
// Solid hands a component a function whatever was written: each set's gets the element.
|
|
39
|
+
const refs = sets.map((set) => set?.ref).filter((ref) => typeof ref === "function");
|
|
40
|
+
if (refs.length < 2)
|
|
41
|
+
return refs[0];
|
|
42
|
+
return (element) => {
|
|
43
|
+
for (const ref of refs)
|
|
44
|
+
ref(element);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
let merged = {};
|
|
48
|
+
for (const set of sets)
|
|
49
|
+
if (set && key in set)
|
|
50
|
+
merged = layer(merged, { [key]: set[key] });
|
|
51
|
+
return merged[key];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Several sets of props as one, for a component's own props and its caller's: a later set
|
|
55
|
+
* wins an attribute it gives (one it leaves `undefined` stays), classes join, styles are
|
|
56
|
+
* merged property by property, the handlers of an event run in order until one calls
|
|
57
|
+
* `event.preventKiranaHandler()`, which stops those after it, and every `ref` gets the
|
|
58
|
+
* element. It reads its sets when a prop is read, so a component's props stay reactive: spread
|
|
59
|
+
* it (`<Primitive {...mergeProps({ class: "badge" }, props)} />`). Not solid-js's
|
|
60
|
+
* `mergeProps`, where a later class replaces an earlier one: import one under another name
|
|
61
|
+
* where both are used.
|
|
62
|
+
*/
|
|
63
|
+
export function mergeProps(...sets) {
|
|
64
|
+
const keys = () => {
|
|
65
|
+
const all = new Set();
|
|
66
|
+
for (const set of sets)
|
|
67
|
+
if (set)
|
|
68
|
+
for (const key of Object.keys(set))
|
|
69
|
+
all.add(key);
|
|
70
|
+
return [...all];
|
|
71
|
+
};
|
|
72
|
+
const given = sets;
|
|
73
|
+
return new Proxy({}, {
|
|
74
|
+
get: (_, key) => (typeof key === "string" ? mergedValue(given, key) : undefined),
|
|
75
|
+
has: (_, key) => typeof key === "string" && keys().includes(key),
|
|
76
|
+
ownKeys: () => keys(),
|
|
77
|
+
getOwnPropertyDescriptor: (_, key) => typeof key === "string" && keys().includes(key)
|
|
78
|
+
? { configurable: true, enumerable: true, get: () => mergedValue(given, key) }
|
|
79
|
+
: undefined,
|
|
80
|
+
});
|
|
81
|
+
}
|
package/src/radio-group.jsx
CHANGED
|
@@ -42,10 +42,10 @@ function Root(props) {
|
|
|
42
42
|
</Context.Provider>);
|
|
43
43
|
}
|
|
44
44
|
function Item(props) {
|
|
45
|
-
const [local, rest] = splitProps(props, ["value", "disabled", "children"]);
|
|
45
|
+
const [local, rest] = splitProps(props, ["value", "disabled", "id", "children"]);
|
|
46
46
|
// An item is its value for as long as it is in the page.
|
|
47
47
|
const value = untrack(() => local.value);
|
|
48
|
-
const options = toSignal(() => ({ disabled: local.disabled }));
|
|
48
|
+
const options = toSignal(() => ({ disabled: local.disabled, id: local.id }));
|
|
49
49
|
const read = () => defined(options.get());
|
|
50
50
|
const group = useRadioGroup();
|
|
51
51
|
return (<ItemContext.Provider value={value}>
|
package/src/select.jsx
CHANGED
package/src/slider.jsx
CHANGED
package/types/alert-dialog.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { AlertDialog } from "./dialog.tsx";
|
|
2
|
-
export type { AlertRootProps as RootProps, BackdropProps, CloseProps, DescriptionProps, PopupProps, PortalProps, TitleProps, TriggerProps, } from "./dialog.tsx";
|
|
2
|
+
export type { AlertRootProps as RootProps, BackdropProps, CloseProps, DescriptionProps, PopupProps, PortalProps, TitleProps, TriggerProps, ViewportProps, } from "./dialog.tsx";
|
package/types/autocomplete.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { Autocomplete } from "./combobox.tsx";
|
|
2
|
-
export type { AutocompleteRootProps as RootProps, ClearProps, EmptyProps, GroupLabelProps, GroupProps, InputProps, ItemProps, ListProps, PopupProps, PortalProps, PositionerProps, SeparatorProps, TriggerProps, } from "./combobox.tsx";
|
|
2
|
+
export type { AutocompleteRootProps as RootProps, ClearProps, CollectionProps, EmptyProps, GroupLabelProps, GroupProps, InputProps, ItemProps, ListProps, PopupProps, PortalProps, PositionerProps, SeparatorProps, StatusProps, TriggerProps, } from "./combobox.tsx";
|
package/types/avatar.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { StateOf } from "@kirana-ui/core";
|
|
2
|
+
import type { AvatarFallbackProps, AvatarImageProps } from "@kirana-ui/core/avatar";
|
|
2
3
|
import type { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
3
4
|
import type { JSX } from "solid-js";
|
|
4
5
|
import type { PartComponentProps } from "./runtime.tsx";
|
|
@@ -8,11 +9,11 @@ declare function Root(props: RootProps): JSX.Element;
|
|
|
8
9
|
export type ImageProps = PartComponentProps<"img", StateOf<Parts["image"]>, {
|
|
9
10
|
/** The picture's address: the element is in the page once it has loaded. */
|
|
10
11
|
src?: string;
|
|
11
|
-
}>;
|
|
12
|
-
/** The picture: in the page once `src` has loaded
|
|
12
|
+
} & AvatarImageProps>;
|
|
13
|
+
/** The picture: in the page once `src` has loaded, or all along with `keepMounted`. */
|
|
13
14
|
declare function Image(props: ImageProps): JSX.Element;
|
|
14
|
-
export type FallbackProps = PartComponentProps<"span", StateOf<Parts["fallback"]
|
|
15
|
-
/** What shows until the picture has loaded, or when it cannot. */
|
|
15
|
+
export type FallbackProps = PartComponentProps<"span", StateOf<Parts["fallback"]>, AvatarFallbackProps>;
|
|
16
|
+
/** What shows until the picture has loaded, or when it cannot; after `delay`, when given one. */
|
|
16
17
|
declare function Fallback(props: FallbackProps): JSX.Element;
|
|
17
18
|
export declare const Avatar: {
|
|
18
19
|
Root: typeof Root;
|
package/types/calendar.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StateOf } from "@kirana-ui/core";
|
|
2
|
-
import type { Calendar as Controller, CalendarDay, CalendarProps, CalendarWeekday } from "@kirana-ui/core/calendar";
|
|
2
|
+
import type { Calendar as Controller, CalendarDay, CalendarMode, CalendarMonth, CalendarProps, CalendarWeekday } from "@kirana-ui/core/calendar";
|
|
3
3
|
import type { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
4
4
|
import type { JSX } from "solid-js";
|
|
5
5
|
import type { PartComponentProps } from "./runtime.tsx";
|
|
@@ -11,16 +11,25 @@ type Parts = Vocabulary["calendar"];
|
|
|
11
11
|
declare const Context: import("solid-js").Context<Controller | undefined>;
|
|
12
12
|
/** For a component made of this one's parts: a date picker. */
|
|
13
13
|
export { Context as CalendarContext };
|
|
14
|
-
|
|
14
|
+
/** `value` and `onValueChange` are typed by `mode`: a day, a range, or a list of days. */
|
|
15
|
+
export type RootProps<Mode extends CalendarMode = "single"> = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<CalendarProps<Mode>, "id"> & {
|
|
15
16
|
id?: string;
|
|
16
17
|
}>;
|
|
17
|
-
declare function Root(props: RootProps): JSX.Element;
|
|
18
|
+
declare function Root<Mode extends CalendarMode = "single">(props: RootProps<Mode>): JSX.Element;
|
|
18
19
|
export type HeadingProps = PartComponentProps<"div", StateOf<Parts["heading"]>>;
|
|
19
20
|
/** Names the month shown, unless it is given something else to say. */
|
|
20
21
|
declare function Heading(props: HeadingProps): JSX.Element;
|
|
21
22
|
export type PreviousProps = PartComponentProps<"button", StateOf<Parts["previous"]>>;
|
|
22
23
|
export type NextProps = PartComponentProps<"button", StateOf<Parts["next"]>>;
|
|
23
24
|
export type GridProps = PartComponentProps<"table", StateOf<Parts["grid"]>>;
|
|
25
|
+
export type MonthsProps = {
|
|
26
|
+
children: (month: CalendarMonth) => JSX.Element;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Draws its child once for each month shown (`months` on the root), side by side: the parts
|
|
30
|
+
* inside each are that month's. Left out for one month.
|
|
31
|
+
*/
|
|
32
|
+
declare function Months(props: MonthsProps): JSX.Element;
|
|
24
33
|
export type WeekdaysProps = {
|
|
25
34
|
children: (weekday: CalendarWeekday) => JSX.Element;
|
|
26
35
|
};
|
|
@@ -43,15 +52,18 @@ export type DayProps = PartComponentProps<"button", StateOf<Parts["day"]>, {
|
|
|
43
52
|
date: string;
|
|
44
53
|
}>;
|
|
45
54
|
declare function Day(props: DayProps): JSX.Element;
|
|
55
|
+
export type InputProps = PartComponentProps<"input", StateOf<Parts["input"]>>;
|
|
46
56
|
export declare const Calendar: {
|
|
47
57
|
Root: typeof Root;
|
|
48
58
|
Heading: typeof Heading;
|
|
49
59
|
Previous: (props: PreviousProps) => JSX.Element;
|
|
50
60
|
Next: (props: NextProps) => JSX.Element;
|
|
61
|
+
Months: typeof Months;
|
|
51
62
|
Grid: (props: GridProps) => JSX.Element;
|
|
52
63
|
Weekdays: typeof Weekdays;
|
|
53
64
|
HeadCell: typeof HeadCell;
|
|
54
65
|
Weeks: typeof Weeks;
|
|
55
66
|
Cell: typeof Cell;
|
|
56
67
|
Day: typeof Day;
|
|
68
|
+
Input: (props: InputProps) => JSX.Element;
|
|
57
69
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { StateOf } from "@kirana-ui/core";
|
|
2
|
+
import type { CheckboxGroupProps as CoreProps } from "@kirana-ui/core/checkbox-group";
|
|
3
|
+
import type { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
4
|
+
import type { JSX } from "solid-js";
|
|
5
|
+
import type { PartComponentProps } from "./runtime.tsx";
|
|
6
|
+
export type CheckboxGroupProps = PartComponentProps<"div", StateOf<Vocabulary["checkboxGroup"]["root"]>, Omit<CoreProps, "id"> & {
|
|
7
|
+
id?: string;
|
|
8
|
+
}>;
|
|
9
|
+
/**
|
|
10
|
+
* Checkboxes that hold one list of values. Each `<Checkbox.Root value>` inside it is checked
|
|
11
|
+
* while the list has its value; with `allValues`, a `<Checkbox.Root parent>` stands for them all.
|
|
12
|
+
*/
|
|
13
|
+
export declare function CheckboxGroup(props: CheckboxGroupProps): JSX.Element;
|
package/types/checkbox.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export type RootProps = PartComponentProps<"span", StateOf<Parts["root"]>, {
|
|
|
8
8
|
defaultChecked?: boolean;
|
|
9
9
|
onCheckedChange?: (checked: boolean, details: ChangeDetails) => void;
|
|
10
10
|
indeterminate?: boolean;
|
|
11
|
+
parent?: boolean;
|
|
11
12
|
disabled?: boolean;
|
|
12
13
|
readOnly?: boolean;
|
|
13
14
|
required?: boolean;
|
package/types/combobox.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { StateOf } from "@kirana-ui/core";
|
|
2
2
|
import type { AutocompleteProps } from "@kirana-ui/core/autocomplete";
|
|
3
|
-
import type { ComboboxProps } from "@kirana-ui/core/combobox";
|
|
3
|
+
import type { ComboboxEntry, ComboboxProps } from "@kirana-ui/core/combobox";
|
|
4
4
|
import type { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
5
|
-
import type { JSX } from "solid-js";
|
|
5
|
+
import type { Accessor, JSX } from "solid-js";
|
|
6
6
|
import type { PortalProps, PositionerOptions } from "./popover.tsx";
|
|
7
7
|
import type { PartComponentProps } from "./runtime.tsx";
|
|
8
8
|
type Parts = Vocabulary["combobox"];
|
|
@@ -57,6 +57,35 @@ export type ChipsProps = PartComponentProps<"div", StateOf<Parts["chips"]>>;
|
|
|
57
57
|
export type PopupProps = PartComponentProps<"div", StateOf<Parts["popup"]>>;
|
|
58
58
|
export type ListProps = PartComponentProps<"div", StateOf<Parts["list"]>>;
|
|
59
59
|
export type SeparatorProps = PartComponentProps<"div", StateOf<Parts["separator"]>>;
|
|
60
|
+
export type StatusProps = PartComponentProps<"div", StateOf<Parts["status"]>>;
|
|
61
|
+
export type ValueProps<Chosen = unknown> = {
|
|
62
|
+
/** Shown while nothing is chosen. */
|
|
63
|
+
placeholder?: JSX.Element;
|
|
64
|
+
/**
|
|
65
|
+
* What to show in place of the label. A function is given the value and its label, each to
|
|
66
|
+
* be called where it is read (`null` and `undefined` while nothing is chosen); with
|
|
67
|
+
* `multiple`, the values and their labels, in the order they were chosen.
|
|
68
|
+
*/
|
|
69
|
+
children?: JSX.Element | ((value: Accessor<Chosen>, label: Accessor<Chosen extends readonly unknown[] ? readonly string[] : string | undefined>) => JSX.Element);
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* The chosen value's label, or `placeholder` while nothing is chosen; with `multiple`, the
|
|
73
|
+
* chosen labels with commas between. For a button that is the combobox, its input inside the
|
|
74
|
+
* popup. It draws no element.
|
|
75
|
+
*/
|
|
76
|
+
declare function Value<Chosen = unknown>(props: ValueProps<Chosen>): JSX.Element;
|
|
77
|
+
export type CollectionProps<Value = unknown> = {
|
|
78
|
+
/** A group the root's `items` gave: its items left are then what is drawn. */
|
|
79
|
+
of?: ComboboxEntry<Value> | undefined;
|
|
80
|
+
/** Drawn once for each item left, or for each group that has items left. */
|
|
81
|
+
children: (entry: ComboboxEntry<Value>) => JSX.Element;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Draws the list from the root's `items`: its child once for each item left for what was
|
|
85
|
+
* typed, or for each group that has items left; with `of`, for each of that group's. The root
|
|
86
|
+
* then filters, and no item hides itself. It draws no element.
|
|
87
|
+
*/
|
|
88
|
+
declare function Collection<Value = unknown>(props: CollectionProps<Value>): JSX.Element;
|
|
60
89
|
export type AutocompleteRootProps = Omit<AutocompleteProps, "id"> & {
|
|
61
90
|
id?: string;
|
|
62
91
|
children?: JSX.Element;
|
|
@@ -67,6 +96,7 @@ export declare const Combobox: {
|
|
|
67
96
|
Root: typeof Root;
|
|
68
97
|
Input: (props: InputProps) => JSX.Element;
|
|
69
98
|
Trigger: (props: TriggerProps) => JSX.Element;
|
|
99
|
+
Value: typeof Value;
|
|
70
100
|
Clear: typeof Clear;
|
|
71
101
|
/** With `multiple`: what holds the chips and the input. */
|
|
72
102
|
Chips: (props: ChipsProps) => JSX.Element;
|
|
@@ -80,6 +110,7 @@ export declare const Combobox: {
|
|
|
80
110
|
* is then the listbox.
|
|
81
111
|
*/
|
|
82
112
|
List: (props: ListProps) => JSX.Element;
|
|
113
|
+
Collection: typeof Collection;
|
|
83
114
|
Group: typeof Group;
|
|
84
115
|
GroupLabel: (props: GroupLabelProps) => JSX.Element;
|
|
85
116
|
/** A line between groups. */
|
|
@@ -87,6 +118,12 @@ export declare const Combobox: {
|
|
|
87
118
|
Item: typeof Item;
|
|
88
119
|
ItemIndicator: typeof ItemIndicator;
|
|
89
120
|
Empty: typeof Empty;
|
|
121
|
+
/**
|
|
122
|
+
* Says how the list stands ("3 results", "Loading") to software that reads the page, as its
|
|
123
|
+
* text changes. Keep it in the page and change what it holds: inside the popup, or beside
|
|
124
|
+
* the input.
|
|
125
|
+
*/
|
|
126
|
+
Status: (props: StatusProps) => JSX.Element;
|
|
90
127
|
};
|
|
91
128
|
export declare const Autocomplete: {
|
|
92
129
|
Root: typeof AutocompleteRoot;
|
|
@@ -97,9 +134,11 @@ export declare const Autocomplete: {
|
|
|
97
134
|
Positioner: typeof Positioner;
|
|
98
135
|
Popup: (props: PopupProps) => JSX.Element;
|
|
99
136
|
List: (props: ListProps) => JSX.Element;
|
|
137
|
+
Collection: typeof Collection;
|
|
100
138
|
Group: typeof Group;
|
|
101
139
|
GroupLabel: (props: GroupLabelProps) => JSX.Element;
|
|
102
140
|
Separator: (props: SeparatorProps) => JSX.Element;
|
|
103
141
|
Item: typeof Item;
|
|
104
142
|
Empty: typeof Empty;
|
|
143
|
+
Status: (props: StatusProps) => JSX.Element;
|
|
105
144
|
};
|
package/types/command.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, {
|
|
|
12
12
|
onSelect?: (value: string, details: ChangeDetails) => void;
|
|
13
13
|
filter?: CommandProps["filter"];
|
|
14
14
|
loop?: boolean;
|
|
15
|
+
/** Whether the first item shown is highlighted from the start. Default: `true`. */
|
|
16
|
+
autoHighlight?: boolean;
|
|
15
17
|
disabled?: boolean;
|
|
16
18
|
id?: string;
|
|
17
19
|
}>;
|
package/types/date-picker.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
|
4
4
|
import type { JSX } from "solid-js";
|
|
5
5
|
import type { PartComponentProps } from "./runtime.tsx";
|
|
6
6
|
type Parts = Vocabulary["datePicker"];
|
|
7
|
-
export type { CellProps, DayProps, GridProps, HeadCellProps, HeadingProps, NextProps, PreviousProps, WeekdaysProps, WeeksProps, } from "./calendar.tsx";
|
|
7
|
+
export type { CellProps, DayProps, GridProps, HeadCellProps, HeadingProps, MonthsProps, NextProps, PreviousProps, WeekdaysProps, WeeksProps, } from "./calendar.tsx";
|
|
8
8
|
export type { InputProps, SegmentProps, SegmentsProps } from "./date-field.tsx";
|
|
9
9
|
export type { PopupProps, PortalProps, PositionerProps, TriggerProps } from "./popover.tsx";
|
|
10
10
|
export type RootProps = Omit<DatePickerProps, "id"> & {
|
|
@@ -31,6 +31,7 @@ export declare const DatePicker: {
|
|
|
31
31
|
Heading: (props: import("./calendar.tsx").HeadingProps) => JSX.Element;
|
|
32
32
|
Previous: (props: import("./calendar.tsx").PreviousProps) => JSX.Element;
|
|
33
33
|
Next: (props: import("./calendar.tsx").NextProps) => JSX.Element;
|
|
34
|
+
Months: (props: import("./calendar.tsx").MonthsProps) => JSX.Element;
|
|
34
35
|
Grid: (props: import("./calendar.tsx").GridProps) => JSX.Element;
|
|
35
36
|
Weekdays: (props: import("./calendar.tsx").WeekdaysProps) => JSX.Element;
|
|
36
37
|
HeadCell: (props: import("./calendar.tsx").HeadCellProps) => JSX.Element;
|
package/types/dialog.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export type PortalProps = {
|
|
|
20
20
|
};
|
|
21
21
|
export type TriggerProps = PartComponentProps<"button", StateOf<Parts["trigger"]>>;
|
|
22
22
|
export type BackdropProps = PartComponentProps<"div", StateOf<Parts["backdrop"]>>;
|
|
23
|
+
export type ViewportProps = PartComponentProps<"div", StateOf<Parts["viewport"]>>;
|
|
23
24
|
export type PopupProps = PartComponentProps<"div", StateOf<Parts["popup"]>>;
|
|
24
25
|
export type TitleProps = PartComponentProps<"h2", StateOf<Parts["title"]>>;
|
|
25
26
|
export type DescriptionProps = PartComponentProps<"p", StateOf<Parts["description"]>>;
|
|
@@ -31,6 +32,8 @@ export declare const Dialog: {
|
|
|
31
32
|
Portal: (props: PortalProps) => JSX.Element;
|
|
32
33
|
Trigger: (props: TriggerProps) => JSX.Element;
|
|
33
34
|
Backdrop: (props: BackdropProps) => JSX.Element;
|
|
35
|
+
/** What a long dialog scrolls in, around its popup: it may be left out. */
|
|
36
|
+
Viewport: (props: ViewportProps) => JSX.Element;
|
|
34
37
|
Popup: (props: PopupProps) => JSX.Element;
|
|
35
38
|
Title: (props: TitleProps) => JSX.Element;
|
|
36
39
|
Description: (props: DescriptionProps) => JSX.Element;
|
|
@@ -42,6 +45,8 @@ export declare const AlertDialog: {
|
|
|
42
45
|
Portal: (props: PortalProps) => JSX.Element;
|
|
43
46
|
Trigger: (props: TriggerProps) => JSX.Element;
|
|
44
47
|
Backdrop: (props: BackdropProps) => JSX.Element;
|
|
48
|
+
/** What a long dialog scrolls in, around its popup: it may be left out. */
|
|
49
|
+
Viewport: (props: ViewportProps) => JSX.Element;
|
|
45
50
|
Popup: (props: PopupProps) => JSX.Element;
|
|
46
51
|
Title: (props: TitleProps) => JSX.Element;
|
|
47
52
|
Description: (props: DescriptionProps) => JSX.Element;
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { Accordion } from "./accordion.tsx";
|
|
2
2
|
export { Checkbox } from "./checkbox.tsx";
|
|
3
|
+
export { CheckboxGroup } from "./checkbox-group.tsx";
|
|
3
4
|
export { Collapsible } from "./collapsible.tsx";
|
|
4
5
|
export { AlertDialog, Dialog, Drawer } from "./dialog.tsx";
|
|
5
6
|
export { MessageScroller } from "./message-scroller.tsx";
|
|
@@ -49,8 +50,8 @@ export { DirectionProvider, useDirection } from "./direction.tsx";
|
|
|
49
50
|
export type { DirectionProviderProps } from "./direction.tsx";
|
|
50
51
|
export { PortalProvider } from "./runtime.tsx";
|
|
51
52
|
export type { PortalProviderProps } from "./runtime.tsx";
|
|
52
|
-
export type { Align, Anchor, AnchorOption, Bindable, ChangeDetails, ChangeSource, ComponentDefinition, Direction, ItemLabels, ListCollection, Orientation, Part, PartDefinition, PartProps, PartState, PartStyle, PhysicalSide, PositionOptions, ReadonlySignal, Side, Signal, StateDefinition, StateOf, } from "@kirana-ui/core";
|
|
53
|
-
export type { CalendarDay, CalendarValue, CalendarWeekday, DateRange, IsoDate, } from "@kirana-ui/core/calendar";
|
|
53
|
+
export type { Align, Anchor, AnchorOption, Bindable, ChangeDetails, ChangeSource, CollisionAvoidance, CollisionBoundary, CollisionPadding, ComponentDefinition, Direction, ItemLabels, ListCollection, OffsetData, OffsetFunction, Orientation, Part, PartDefinition, PartProps, PartState, PartStyle, PhysicalSide, PositionOptions, ReadonlySignal, Side, Signal, StateDefinition, StateOf, } from "@kirana-ui/core";
|
|
54
|
+
export type { CalendarDay, CalendarMode, CalendarMonth, CalendarValue, CalendarValueOf, CalendarWeekday, DateRange, IsoDate, } from "@kirana-ui/core/calendar";
|
|
54
55
|
export type { DateFieldSegment, DateUnit } from "@kirana-ui/core/date-field";
|
|
55
56
|
export type { DrawerSide, DrawerSnapPoint } from "@kirana-ui/core/drawer";
|
|
56
57
|
export type { FieldValidity, ValidityKey } from "@kirana-ui/core/field";
|
|
@@ -58,4 +59,6 @@ export type { FormErrors, FormValues, ValidationMode } from "@kirana-ui/core/for
|
|
|
58
59
|
export type { PaginationEntry } from "@kirana-ui/core/pagination";
|
|
59
60
|
export type { QrCorrection } from "@kirana-ui/core/qr-code";
|
|
60
61
|
export type { SelectShown } from "@kirana-ui/core/select";
|
|
62
|
+
export type { ComboboxEntry, ComboboxGroupData, ComboboxGroupEntry, ComboboxItemData, ComboboxItemEntry, ComboboxShown, } from "@kirana-ui/core/combobox";
|
|
61
63
|
export type { SliderChangeDetails, SliderTold } from "@kirana-ui/core/slider";
|
|
64
|
+
export type { ImageStatus } from "@kirana-ui/core/avatar";
|
package/types/number-field.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StateOf } from "@kirana-ui/core";
|
|
2
|
-
import type { NumberFieldProps } from "@kirana-ui/core/number-field";
|
|
2
|
+
import type { NumberFieldProps, NumberFieldScrubOptions } from "@kirana-ui/core/number-field";
|
|
3
3
|
import type { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
4
4
|
import type { JSX } from "solid-js";
|
|
5
5
|
import type { PartComponentProps } from "./runtime.tsx";
|
|
@@ -12,8 +12,16 @@ export type GroupProps = PartComponentProps<"div", StateOf<Parts["group"]>>;
|
|
|
12
12
|
export type InputProps = PartComponentProps<"input", StateOf<Parts["input"]>>;
|
|
13
13
|
export type IncrementProps = PartComponentProps<"button", StateOf<Parts["increment"]>>;
|
|
14
14
|
export type DecrementProps = PartComponentProps<"button", StateOf<Parts["decrement"]>>;
|
|
15
|
+
export type ScrubAreaProps = PartComponentProps<"span", StateOf<Parts["scrubArea"]>, NumberFieldScrubOptions>;
|
|
16
|
+
export type ScrubAreaCursorProps = PartComponentProps<"span", StateOf<Parts["scrubAreaCursor"]>>;
|
|
17
|
+
/** Pressed and dragged to change the number; `direction`, `pixelSensitivity`, `teleportDistance`. */
|
|
18
|
+
declare function ScrubArea(props: ScrubAreaProps): JSX.Element;
|
|
19
|
+
/** Drawn in place of the pointer while it is locked for a drag, at the end of `<body>`. */
|
|
20
|
+
declare function ScrubAreaCursor(props: ScrubAreaCursorProps): JSX.Element;
|
|
15
21
|
export declare const NumberField: {
|
|
16
22
|
Root: typeof Root;
|
|
23
|
+
ScrubArea: typeof ScrubArea;
|
|
24
|
+
ScrubAreaCursor: typeof ScrubAreaCursor;
|
|
17
25
|
Group: (props: GroupProps) => JSX.Element;
|
|
18
26
|
Input: (props: InputProps) => JSX.Element;
|
|
19
27
|
Increment: (props: IncrementProps) => JSX.Element;
|
package/types/otp.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, {
|
|
|
11
11
|
onValueChange?: (value: string, details: ChangeDetails) => void;
|
|
12
12
|
onComplete?: (value: string) => void;
|
|
13
13
|
mode?: OtpProps["mode"];
|
|
14
|
+
pattern?: string;
|
|
14
15
|
disabled?: boolean;
|
|
15
16
|
name?: string;
|
|
16
17
|
form?: string;
|
package/types/popover.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Anchor, ChangeDetails, PositionOptions, Signal, StateOf } from "@kirana-ui/core";
|
|
2
|
-
import type { Popover as Controller } from "@kirana-ui/core/popover";
|
|
2
|
+
import type { Popover as Controller, PopoverTriggerOptions } from "@kirana-ui/core/popover";
|
|
3
3
|
import type { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
4
4
|
import type { JSX } from "solid-js";
|
|
5
5
|
import type { PartComponentProps } from "./runtime.tsx";
|
|
@@ -15,6 +15,13 @@ export type RootProps = {
|
|
|
15
15
|
open?: boolean;
|
|
16
16
|
defaultOpen?: boolean;
|
|
17
17
|
onOpenChange?: (open: boolean, details: ChangeDetails) => void;
|
|
18
|
+
/**
|
|
19
|
+
* What the page behind it may do while it is open. `false` (the default): everything.
|
|
20
|
+
* `true`: nothing, the page is inert and does not scroll, and Tab stays inside the popover.
|
|
21
|
+
* `"trap-focus"`: Tab stays inside the popover, and the page can still be pressed and
|
|
22
|
+
* scrolled. A popover the pointer opened holds nothing until it is pressed. Read as it opens.
|
|
23
|
+
*/
|
|
24
|
+
modal?: boolean | "trap-focus";
|
|
18
25
|
id?: string;
|
|
19
26
|
children?: JSX.Element;
|
|
20
27
|
};
|
|
@@ -39,17 +46,24 @@ export type PositionerProps = PartComponentProps<"div", StateOf<Parts["positione
|
|
|
39
46
|
*/
|
|
40
47
|
export declare function positioned<P extends PositionerOptions>(props: P, positioning: Signal<Partial<PositionOptions>>): Omit<P, keyof PositionerOptions>;
|
|
41
48
|
declare function Positioner(props: PositionerProps): JSX.Element;
|
|
42
|
-
|
|
49
|
+
/** What a trigger takes of its own: whether the pointer opens the popover too, and its waits. */
|
|
50
|
+
export type TriggerOptions = PopoverTriggerOptions;
|
|
51
|
+
export type TriggerProps = PartComponentProps<"button", StateOf<Parts["trigger"]>, TriggerOptions>;
|
|
52
|
+
export type BackdropProps = PartComponentProps<"div", StateOf<Parts["backdrop"]>>;
|
|
53
|
+
export type ArrowProps = PartComponentProps<"div", StateOf<Parts["arrow"]>>;
|
|
43
54
|
export type PopupProps = PartComponentProps<"div", StateOf<Parts["popup"]>>;
|
|
44
55
|
export type TitleProps = PartComponentProps<"h2", StateOf<Parts["title"]>>;
|
|
45
56
|
export type DescriptionProps = PartComponentProps<"p", StateOf<Parts["description"]>>;
|
|
46
57
|
export type CloseProps = PartComponentProps<"button", StateOf<Parts["close"]>>;
|
|
58
|
+
declare function Trigger(props: TriggerProps): JSX.Element;
|
|
47
59
|
export declare const Popover: {
|
|
48
60
|
Root: typeof Root;
|
|
49
61
|
Portal: (props: PortalProps) => JSX.Element;
|
|
62
|
+
Backdrop: (props: BackdropProps) => JSX.Element;
|
|
50
63
|
Positioner: typeof Positioner;
|
|
51
|
-
Trigger:
|
|
64
|
+
Trigger: typeof Trigger;
|
|
52
65
|
Popup: (props: PopupProps) => JSX.Element;
|
|
66
|
+
Arrow: (props: ArrowProps) => JSX.Element;
|
|
53
67
|
Title: (props: TitleProps) => JSX.Element;
|
|
54
68
|
Description: (props: DescriptionProps) => JSX.Element;
|
|
55
69
|
Close: (props: CloseProps) => JSX.Element;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { PartProps } from "@kirana-ui/core";
|
|
2
|
+
import type { JSX } from "solid-js";
|
|
3
|
+
import type { PartTag } from "./runtime.tsx";
|
|
4
|
+
/** What a `Primitive` reads of its props; the rest are its element's. */
|
|
5
|
+
export interface PrimitiveOwnProps<State extends Record<string, unknown>> {
|
|
6
|
+
/** Another tag for the element; a `div` when left out. */
|
|
7
|
+
as?: PartTag | (string & {}) | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Renders the caller's own element in place of the `Primitive`'s, as a part's `render` does:
|
|
10
|
+
* `props()` is the attributes given here with the state's `data-*` attributes under them, and
|
|
11
|
+
* `children` what the `Primitive` holds; `state()` is `state`. What the element writes after
|
|
12
|
+
* `{...props()}` wins.
|
|
13
|
+
*/
|
|
14
|
+
render?: ((props: () => PartProps, state: () => State) => JSX.Element) | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* The element's state. `render` is given it, and it is written on the element as `data-*`
|
|
17
|
+
* attributes, under the attributes given: `true` is present and empty, `false`, `null` and
|
|
18
|
+
* `undefined` are absent, anything else is its text, and `isActive` is `data-is-active`.
|
|
19
|
+
*/
|
|
20
|
+
state?: State | undefined;
|
|
21
|
+
children?: JSX.Element;
|
|
22
|
+
}
|
|
23
|
+
/** What a `Primitive` drawn as `Tag` takes: its own props, and what the element takes. */
|
|
24
|
+
export type PrimitiveProps<Tag extends PartTag = "div", State extends Record<string, unknown> = Record<string, never>> = PrimitiveOwnProps<State> & Omit<JSX.IntrinsicElements[Tag], keyof PrimitiveOwnProps<State>> & {
|
|
25
|
+
as?: Tag | (string & {}) | undefined;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* A plain element of one's own (a badge, a breadcrumb's link) with the composition a part has:
|
|
29
|
+
* `as` for another tag (a `div` unless said), or `render` for the caller's own element, given the
|
|
30
|
+
* props to spread and the state. `state` is written as `data-*` attributes under the attributes
|
|
31
|
+
* given. Merge the component's own props with its caller's through `mergeProps`, as a part's
|
|
32
|
+
* are merged.
|
|
33
|
+
*/
|
|
34
|
+
export declare function Primitive<Tag extends PartTag = "div", State extends Record<string, unknown> = Record<string, never>>(props: PrimitiveProps<Tag, State>): JSX.Element;
|
|
35
|
+
/** The props of several sets as one: each set's, the later's over the earlier's. */
|
|
36
|
+
export type Merged<Sets extends readonly unknown[]> = Sets extends readonly [
|
|
37
|
+
infer First,
|
|
38
|
+
...infer Rest
|
|
39
|
+
] ? Omit<NonNullable<First>, keyof Merged<Rest>> & Merged<Rest> : Sets extends readonly [] ? {} : Record<string, unknown>;
|
|
40
|
+
/**
|
|
41
|
+
* Several sets of props as one, for a component's own props and its caller's: a later set
|
|
42
|
+
* wins an attribute it gives (one it leaves `undefined` stays), classes join, styles are
|
|
43
|
+
* merged property by property, the handlers of an event run in order until one calls
|
|
44
|
+
* `event.preventKiranaHandler()`, which stops those after it, and every `ref` gets the
|
|
45
|
+
* element. It reads its sets when a prop is read, so a component's props stay reactive: spread
|
|
46
|
+
* it (`<Primitive {...mergeProps({ class: "badge" }, props)} />`). Not solid-js's
|
|
47
|
+
* `mergeProps`, where a later class replaces an earlier one: import one under another name
|
|
48
|
+
* where both are used.
|
|
49
|
+
*/
|
|
50
|
+
export declare function mergeProps<const Sets extends readonly (object | undefined)[]>(...sets: Sets): Merged<Sets>;
|