@kirana-ui/react 0.1.0 → 0.2.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/llms.txt +3216 -0
- package/package.json +124 -2
- package/skills/kirana-ui-primitives/SKILL.md +142 -0
- package/src/accordion.d.ts +26 -15
- package/src/accordion.js +12 -11
- package/src/accordion.js.map +1 -1
- package/src/agent.d.ts +1 -0
- package/src/agent.js +1 -0
- package/src/alert-dialog.d.ts +3 -2
- package/src/autocomplete.d.ts +3 -0
- package/src/autocomplete.js +1 -0
- package/src/autosize.d.ts +12 -0
- package/src/autosize.js +12 -0
- package/src/autosize.js.map +1 -0
- package/src/avatar.d.ts +12 -8
- package/src/avatar.js +19 -10
- package/src/avatar.js.map +1 -1
- package/src/button.d.ts +4 -2
- package/src/button.js +3 -3
- package/src/button.js.map +1 -1
- package/src/calendar.d.ts +65 -0
- package/src/calendar.js +89 -0
- package/src/calendar.js.map +1 -0
- package/src/carousel.d.ts +36 -0
- package/src/carousel.js +52 -0
- package/src/carousel.js.map +1 -0
- package/src/checkbox.d.ts +10 -7
- package/src/checkbox.js +19 -12
- package/src/checkbox.js.map +1 -1
- package/src/collapsible.d.ts +12 -8
- package/src/collapsible.js +8 -7
- package/src/collapsible.js.map +1 -1
- package/src/combobox.d.ts +119 -0
- package/src/combobox.js +177 -0
- package/src/combobox.js.map +1 -0
- package/src/command.d.ts +53 -0
- package/src/command.js +95 -0
- package/src/command.js.map +1 -0
- package/src/context-menu.d.ts +3 -0
- package/src/context-menu.js +1 -0
- package/src/date-field.d.ts +37 -0
- package/src/date-field.js +64 -0
- package/src/date-field.js.map +1 -0
- package/src/date-picker.d.ts +44 -0
- package/src/date-picker.js +62 -0
- package/src/date-picker.js.map +1 -0
- package/src/dialog.d.ts +54 -27
- package/src/dialog.js +23 -6
- package/src/dialog.js.map +1 -1
- package/src/direction.d.ts +1 -0
- package/src/direction.js +1 -1
- package/src/direction.js.map +1 -1
- package/src/drawer.d.ts +3 -0
- package/src/drawer.js +1 -0
- package/src/element.d.ts +12 -0
- package/src/element.js +20 -0
- package/src/element.js.map +1 -0
- package/src/field.d.ts +24 -16
- package/src/field.js +11 -9
- package/src/field.js.map +1 -1
- package/src/fieldset.d.ts +10 -5
- package/src/fieldset.js +4 -5
- package/src/fieldset.js.map +1 -1
- package/src/form.d.ts +5 -2
- package/src/form.js +6 -6
- package/src/form.js.map +1 -1
- package/src/hover-card.d.ts +16 -10
- package/src/hover-card.js +1 -1
- package/src/hover-card.js.map +1 -1
- package/src/hover-popup.d.ts +26 -12
- package/src/hover-popup.js +12 -12
- package/src/hover-popup.js.map +1 -1
- package/src/index.d.ts +37 -3
- package/src/index.js +26 -2
- package/src/input.d.ts +12 -0
- package/src/input.js +21 -0
- package/src/input.js.map +1 -0
- package/src/label.d.ts +8 -0
- package/src/label.js +14 -0
- package/src/label.js.map +1 -0
- package/src/listbox.d.ts +36 -0
- package/src/listbox.js +88 -0
- package/src/listbox.js.map +1 -0
- package/src/menu.d.ts +107 -0
- package/src/menu.js +206 -0
- package/src/menu.js.map +1 -0
- package/src/menubar-context.d.ts +4 -0
- package/src/menubar-context.js +7 -0
- package/src/menubar-context.js.map +1 -0
- package/src/menubar.d.ts +11 -0
- package/src/menubar.js +25 -0
- package/src/menubar.js.map +1 -0
- package/src/message-scroller.d.ts +24 -0
- package/src/message-scroller.js +35 -0
- package/src/message-scroller.js.map +1 -0
- package/src/meter.d.ts +18 -9
- package/src/meter.js +1 -1
- package/src/meter.js.map +1 -1
- package/src/navigation-menu.d.ts +58 -0
- package/src/navigation-menu.js +106 -0
- package/src/navigation-menu.js.map +1 -0
- package/src/number-field.d.ts +28 -0
- package/src/number-field.js +58 -0
- package/src/number-field.js.map +1 -0
- package/src/otp.d.ts +35 -0
- package/src/otp.js +64 -0
- package/src/otp.js.map +1 -0
- package/src/pagination.d.ts +37 -0
- package/src/pagination.js +50 -0
- package/src/pagination.js.map +1 -0
- package/src/popover.d.ts +32 -22
- package/src/popover.js +10 -14
- package/src/popover.js.map +1 -1
- package/src/progress.d.ts +18 -9
- package/src/progress.js +1 -1
- package/src/progress.js.map +1 -1
- package/src/qr-code.d.ts +21 -0
- package/src/qr-code.js +32 -0
- package/src/qr-code.js.map +1 -0
- package/src/radio-group.d.ts +17 -11
- package/src/radio-group.js +20 -22
- package/src/radio-group.js.map +1 -1
- package/src/resizable.d.ts +24 -0
- package/src/resizable.js +51 -0
- package/src/resizable.js.map +1 -0
- package/src/runtime.d.ts +114 -13
- package/src/runtime.js +205 -24
- package/src/runtime.js.map +1 -1
- package/src/scroll-area.d.ts +36 -0
- package/src/scroll-area.js +64 -0
- package/src/scroll-area.js.map +1 -0
- package/src/select.d.ts +79 -31
- package/src/select.js +86 -23
- package/src/select.js.map +1 -1
- package/src/separator.d.ts +4 -2
- package/src/separator.js +3 -3
- package/src/separator.js.map +1 -1
- package/src/slider.d.ts +35 -20
- package/src/slider.js +20 -19
- package/src/slider.js.map +1 -1
- package/src/switch.d.ts +10 -6
- package/src/switch.js +12 -9
- package/src/switch.js.map +1 -1
- package/src/tabs.d.ts +22 -14
- package/src/tabs.js +7 -8
- package/src/tabs.js.map +1 -1
- package/src/testing.d.ts +1 -0
- package/src/testing.js +1 -0
- package/src/toast.d.ts +68 -0
- package/src/toast.js +107 -0
- package/src/toast.js.map +1 -0
- package/src/toggle-group.d.ts +10 -0
- package/src/toggle-group.js +32 -0
- package/src/toggle-group.js.map +1 -0
- package/src/toggle.d.ts +5 -2
- package/src/toggle.js +15 -5
- package/src/toggle.js.map +1 -1
- package/src/toolbar-context.d.ts +7 -0
- package/src/toolbar-context.js +9 -0
- package/src/toolbar-context.js.map +1 -0
- package/src/toolbar.d.ts +35 -0
- package/src/toolbar.js +63 -0
- package/src/toolbar.js.map +1 -0
- package/src/tooltip.d.ts +16 -10
- package/src/tooltip.js +1 -1
- package/src/tooltip.js.map +1 -1
- package/src/use-render.d.ts +38 -0
- package/src/use-render.js +50 -0
- package/src/use-render.js.map +1 -0
- package/src/value-bar.d.ts +19 -11
- package/src/value-bar.js +8 -5
- package/src/value-bar.js.map +1 -1
package/src/progress.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress.js","names":[],"sources":["../../../../packages/react/src/progress.tsx"],"sourcesContent":["import { createProgress } from \"@kirana-ui/core/progress\"\n\nimport { valueBar } from \"./value-bar.tsx\"\n\nexport const Progress = valueBar(\"Progress\", createProgress)\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"progress.js","names":[],"sources":["../../../../packages/react/src/progress.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createProgress } from \"@kirana-ui/core/progress\"\nimport type { ProgressProps } from \"@kirana-ui/core/progress\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\n\nimport type { PartComponentProps } from \"./runtime.tsx\"\nimport { valueBar } from \"./value-bar.tsx\"\nimport type { ValueOptions } from \"./value-bar.tsx\"\n\ntype Parts = Vocabulary[\"progress\"]\n\nexport type RootProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<ProgressProps, \"id\"> & { id?: string }\n>\nexport type TrackProps = PartComponentProps<\"div\", StateOf<Parts[\"track\"]>>\nexport type IndicatorProps = PartComponentProps<\"div\", StateOf<Parts[\"indicator\"]>>\nexport type ValueProps = PartComponentProps<\"span\", StateOf<Parts[\"value\"]>, ValueOptions>\nexport type LabelProps = PartComponentProps<\"span\", StateOf<Parts[\"label\"]>>\n\nexport const Progress = /* @__PURE__ */ valueBar<\n ProgressProps,\n {\n Root: RootProps\n Track: TrackProps\n Indicator: IndicatorProps\n Value: ValueProps\n Label: LabelProps\n }\n>(\"Progress\", createProgress)\n"],"mappings":";;;AAqBA,MAAa,WAA2B,yBAStC,YAAY,cAAc"}
|
package/src/qr-code.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { StateOf } from "@kirana-ui/core";
|
|
3
|
+
import { ReactElement } from "react";
|
|
4
|
+
import { QrCodeProps } from "@kirana-ui/core/qr-code";
|
|
5
|
+
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
|
+
type Parts = Vocabulary["qrCode"];
|
|
7
|
+
export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<QrCodeProps, "id"> & {
|
|
8
|
+
id?: string;
|
|
9
|
+
}>;
|
|
10
|
+
declare function Root({ value, correction, id, ...rest }: RootProps): ReactElement;
|
|
11
|
+
export type FrameProps = PartComponentProps<"svg", StateOf<Parts["frame"]>>;
|
|
12
|
+
declare const Frame: (props: FrameProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
13
|
+
export type PatternProps = PartComponentProps<"path", StateOf<Parts["pattern"]>>;
|
|
14
|
+
declare const Pattern: (props: PatternProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
15
|
+
export declare const QrCode: {
|
|
16
|
+
readonly Root: typeof Root;
|
|
17
|
+
readonly Frame: typeof Frame;
|
|
18
|
+
readonly Pattern: typeof Pattern;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=qr-code.d.ts.map
|
package/src/qr-code.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { parts, useController, usePart } from "./runtime.js";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { createQrCode } from "@kirana-ui/core/qr-code";
|
|
5
|
+
// src/qr-code.tsx
|
|
6
|
+
const Context = createContext(null);
|
|
7
|
+
function useQrCode(part) {
|
|
8
|
+
const controller = useContext(Context);
|
|
9
|
+
if (!controller) throw new Error(`<QrCode.${part}> must be inside <QrCode.Root>`);
|
|
10
|
+
return controller;
|
|
11
|
+
}
|
|
12
|
+
function Root({ value, correction, id, ...rest }) {
|
|
13
|
+
const controller = useController(createQrCode, {
|
|
14
|
+
value,
|
|
15
|
+
correction,
|
|
16
|
+
id
|
|
17
|
+
});
|
|
18
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
19
|
+
value: controller,
|
|
20
|
+
children: usePart(controller.root, "div", rest)
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const Frame = (props) => usePart(useQrCode("Frame").frame, "svg", props);
|
|
24
|
+
const Pattern = (props) => usePart(useQrCode("Pattern").pattern, "path", props);
|
|
25
|
+
const QrCode = /* @__PURE__ */ parts("QrCode", {
|
|
26
|
+
Root,
|
|
27
|
+
Frame,
|
|
28
|
+
Pattern
|
|
29
|
+
});
|
|
30
|
+
export { QrCode };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=qr-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qr-code.js","names":[],"sources":["../../../../packages/react/src/qr-code.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createQrCode } from \"@kirana-ui/core/qr-code\"\nimport type { QrCode as Controller, QrCodeProps } from \"@kirana-ui/core/qr-code\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { parts, useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"qrCode\"]\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useQrCode(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<QrCode.${part}> must be inside <QrCode.Root>`)\n return controller\n}\n\nexport type RootProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<QrCodeProps, \"id\"> & { id?: string }\n>\n\nfunction Root({ value, correction, id, ...rest }: RootProps): ReactElement {\n const controller = useController<QrCodeProps, Controller>(createQrCode, {\n value,\n correction,\n id,\n })\n return (\n <Context.Provider value={controller}>{usePart(controller.root, \"div\", rest)}</Context.Provider>\n )\n}\n\nexport type FrameProps = PartComponentProps<\"svg\", StateOf<Parts[\"frame\"]>>\n\nconst Frame = (props: FrameProps) => usePart(useQrCode(\"Frame\").frame, \"svg\", props)\nexport type PatternProps = PartComponentProps<\"path\", StateOf<Parts[\"pattern\"]>>\n\nconst Pattern = (props: PatternProps) => usePart(useQrCode(\"Pattern\").pattern, \"path\", props)\n\nexport const QrCode = /* @__PURE__ */ parts(\"QrCode\", { Root, Frame, Pattern })\n"],"mappings":";;;;;AAYA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,UAAU,MAA0B;CAC3C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,WAAW,KAAK,+BAA+B;CAChF,OAAO;AACT;AAQA,SAAS,KAAK,EAAE,OAAO,YAAY,IAAI,GAAG,QAAiC;CACzE,MAAM,aAAa,cAAuC,cAAc;EACtE;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CAAoB,CAAA;AAElG;AAIA,MAAM,SAAS,UAAsB,QAAQ,UAAU,OAAO,CAAC,CAAC,OAAO,OAAO,KAAK;AAGnF,MAAM,WAAW,UAAwB,QAAQ,UAAU,SAAS,CAAC,CAAC,SAAS,QAAQ,KAAK;AAE5F,MAAa,SAAyB,sBAAM,UAAU;CAAE;CAAM;CAAO;AAAQ,CAAC"}
|
package/src/radio-group.d.ts
CHANGED
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { StateOf } from "@kirana-ui/core";
|
|
2
3
|
import { ReactElement } from "react";
|
|
3
4
|
import { RadioGroupProps } from "@kirana-ui/core/radio-group";
|
|
4
|
-
|
|
5
|
+
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
|
+
type Parts = Vocabulary["radioGroup"];
|
|
7
|
+
/** `Value` is what tells an item from the others: the type of `value`. */
|
|
8
|
+
export type RootProps<Value = unknown> = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<RadioGroupProps<Value>, "id"> & {
|
|
5
9
|
id?: string;
|
|
6
|
-
}
|
|
7
|
-
declare function Root<Value>({ value, defaultValue, onValueChange, disabled, readOnly, required, name, id, ...rest }: RootProps<Value>): ReactElement;
|
|
8
|
-
export
|
|
10
|
+
}>;
|
|
11
|
+
declare function Root<Value = unknown>({ value, defaultValue, onValueChange, disabled, readOnly, required, name, form, id, ...rest }: RootProps<Value>): ReactElement;
|
|
12
|
+
export type ItemProps = PartComponentProps<"span", StateOf<Parts["item"]>, {
|
|
13
|
+
/** What the group's value is while this item is the chosen one. */
|
|
9
14
|
value: unknown;
|
|
15
|
+
/** Disables this item: it cannot be chosen. */
|
|
10
16
|
disabled?: boolean;
|
|
11
|
-
}
|
|
12
|
-
declare function Item({ value, disabled,
|
|
13
|
-
export
|
|
17
|
+
}>;
|
|
18
|
+
declare function Item({ value, disabled, ...rest }: ItemProps): ReactElement;
|
|
19
|
+
export type IndicatorProps = PartComponentProps<"span", StateOf<Parts["indicator"]>, {
|
|
14
20
|
/** Keeps the mark in the page while its item is not the chosen one. */
|
|
15
21
|
keepMounted?: boolean;
|
|
16
|
-
}
|
|
22
|
+
}>;
|
|
17
23
|
declare function Indicator({ keepMounted, ...props }: IndicatorProps): ReactElement | null;
|
|
18
24
|
export declare const RadioGroup: {
|
|
19
|
-
Root: typeof Root;
|
|
20
|
-
Item: typeof Item;
|
|
21
|
-
Indicator: typeof Indicator;
|
|
25
|
+
readonly Root: typeof Root;
|
|
26
|
+
readonly Item: typeof Item;
|
|
27
|
+
readonly Indicator: typeof Indicator;
|
|
22
28
|
};
|
|
23
29
|
export {};
|
|
24
30
|
//# sourceMappingURL=radio-group.d.ts.map
|
package/src/radio-group.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DirectionContext } from "./direction-context.js";
|
|
2
2
|
import { FieldContext } from "./field-context.js";
|
|
3
|
-
import { useController, useOptions, usePart, useSignal } from "./runtime.js";
|
|
3
|
+
import { PartElement, parts, useController, useMount, useOptions, usePart, useSignal } from "./runtime.js";
|
|
4
4
|
import { defined, within } from "@kirana-ui/core";
|
|
5
|
-
import { createContext, useContext,
|
|
6
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { createContext, useContext, useMemo } from "react";
|
|
6
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { createRadioGroup } from "@kirana-ui/core/radio-group";
|
|
8
8
|
// src/radio-group.tsx
|
|
9
9
|
const Context = createContext(null);
|
|
@@ -13,7 +13,7 @@ function useRadioGroup(part) {
|
|
|
13
13
|
if (!controller) throw new Error(`<RadioGroup.${part}> must be inside <RadioGroup.Root>`);
|
|
14
14
|
return controller;
|
|
15
15
|
}
|
|
16
|
-
function Root({ value, defaultValue, onValueChange, disabled, readOnly, required, name, id, ...rest }) {
|
|
16
|
+
function Root({ value, defaultValue, onValueChange, disabled, readOnly, required, name, form, id, ...rest }) {
|
|
17
17
|
const field = useContext(FieldContext) ?? void 0;
|
|
18
18
|
const direction = useContext(DirectionContext) ?? void 0;
|
|
19
19
|
const create = within(createRadioGroup, {
|
|
@@ -28,18 +28,22 @@ function Root({ value, defaultValue, onValueChange, disabled, readOnly, required
|
|
|
28
28
|
readOnly,
|
|
29
29
|
required,
|
|
30
30
|
name,
|
|
31
|
+
form,
|
|
31
32
|
id
|
|
32
33
|
});
|
|
33
34
|
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
34
35
|
value: controller,
|
|
35
|
-
children: /* @__PURE__ */ jsx(
|
|
36
|
+
children: /* @__PURE__ */ jsx(PartElement, {
|
|
37
|
+
of: controller.root,
|
|
38
|
+
tag: "div",
|
|
39
|
+
...rest
|
|
40
|
+
})
|
|
36
41
|
});
|
|
37
42
|
}
|
|
38
|
-
|
|
39
|
-
function Item({ value, disabled, children, ...rest }) {
|
|
43
|
+
function Item({ value, disabled, ...rest }) {
|
|
40
44
|
const controller = useRadioGroup("Item");
|
|
41
45
|
const options = useOptions({ disabled });
|
|
42
|
-
const
|
|
46
|
+
const made = useMemo(() => {
|
|
43
47
|
const read = () => defined(options.get());
|
|
44
48
|
return {
|
|
45
49
|
item: controller.item(value, read),
|
|
@@ -52,35 +56,29 @@ function Item({ value, disabled, children, ...rest }) {
|
|
|
52
56
|
]);
|
|
53
57
|
return /* @__PURE__ */ jsx(ItemContext.Provider, {
|
|
54
58
|
value,
|
|
55
|
-
children: /* @__PURE__ */ jsxs(PartElement, {
|
|
56
|
-
|
|
57
|
-
tag: "
|
|
58
|
-
|
|
59
|
-
children: [children, /* @__PURE__ */ jsx(PartElement, {
|
|
60
|
-
part: parts.input,
|
|
61
|
-
tag: "input"
|
|
62
|
-
})]
|
|
63
|
-
})
|
|
59
|
+
children: usePart(made.item, "span", rest, void 0, (content) => /* @__PURE__ */ jsxs(Fragment$1, { children: [content, /* @__PURE__ */ jsx(PartElement, {
|
|
60
|
+
of: made.input,
|
|
61
|
+
tag: "input"
|
|
62
|
+
})] }))
|
|
64
63
|
});
|
|
65
64
|
}
|
|
66
|
-
const PartElement = ({ part, tag, ...props }) => usePart(part, tag, props);
|
|
67
65
|
function Indicator({ keepMounted, ...props }) {
|
|
68
66
|
const controller = useRadioGroup("Indicator");
|
|
69
67
|
const value = useContext(ItemContext);
|
|
70
68
|
const indicator = useMemo(() => controller.indicator(value), [controller, value]);
|
|
71
|
-
|
|
69
|
+
useMount(indicator);
|
|
72
70
|
if (!useSignal(indicator.mounted) && !keepMounted) return null;
|
|
73
71
|
return /* @__PURE__ */ jsx(PartElement, {
|
|
74
|
-
|
|
72
|
+
of: indicator.part,
|
|
75
73
|
tag: "span",
|
|
76
74
|
...props
|
|
77
75
|
});
|
|
78
76
|
}
|
|
79
|
-
const RadioGroup = {
|
|
77
|
+
const RadioGroup = /* @__PURE__ */ parts("RadioGroup", {
|
|
80
78
|
Root,
|
|
81
79
|
Item,
|
|
82
80
|
Indicator
|
|
83
|
-
};
|
|
81
|
+
});
|
|
84
82
|
export { RadioGroup };
|
|
85
83
|
|
|
86
84
|
//# sourceMappingURL=radio-group.js.map
|
package/src/radio-group.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio-group.js","names":[],"sources":["../../../../packages/react/src/radio-group.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type {
|
|
1
|
+
{"version":3,"file":"radio-group.js","names":[],"sources":["../../../../packages/react/src/radio-group.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createRadioGroup } from \"@kirana-ui/core/radio-group\"\nimport type { RadioGroup as Controller, RadioGroupProps } from \"@kirana-ui/core/radio-group\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { FieldContext } from \"./field-context.ts\"\nimport {\n PartElement,\n parts,\n useController,\n useMount,\n useOptions,\n usePart,\n useSignal,\n} from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"radioGroup\"]\n\nconst Context = createContext<Controller | null>(null)\nconst ItemContext = createContext<unknown>(undefined)\n\nfunction useRadioGroup(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<RadioGroup.${part}> must be inside <RadioGroup.Root>`)\n return controller\n}\n\n/** `Value` is what tells an item from the others: the type of `value`. */\nexport type RootProps<Value = unknown> = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<RadioGroupProps<Value>, \"id\"> & { id?: string }\n>\n\nfunction Root<Value = unknown>({\n value,\n defaultValue,\n onValueChange,\n disabled,\n readOnly,\n required,\n name,\n form,\n id,\n ...rest\n}: RootProps<Value>): ReactElement {\n const field = useContext(FieldContext) ?? undefined\n const direction = useContext(DirectionContext) ?? undefined\n const create = within(createRadioGroup<Value>, { field, direction })\n const controller: Controller = useController(create, {\n value,\n defaultValue,\n onValueChange,\n disabled,\n readOnly,\n required,\n name,\n form,\n id,\n })\n return (\n <Context.Provider value={controller}>\n <PartElement of={controller.root} tag=\"div\" {...rest} />\n </Context.Provider>\n )\n}\n\nexport type ItemProps = PartComponentProps<\n \"span\",\n StateOf<Parts[\"item\"]>,\n {\n /** What the group's value is while this item is the chosen one. */\n value: unknown\n /** Disables this item: it cannot be chosen. */\n disabled?: boolean\n }\n>\n\nfunction Item({ value, disabled, ...rest }: ItemProps): ReactElement {\n const controller = useRadioGroup(\"Item\")\n const options = useOptions({ disabled })\n const made = useMemo(() => {\n const read = () => defined(options.get())\n return { item: controller.item(value, read), input: controller.itemInput(value, read) }\n }, [controller, value, options])\n return (\n <ItemContext.Provider value={value}>\n {usePart(made.item, \"span\", rest, undefined, (content) => (\n // Its native input is the element's last child, whatever element the caller asked for.\n <>\n {content}\n <PartElement of={made.input} tag=\"input\" />\n </>\n ))}\n </ItemContext.Provider>\n )\n}\n\nexport type IndicatorProps = PartComponentProps<\n \"span\",\n StateOf<Parts[\"indicator\"]>,\n {\n /** Keeps the mark in the page while its item is not the chosen one. */\n keepMounted?: boolean\n }\n>\n\nfunction Indicator({ keepMounted, ...props }: IndicatorProps): ReactElement | null {\n const controller = useRadioGroup(\"Indicator\")\n const value = useContext(ItemContext)\n const indicator = useMemo(() => controller.indicator(value), [controller, value])\n useMount(indicator)\n const mounted = useSignal(indicator.mounted)\n if (!mounted && !keepMounted) return null\n return <PartElement of={indicator.part} tag=\"span\" {...props} />\n}\n\nexport const RadioGroup = /* @__PURE__ */ parts(\"RadioGroup\", { Root, Item, Indicator })\n"],"mappings":";;;;;;;;AAuBA,MAAM,UAAU,cAAiC,IAAI;AACrD,MAAM,cAAc,cAAuB,KAAA,CAAS;AAEpD,SAAS,cAAc,MAA0B;CAC/C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,eAAe,KAAK,mCAAmC;CACxF,OAAO;AACT;AASA,SAAS,KAAsB,EAC7B,OACA,cACA,eACA,UACA,UACA,UACA,MACA,MACA,IACA,GAAG,QAC8B;CACjC,MAAM,QAAQ,WAAW,YAAY,KAAK,KAAA;CAC1C,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,SAAS,OAAO,kBAAyB;EAAE;EAAO;CAAU,CAAC;CACnE,MAAM,aAAyB,cAAc,QAAQ;EACnD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EACvB,UAAA,oBAAC,aAAD;GAAa,IAAI,WAAW;GAAM,KAAI;GAAM,GAAI;EAAO,CAAA;CACvC,CAAA;AAEtB;AAaA,SAAS,KAAK,EAAE,OAAO,UAAU,GAAG,QAAiC;CACnE,MAAM,aAAa,cAAc,MAAM;CACvC,MAAM,UAAU,WAAW,EAAE,SAAS,CAAC;CACvC,MAAM,OAAO,cAAc;EACzB,MAAM,aAAa,QAAQ,QAAQ,IAAI,CAAC;EACxC,OAAO;GAAE,MAAM,WAAW,KAAK,OAAO,IAAI;GAAG,OAAO,WAAW,UAAU,OAAO,IAAI;EAAE;CACxF,GAAG;EAAC;EAAY;EAAO;CAAO,CAAC;CAC/B,OACE,oBAAC,YAAY,UAAb;EAA6B;EAC1B,UAAA,QAAQ,KAAK,MAAM,QAAQ,MAAM,KAAA,IAAY,YAE5C,qBAAA,YAAA,EAAA,UAAA,CACG,SACD,oBAAC,aAAD;GAAa,IAAI,KAAK;GAAO,KAAI;EAAS,CAAA,CAC1C,EAAA,CAAA,CACH;CACmB,CAAA;AAE1B;AAWA,SAAS,UAAU,EAAE,aAAa,GAAG,SAA8C;CACjF,MAAM,aAAa,cAAc,WAAW;CAC5C,MAAM,QAAQ,WAAW,WAAW;CACpC,MAAM,YAAY,cAAc,WAAW,UAAU,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC;CAChF,SAAS,SAAS;CAElB,IAAI,CADY,UAAU,UAAU,OACzB,KAAK,CAAC,aAAa,OAAO;CACrC,OAAO,oBAAC,aAAD;EAAa,IAAI,UAAU;EAAM,KAAI;EAAO,GAAI;CAAQ,CAAA;AACjE;AAEA,MAAa,aAA6B,sBAAM,cAAc;CAAE;CAAM;CAAM;AAAU,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { StateOf } from "@kirana-ui/core";
|
|
3
|
+
import { ReactElement } from "react";
|
|
4
|
+
import { ResizablePanelOptions, ResizableProps } from "@kirana-ui/core/resizable";
|
|
5
|
+
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
|
+
type Parts = Vocabulary["resizable"];
|
|
7
|
+
export type GroupProps = PartComponentProps<"div", StateOf<Parts["group"]>, Omit<ResizableProps, "id"> & {
|
|
8
|
+
id?: string;
|
|
9
|
+
}>;
|
|
10
|
+
declare function Group({ orientation, onSizesChange, keyboardStep, disabled, id, ...rest }: GroupProps): ReactElement;
|
|
11
|
+
export type PanelProps = PartComponentProps<"div", StateOf<Parts["panel"]>, ResizablePanelOptions>;
|
|
12
|
+
declare function Panel({ defaultSize, minSize, maxSize, ...props }: PanelProps): ReactElement;
|
|
13
|
+
export type HandleProps = PartComponentProps<"div", StateOf<Parts["handle"]>, {
|
|
14
|
+
/** Disables this handle: it cannot be dragged or moved with the keyboard. */
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
declare function Handle({ disabled, ...props }: HandleProps): ReactElement;
|
|
18
|
+
export declare const Resizable: {
|
|
19
|
+
readonly Group: typeof Group;
|
|
20
|
+
readonly Panel: typeof Panel;
|
|
21
|
+
readonly Handle: typeof Handle;
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=resizable.d.ts.map
|
package/src/resizable.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { DirectionContext } from "./direction-context.js";
|
|
2
|
+
import { parts, useController, useOptions, usePart } from "./runtime.js";
|
|
3
|
+
import { defined, within } from "@kirana-ui/core";
|
|
4
|
+
import { createContext, useContext, useMemo } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { createResizable } from "@kirana-ui/core/resizable";
|
|
7
|
+
// src/resizable.tsx
|
|
8
|
+
const Context = createContext(null);
|
|
9
|
+
function useResizable(part) {
|
|
10
|
+
const controller = useContext(Context);
|
|
11
|
+
if (!controller) throw new Error(`<Resizable.${part}> must be inside <Resizable.Group>`);
|
|
12
|
+
return controller;
|
|
13
|
+
}
|
|
14
|
+
function Group({ orientation, onSizesChange, keyboardStep, disabled, id, ...rest }) {
|
|
15
|
+
const direction = useContext(DirectionContext) ?? void 0;
|
|
16
|
+
const controller = useController(within(createResizable, { direction }), {
|
|
17
|
+
orientation,
|
|
18
|
+
onSizesChange,
|
|
19
|
+
keyboardStep,
|
|
20
|
+
disabled,
|
|
21
|
+
id
|
|
22
|
+
});
|
|
23
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
24
|
+
value: controller,
|
|
25
|
+
children: usePart(controller.group, "div", rest)
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function Panel({ defaultSize, minSize, maxSize, ...props }) {
|
|
29
|
+
const controller = useResizable("Panel");
|
|
30
|
+
const options = useOptions({
|
|
31
|
+
defaultSize,
|
|
32
|
+
minSize,
|
|
33
|
+
maxSize
|
|
34
|
+
});
|
|
35
|
+
const part = useMemo(() => controller.panel(() => defined(options.get())), [controller, options]);
|
|
36
|
+
return usePart(part, "div", props);
|
|
37
|
+
}
|
|
38
|
+
function Handle({ disabled, ...props }) {
|
|
39
|
+
const controller = useResizable("Handle");
|
|
40
|
+
const options = useOptions({ disabled });
|
|
41
|
+
const part = useMemo(() => controller.handle(() => defined(options.get())), [controller, options]);
|
|
42
|
+
return usePart(part, "div", props);
|
|
43
|
+
}
|
|
44
|
+
const Resizable = /* @__PURE__ */ parts("Resizable", {
|
|
45
|
+
Group,
|
|
46
|
+
Panel,
|
|
47
|
+
Handle
|
|
48
|
+
});
|
|
49
|
+
export { Resizable };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=resizable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resizable.js","names":[],"sources":["../../../../packages/react/src/resizable.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createResizable } from \"@kirana-ui/core/resizable\"\nimport type {\n Resizable as Controller,\n ResizablePanelOptions,\n ResizableProps,\n} from \"@kirana-ui/core/resizable\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { parts, useController, useOptions, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"resizable\"]\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useResizable(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Resizable.${part}> must be inside <Resizable.Group>`)\n return controller\n}\n\nexport type GroupProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"group\"]>,\n Omit<ResizableProps, \"id\"> & { id?: string }\n>\n\nfunction Group({\n orientation,\n onSizesChange,\n keyboardStep,\n disabled,\n id,\n ...rest\n}: GroupProps): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const controller = useController<ResizableProps, Controller>(\n within(createResizable, { direction }),\n { orientation, onSizesChange, keyboardStep, disabled, id }\n )\n return (\n <Context.Provider value={controller}>{usePart(controller.group, \"div\", rest)}</Context.Provider>\n )\n}\n\nexport type PanelProps = PartComponentProps<\"div\", StateOf<Parts[\"panel\"]>, ResizablePanelOptions>\n\nfunction Panel({ defaultSize, minSize, maxSize, ...props }: PanelProps): ReactElement {\n const controller = useResizable(\"Panel\")\n const options = useOptions({ defaultSize, minSize, maxSize })\n const part = useMemo(() => controller.panel(() => defined(options.get())), [controller, options])\n return usePart(part, \"div\", props)\n}\n\nexport type HandleProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"handle\"]>,\n {\n /** Disables this handle: it cannot be dragged or moved with the keyboard. */\n disabled?: boolean\n }\n>\n\nfunction Handle({ disabled, ...props }: HandleProps): ReactElement {\n const controller = useResizable(\"Handle\")\n const options = useOptions({ disabled })\n const part = useMemo(() => controller.handle(() => defined(options.get())), [controller, options])\n return usePart(part, \"div\", props)\n}\n\nexport const Resizable = /* @__PURE__ */ parts(\"Resizable\", { Group, Panel, Handle })\n"],"mappings":";;;;;;;AAkBA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,aAAa,MAA0B;CAC9C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,cAAc,KAAK,mCAAmC;CACvF,OAAO;AACT;AAQA,SAAS,MAAM,EACb,aACA,eACA,cACA,UACA,IACA,GAAG,QACwB;CAC3B,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,aAAa,cACjB,OAAO,iBAAiB,EAAE,UAAU,CAAC,GACrC;EAAE;EAAa;EAAe;EAAc;EAAU;CAAG,CAC3D;CACA,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa,UAAA,QAAQ,WAAW,OAAO,OAAO,IAAI;CAAoB,CAAA;AAEnG;AAIA,SAAS,MAAM,EAAE,aAAa,SAAS,SAAS,GAAG,SAAmC;CACpF,MAAM,aAAa,aAAa,OAAO;CACvC,MAAM,UAAU,WAAW;EAAE;EAAa;EAAS;CAAQ,CAAC;CAC5D,MAAM,OAAO,cAAc,WAAW,YAAY,QAAQ,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,YAAY,OAAO,CAAC;CAChG,OAAO,QAAQ,MAAM,OAAO,KAAK;AACnC;AAWA,SAAS,OAAO,EAAE,UAAU,GAAG,SAAoC;CACjE,MAAM,aAAa,aAAa,QAAQ;CACxC,MAAM,UAAU,WAAW,EAAE,SAAS,CAAC;CACvC,MAAM,OAAO,cAAc,WAAW,aAAa,QAAQ,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,YAAY,OAAO,CAAC;CACjG,OAAO,QAAQ,MAAM,OAAO,KAAK;AACnC;AAEA,MAAa,YAA4B,sBAAM,aAAa;CAAE;CAAO;CAAO;AAAO,CAAC"}
|
package/src/runtime.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { Part, ReadonlySignal } from "@kirana-ui/core";
|
|
2
|
-
import { ReactElement, ReactNode, Ref } from "react";
|
|
1
|
+
import { Anchor, Part, PartEvent, PartState, PositionOptions, ReadonlySignal, Signal } from "@kirana-ui/core";
|
|
2
|
+
import { ClassAttributes, ComponentPropsWithoutRef, HTMLAttributes, JSX, ReactElement, ReactNode, Ref, RefCallback, RefObject, SyntheticEvent, useLayoutEffect } from "react";
|
|
3
|
+
/** A layout effect in the browser, an effect (which never runs) on a server. */
|
|
4
|
+
export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
|
|
3
5
|
/** A core signal's value, re-rendering when it changes. */
|
|
4
6
|
export declare function useSignal<T>(source: ReadonlySignal<T>): T;
|
|
5
7
|
/**
|
|
@@ -12,23 +14,122 @@ export declare function useController<P extends object, C extends {
|
|
|
12
14
|
}>(create: (props: ReadonlySignal<P>) => C, props: Omit<P, "id"> & {
|
|
13
15
|
id?: string | undefined;
|
|
14
16
|
}): C;
|
|
17
|
+
/**
|
|
18
|
+
* Starts what a controller (or an item of one) runs while it is in the page. StrictMode runs an
|
|
19
|
+
* effect, undoes it and runs it again in one commit, to find effects that cannot be run twice:
|
|
20
|
+
* a mount is not undone for that. The cleanup waits a moment, and a mount that comes back in
|
|
21
|
+
* the meantime keeps what is running.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useMount(mounted: {
|
|
24
|
+
mount(): () => void;
|
|
25
|
+
}): void;
|
|
15
26
|
/** A part's own options as a core signal that follows each render, after it commits. */
|
|
16
27
|
export declare function useOptions<T extends Record<string, unknown>>(options: T): ReadonlySignal<T>;
|
|
17
|
-
|
|
18
|
-
export
|
|
19
|
-
|
|
28
|
+
/** The elements a part is drawn as, by their tag: `"button"`, `"div"`, `"svg"`. */
|
|
29
|
+
export type PartTag = keyof JSX.IntrinsicElements;
|
|
30
|
+
/** The element a tag draws: an `HTMLButtonElement` for `"button"`. */
|
|
31
|
+
export type ElementOf<Tag extends PartTag> = JSX.IntrinsicElements[Tag] extends ClassAttributes<infer Drawn> ? Drawn : Element;
|
|
32
|
+
type Hearing<Prop> = Prop extends ((event: infer Heard) => infer Answer) ? Heard extends SyntheticEvent ? (event: PartEvent<Heard>) => Answer : Prop : Prop;
|
|
33
|
+
/**
|
|
34
|
+
* The props a `render` function is handed, to spread on what it draws: the part's attributes,
|
|
35
|
+
* its handlers and its ref, with the caller's under them. An attribute of one kind of element
|
|
36
|
+
* (`href`, `type`) is among them unnamed, as `unknown`.
|
|
37
|
+
*/
|
|
38
|
+
export type RenderedProps = HTMLAttributes<HTMLElement> & {
|
|
39
|
+
ref?: RefCallback<HTMLElement> | undefined;
|
|
40
|
+
} & Record<string, unknown>;
|
|
41
|
+
/**
|
|
42
|
+
* What `render` takes: an element, drawn with the part's props merged over its own, or a
|
|
43
|
+
* function given the part's props and its state.
|
|
44
|
+
*/
|
|
45
|
+
export type RenderProp<State = PartState> = ReactElement<Record<string, unknown>> | ((props: RenderedProps, state: State) => ReactElement);
|
|
46
|
+
/**
|
|
47
|
+
* A part's props: its element's own (`Tag`'s attributes and handlers, a `ref` to that
|
|
48
|
+
* element), `render`, and the part's own props (`Own`) in place of the element's of the same
|
|
49
|
+
* name. `State` is what a `render` function is told of the part.
|
|
50
|
+
*/
|
|
51
|
+
export type PartComponentProps<Tag extends PartTag = "div", State = PartState, Own = unknown> = { [Name in keyof ComponentPropsWithoutRef<Tag> as Name extends keyof Own ? never : Name]: Hearing<ComponentPropsWithoutRef<Tag>[Name]>; } & Own & {
|
|
52
|
+
/**
|
|
53
|
+
* Renders the part as another element or component. An element's own props lie over the
|
|
54
|
+
* props handed to the part, and the part's own (its role, its state, its handlers) over
|
|
55
|
+
* both; a function is given the part's props and its state (`open`, `side` …, read from
|
|
56
|
+
* its `data-*` attributes).
|
|
57
|
+
*/
|
|
20
58
|
render?: RenderProp<State> | undefined;
|
|
59
|
+
ref?: Ref<ElementOf<Tag>> | undefined;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Renders a part: its element (or the caller's `render`), and the part's DOM work attached to
|
|
63
|
+
* the element. Three layers of props, lowest first: what was handed to the part, the `render`
|
|
64
|
+
* element's own, the part's. A higher layer wins an attribute; classes join; styles are merged
|
|
65
|
+
* property by property; every handler of an event runs, lowest first, and
|
|
66
|
+
* `event.preventKiranaHandler()` in a caller's stops the part's. The `render` element's own
|
|
67
|
+
* children are drawn when it has any, and both its ref and the part's `ref` get the element.
|
|
68
|
+
* `hold` is for a part that keeps something of its own in its element (a hidden input): it is
|
|
69
|
+
* given the content and returns what the element holds, whoever drew the element.
|
|
70
|
+
*/
|
|
71
|
+
export declare function usePart<Tag extends PartTag, State = PartState>(part: Part, tag: Tag, props: PartComponentProps<Tag, State>, state?: State, hold?: (content: ReactNode) => ReactNode): ReactElement;
|
|
72
|
+
/**
|
|
73
|
+
* A component that is handed its caller's `ref` on every React the package takes, under the
|
|
74
|
+
* name DevTools shows it by. React 19 gives a component its `ref` among its props, which is
|
|
75
|
+
* where a part reads it; before, only a `forwardRef` component was given one, so there the
|
|
76
|
+
* component is drawn by one that puts the ref back among the props. Its type is its own
|
|
77
|
+
* either way, so one that is generic stays generic. One that already has a name keeps it.
|
|
78
|
+
*/
|
|
79
|
+
export declare function component<Drawn extends (props: never) => ReactNode>(name: string, draw: Drawn): Drawn;
|
|
80
|
+
/**
|
|
81
|
+
* A component's parts, each one a `component` named `Name.Part`. A part that is another
|
|
82
|
+
* component's (a date picker's trigger is a popover's) is the same component there and here.
|
|
83
|
+
*/
|
|
84
|
+
export declare function parts<const Parts extends Record<string, unknown>>(name: string, all: Parts): Parts;
|
|
85
|
+
/**
|
|
86
|
+
* A part's element as a component of its own, for a part that is not always in the page: the
|
|
87
|
+
* part decides, and draws this when it is. It takes the part's props, with the part it is the
|
|
88
|
+
* element `of`, its tag, and what the element holds of the part's own (`hold`, as `usePart`'s).
|
|
89
|
+
*/
|
|
90
|
+
export declare const PartElement: <Tag extends PartTag, State = PartState>({ of, tag, hold, ...props }: PartComponentProps<Tag, State> & {
|
|
91
|
+
of: Part;
|
|
92
|
+
tag: Tag;
|
|
93
|
+
hold?: ((content: ReactNode) => ReactNode) | undefined;
|
|
94
|
+
}) => ReactElement;
|
|
95
|
+
/** A positioner's own props: where its popup goes, and what it is placed against. */
|
|
96
|
+
export type PositionerOptions = Partial<Omit<PositionOptions, "anchor">> & {
|
|
97
|
+
/**
|
|
98
|
+
* What the popup is placed against, when that is not its trigger: an element, a ref to one,
|
|
99
|
+
* a place in the viewport (an object with `getBoundingClientRect`), or a function that gives
|
|
100
|
+
* one. It may change while the popup is open: the popup follows.
|
|
101
|
+
*/
|
|
102
|
+
anchor?: Anchor | RefObject<Element | null> | (() => Anchor | null | undefined) | null | undefined;
|
|
103
|
+
};
|
|
104
|
+
/** A positioner's props: where its popup goes and what it is placed against, and its element's. */
|
|
105
|
+
export type PositionerProps<State = PartState> = PartComponentProps<"div", State, PositionerOptions>;
|
|
106
|
+
/**
|
|
107
|
+
* A positioner's own props, written where its placement reads them: the one place they are
|
|
108
|
+
* named. Gives back what is left, for the part's element.
|
|
109
|
+
*/
|
|
110
|
+
export declare function usePositioning<Props extends PositionerOptions>(positioning: Signal<Partial<PositionOptions>>, { side, align, sideOffset, alignOffset, collisionPadding, anchor, ...rest }: Props): Omit<Props, keyof PositionerOptions>;
|
|
111
|
+
/**
|
|
112
|
+
* A text input whose text is the core's own (a combobox's, a number field's): its `value` is
|
|
113
|
+
* given to React as the input's default. To React a `value` with no `onChange` is an input
|
|
114
|
+
* that cannot be typed in; the core writes the text itself, as it changes.
|
|
115
|
+
*/
|
|
116
|
+
export declare function useOwnText(part: Part): Part;
|
|
117
|
+
/** What `PortalProvider` takes. */
|
|
118
|
+
export interface PortalProviderProps {
|
|
119
|
+
/** Where the popups inside are drawn; the end of `<body>` while it is not given. */
|
|
120
|
+
container?: HTMLElement | null | undefined;
|
|
21
121
|
children?: ReactNode;
|
|
22
|
-
ref?: Ref<HTMLElement> | undefined;
|
|
23
|
-
[attribute: string]: unknown;
|
|
24
122
|
}
|
|
25
123
|
/**
|
|
26
|
-
*
|
|
27
|
-
* the
|
|
124
|
+
* Says where every popup inside it is drawn, the popups those open included: an element of
|
|
125
|
+
* the page (a shadow root's host, a full-screen element, a frame) in place of `<body>`.
|
|
28
126
|
*/
|
|
29
|
-
export declare function
|
|
30
|
-
/**
|
|
31
|
-
export
|
|
127
|
+
export declare function PortalProvider({ container, children }: PortalProviderProps): ReactElement;
|
|
128
|
+
/** Draws no element of its own: its children at the end of `<body>`, or where a `PortalProvider` says. */
|
|
129
|
+
export interface PortalProps {
|
|
32
130
|
children?: ReactNode;
|
|
33
|
-
}
|
|
131
|
+
}
|
|
132
|
+
/** Its children in a container at the end of the page, once the page has hydrated. */
|
|
133
|
+
export declare function Portal({ children }: PortalProps): ReactElement | null;
|
|
134
|
+
export type { PartEvent };
|
|
34
135
|
//# sourceMappingURL=runtime.d.ts.map
|