@kirana-ui/react 0.0.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/LICENSE +1 -1
- package/llms.txt +1838 -0
- package/package.json +231 -6
- package/src/accordion.d.ts +28 -0
- package/src/accordion.js +81 -0
- package/src/accordion.js.map +1 -0
- package/src/alert-dialog.d.ts +2 -0
- package/src/alert-dialog.js +1 -0
- 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.d.ts +16 -0
- package/src/avatar.js +42 -0
- package/src/avatar.js.map +1 -0
- package/src/button.d.ts +7 -0
- package/src/button.js +15 -0
- package/src/button.js.map +1 -0
- 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 +18 -0
- package/src/checkbox.js +51 -0
- package/src/checkbox.js.map +1 -0
- package/src/collapsible.d.ts +20 -0
- package/src/collapsible.js +43 -0
- package/src/collapsible.js.map +1 -0
- 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 +63 -0
- package/src/dialog.js +66 -0
- package/src/dialog.js.map +1 -0
- package/src/direction-context.d.ts +4 -0
- package/src/direction-context.js +7 -0
- package/src/direction-context.js.map +1 -0
- package/src/direction.d.ts +15 -0
- package/src/direction.js +27 -0
- package/src/direction.js.map +1 -0
- package/src/drawer.d.ts +2 -0
- package/src/drawer.js +1 -0
- package/src/field-context.d.ts +4 -0
- package/src/field-context.js +7 -0
- package/src/field-context.js.map +1 -0
- package/src/field.d.ts +31 -0
- package/src/field.js +71 -0
- package/src/field.js.map +1 -0
- package/src/fieldset.d.ts +15 -0
- package/src/fieldset.js +31 -0
- package/src/fieldset.js.map +1 -0
- package/src/form.d.ts +8 -0
- package/src/form.js +27 -0
- package/src/form.js.map +1 -0
- package/src/hover-card.d.ts +13 -0
- package/src/hover-card.js +7 -0
- package/src/hover-card.js.map +1 -0
- package/src/hover-popup.d.ts +25 -0
- package/src/hover-popup.js +57 -0
- package/src/hover-popup.js.map +1 -0
- package/src/index.d.ts +48 -0
- package/src/index.js +47 -0
- 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/meter.d.ts +13 -0
- package/src/meter.js +7 -0
- package/src/meter.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 +32 -0
- package/src/popover.js +51 -0
- package/src/popover.js.map +1 -0
- package/src/progress.d.ts +13 -0
- package/src/progress.js +7 -0
- package/src/progress.js.map +1 -0
- 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 +24 -0
- package/src/radio-group.js +87 -0
- package/src/radio-group.js.map +1 -0
- 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 +61 -0
- package/src/runtime.js +208 -0
- package/src/runtime.js.map +1 -0
- 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 +74 -0
- package/src/select.js +149 -0
- package/src/select.js.map +1 -0
- package/src/separator.d.ts +6 -0
- package/src/separator.js +10 -0
- package/src/separator.js.map +1 -0
- package/src/slider.d.ts +29 -0
- package/src/slider.js +84 -0
- package/src/slider.js.map +1 -0
- package/src/switch.d.ts +14 -0
- package/src/switch.js +46 -0
- package/src/switch.js.map +1 -0
- package/src/tabs.d.ts +30 -0
- package/src/tabs.js +73 -0
- package/src/tabs.js.map +1 -0
- 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 +7 -0
- package/src/toggle.js +25 -0
- package/src/toggle.js.map +1 -0
- 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 +13 -0
- package/src/tooltip.js +7 -0
- package/src/tooltip.js.map +1 -0
- package/src/value-bar.d.ts +17 -0
- package/src/value-bar.js +51 -0
- package/src/value-bar.js.map +1 -0
- package/README.md +0 -7
- package/index.js +0 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar.js","names":[],"sources":["../../../../packages/react/src/calendar.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport { createCalendar } from \"@kirana-ui/core/calendar\"\nimport type {\n Calendar as Controller,\n CalendarDay,\n CalendarProps,\n CalendarWeekday,\n} from \"@kirana-ui/core/calendar\"\nimport { Fragment, createContext, useContext, useMemo } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { 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 CalendarContext }\n\nfunction useCalendar(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Calendar.${part}> must be inside <Calendar.Root>`)\n return controller\n}\n\nexport type RootProps = Omit<CalendarProps, \"id\"> & { id?: string } & PartComponentProps\n\nfunction Root({\n value,\n defaultValue,\n onValueChange,\n mode,\n defaultFocusedValue,\n onMonthChange,\n locale,\n calendarSystem,\n min,\n max,\n isDateUnavailable,\n disabled,\n readOnly,\n fixedWeeks,\n id,\n ...rest\n}: RootProps): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const controller = useController<CalendarProps, Controller>(\n within(createCalendar, { direction }),\n {\n value,\n defaultValue,\n onValueChange,\n mode,\n defaultFocusedValue,\n onMonthChange,\n locale,\n calendarSystem,\n min,\n max,\n isDateUnavailable,\n disabled,\n readOnly,\n fixedWeeks,\n id,\n }\n )\n return (\n <Context.Provider value={controller}>{usePart(controller.root, \"div\", rest)}</Context.Provider>\n )\n}\n\n/** Names the month shown, unless it is given something else to say. */\nfunction Heading({ children, ...props }: PartComponentProps): ReactElement {\n const controller = useCalendar(\"Heading\")\n const title = useSignal(controller.title)\n return usePart(controller.heading, \"div\", { ...props, children: children ?? title })\n}\n\nconst Previous = (props: PartComponentProps) =>\n usePart(useCalendar(\"Previous\").previous, \"button\", props)\nconst Next = (props: PartComponentProps) => usePart(useCalendar(\"Next\").next, \"button\", props)\nconst Grid = (props: PartComponentProps) => usePart(useCalendar(\"Grid\").grid, \"table\", props)\n\n/** Draws its child once for each day of the week, in the locale's order. */\nfunction Weekdays({ children }: { children: (weekday: CalendarWeekday) => ReactNode }) {\n const weekdays = useSignal(useCalendar(\"Weekdays\").weekdays)\n return (\n <>\n {weekdays.map((weekday) => (\n <Fragment key={weekday.index}>{children(weekday)}</Fragment>\n ))}\n </>\n )\n}\n\n/** Draws its child once for each week of the month shown. */\nfunction Weeks({ children }: { children: (week: readonly CalendarDay[]) => ReactNode }) {\n const weeks = useSignal(useCalendar(\"Weeks\").weeks)\n return (\n <>\n {weeks.map((week) => (\n <Fragment key={week[0]!.date}>{children(week)}</Fragment>\n ))}\n </>\n )\n}\n\nfunction HeadCell({ weekday, ...props }: PartComponentProps & { weekday: CalendarWeekday }) {\n const controller = useCalendar(\"HeadCell\")\n const part = useMemo(() => controller.headCell(weekday), [controller, weekday])\n return usePart(part, \"th\", props)\n}\n\nfunction Cell({ date, ...props }: PartComponentProps & { date: string }): ReactElement {\n return usePart(useCalendar(\"Cell\").cell(date), \"td\", props)\n}\n\nfunction Day({ date, ...props }: PartComponentProps & { date: string }): ReactElement {\n return usePart(useCalendar(\"Day\").day(date), \"button\", props)\n}\n\nexport const Calendar = {\n Root,\n Heading,\n Previous,\n Next,\n Grid,\n Weekdays,\n HeadCell,\n Weeks,\n Cell,\n Day,\n}\n"],"mappings":";;;;;;;AAeA,MAAM,UAAU,cAAiC,IAAI;AAIrD,SAAS,YAAY,MAA0B;CAC7C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,aAAa,KAAK,iCAAiC;CACpF,OAAO;AACT;AAIA,SAAS,KAAK,EACZ,OACA,cACA,eACA,MACA,qBACA,e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CACzD,EACD,CAAA;AAEN;AAEA,SAAS,SAAS,EAAE,SAAS,GAAG,SAA4D;CAC1F,MAAM,aAAa,YAAY,UAAU;CACzC,MAAM,OAAO,cAAc,WAAW,SAAS,OAAO,GAAG,CAAC,YAAY,OAAO,CAAC;CAC9E,OAAO,QAAQ,MAAM,MAAM,KAAK;AAClC;AAEA,SAAS,KAAK,EAAE,MAAM,GAAG,SAA8D;CACrF,OAAO,QAAQ,YAAY,MAAM,CAAC,CAAC,KAAK,IAAI,GAAG,MAAM,KAAK;AAC5D;AAEA,SAAS,IAAI,EAAE,MAAM,GAAG,SAA8D;CACpF,OAAO,QAAQ,YAAY,KAAK,CAAC,CAAC,IAAI,IAAI,GAAG,UAAU,KAAK;AAC9D;AAEA,MAAa,WAAW;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
import { CarouselProps } from "@kirana-ui/core/carousel";
|
|
4
|
+
export type RootProps = Omit<CarouselProps, "id"> & {
|
|
5
|
+
id?: string;
|
|
6
|
+
} & PartComponentProps;
|
|
7
|
+
declare function Root({ index, defaultIndex, onIndexChange, orientation, loop, id, ...rest }: RootProps): ReactElement;
|
|
8
|
+
declare const Viewport: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
9
|
+
declare function Item({ index, ...props }: PartComponentProps & {
|
|
10
|
+
index: number;
|
|
11
|
+
}): ReactElement;
|
|
12
|
+
declare const Previous: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
13
|
+
declare const Next: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
14
|
+
declare function Indicator({ index, ...props }: PartComponentProps & {
|
|
15
|
+
index: number;
|
|
16
|
+
}): ReactElement;
|
|
17
|
+
export declare const Carousel: {
|
|
18
|
+
Root: typeof Root;
|
|
19
|
+
Viewport: typeof Viewport;
|
|
20
|
+
Item: typeof Item;
|
|
21
|
+
Previous: typeof Previous;
|
|
22
|
+
Next: typeof Next;
|
|
23
|
+
Indicator: typeof Indicator;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=carousel.d.ts.map
|
package/src/carousel.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { DirectionContext } from "./direction-context.js";
|
|
2
|
+
import { useController, usePart } from "./runtime.js";
|
|
3
|
+
import { within } from "@kirana-ui/core";
|
|
4
|
+
import { createContext, useContext, useMemo } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { createCarousel } from "@kirana-ui/core/carousel";
|
|
7
|
+
// src/carousel.tsx
|
|
8
|
+
const Context = createContext(null);
|
|
9
|
+
function useCarousel(part) {
|
|
10
|
+
const controller = useContext(Context);
|
|
11
|
+
if (!controller) throw new Error(`<Carousel.${part}> must be inside <Carousel.Root>`);
|
|
12
|
+
return controller;
|
|
13
|
+
}
|
|
14
|
+
function Root({ index, defaultIndex, onIndexChange, orientation, loop, id, ...rest }) {
|
|
15
|
+
const direction = useContext(DirectionContext) ?? void 0;
|
|
16
|
+
const controller = useController(within(createCarousel, { direction }), {
|
|
17
|
+
index,
|
|
18
|
+
defaultIndex,
|
|
19
|
+
onIndexChange,
|
|
20
|
+
orientation,
|
|
21
|
+
loop,
|
|
22
|
+
id
|
|
23
|
+
});
|
|
24
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
25
|
+
value: controller,
|
|
26
|
+
children: usePart(controller.root, "div", rest)
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const Viewport = (props) => usePart(useCarousel("Viewport").viewport, "div", props);
|
|
30
|
+
function Item({ index, ...props }) {
|
|
31
|
+
const controller = useCarousel("Item");
|
|
32
|
+
const part = useMemo(() => controller.item(index), [controller, index]);
|
|
33
|
+
return usePart(part, "div", props);
|
|
34
|
+
}
|
|
35
|
+
const Previous = (props) => usePart(useCarousel("Previous").previous, "button", props);
|
|
36
|
+
const Next = (props) => usePart(useCarousel("Next").next, "button", props);
|
|
37
|
+
function Indicator({ index, ...props }) {
|
|
38
|
+
const controller = useCarousel("Indicator");
|
|
39
|
+
const part = useMemo(() => controller.indicator(index), [controller, index]);
|
|
40
|
+
return usePart(part, "button", props);
|
|
41
|
+
}
|
|
42
|
+
const Carousel = {
|
|
43
|
+
Root,
|
|
44
|
+
Viewport,
|
|
45
|
+
Item,
|
|
46
|
+
Previous,
|
|
47
|
+
Next,
|
|
48
|
+
Indicator
|
|
49
|
+
};
|
|
50
|
+
export { Carousel };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=carousel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"carousel.js","names":[],"sources":["../../../../packages/react/src/carousel.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport { createCarousel } from \"@kirana-ui/core/carousel\"\nimport type { Carousel as Controller, CarouselProps } from \"@kirana-ui/core/carousel\"\nimport { createContext, useContext, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useCarousel(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Carousel.${part}> must be inside <Carousel.Root>`)\n return controller\n}\n\nexport type RootProps = Omit<CarouselProps, \"id\"> & { id?: string } & PartComponentProps\n\nfunction Root({\n index,\n defaultIndex,\n onIndexChange,\n orientation,\n loop,\n id,\n ...rest\n}: RootProps): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const controller = useController<CarouselProps, Controller>(\n within(createCarousel, { direction }),\n { index, defaultIndex, onIndexChange, orientation, loop, id }\n )\n return (\n <Context.Provider value={controller}>{usePart(controller.root, \"div\", rest)}</Context.Provider>\n )\n}\n\nconst Viewport = (props: PartComponentProps) =>\n usePart(useCarousel(\"Viewport\").viewport, \"div\", props)\n\nfunction Item({ index, ...props }: PartComponentProps & { index: number }): ReactElement {\n const controller = useCarousel(\"Item\")\n const part = useMemo(() => controller.item(index), [controller, index])\n return usePart(part, \"div\", props)\n}\n\nconst Previous = (props: PartComponentProps) =>\n usePart(useCarousel(\"Previous\").previous, \"button\", props)\nconst Next = (props: PartComponentProps) => usePart(useCarousel(\"Next\").next, \"button\", props)\n\nfunction Indicator({ index, ...props }: PartComponentProps & { index: number }): ReactElement {\n const controller = useCarousel(\"Indicator\")\n const part = useMemo(() => controller.indicator(index), [controller, index])\n return usePart(part, \"button\", props)\n}\n\nexport const Carousel = { Root, Viewport, Item, Previous, Next, Indicator }\n"],"mappings":";;;;;;;AAUA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,YAAY,MAA0B;CAC7C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,aAAa,KAAK,iCAAiC;CACpF,OAAO;AACT;AAIA,SAAS,KAAK,EACZ,OACA,cACA,eACA,aACA,MACA,IACA,GAAG,QACuB;CAC1B,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,aAAa,cACjB,OAAO,gBAAgB,EAAE,UAAU,CAAC,GACpC;EAAE;EAAO;EAAc;EAAe;EAAa;EAAM;CAAG,CAC9D;CACA,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CAAoB,CAAA;AAElG;AAEA,MAAM,YAAY,UAChB,QAAQ,YAAY,UAAU,CAAC,CAAC,UAAU,OAAO,KAAK;AAExD,SAAS,KAAK,EAAE,OAAO,GAAG,SAA+D;CACvF,MAAM,aAAa,YAAY,MAAM;CACrC,MAAM,OAAO,cAAc,WAAW,KAAK,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC;CACtE,OAAO,QAAQ,MAAM,OAAO,KAAK;AACnC;AAEA,MAAM,YAAY,UAChB,QAAQ,YAAY,UAAU,CAAC,CAAC,UAAU,UAAU,KAAK;AAC3D,MAAM,QAAQ,UAA8B,QAAQ,YAAY,MAAM,CAAC,CAAC,MAAM,UAAU,KAAK;AAE7F,SAAS,UAAU,EAAE,OAAO,GAAG,SAA+D;CAC5F,MAAM,aAAa,YAAY,WAAW;CAC1C,MAAM,OAAO,cAAc,WAAW,UAAU,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC;CAC3E,OAAO,QAAQ,MAAM,UAAU,KAAK;AACtC;AAEA,MAAa,WAAW;CAAE;CAAM;CAAU;CAAM;CAAU;CAAM;AAAU"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
import { CheckboxProps } from "@kirana-ui/core/checkbox";
|
|
4
|
+
export type RootProps = Omit<CheckboxProps, "id"> & {
|
|
5
|
+
id?: string;
|
|
6
|
+
} & PartComponentProps;
|
|
7
|
+
declare function Root({ checked, defaultChecked, onCheckedChange, indeterminate, disabled, readOnly, required, name, form, value, id, children, ...rest }: RootProps): ReactElement;
|
|
8
|
+
export interface IndicatorProps extends PartComponentProps {
|
|
9
|
+
/** Keeps the mark in the page while the box is unchecked. */
|
|
10
|
+
keepMounted?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare function Indicator({ keepMounted, ...props }: IndicatorProps): ReactElement | null;
|
|
13
|
+
export declare const Checkbox: {
|
|
14
|
+
Root: typeof Root;
|
|
15
|
+
Indicator: typeof Indicator;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=checkbox.d.ts.map
|
package/src/checkbox.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { FieldContext } from "./field-context.js";
|
|
2
|
+
import { useController, usePart, useSignal } from "./runtime.js";
|
|
3
|
+
import { within } from "@kirana-ui/core";
|
|
4
|
+
import { createContext, useContext } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { createCheckbox } from "@kirana-ui/core/checkbox";
|
|
7
|
+
// src/checkbox.tsx
|
|
8
|
+
const Context = createContext(null);
|
|
9
|
+
function useCheckbox(part) {
|
|
10
|
+
const controller = useContext(Context);
|
|
11
|
+
if (!controller) throw new Error(`<Checkbox.${part}> must be inside <Checkbox.Root>`);
|
|
12
|
+
return controller;
|
|
13
|
+
}
|
|
14
|
+
function Root({ checked, defaultChecked, onCheckedChange, indeterminate, disabled, readOnly, required, name, form, value, id, children, ...rest }) {
|
|
15
|
+
const field = useContext(FieldContext) ?? void 0;
|
|
16
|
+
const create = within(createCheckbox, { field });
|
|
17
|
+
const controller = useController(create, {
|
|
18
|
+
checked,
|
|
19
|
+
defaultChecked,
|
|
20
|
+
onCheckedChange,
|
|
21
|
+
indeterminate,
|
|
22
|
+
disabled,
|
|
23
|
+
readOnly,
|
|
24
|
+
required,
|
|
25
|
+
name,
|
|
26
|
+
form,
|
|
27
|
+
value,
|
|
28
|
+
id
|
|
29
|
+
});
|
|
30
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
31
|
+
value: controller,
|
|
32
|
+
children: /* @__PURE__ */ jsxs(RootElement, {
|
|
33
|
+
...rest,
|
|
34
|
+
children: [children, /* @__PURE__ */ jsx(Input, {})]
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const RootElement = (props) => usePart(useCheckbox("Root").root, "span", props);
|
|
39
|
+
const Input = () => usePart(useCheckbox("Root").input, "input", {});
|
|
40
|
+
function Indicator({ keepMounted, ...props }) {
|
|
41
|
+
if (!useSignal(useCheckbox("Indicator").indicatorMounted) && !keepMounted) return null;
|
|
42
|
+
return /* @__PURE__ */ jsx(IndicatorElement, { ...props });
|
|
43
|
+
}
|
|
44
|
+
const IndicatorElement = (props) => usePart(useCheckbox("Indicator").indicator, "span", props);
|
|
45
|
+
const Checkbox = {
|
|
46
|
+
Root,
|
|
47
|
+
Indicator
|
|
48
|
+
};
|
|
49
|
+
export { Checkbox };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.js","names":[],"sources":["../../../../packages/react/src/checkbox.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport { createCheckbox } from \"@kirana-ui/core/checkbox\"\nimport type { Checkbox as Controller, CheckboxProps } from \"@kirana-ui/core/checkbox\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { FieldContext } from \"./field-context.ts\"\nimport { useController, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useCheckbox(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Checkbox.${part}> must be inside <Checkbox.Root>`)\n return controller\n}\n\nexport type RootProps = Omit<CheckboxProps, \"id\"> & { id?: string } & PartComponentProps\n\nfunction Root({\n checked,\n defaultChecked,\n onCheckedChange,\n indeterminate,\n disabled,\n readOnly,\n required,\n name,\n form,\n value,\n id,\n children,\n ...rest\n}: RootProps): ReactElement {\n const field = useContext(FieldContext) ?? undefined\n const create = within(createCheckbox, { field })\n const controller = useController(create, {\n checked,\n defaultChecked,\n onCheckedChange,\n indeterminate,\n disabled,\n readOnly,\n required,\n name,\n form,\n value: value as string | undefined,\n id,\n })\n return (\n <Context.Provider value={controller}>\n <RootElement {...rest}>\n {children}\n <Input />\n </RootElement>\n </Context.Provider>\n )\n}\n\nconst RootElement = (props: PartComponentProps) => usePart(useCheckbox(\"Root\").root, \"span\", props)\nconst Input = () => usePart(useCheckbox(\"Root\").input, \"input\", {})\n\nexport interface IndicatorProps extends PartComponentProps {\n /** Keeps the mark in the page while the box is unchecked. */\n keepMounted?: boolean\n}\n\nfunction Indicator({ keepMounted, ...props }: IndicatorProps): ReactElement | null {\n const mounted = useSignal(useCheckbox(\"Indicator\").indicatorMounted)\n if (!mounted && !keepMounted) return null\n return <IndicatorElement {...props} />\n}\n\nconst IndicatorElement = (props: PartComponentProps) =>\n usePart(useCheckbox(\"Indicator\").indicator, \"span\", props)\n\nexport const Checkbox = { Root, Indicator }\n"],"mappings":";;;;;;;AAUA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,YAAY,MAA0B;CAC7C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,aAAa,KAAK,iCAAiC;CACpF,OAAO;AACT;AAIA,SAAS,KAAK,EACZ,SACA,gBACA,iBACA,eACA,UACA,UACA,UACA,MACA,MACA,OACA,IACA,UACA,GAAG,QACuB;CAC1B,MAAM,QAAQ,WAAW,YAAY,KAAK,KAAA;CAC1C,MAAM,SAAS,OAAO,gBAAgB,EAAE,MAAM,CAAC;CAC/C,MAAM,aAAa,cAAc,QAAQ;EACvC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACO;EACP;CACF,CAAC;CACD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EACvB,UAAA,qBAAC,aAAD;GAAa,GAAI;GAAjB,UAAA,CACG,UACD,oBAAC,OAAD,CAAQ,CAAA,CACG;;CACG,CAAA;AAEtB;AAEA,MAAM,eAAe,UAA8B,QAAQ,YAAY,MAAM,CAAC,CAAC,MAAM,QAAQ,KAAK;AAClG,MAAM,cAAc,QAAQ,YAAY,MAAM,CAAC,CAAC,OAAO,SAAS,CAAC,CAAC;AAOlE,SAAS,UAAU,EAAE,aAAa,GAAG,SAA8C;CAEjF,IAAI,CADY,UAAU,YAAY,WAAW,CAAC,CAAC,gBACxC,KAAK,CAAC,aAAa,OAAO;CACrC,OAAO,oBAAC,kBAAD,EAAkB,GAAI,MAAQ,CAAA;AACvC;AAEA,MAAM,oBAAoB,UACxB,QAAQ,YAAY,WAAW,CAAC,CAAC,WAAW,QAAQ,KAAK;AAE3D,MAAa,WAAW;CAAE;CAAM;AAAU"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
import { CollapsibleProps } from "@kirana-ui/core/collapsible";
|
|
4
|
+
export type RootProps = Omit<CollapsibleProps, "id"> & {
|
|
5
|
+
id?: string;
|
|
6
|
+
} & PartComponentProps;
|
|
7
|
+
declare function Root({ open, defaultOpen, onOpenChange, disabled, id, ...rest }: RootProps): ReactElement;
|
|
8
|
+
declare function Trigger(props: PartComponentProps): ReactElement;
|
|
9
|
+
export interface PanelProps extends PartComponentProps {
|
|
10
|
+
/** Keeps the closed panel in the page, `hidden`. */
|
|
11
|
+
keepMounted?: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare function Panel({ keepMounted, ...props }: PanelProps): ReactElement | null;
|
|
14
|
+
export declare const Collapsible: {
|
|
15
|
+
Root: typeof Root;
|
|
16
|
+
Trigger: typeof Trigger;
|
|
17
|
+
Panel: typeof Panel;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=collapsible.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useController, usePart, useSignal } from "./runtime.js";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { createCollapsible } from "@kirana-ui/core/collapsible";
|
|
5
|
+
// src/collapsible.tsx
|
|
6
|
+
const Context = createContext(null);
|
|
7
|
+
function useCollapsible(part) {
|
|
8
|
+
const controller = useContext(Context);
|
|
9
|
+
if (!controller) throw new Error(`<Collapsible.${part}> must be inside <Collapsible.Root>`);
|
|
10
|
+
return controller;
|
|
11
|
+
}
|
|
12
|
+
function Root({ open, defaultOpen, onOpenChange, disabled, id, ...rest }) {
|
|
13
|
+
const controller = useController(createCollapsible, {
|
|
14
|
+
open,
|
|
15
|
+
defaultOpen,
|
|
16
|
+
onOpenChange,
|
|
17
|
+
disabled,
|
|
18
|
+
id
|
|
19
|
+
});
|
|
20
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
21
|
+
value: controller,
|
|
22
|
+
children: usePart(controller.root, "div", rest)
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function Trigger(props) {
|
|
26
|
+
return usePart(useCollapsible("Trigger").trigger, "button", props);
|
|
27
|
+
}
|
|
28
|
+
function Panel({ keepMounted, ...props }) {
|
|
29
|
+
const controller = useCollapsible("Panel");
|
|
30
|
+
if (!useSignal(controller.mounted) && !keepMounted) return null;
|
|
31
|
+
return /* @__PURE__ */ jsx(PanelElement, { ...props });
|
|
32
|
+
}
|
|
33
|
+
function PanelElement(props) {
|
|
34
|
+
return usePart(useCollapsible("Panel").panel, "div", props);
|
|
35
|
+
}
|
|
36
|
+
const Collapsible = {
|
|
37
|
+
Root,
|
|
38
|
+
Trigger,
|
|
39
|
+
Panel
|
|
40
|
+
};
|
|
41
|
+
export { Collapsible };
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=collapsible.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collapsible.js","names":[],"sources":["../../../../packages/react/src/collapsible.tsx"],"sourcesContent":["import { createCollapsible } from \"@kirana-ui/core/collapsible\"\nimport type { Collapsible as Controller, CollapsibleProps } from \"@kirana-ui/core/collapsible\"\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)\n\nfunction useCollapsible(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Collapsible.${part}> must be inside <Collapsible.Root>`)\n return controller\n}\n\nexport type RootProps = Omit<CollapsibleProps, \"id\"> & { id?: string } & PartComponentProps\n\nfunction Root({ open, defaultOpen, onOpenChange, disabled, id, ...rest }: RootProps): ReactElement {\n const controller = useController(createCollapsible, {\n open,\n defaultOpen,\n onOpenChange,\n disabled,\n id,\n })\n return (\n <Context.Provider value={controller}>{usePart(controller.root, \"div\", rest)}</Context.Provider>\n )\n}\n\nfunction Trigger(props: PartComponentProps): ReactElement {\n return usePart(useCollapsible(\"Trigger\").trigger, \"button\", props)\n}\n\nexport interface PanelProps extends PartComponentProps {\n /** Keeps the closed panel in the page, `hidden`. */\n keepMounted?: boolean\n}\n\nfunction Panel({ keepMounted, ...props }: PanelProps): ReactElement | null {\n const controller = useCollapsible(\"Panel\")\n const mounted = useSignal(controller.mounted)\n if (!mounted && !keepMounted) return null\n return <PanelElement {...props} />\n}\n\nfunction PanelElement(props: PartComponentProps): ReactElement {\n return usePart(useCollapsible(\"Panel\").panel, \"div\", props)\n}\n\nexport const Collapsible = { Root, Trigger, Panel }\n"],"mappings":";;;;;AAQA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,eAAe,MAA0B;CAChD,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,gBAAgB,KAAK,oCAAoC;CAC1F,OAAO;AACT;AAIA,SAAS,KAAK,EAAE,MAAM,aAAa,cAAc,UAAU,IAAI,GAAG,QAAiC;CACjG,MAAM,aAAa,cAAc,mBAAmB;EAClD;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CAAoB,CAAA;AAElG;AAEA,SAAS,QAAQ,OAAyC;CACxD,OAAO,QAAQ,eAAe,SAAS,CAAC,CAAC,SAAS,UAAU,KAAK;AACnE;AAOA,SAAS,MAAM,EAAE,aAAa,GAAG,SAA0C;CACzE,MAAM,aAAa,eAAe,OAAO;CAEzC,IAAI,CADY,UAAU,WAAW,OAC1B,KAAK,CAAC,aAAa,OAAO;CACrC,OAAO,oBAAC,cAAD,EAAc,GAAI,MAAQ,CAAA;AACnC;AAEA,SAAS,aAAa,OAAyC;CAC7D,OAAO,QAAQ,eAAe,OAAO,CAAC,CAAC,OAAO,OAAO,KAAK;AAC5D;AAEA,MAAa,cAAc;CAAE;CAAM;CAAS;AAAM"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { PositionOptions } from "@kirana-ui/core";
|
|
3
|
+
import { ReactElement, ReactNode } from "react";
|
|
4
|
+
import { AutocompleteProps } from "@kirana-ui/core/autocomplete";
|
|
5
|
+
import { ComboboxProps } from "@kirana-ui/core/combobox";
|
|
6
|
+
export type RootProps<Value> = Omit<ComboboxProps<Value>, "id"> & {
|
|
7
|
+
id?: string;
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
};
|
|
10
|
+
declare function Root<Value>({ children, ...props }: RootProps<Value>): ReactElement;
|
|
11
|
+
declare const Input: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
12
|
+
declare const Trigger: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
13
|
+
declare const Popup: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
14
|
+
declare function Portal({ children }: {
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
}): ReactElement | null;
|
|
17
|
+
export type PositionerProps = PartComponentProps & Partial<PositionOptions>;
|
|
18
|
+
declare function Positioner({ side, align, sideOffset, alignOffset, collisionPadding, ...props }: PositionerProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
19
|
+
/** Items that belong together, named by their `GroupLabel`. Hidden while none is shown. */
|
|
20
|
+
declare function Group({ id, ...props }: PartComponentProps & {
|
|
21
|
+
id?: string;
|
|
22
|
+
}): ReactElement;
|
|
23
|
+
/** A group's name. Outside a group it is plain text, and names nothing. */
|
|
24
|
+
declare function GroupLabel(props: PartComponentProps): ReactElement;
|
|
25
|
+
/** A line between groups. */
|
|
26
|
+
declare const Separator: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
27
|
+
export interface ItemProps extends PartComponentProps {
|
|
28
|
+
value: unknown;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
/** What is filtered and what the input shows; the item's text when left out. */
|
|
31
|
+
label?: string;
|
|
32
|
+
id?: string;
|
|
33
|
+
/** Its place among all the rows, in a virtualized list. */
|
|
34
|
+
index?: number;
|
|
35
|
+
}
|
|
36
|
+
declare function Item({ value, disabled, label, id, index, ...props }: ItemProps): ReactElement;
|
|
37
|
+
export interface ItemIndicatorProps extends PartComponentProps {
|
|
38
|
+
keepMounted?: boolean;
|
|
39
|
+
}
|
|
40
|
+
declare function ItemIndicator({ keepMounted, render: _render, ref: _ref, ...rest }: ItemIndicatorProps): import("react").JSX.Element | null;
|
|
41
|
+
/** A button that empties the input and the value. Drawn while there is something to clear. */
|
|
42
|
+
declare function Clear({ keepMounted, ...props }: ItemIndicatorProps): ReactElement | null;
|
|
43
|
+
/** With `multiple`: what holds the chips and the input. */
|
|
44
|
+
declare const Chips: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
45
|
+
/** With `multiple`: one chosen value. Its `value` is what its remove button takes away. */
|
|
46
|
+
declare function Chip({ value, ...props }: PartComponentProps & {
|
|
47
|
+
value: unknown;
|
|
48
|
+
}): ReactElement;
|
|
49
|
+
declare function ChipRemove(props: PartComponentProps): ReactElement;
|
|
50
|
+
/** Drawn while no item is shown for what was typed. */
|
|
51
|
+
declare function Empty(props: PartComponentProps): ReactElement | null;
|
|
52
|
+
export type AutocompleteRootProps = Omit<AutocompleteProps, "id"> & {
|
|
53
|
+
id?: string;
|
|
54
|
+
children?: ReactNode;
|
|
55
|
+
};
|
|
56
|
+
/** A combobox whose text is the value: the list only suggests. */
|
|
57
|
+
declare function AutocompleteRoot({ children, ...props }: AutocompleteRootProps): ReactElement;
|
|
58
|
+
export declare const Autocomplete: {
|
|
59
|
+
Root: typeof AutocompleteRoot;
|
|
60
|
+
Input: typeof Input;
|
|
61
|
+
Trigger: typeof Trigger;
|
|
62
|
+
Clear: typeof Clear;
|
|
63
|
+
Portal: typeof Portal;
|
|
64
|
+
Positioner: typeof Positioner;
|
|
65
|
+
Popup: typeof Popup;
|
|
66
|
+
Group: typeof Group;
|
|
67
|
+
GroupLabel: typeof GroupLabel;
|
|
68
|
+
Separator: typeof Separator;
|
|
69
|
+
Item: typeof Item;
|
|
70
|
+
Empty: typeof Empty;
|
|
71
|
+
};
|
|
72
|
+
export declare const Combobox: {
|
|
73
|
+
Root: typeof Root;
|
|
74
|
+
Input: typeof Input;
|
|
75
|
+
Trigger: typeof Trigger;
|
|
76
|
+
Clear: typeof Clear;
|
|
77
|
+
Chips: typeof Chips;
|
|
78
|
+
Chip: typeof Chip;
|
|
79
|
+
ChipRemove: typeof ChipRemove;
|
|
80
|
+
Portal: typeof Portal;
|
|
81
|
+
Positioner: typeof Positioner;
|
|
82
|
+
Popup: typeof Popup;
|
|
83
|
+
Group: typeof Group;
|
|
84
|
+
GroupLabel: typeof GroupLabel;
|
|
85
|
+
Separator: typeof Separator;
|
|
86
|
+
Item: typeof Item;
|
|
87
|
+
ItemIndicator: typeof ItemIndicator;
|
|
88
|
+
Empty: typeof Empty;
|
|
89
|
+
};
|
|
90
|
+
export {};
|
|
91
|
+
//# sourceMappingURL=combobox.d.ts.map
|
package/src/combobox.js
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { FieldContext } from "./field-context.js";
|
|
2
|
+
import { Portal as Portal$1, useController, useOptions, useOwnText, usePart, useSignal } from "./runtime.js";
|
|
3
|
+
import { defined, within } from "@kirana-ui/core";
|
|
4
|
+
import { createContext, useContext, useId, useMemo } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { createAutocomplete } from "@kirana-ui/core/autocomplete";
|
|
7
|
+
import { createCombobox } from "@kirana-ui/core/combobox";
|
|
8
|
+
// src/combobox.tsx
|
|
9
|
+
const Context = createContext(null);
|
|
10
|
+
const ItemContext = createContext(void 0);
|
|
11
|
+
function useCombobox(part) {
|
|
12
|
+
const controller = useContext(Context);
|
|
13
|
+
if (!controller) throw new Error(`<Combobox.${part}> must be inside <Combobox.Root>`);
|
|
14
|
+
return controller;
|
|
15
|
+
}
|
|
16
|
+
function Root({ children, ...props }) {
|
|
17
|
+
const field = useContext(FieldContext) ?? void 0;
|
|
18
|
+
const controller = useController(within(createCombobox, { field }), props);
|
|
19
|
+
const named = useSignal(controller.named);
|
|
20
|
+
return /* @__PURE__ */ jsxs(Context.Provider, {
|
|
21
|
+
value: controller,
|
|
22
|
+
children: [children, named ? /* @__PURE__ */ jsx(HiddenInput, {}) : null]
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
const HiddenInput = () => usePart(useCombobox("Root").hidden, "input", {});
|
|
26
|
+
const Input = (props) => usePart(useOwnText(useCombobox("Input").input), "input", props);
|
|
27
|
+
const Trigger = (props) => usePart(useCombobox("Trigger").trigger, "button", props);
|
|
28
|
+
const Popup = (props) => usePart(useCombobox("Popup").popup, "div", props);
|
|
29
|
+
function Portal({ children }) {
|
|
30
|
+
return useSignal(useCombobox("Portal").mounted) ? /* @__PURE__ */ jsx(Portal$1, { children }) : null;
|
|
31
|
+
}
|
|
32
|
+
function Positioner({ side, align, sideOffset, alignOffset, collisionPadding, ...props }) {
|
|
33
|
+
const controller = useCombobox("Positioner");
|
|
34
|
+
controller.positioning.set(defined({
|
|
35
|
+
side,
|
|
36
|
+
align,
|
|
37
|
+
sideOffset,
|
|
38
|
+
alignOffset,
|
|
39
|
+
collisionPadding
|
|
40
|
+
}));
|
|
41
|
+
return usePart(controller.positioner, "div", props);
|
|
42
|
+
}
|
|
43
|
+
const GroupContext = createContext(null);
|
|
44
|
+
/** Items that belong together, named by their `GroupLabel`. Hidden while none is shown. */
|
|
45
|
+
function Group({ id, ...props }) {
|
|
46
|
+
const controller = useCombobox("Group");
|
|
47
|
+
const generated = useId();
|
|
48
|
+
const group = useMemo(() => controller.group(id ?? generated), [
|
|
49
|
+
controller,
|
|
50
|
+
id,
|
|
51
|
+
generated
|
|
52
|
+
]);
|
|
53
|
+
return /* @__PURE__ */ jsx(GroupContext.Provider, {
|
|
54
|
+
value: group,
|
|
55
|
+
children: usePart(group.root, "div", props)
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/** A group's name. Outside a group it is plain text, and names nothing. */
|
|
59
|
+
function GroupLabel(props) {
|
|
60
|
+
const lone = useCombobox("GroupLabel").groupLabel;
|
|
61
|
+
return usePart(useContext(GroupContext)?.label ?? lone, "div", props);
|
|
62
|
+
}
|
|
63
|
+
/** A line between groups. */
|
|
64
|
+
const Separator = (props) => usePart(useCombobox("Separator").separator, "div", props);
|
|
65
|
+
function Item({ value, disabled, label, id, index, ...props }) {
|
|
66
|
+
const controller = useCombobox("Item");
|
|
67
|
+
const group = useContext(GroupContext) ?? void 0;
|
|
68
|
+
const generated = useId();
|
|
69
|
+
const options = useOptions({
|
|
70
|
+
disabled,
|
|
71
|
+
label,
|
|
72
|
+
index,
|
|
73
|
+
id: id ?? generated
|
|
74
|
+
});
|
|
75
|
+
const part = useMemo(() => controller.item(value, () => options.get(), group), [
|
|
76
|
+
controller,
|
|
77
|
+
value,
|
|
78
|
+
options,
|
|
79
|
+
group
|
|
80
|
+
]);
|
|
81
|
+
return /* @__PURE__ */ jsx(ItemContext.Provider, {
|
|
82
|
+
value,
|
|
83
|
+
children: usePart(part, "div", props)
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function ItemIndicator({ keepMounted, render: _render, ref: _ref, ...rest }) {
|
|
87
|
+
if (!useSignal(useCombobox("ItemIndicator").selected(useContext(ItemContext))) && !keepMounted) return null;
|
|
88
|
+
return /* @__PURE__ */ jsx("span", {
|
|
89
|
+
"aria-hidden": "true",
|
|
90
|
+
...rest
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
const ClearElement = (props) => usePart(useCombobox("Clear").clear, "button", props);
|
|
94
|
+
/** A button that empties the input and the value. Drawn while there is something to clear. */
|
|
95
|
+
function Clear({ keepMounted, ...props }) {
|
|
96
|
+
return useSignal(useCombobox("Clear").clearable) || keepMounted ? /* @__PURE__ */ jsx(ClearElement, { ...props }) : null;
|
|
97
|
+
}
|
|
98
|
+
/** With `multiple`: what holds the chips and the input. */
|
|
99
|
+
const Chips = (props) => usePart(useCombobox("Chips").chips, "div", props);
|
|
100
|
+
const ChipContext = createContext(void 0);
|
|
101
|
+
/** With `multiple`: one chosen value. Its `value` is what its remove button takes away. */
|
|
102
|
+
function Chip({ value, ...props }) {
|
|
103
|
+
const controller = useCombobox("Chip");
|
|
104
|
+
const part = useMemo(() => controller.chip(value), [controller, value]);
|
|
105
|
+
return /* @__PURE__ */ jsx(ChipContext.Provider, {
|
|
106
|
+
value,
|
|
107
|
+
children: usePart(part, "span", props)
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function ChipRemove(props) {
|
|
111
|
+
const controller = useCombobox("ChipRemove");
|
|
112
|
+
const value = useContext(ChipContext);
|
|
113
|
+
const part = useMemo(() => controller.chipRemove(value), [controller, value]);
|
|
114
|
+
return usePart(part, "button", props);
|
|
115
|
+
}
|
|
116
|
+
const EmptyElement = (props) => usePart(useCombobox("Empty").emptyPart, "div", props);
|
|
117
|
+
/** Drawn while no item is shown for what was typed. */
|
|
118
|
+
function Empty(props) {
|
|
119
|
+
return useSignal(useCombobox("Empty").empty) ? /* @__PURE__ */ jsx(EmptyElement, { ...props }) : null;
|
|
120
|
+
}
|
|
121
|
+
/** A combobox whose text is the value: the list only suggests. */
|
|
122
|
+
function AutocompleteRoot({ children, ...props }) {
|
|
123
|
+
const field = useContext(FieldContext) ?? void 0;
|
|
124
|
+
const controller = useController(within(createAutocomplete, { field }), props);
|
|
125
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
126
|
+
value: controller,
|
|
127
|
+
children
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
const Autocomplete = {
|
|
131
|
+
Root: AutocompleteRoot,
|
|
132
|
+
Input,
|
|
133
|
+
Trigger,
|
|
134
|
+
Clear,
|
|
135
|
+
Portal,
|
|
136
|
+
Positioner,
|
|
137
|
+
Popup,
|
|
138
|
+
Group,
|
|
139
|
+
GroupLabel,
|
|
140
|
+
Separator,
|
|
141
|
+
Item,
|
|
142
|
+
Empty
|
|
143
|
+
};
|
|
144
|
+
const Combobox = {
|
|
145
|
+
Root,
|
|
146
|
+
Input,
|
|
147
|
+
Trigger,
|
|
148
|
+
Clear,
|
|
149
|
+
Chips,
|
|
150
|
+
Chip,
|
|
151
|
+
ChipRemove,
|
|
152
|
+
Portal,
|
|
153
|
+
Positioner,
|
|
154
|
+
Popup,
|
|
155
|
+
Group,
|
|
156
|
+
GroupLabel,
|
|
157
|
+
Separator,
|
|
158
|
+
Item,
|
|
159
|
+
ItemIndicator,
|
|
160
|
+
Empty
|
|
161
|
+
};
|
|
162
|
+
export { Autocomplete, Combobox };
|
|
163
|
+
|
|
164
|
+
//# sourceMappingURL=combobox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combobox.js","names":["BodyPortal"],"sources":["../../../../packages/react/src/combobox.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { PositionOptions } from \"@kirana-ui/core\"\nimport { createAutocomplete } from \"@kirana-ui/core/autocomplete\"\nimport type { AutocompleteProps } from \"@kirana-ui/core/autocomplete\"\nimport { createCombobox } from \"@kirana-ui/core/combobox\"\nimport type { Combobox as Controller, ComboboxGroup, ComboboxProps } from \"@kirana-ui/core/combobox\"\nimport { createContext, useContext, useId, useMemo } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { FieldContext } from \"./field-context.ts\"\nimport {\n Portal as BodyPortal,\n useController,\n useOptions,\n useOwnText,\n usePart,\n useSignal,\n} from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nconst Context = createContext<Controller | null>(null)\nconst ItemContext = createContext<unknown>(undefined)\n\nfunction useCombobox(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Combobox.${part}> must be inside <Combobox.Root>`)\n return controller\n}\n\nexport type RootProps<Value> = Omit<ComboboxProps<Value>, \"id\"> & {\n id?: string\n children?: ReactNode\n}\n\nfunction Root<Value>({ children, ...props }: RootProps<Value>): ReactElement {\n const field = useContext(FieldContext) ?? undefined\n const controller = useController<ComboboxProps<Value>, Controller<Value>>(\n within(createCombobox<Value>, { field }),\n props\n ) as unknown as Controller\n const named = useSignal(controller.named)\n return (\n <Context.Provider value={controller}>\n {children}\n {named ? <HiddenInput /> : null}\n </Context.Provider>\n )\n}\n\nconst HiddenInput = () => usePart(useCombobox(\"Root\").hidden, \"input\", {})\nconst Input = (props: PartComponentProps) =>\n usePart(useOwnText(useCombobox(\"Input\").input), \"input\", props)\nconst Trigger = (props: PartComponentProps) =>\n usePart(useCombobox(\"Trigger\").trigger, \"button\", props)\nconst Popup = (props: PartComponentProps) => usePart(useCombobox(\"Popup\").popup, \"div\", props)\n\nfunction Portal({ children }: { children?: ReactNode }): ReactElement | null {\n const mounted = useSignal(useCombobox(\"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 = useCombobox(\"Positioner\")\n controller.positioning.set(defined({ side, align, sideOffset, alignOffset, collisionPadding }))\n return usePart(controller.positioner, \"div\", props)\n}\n\nconst GroupContext = createContext<ComboboxGroup | null>(null)\n\n/** Items that belong together, named by their `GroupLabel`. Hidden while none is shown. */\nfunction Group({ id, ...props }: PartComponentProps & { id?: string }): ReactElement {\n const controller = useCombobox(\"Group\")\n const generated = useId()\n const group = useMemo(() => controller.group(id ?? generated), [controller, id, generated])\n return (\n <GroupContext.Provider value={group}>{usePart(group.root, \"div\", props)}</GroupContext.Provider>\n )\n}\n\n/** A group's name. Outside a group it is plain text, and names nothing. */\nfunction GroupLabel(props: PartComponentProps): ReactElement {\n const lone = useCombobox(\"GroupLabel\").groupLabel\n return usePart(useContext(GroupContext)?.label ?? lone, \"div\", props)\n}\n\n/** A line between groups. */\nconst Separator = (props: PartComponentProps) =>\n usePart(useCombobox(\"Separator\").separator, \"div\", props)\n\nexport interface ItemProps extends PartComponentProps {\n value: unknown\n disabled?: boolean\n /** What is filtered and what the input shows; the item's text when left out. */\n label?: string\n id?: string\n /** Its place among all the rows, in a virtualized list. */\n index?: number\n}\n\nfunction Item({ value, disabled, label, id, index, ...props }: ItemProps): ReactElement {\n const controller = useCombobox(\"Item\")\n const group = useContext(GroupContext) ?? undefined\n const generated = useId()\n const options = useOptions({ disabled, label, index, id: id ?? generated })\n const part = useMemo(\n () => controller.item(value, () => options.get(), group),\n [controller, value, options, group]\n )\n return <ItemContext.Provider value={value}>{usePart(part, \"div\", props)}</ItemContext.Provider>\n}\n\nexport interface ItemIndicatorProps extends PartComponentProps {\n keepMounted?: boolean\n}\n\nfunction ItemIndicator({ keepMounted, render: _render, ref: _ref, ...rest }: ItemIndicatorProps) {\n const selected = useSignal(useCombobox(\"ItemIndicator\").selected(useContext(ItemContext)))\n if (!selected && !keepMounted) return null\n return <span aria-hidden=\"true\" {...(rest as object)} />\n}\n\nconst ClearElement = (props: PartComponentProps) =>\n usePart(useCombobox(\"Clear\").clear, \"button\", props)\n\n/** A button that empties the input and the value. Drawn while there is something to clear. */\nfunction Clear({ keepMounted, ...props }: ItemIndicatorProps): ReactElement | null {\n const clearable = useSignal(useCombobox(\"Clear\").clearable)\n return clearable || keepMounted ? <ClearElement {...props} /> : null\n}\n\n/** With `multiple`: what holds the chips and the input. */\nconst Chips = (props: PartComponentProps) => usePart(useCombobox(\"Chips\").chips, \"div\", props)\n\nconst ChipContext = createContext<unknown>(undefined)\n\n/** With `multiple`: one chosen value. Its `value` is what its remove button takes away. */\nfunction Chip({ value, ...props }: PartComponentProps & { value: unknown }): ReactElement {\n const controller = useCombobox(\"Chip\")\n const part = useMemo(() => controller.chip(value), [controller, value])\n return <ChipContext.Provider value={value}>{usePart(part, \"span\", props)}</ChipContext.Provider>\n}\n\nfunction ChipRemove(props: PartComponentProps): ReactElement {\n const controller = useCombobox(\"ChipRemove\")\n const value = useContext(ChipContext)\n const part = useMemo(() => controller.chipRemove(value), [controller, value])\n return usePart(part, \"button\", props)\n}\n\nconst EmptyElement = (props: PartComponentProps) =>\n usePart(useCombobox(\"Empty\").emptyPart, \"div\", props)\n\n/** Drawn while no item is shown for what was typed. */\nfunction Empty(props: PartComponentProps): ReactElement | null {\n const empty = useSignal(useCombobox(\"Empty\").empty)\n return empty ? <EmptyElement {...props} /> : null\n}\n\nexport type AutocompleteRootProps = Omit<AutocompleteProps, \"id\"> & {\n id?: string\n children?: ReactNode\n}\n\n/** A combobox whose text is the value: the list only suggests. */\nfunction AutocompleteRoot({ children, ...props }: AutocompleteRootProps): ReactElement {\n const field = useContext(FieldContext) ?? undefined\n const controller = useController<AutocompleteProps, Controller>(\n within(createAutocomplete, { field }),\n props\n )\n return <Context.Provider value={controller}>{children}</Context.Provider>\n}\n\nexport const Autocomplete = {\n Root: AutocompleteRoot,\n Input,\n Trigger,\n Clear,\n Portal,\n Positioner,\n Popup,\n Group,\n GroupLabel,\n Separator,\n Item,\n Empty,\n}\n\nexport const Combobox = {\n Root,\n Input,\n Trigger,\n Clear,\n Chips,\n Chip,\n ChipRemove,\n Portal,\n Positioner,\n Popup,\n Group,\n GroupLabel,\n Separator,\n Item,\n ItemIndicator,\n Empty,\n}\n"],"mappings":";;;;;;;;AAoBA,MAAM,UAAU,cAAiC,IAAI;AACrD,MAAM,cAAc,cAAuB,KAAA,CAAS;AAEpD,SAAS,YAAY,MAA0B;CAC7C,MAAM,aAAa,WAAW,OAAO;CAC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ACA;CACA;AACF"}
|
package/src/command.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
import { CommandProps } from "@kirana-ui/core/command";
|
|
4
|
+
export type RootProps = Omit<CommandProps, "id"> & {
|
|
5
|
+
id?: string;
|
|
6
|
+
} & PartComponentProps;
|
|
7
|
+
declare function Root({ inputValue, defaultInputValue, onInputValueChange, onSelect, filter, loop, disabled, id, ...rest }: RootProps): ReactElement;
|
|
8
|
+
declare const Input: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
9
|
+
declare const List: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
10
|
+
/** Drawn while no item is shown for what was typed. */
|
|
11
|
+
declare function Empty(props: PartComponentProps): ReactElement | null;
|
|
12
|
+
/** Items under a `<Command.GroupHeading>`. Hidden while none of them is shown. */
|
|
13
|
+
declare function Group({ id, ...props }: PartComponentProps & {
|
|
14
|
+
id?: string;
|
|
15
|
+
}): ReactElement;
|
|
16
|
+
declare function GroupHeading(props: PartComponentProps): ReactElement;
|
|
17
|
+
export interface ItemProps extends PartComponentProps {
|
|
18
|
+
/** What `onSelect` is told. */
|
|
19
|
+
value: string;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/** What is filtered; the item's text when left out. */
|
|
22
|
+
label?: string;
|
|
23
|
+
/** Other words the item answers to. */
|
|
24
|
+
keywords?: readonly string[];
|
|
25
|
+
id?: string;
|
|
26
|
+
}
|
|
27
|
+
declare function Item({ value, disabled, label, keywords, id, ...props }: ItemProps): ReactElement;
|
|
28
|
+
export interface SeparatorProps extends PartComponentProps {
|
|
29
|
+
/** Stays while something is typed. */
|
|
30
|
+
alwaysRender?: boolean;
|
|
31
|
+
}
|
|
32
|
+
declare function Separator({ alwaysRender, ...props }: SeparatorProps): ReactElement;
|
|
33
|
+
export declare const Command: {
|
|
34
|
+
Root: typeof Root;
|
|
35
|
+
Input: typeof Input;
|
|
36
|
+
List: typeof List;
|
|
37
|
+
Empty: typeof Empty;
|
|
38
|
+
Group: typeof Group;
|
|
39
|
+
GroupHeading: typeof GroupHeading;
|
|
40
|
+
Item: typeof Item;
|
|
41
|
+
Separator: typeof Separator;
|
|
42
|
+
};
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=command.d.ts.map
|