@kirana-ui/react 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/llms.txt +1838 -0
- package/package.json +112 -2
- package/src/accordion.js +3 -3
- package/src/accordion.js.map +1 -1
- package/src/autocomplete.d.ts +2 -0
- package/src/autocomplete.js +1 -0
- package/src/autosize.d.ts +9 -0
- package/src/autosize.js +12 -0
- package/src/autosize.js.map +1 -0
- package/src/avatar.js +2 -2
- package/src/avatar.js.map +1 -1
- package/src/calendar.d.ts +44 -0
- package/src/calendar.js +85 -0
- package/src/calendar.js.map +1 -0
- package/src/carousel.d.ts +26 -0
- package/src/carousel.js +52 -0
- package/src/carousel.js.map +1 -0
- package/src/checkbox.d.ts +1 -1
- package/src/checkbox.js +2 -1
- package/src/checkbox.js.map +1 -1
- package/src/combobox.d.ts +91 -0
- package/src/combobox.js +164 -0
- package/src/combobox.js.map +1 -0
- package/src/command.d.ts +44 -0
- package/src/command.js +88 -0
- package/src/command.js.map +1 -0
- package/src/context-menu.d.ts +2 -0
- package/src/context-menu.js +1 -0
- package/src/date-field.d.ts +25 -0
- package/src/date-field.js +60 -0
- package/src/date-field.js.map +1 -0
- package/src/date-picker.d.ts +53 -0
- package/src/date-picker.js +62 -0
- package/src/date-picker.js.map +1 -0
- package/src/dialog.d.ts +17 -0
- package/src/dialog.js +14 -1
- package/src/dialog.js.map +1 -1
- package/src/direction.js +1 -1
- package/src/drawer.d.ts +2 -0
- package/src/drawer.js +1 -0
- package/src/field.js +3 -3
- package/src/field.js.map +1 -1
- package/src/hover-card.d.ts +2 -2
- package/src/hover-popup.d.ts +5 -1
- package/src/hover-popup.js +9 -1
- package/src/hover-popup.js.map +1 -1
- package/src/index.d.ts +27 -3
- package/src/index.js +26 -2
- package/src/input.d.ts +10 -0
- package/src/input.js +21 -0
- package/src/input.js.map +1 -0
- package/src/label.d.ts +5 -0
- package/src/label.js +14 -0
- package/src/label.js.map +1 -0
- package/src/listbox.d.ts +28 -0
- package/src/listbox.js +89 -0
- package/src/listbox.js.map +1 -0
- package/src/menu.d.ts +89 -0
- package/src/menu.js +214 -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 +9 -0
- package/src/menubar.js +25 -0
- package/src/menubar.js.map +1 -0
- package/src/message-scroller.d.ts +18 -0
- package/src/message-scroller.js +35 -0
- package/src/message-scroller.js.map +1 -0
- package/src/navigation-menu.d.ts +48 -0
- package/src/navigation-menu.js +115 -0
- package/src/navigation-menu.js.map +1 -0
- package/src/number-field.d.ts +21 -0
- package/src/number-field.js +62 -0
- package/src/number-field.js.map +1 -0
- package/src/otp.d.ts +26 -0
- package/src/otp.js +70 -0
- package/src/otp.js.map +1 -0
- package/src/pagination.d.ts +27 -0
- package/src/pagination.js +50 -0
- package/src/pagination.js.map +1 -0
- package/src/popover.d.ts +3 -2
- package/src/popover.js +1 -1
- package/src/popover.js.map +1 -1
- package/src/qr-code.d.ts +16 -0
- package/src/qr-code.js +32 -0
- package/src/qr-code.js.map +1 -0
- package/src/radio-group.d.ts +1 -1
- package/src/radio-group.js +5 -4
- package/src/radio-group.js.map +1 -1
- package/src/resizable.d.ts +19 -0
- package/src/resizable.js +51 -0
- package/src/resizable.js.map +1 -0
- package/src/runtime.d.ts +28 -1
- package/src/runtime.js +97 -9
- package/src/runtime.js.map +1 -1
- package/src/scroll-area.d.ts +25 -0
- package/src/scroll-area.js +61 -0
- package/src/scroll-area.js.map +1 -0
- package/src/select.d.ts +31 -3
- package/src/select.js +63 -5
- package/src/select.js.map +1 -1
- package/src/slider.d.ts +1 -1
- package/src/slider.js +3 -1
- package/src/slider.js.map +1 -1
- package/src/switch.d.ts +1 -1
- package/src/switch.js +2 -1
- package/src/switch.js.map +1 -1
- package/src/tabs.js +3 -3
- package/src/tabs.js.map +1 -1
- package/src/toast.d.ts +32 -0
- package/src/toast.js +61 -0
- package/src/toast.js.map +1 -0
- package/src/toggle-group.d.ts +7 -0
- package/src/toggle-group.js +32 -0
- package/src/toggle-group.js.map +1 -0
- package/src/toggle.d.ts +2 -1
- package/src/toggle.js +13 -3
- 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 +20 -0
- package/src/toolbar.js +53 -0
- package/src/toolbar.js.map +1 -0
- package/src/tooltip.d.ts +2 -2
package/src/otp.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
import { OtpProps } from "@kirana-ui/core/otp";
|
|
4
|
+
export type RootProps = Omit<OtpProps, "id"> & {
|
|
5
|
+
id?: string;
|
|
6
|
+
} & PartComponentProps;
|
|
7
|
+
declare function Root({ length, value, defaultValue, onValueChange, onComplete, mode, disabled, name, form, id, ...rest }: RootProps): ReactElement;
|
|
8
|
+
declare const Input: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
9
|
+
declare const Group: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
10
|
+
declare const Separator: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
11
|
+
/** One cell: it shows its character, then whatever it is given (a caret). */
|
|
12
|
+
declare function Slot({ index, children, ...props }: PartComponentProps & {
|
|
13
|
+
index: number;
|
|
14
|
+
}): import("react").JSX.Element;
|
|
15
|
+
/** Drawn in its cell while the cell is the active one and empty. */
|
|
16
|
+
declare function Caret(props: PartComponentProps): ReactElement | null;
|
|
17
|
+
export declare const Otp: {
|
|
18
|
+
Root: typeof Root;
|
|
19
|
+
Input: typeof Input;
|
|
20
|
+
Group: typeof Group;
|
|
21
|
+
Slot: typeof Slot;
|
|
22
|
+
Separator: typeof Separator;
|
|
23
|
+
Caret: typeof Caret;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=otp.d.ts.map
|
package/src/otp.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useController, usePart, useSignal } from "./runtime.js";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { createOtp } from "@kirana-ui/core/otp";
|
|
5
|
+
// src/otp.tsx
|
|
6
|
+
const Context = createContext(null);
|
|
7
|
+
const SlotContext = createContext(null);
|
|
8
|
+
function useOtp(part) {
|
|
9
|
+
const controller = useContext(Context);
|
|
10
|
+
if (!controller) throw new Error(`<Otp.${part}> must be inside <Otp.Root>`);
|
|
11
|
+
return controller;
|
|
12
|
+
}
|
|
13
|
+
function Root({ length, value, defaultValue, onValueChange, onComplete, mode, disabled, name, form, id, ...rest }) {
|
|
14
|
+
const controller = useController(createOtp, {
|
|
15
|
+
length,
|
|
16
|
+
value,
|
|
17
|
+
defaultValue,
|
|
18
|
+
onValueChange,
|
|
19
|
+
onComplete,
|
|
20
|
+
mode,
|
|
21
|
+
disabled,
|
|
22
|
+
name,
|
|
23
|
+
form,
|
|
24
|
+
id
|
|
25
|
+
});
|
|
26
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
27
|
+
value: controller,
|
|
28
|
+
children: usePart(controller.root, "div", rest)
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const PartElement = ({ part, tag, ...props }) => usePart(part, tag, props);
|
|
32
|
+
const Input = (props) => usePart(useOtp("Input").input, "input", props);
|
|
33
|
+
const Group = (props) => usePart(useOtp("Group").group, "div", props);
|
|
34
|
+
const Separator = (props) => usePart(useOtp("Separator").separator, "div", props);
|
|
35
|
+
/** One cell: it shows its character, then whatever it is given (a caret). */
|
|
36
|
+
function Slot({ index, children, ...props }) {
|
|
37
|
+
const slot = useOtp("Slot").slot(index);
|
|
38
|
+
const char = useSignal(slot.char);
|
|
39
|
+
return /* @__PURE__ */ jsx(SlotContext.Provider, {
|
|
40
|
+
value: slot,
|
|
41
|
+
children: /* @__PURE__ */ jsxs(PartElement, {
|
|
42
|
+
part: slot.part,
|
|
43
|
+
tag: "div",
|
|
44
|
+
...props,
|
|
45
|
+
children: [char, children]
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/** Drawn in its cell while the cell is the active one and empty. */
|
|
50
|
+
function Caret(props) {
|
|
51
|
+
const controller = useOtp("Caret");
|
|
52
|
+
const slot = useContext(SlotContext);
|
|
53
|
+
if (!slot) throw new Error("<Otp.Caret> must be inside <Otp.Slot>");
|
|
54
|
+
return useSignal(slot.caret) ? /* @__PURE__ */ jsx(PartElement, {
|
|
55
|
+
part: controller.caretPart,
|
|
56
|
+
tag: "div",
|
|
57
|
+
...props
|
|
58
|
+
}) : null;
|
|
59
|
+
}
|
|
60
|
+
const Otp = {
|
|
61
|
+
Root,
|
|
62
|
+
Input,
|
|
63
|
+
Group,
|
|
64
|
+
Slot,
|
|
65
|
+
Separator,
|
|
66
|
+
Caret
|
|
67
|
+
};
|
|
68
|
+
export { Otp };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=otp.js.map
|
package/src/otp.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otp.js","names":[],"sources":["../../../../packages/react/src/otp.tsx"],"sourcesContent":["import type { Part } from \"@kirana-ui/core\"\nimport { createOtp } from \"@kirana-ui/core/otp\"\nimport type { Otp as Controller, OtpProps, OtpSlot } from \"@kirana-ui/core/otp\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { useController, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nconst Context = createContext<Controller | null>(null)\nconst SlotContext = createContext<OtpSlot | null>(null)\n\nfunction useOtp(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Otp.${part}> must be inside <Otp.Root>`)\n return controller\n}\n\nexport type RootProps = Omit<OtpProps, \"id\"> & { id?: string } & PartComponentProps\n\nfunction Root({\n length,\n value,\n defaultValue,\n onValueChange,\n onComplete,\n mode,\n disabled,\n name,\n form,\n id,\n ...rest\n}: RootProps): ReactElement {\n const controller = useController<OtpProps, Controller>(createOtp, {\n length,\n value,\n defaultValue,\n onValueChange,\n onComplete,\n mode,\n disabled,\n name,\n form,\n id,\n })\n return (\n <Context.Provider value={controller}>{usePart(controller.root, \"div\", rest)}</Context.Provider>\n )\n}\n\nconst PartElement = ({ part, tag, ...props }: PartComponentProps & { part: Part; tag: string }) =>\n usePart(part, tag, props)\n\nconst Input = (props: PartComponentProps) => usePart(useOtp(\"Input\").input, \"input\", props)\nconst Group = (props: PartComponentProps) => usePart(useOtp(\"Group\").group, \"div\", props)\nconst Separator = (props: PartComponentProps) =>\n usePart(useOtp(\"Separator\").separator, \"div\", props)\n\n/** One cell: it shows its character, then whatever it is given (a caret). */\nfunction Slot({ index, children, ...props }: PartComponentProps & { index: number }) {\n const slot = useOtp(\"Slot\").slot(index)\n const char = useSignal(slot.char)\n return (\n <SlotContext.Provider value={slot}>\n <PartElement part={slot.part} tag=\"div\" {...props}>\n {char}\n {children}\n </PartElement>\n </SlotContext.Provider>\n )\n}\n\n/** Drawn in its cell while the cell is the active one and empty. */\nfunction Caret(props: PartComponentProps): ReactElement | null {\n const controller = useOtp(\"Caret\")\n const slot = useContext(SlotContext)\n if (!slot) throw new Error(\"<Otp.Caret> must be inside <Otp.Slot>\")\n const shown = useSignal(slot.caret)\n return shown ? <PartElement part={controller.caretPart} tag=\"div\" {...props} /> : null\n}\n\nexport const Otp = { Root, Input, Group, Slot, Separator, Caret }\n"],"mappings":";;;;;AASA,MAAM,UAAU,cAAiC,IAAI;AACrD,MAAM,cAAc,cAA8B,IAAI;AAEtD,SAAS,OAAO,MAA0B;CACxC,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,QAAQ,KAAK,4BAA4B;CAC1E,OAAO;AACT;AAIA,SAAS,KAAK,EACZ,QACA,OACA,cACA,eACA,YACA,MACA,UACA,MACA,MACA,IACA,GAAG,QACuB;CAC1B,MAAM,aAAa,cAAoC,WAAW;EAChE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CAAoB,CAAA;AAElG;AAEA,MAAM,eAAe,EAAE,MAAM,KAAK,GAAG,YACnC,QAAQ,MAAM,KAAK,KAAK;AAE1B,MAAM,SAAS,UAA8B,QAAQ,OAAO,OAAO,CAAC,CAAC,OAAO,SAAS,KAAK;AAC1F,MAAM,SAAS,UAA8B,QAAQ,OAAO,OAAO,CAAC,CAAC,OAAO,OAAO,KAAK;AACxF,MAAM,aAAa,UACjB,QAAQ,OAAO,WAAW,CAAC,CAAC,WAAW,OAAO,KAAK;;AAGrD,SAAS,KAAK,EAAE,OAAO,UAAU,GAAG,SAAiD;CACnF,MAAM,OAAO,OAAO,MAAM,CAAC,CAAC,KAAK,KAAK;CACtC,MAAM,OAAO,UAAU,KAAK,IAAI;CAChC,OACE,oBAAC,YAAY,UAAb;EAAsB,OAAO;EAC3B,UAAA,qBAAC,aAAD;GAAa,MAAM,KAAK;GAAM,KAAI;GAAM,GAAI;GAA5C,UAAA,CACG,MACA,QACU;;CACO,CAAA;AAE1B;;AAGA,SAAS,MAAM,OAAgD;CAC7D,MAAM,aAAa,OAAO,OAAO;CACjC,MAAM,OAAO,WAAW,WAAW;CACnC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,uCAAuC;CAElE,OADc,UAAU,KAAK,KAClB,IAAI,oBAAC,aAAD;EAAa,MAAM,WAAW;EAAW,KAAI;EAAM,GAAI;CAAQ,CAAA,IAAI;AACpF;AAEA,MAAa,MAAM;CAAE;CAAM;CAAO;CAAO;CAAM;CAAW;AAAM"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { ReactElement, ReactNode } from "react";
|
|
3
|
+
import { PaginationEntry, PaginationProps } from "@kirana-ui/core/pagination";
|
|
4
|
+
export type RootProps = Omit<PaginationProps, "id"> & {
|
|
5
|
+
id?: string;
|
|
6
|
+
} & PartComponentProps;
|
|
7
|
+
declare function Root({ page, defaultPage, onPageChange, count, pageSize, siblingCount, boundaryCount, disabled, id, ...rest }: RootProps): ReactElement;
|
|
8
|
+
/** Draws its child once for each piece of the row: a page, or the mark for pages left out. */
|
|
9
|
+
declare function Items({ children }: {
|
|
10
|
+
children: (entry: PaginationEntry) => ReactNode;
|
|
11
|
+
}): ReactElement;
|
|
12
|
+
declare function Item({ page, ...props }: PartComponentProps & {
|
|
13
|
+
page: number;
|
|
14
|
+
}): ReactElement;
|
|
15
|
+
declare const Ellipsis: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
16
|
+
declare const Previous: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
17
|
+
declare const Next: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
18
|
+
export declare const Pagination: {
|
|
19
|
+
Root: typeof Root;
|
|
20
|
+
Items: typeof Items;
|
|
21
|
+
Item: typeof Item;
|
|
22
|
+
Ellipsis: typeof Ellipsis;
|
|
23
|
+
Previous: typeof Previous;
|
|
24
|
+
Next: typeof Next;
|
|
25
|
+
};
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useController, usePart, useSignal } from "./runtime.js";
|
|
2
|
+
import { Fragment, createContext, useContext } from "react";
|
|
3
|
+
import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
|
|
4
|
+
import { createPagination } from "@kirana-ui/core/pagination";
|
|
5
|
+
// src/pagination.tsx
|
|
6
|
+
const Context = createContext(null);
|
|
7
|
+
function usePagination(part) {
|
|
8
|
+
const controller = useContext(Context);
|
|
9
|
+
if (!controller) throw new Error(`<Pagination.${part}> must be inside <Pagination.Root>`);
|
|
10
|
+
return controller;
|
|
11
|
+
}
|
|
12
|
+
function Root({ page, defaultPage, onPageChange, count, pageSize, siblingCount, boundaryCount, disabled, id, ...rest }) {
|
|
13
|
+
const controller = useController(createPagination, {
|
|
14
|
+
page,
|
|
15
|
+
defaultPage,
|
|
16
|
+
onPageChange,
|
|
17
|
+
count,
|
|
18
|
+
pageSize,
|
|
19
|
+
siblingCount,
|
|
20
|
+
boundaryCount,
|
|
21
|
+
disabled,
|
|
22
|
+
id
|
|
23
|
+
});
|
|
24
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
25
|
+
value: controller,
|
|
26
|
+
children: usePart(controller.root, "nav", rest)
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/** Draws its child once for each piece of the row: a page, or the mark for pages left out. */
|
|
30
|
+
function Items({ children }) {
|
|
31
|
+
const entries = useSignal(usePagination("Items").entries);
|
|
32
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children: entries.map((entry) => /* @__PURE__ */ jsx(Fragment, { children: children(entry) }, entry.key)) });
|
|
33
|
+
}
|
|
34
|
+
function Item({ page, ...props }) {
|
|
35
|
+
return usePart(usePagination("Item").item(page), "button", props);
|
|
36
|
+
}
|
|
37
|
+
const Ellipsis = (props) => usePart(usePagination("Ellipsis").ellipsis, "span", props);
|
|
38
|
+
const Previous = (props) => usePart(usePagination("Previous").previous, "button", props);
|
|
39
|
+
const Next = (props) => usePart(usePagination("Next").next, "button", props);
|
|
40
|
+
const Pagination = {
|
|
41
|
+
Root,
|
|
42
|
+
Items,
|
|
43
|
+
Item,
|
|
44
|
+
Ellipsis,
|
|
45
|
+
Previous,
|
|
46
|
+
Next
|
|
47
|
+
};
|
|
48
|
+
export { Pagination };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.js","names":[],"sources":["../../../../packages/react/src/pagination.tsx"],"sourcesContent":["import { createPagination } from \"@kirana-ui/core/pagination\"\nimport type {\n Pagination as Controller,\n PaginationEntry,\n PaginationProps,\n} from \"@kirana-ui/core/pagination\"\nimport { Fragment, createContext, useContext } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { useController, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nconst Context = createContext<Controller | null>(null)\n\nfunction usePagination(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Pagination.${part}> must be inside <Pagination.Root>`)\n return controller\n}\n\nexport type RootProps = Omit<PaginationProps, \"id\"> & { id?: string } & PartComponentProps\n\nfunction Root({\n page,\n defaultPage,\n onPageChange,\n count,\n pageSize,\n siblingCount,\n boundaryCount,\n disabled,\n id,\n ...rest\n}: RootProps): ReactElement {\n const controller = useController<PaginationProps, Controller>(createPagination, {\n page,\n defaultPage,\n onPageChange,\n count,\n pageSize,\n siblingCount,\n boundaryCount,\n disabled,\n id,\n })\n return (\n <Context.Provider value={controller}>{usePart(controller.root, \"nav\", rest)}</Context.Provider>\n )\n}\n\n/** Draws its child once for each piece of the row: a page, or the mark for pages left out. */\nfunction Items({ children }: { children: (entry: PaginationEntry) => ReactNode }): ReactElement {\n const entries = useSignal(usePagination(\"Items\").entries)\n return (\n <>\n {entries.map((entry) => (\n <Fragment key={entry.key}>{children(entry)}</Fragment>\n ))}\n </>\n )\n}\n\nfunction Item({ page, ...props }: PartComponentProps & { page: number }): ReactElement {\n return usePart(usePagination(\"Item\").item(page), \"button\", props)\n}\n\nconst Ellipsis = (props: PartComponentProps) =>\n usePart(usePagination(\"Ellipsis\").ellipsis, \"span\", props)\nconst Previous = (props: PartComponentProps) =>\n usePart(usePagination(\"Previous\").previous, \"button\", props)\nconst Next = (props: PartComponentProps) => usePart(usePagination(\"Next\").next, \"button\", props)\n\nexport const Pagination = { Root, Items, Item, Ellipsis, Previous, Next }\n"],"mappings":";;;;;AAYA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,cAAc,MAA0B;CAC/C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,eAAe,KAAK,mCAAmC;CACxF,OAAO;AACT;AAIA,SAAS,KAAK,EACZ,MACA,aACA,cACA,OACA,UACA,cACA,eACA,UACA,IACA,GAAG,QACuB;CAC1B,MAAM,aAAa,cAA2C,kBAAkB;EAC9E;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CAAoB,CAAA;AAElG;;AAGA,SAAS,MAAM,EAAE,YAA+E;CAC9F,MAAM,UAAU,UAAU,cAAc,OAAO,CAAC,CAAC,OAAO;CACxD,OACE,oBAAA,YAAA,EAAA,UACG,QAAQ,KAAK,UACZ,oBAAC,UAAD,EAAA,UAA2B,SAAS,KAAK,EAAY,GAAtC,MAAM,GAAgC,CACtD,EACD,CAAA;AAEN;AAEA,SAAS,KAAK,EAAE,MAAM,GAAG,SAA8D;CACrF,OAAO,QAAQ,cAAc,MAAM,CAAC,CAAC,KAAK,IAAI,GAAG,UAAU,KAAK;AAClE;AAEA,MAAM,YAAY,UAChB,QAAQ,cAAc,UAAU,CAAC,CAAC,UAAU,QAAQ,KAAK;AAC3D,MAAM,YAAY,UAChB,QAAQ,cAAc,UAAU,CAAC,CAAC,UAAU,UAAU,KAAK;AAC7D,MAAM,QAAQ,UAA8B,QAAQ,cAAc,MAAM,CAAC,CAAC,MAAM,UAAU,KAAK;AAE/F,MAAa,aAAa;CAAE;CAAM;CAAO;CAAM;CAAU;CAAU;AAAK"}
|
package/src/popover.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { PartComponentProps } from "./runtime.js";
|
|
2
2
|
import { PositionOptions } from "@kirana-ui/core";
|
|
3
3
|
import { ReactElement, ReactNode } from "react";
|
|
4
|
-
import { PopoverProps } from "@kirana-ui/core/popover";
|
|
4
|
+
import { Popover as Popover$1, PopoverProps } from "@kirana-ui/core/popover";
|
|
5
|
+
declare const Context: import("react").Context<Popover$1 | null>;
|
|
5
6
|
export type RootProps = Omit<PopoverProps, "id"> & {
|
|
6
7
|
id?: string;
|
|
7
8
|
children?: ReactNode;
|
|
@@ -27,5 +28,5 @@ export declare const Popover: {
|
|
|
27
28
|
Description: typeof Description;
|
|
28
29
|
Close: typeof Close;
|
|
29
30
|
};
|
|
30
|
-
export {};
|
|
31
|
+
export { Context as PopoverContext };
|
|
31
32
|
//# sourceMappingURL=popover.d.ts.map
|
package/src/popover.js
CHANGED
package/src/popover.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.js","names":["BodyPortal"],"sources":["../../../../packages/react/src/popover.tsx"],"sourcesContent":["import { defined } from \"@kirana-ui/core\"\nimport type { PositionOptions } from \"@kirana-ui/core\"\nimport { createPopover } from \"@kirana-ui/core/popover\"\nimport type { Popover as Controller, PopoverProps } from \"@kirana-ui/core/popover\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { Portal as BodyPortal, useController, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nconst Context = createContext<Controller | null>(null)\n\nfunction usePopover(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Popover.${part}> must be inside <Popover.Root>`)\n return controller\n}\n\nexport type RootProps = Omit<PopoverProps, \"id\"> & { id?: string; children?: ReactNode }\n\nfunction Root({ children, ...props }: RootProps): ReactElement {\n const controller = useController(createPopover, props)\n return <Context.Provider value={controller}>{children}</Context.Provider>\n}\n\nfunction Portal({ children }: { children?: ReactNode }): ReactElement | null {\n const mounted = useSignal(usePopover(\"Portal\").mounted)\n return mounted ? <BodyPortal>{children}</BodyPortal> : null\n}\n\nexport type PositionerProps = PartComponentProps & Partial<PositionOptions>\n\nfunction Positioner({\n side,\n align,\n sideOffset,\n alignOffset,\n collisionPadding,\n ...props\n}: PositionerProps) {\n const controller = usePopover(\"Positioner\")\n // Written while rendering, so the first placement (made when the element attaches, before\n // this component's effects) reads them. Nothing re-renders for it: the core compares.\n controller.positioning.set(defined({ side, align, sideOffset, alignOffset, collisionPadding }))\n return usePart(controller.positioner, \"div\", props)\n}\n\nconst Trigger = (props: PartComponentProps) =>\n usePart(usePopover(\"Trigger\").trigger, \"button\", props)\nconst Popup = (props: PartComponentProps) => usePart(usePopover(\"Popup\").popup, \"div\", props)\nconst Title = (props: PartComponentProps) => usePart(usePopover(\"Title\").title, \"h2\", props)\nconst Description = (props: PartComponentProps) =>\n usePart(usePopover(\"Description\").description, \"p\", props)\nconst Close = (props: PartComponentProps) => usePart(usePopover(\"Close\").close, \"button\", props)\n\nexport const Popover = { Root, Trigger, Portal, Positioner, Popup, Title, Description, Close }\n"],"mappings":";;;;;;AAUA,MAAM,UAAU,cAAiC,IAAI;
|
|
1
|
+
{"version":3,"file":"popover.js","names":["BodyPortal"],"sources":["../../../../packages/react/src/popover.tsx"],"sourcesContent":["import { defined } from \"@kirana-ui/core\"\nimport type { PositionOptions } from \"@kirana-ui/core\"\nimport { createPopover } from \"@kirana-ui/core/popover\"\nimport type { Popover as Controller, PopoverProps } from \"@kirana-ui/core/popover\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { Portal as BodyPortal, useController, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nconst Context = createContext<Controller | null>(null)\n/** For a component made of this one's parts: a date picker. */\nexport { Context as PopoverContext }\n\nfunction usePopover(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Popover.${part}> must be inside <Popover.Root>`)\n return controller\n}\n\nexport type RootProps = Omit<PopoverProps, \"id\"> & { id?: string; children?: ReactNode }\n\nfunction Root({ children, ...props }: RootProps): ReactElement {\n const controller = useController(createPopover, props)\n return <Context.Provider value={controller}>{children}</Context.Provider>\n}\n\nfunction Portal({ children }: { children?: ReactNode }): ReactElement | null {\n const mounted = useSignal(usePopover(\"Portal\").mounted)\n return mounted ? <BodyPortal>{children}</BodyPortal> : null\n}\n\nexport type PositionerProps = PartComponentProps & Partial<PositionOptions>\n\nfunction Positioner({\n side,\n align,\n sideOffset,\n alignOffset,\n collisionPadding,\n ...props\n}: PositionerProps) {\n const controller = usePopover(\"Positioner\")\n // Written while rendering, so the first placement (made when the element attaches, before\n // this component's effects) reads them. Nothing re-renders for it: the core compares.\n controller.positioning.set(defined({ side, align, sideOffset, alignOffset, collisionPadding }))\n return usePart(controller.positioner, \"div\", props)\n}\n\nconst Trigger = (props: PartComponentProps) =>\n usePart(usePopover(\"Trigger\").trigger, \"button\", props)\nconst Popup = (props: PartComponentProps) => usePart(usePopover(\"Popup\").popup, \"div\", props)\nconst Title = (props: PartComponentProps) => usePart(usePopover(\"Title\").title, \"h2\", props)\nconst Description = (props: PartComponentProps) =>\n usePart(usePopover(\"Description\").description, \"p\", props)\nconst Close = (props: PartComponentProps) => usePart(usePopover(\"Close\").close, \"button\", props)\n\nexport const Popover = { Root, Trigger, Portal, Positioner, Popup, Title, Description, Close }\n"],"mappings":";;;;;;AAUA,MAAM,UAAU,cAAiC,IAAI;AAIrD,SAAS,WAAW,MAA0B;CAC5C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,YAAY,KAAK,gCAAgC;CAClF,OAAO;AACT;AAIA,SAAS,KAAK,EAAE,UAAU,GAAG,SAAkC;CAC7D,MAAM,aAAa,cAAc,eAAe,KAAK;CACrD,OAAO,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa;CAA2B,CAAA;AAC1E;AAEA,SAAS,OAAO,EAAE,YAA2D;CAE3E,OADgB,UAAU,WAAW,QAAQ,CAAC,CAAC,OAClC,IAAI,oBAACA,UAAD,EAAa,SAAqB,CAAA,IAAI;AACzD;AAIA,SAAS,WAAW,EAClB,MACA,OACA,YACA,aACA,kBACA,GAAG,SACe;CAClB,MAAM,aAAa,WAAW,YAAY;CAG1C,WAAW,YAAY,IAAI,QAAQ;EAAE;EAAM;EAAO;EAAY;EAAa;CAAiB,CAAC,CAAC;CAC9F,OAAO,QAAQ,WAAW,YAAY,OAAO,KAAK;AACpD;AAEA,MAAM,WAAW,UACf,QAAQ,WAAW,SAAS,CAAC,CAAC,SAAS,UAAU,KAAK;AACxD,MAAM,SAAS,UAA8B,QAAQ,WAAW,OAAO,CAAC,CAAC,OAAO,OAAO,KAAK;AAC5F,MAAM,SAAS,UAA8B,QAAQ,WAAW,OAAO,CAAC,CAAC,OAAO,MAAM,KAAK;AAC3F,MAAM,eAAe,UACnB,QAAQ,WAAW,aAAa,CAAC,CAAC,aAAa,KAAK,KAAK;AAC3D,MAAM,SAAS,UAA8B,QAAQ,WAAW,OAAO,CAAC,CAAC,OAAO,UAAU,KAAK;AAE/F,MAAa,UAAU;CAAE;CAAM;CAAS;CAAQ;CAAY;CAAO;CAAO;CAAa;AAAM"}
|
package/src/qr-code.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
import { QrCodeProps } from "@kirana-ui/core/qr-code";
|
|
4
|
+
export type RootProps = Omit<QrCodeProps, "id"> & {
|
|
5
|
+
id?: string;
|
|
6
|
+
} & PartComponentProps;
|
|
7
|
+
declare function Root({ value, correction, id, ...rest }: RootProps): ReactElement;
|
|
8
|
+
declare const Frame: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
9
|
+
declare const Pattern: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
10
|
+
export declare const QrCode: {
|
|
11
|
+
Root: typeof Root;
|
|
12
|
+
Frame: typeof Frame;
|
|
13
|
+
Pattern: typeof Pattern;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=qr-code.d.ts.map
|
package/src/qr-code.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { 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 = {
|
|
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 { createQrCode } from \"@kirana-ui/core/qr-code\"\nimport type { QrCode as Controller, QrCodeProps } from \"@kirana-ui/core/qr-code\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\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 = Omit<QrCodeProps, \"id\"> & { id?: string } & PartComponentProps\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\nconst Frame = (props: PartComponentProps) => usePart(useQrCode(\"Frame\").frame, \"svg\", props)\nconst Pattern = (props: PartComponentProps) => usePart(useQrCode(\"Pattern\").pattern, \"path\", props)\n\nexport const QrCode = { Root, Frame, Pattern }\n"],"mappings":";;;;;AAQA,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;AAIA,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;AAEA,MAAM,SAAS,UAA8B,QAAQ,UAAU,OAAO,CAAC,CAAC,OAAO,OAAO,KAAK;AAC3F,MAAM,WAAW,UAA8B,QAAQ,UAAU,SAAS,CAAC,CAAC,SAAS,QAAQ,KAAK;AAElG,MAAa,SAAS;CAAE;CAAM;CAAO;AAAQ"}
|
package/src/radio-group.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { RadioGroupProps } from "@kirana-ui/core/radio-group";
|
|
|
4
4
|
export type RootProps<Value> = Omit<RadioGroupProps<Value>, "id"> & {
|
|
5
5
|
id?: string;
|
|
6
6
|
} & PartComponentProps;
|
|
7
|
-
declare function Root<Value>({ value, defaultValue, onValueChange, disabled, readOnly, required, name, id, ...rest }: RootProps<Value>): ReactElement;
|
|
7
|
+
declare function Root<Value>({ value, defaultValue, onValueChange, disabled, readOnly, required, name, form, id, ...rest }: RootProps<Value>): ReactElement;
|
|
8
8
|
export interface ItemProps extends PartComponentProps {
|
|
9
9
|
value: unknown;
|
|
10
10
|
disabled?: boolean;
|
package/src/radio-group.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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 { useController, useMount, useOptions, usePart, useSignal } from "./runtime.js";
|
|
4
4
|
import { defined, within } from "@kirana-ui/core";
|
|
5
|
-
import { createContext, useContext,
|
|
5
|
+
import { createContext, useContext, useMemo } from "react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { createRadioGroup } from "@kirana-ui/core/radio-group";
|
|
8
8
|
// src/radio-group.tsx
|
|
@@ -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,6 +28,7 @@ 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, {
|
|
@@ -68,7 +69,7 @@ function Indicator({ keepMounted, ...props }) {
|
|
|
68
69
|
const controller = useRadioGroup("Indicator");
|
|
69
70
|
const value = useContext(ItemContext);
|
|
70
71
|
const indicator = useMemo(() => controller.indicator(value), [controller, value]);
|
|
71
|
-
|
|
72
|
+
useMount(indicator);
|
|
72
73
|
if (!useSignal(indicator.mounted) && !keepMounted) return null;
|
|
73
74
|
return /* @__PURE__ */ jsx(PartElement, {
|
|
74
75
|
part: indicator.part,
|
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 { Part } 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 { createContext, useContext,
|
|
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 { Part } 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 { createContext, useContext, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { FieldContext } from \"./field-context.ts\"\nimport { useController, useMount, useOptions, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\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\nexport type RootProps<Value> = Omit<RadioGroupProps<Value>, \"id\"> & {\n id?: string\n} & PartComponentProps\n\nfunction Root<Value>({\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 = useController(create, {\n value: value as Value | null | undefined,\n defaultValue: defaultValue as Value | null | undefined,\n onValueChange,\n disabled,\n readOnly,\n required,\n name,\n form,\n id,\n }) as unknown as Controller\n return (\n <Context.Provider value={controller}>\n <RootElement {...rest} />\n </Context.Provider>\n )\n}\n\nconst RootElement = (props: PartComponentProps) => usePart(useRadioGroup(\"Root\").root, \"div\", props)\n\nexport interface ItemProps extends PartComponentProps {\n value: unknown\n disabled?: boolean\n}\n\nfunction Item({ value, disabled, children, ...rest }: ItemProps): ReactElement {\n const controller = useRadioGroup(\"Item\")\n const options = useOptions({ disabled })\n const parts = 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 <PartElement part={parts.item} tag=\"span\" {...rest}>\n {children}\n <PartElement part={parts.input} tag=\"input\" />\n </PartElement>\n </ItemContext.Provider>\n )\n}\n\nconst PartElement = ({ part, tag, ...props }: PartComponentProps & { part: Part; tag: string }) =>\n usePart(part, tag, props)\n\nexport interface IndicatorProps extends PartComponentProps {\n /** Keeps the mark in the page while its item is not the chosen one. */\n keepMounted?: boolean\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 part={indicator.part} tag=\"span\" {...props} />\n}\n\nexport const RadioGroup = { Root, Item, Indicator }\n"],"mappings":";;;;;;;;AAYA,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;AAMA,SAAS,KAAY,EACnB,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,aAAa,cAAc,QAAQ;EAChC;EACO;EACd;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EACvB,UAAA,oBAAC,aAAD,EAAa,GAAI,KAAO,CAAA;CACR,CAAA;AAEtB;AAEA,MAAM,eAAe,UAA8B,QAAQ,cAAc,MAAM,CAAC,CAAC,MAAM,OAAO,KAAK;AAOnG,SAAS,KAAK,EAAE,OAAO,UAAU,UAAU,GAAG,QAAiC;CAC7E,MAAM,aAAa,cAAc,MAAM;CACvC,MAAM,UAAU,WAAW,EAAE,SAAS,CAAC;CACvC,MAAM,QAAQ,cAAc;EAC1B,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;EAC3B,UAAA,qBAAC,aAAD;GAAa,MAAM,MAAM;GAAM,KAAI;GAAO,GAAI;GAA9C,UAAA,CACG,UACD,oBAAC,aAAD;IAAa,MAAM,MAAM;IAAO,KAAI;GAAS,CAAA,CAClC;;CACO,CAAA;AAE1B;AAEA,MAAM,eAAe,EAAE,MAAM,KAAK,GAAG,YACnC,QAAQ,MAAM,KAAK,KAAK;AAO1B,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,MAAM,UAAU;EAAM,KAAI;EAAO,GAAI;CAAQ,CAAA;AACnE;AAEA,MAAa,aAAa;CAAE;CAAM;CAAM;AAAU"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
import { ResizablePanelOptions, ResizableProps } from "@kirana-ui/core/resizable";
|
|
4
|
+
export type GroupProps = Omit<ResizableProps, "id"> & {
|
|
5
|
+
id?: string;
|
|
6
|
+
} & PartComponentProps;
|
|
7
|
+
declare function Group({ orientation, onSizesChange, keyboardStep, disabled, id, ...rest }: GroupProps): ReactElement;
|
|
8
|
+
export type PanelProps = PartComponentProps & ResizablePanelOptions;
|
|
9
|
+
declare function Panel({ defaultSize, minSize, maxSize, ...props }: PanelProps): ReactElement;
|
|
10
|
+
declare function Handle({ disabled, ...props }: PartComponentProps & {
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
}): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
13
|
+
export declare const Resizable: {
|
|
14
|
+
Group: typeof Group;
|
|
15
|
+
Panel: typeof Panel;
|
|
16
|
+
Handle: typeof Handle;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=resizable.d.ts.map
|
package/src/resizable.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { DirectionContext } from "./direction-context.js";
|
|
2
|
+
import { 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 = {
|
|
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 { createResizable } from \"@kirana-ui/core/resizable\"\nimport type {\n Resizable as Controller,\n ResizablePanelOptions,\n ResizableProps,\n} from \"@kirana-ui/core/resizable\"\nimport { createContext, useContext, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { useController, useOptions, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\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 = Omit<ResizableProps, \"id\"> & { id?: string } & PartComponentProps\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 & 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\nfunction Handle({ disabled, ...props }: PartComponentProps & { disabled?: boolean }) {\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 = { Group, Panel, Handle }\n"],"mappings":";;;;;;;AAcA,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;AAIA,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;AAEA,SAAS,OAAO,EAAE,UAAU,GAAG,SAAsD;CACnF,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,YAAY;CAAE;CAAO;CAAO;AAAO"}
|
package/src/runtime.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Part, ReadonlySignal } from "@kirana-ui/core";
|
|
2
|
-
import { ReactElement, ReactNode, Ref } from "react";
|
|
2
|
+
import { ReactElement, ReactNode, Ref, 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,6 +14,15 @@ 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
28
|
export type RenderProp<State = undefined> = ReactElement<Record<string, unknown>> | ((props: Record<string, unknown>, state: State) => ReactElement);
|
|
@@ -27,6 +38,22 @@ export interface PartComponentProps<State = undefined> {
|
|
|
27
38
|
* the part's, and the part's DOM work attached to the element.
|
|
28
39
|
*/
|
|
29
40
|
export declare function usePart<State = undefined>(part: Part, tag: string, { render, ref, ...caller }: PartComponentProps<State>, state?: State): ReactElement;
|
|
41
|
+
/**
|
|
42
|
+
* A text input whose text is the core's own (a combobox's, a number field's): its `value` is
|
|
43
|
+
* given to React as the input's default. To React a `value` with no `onChange` is an input
|
|
44
|
+
* that cannot be typed in; the core writes the text itself, as it changes.
|
|
45
|
+
*/
|
|
46
|
+
export declare function useOwnText(part: Part): Part;
|
|
47
|
+
export interface PortalProviderProps {
|
|
48
|
+
/** Where the popups inside are drawn; the end of `<body>` while it is not given. */
|
|
49
|
+
container?: HTMLElement | null | undefined;
|
|
50
|
+
children?: ReactNode;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Says where every popup inside it is drawn, the popups those open included: an element of
|
|
54
|
+
* the page (a shadow root's host, a full-screen element, a frame) in place of `<body>`.
|
|
55
|
+
*/
|
|
56
|
+
export declare function PortalProvider({ container, children }: PortalProviderProps): ReactElement;
|
|
30
57
|
/** Its children in a container at the end of the page, once the page has hydrated. */
|
|
31
58
|
export declare function Portal({ children }: {
|
|
32
59
|
children?: ReactNode;
|