@kirana-ui/react 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/llms.txt +1601 -223
- package/package.json +14 -2
- package/skills/kirana-ui-primitives/SKILL.md +142 -0
- package/src/accordion.d.ts +26 -15
- package/src/accordion.js +11 -10
- package/src/accordion.js.map +1 -1
- package/src/agent.d.ts +1 -0
- package/src/agent.js +1 -0
- package/src/alert-dialog.d.ts +3 -2
- package/src/autocomplete.d.ts +3 -2
- package/src/autosize.d.ts +5 -2
- package/src/autosize.js +2 -2
- package/src/autosize.js.map +1 -1
- package/src/avatar.d.ts +12 -8
- package/src/avatar.js +18 -9
- package/src/avatar.js.map +1 -1
- package/src/button.d.ts +4 -2
- package/src/button.js +3 -3
- package/src/button.js.map +1 -1
- package/src/calendar.d.ts +49 -28
- package/src/calendar.js +7 -3
- package/src/calendar.js.map +1 -1
- package/src/carousel.d.ts +25 -15
- package/src/carousel.js +3 -3
- package/src/carousel.js.map +1 -1
- package/src/checkbox.d.ts +10 -7
- package/src/checkbox.js +18 -12
- package/src/checkbox.js.map +1 -1
- package/src/collapsible.d.ts +12 -8
- package/src/collapsible.js +8 -7
- package/src/collapsible.js.map +1 -1
- package/src/combobox.d.ts +88 -60
- package/src/combobox.js +44 -31
- package/src/combobox.js.map +1 -1
- package/src/command.d.ts +30 -21
- package/src/command.js +14 -7
- package/src/command.js.map +1 -1
- package/src/context-menu.d.ts +3 -2
- package/src/date-field.d.ts +25 -13
- package/src/date-field.js +7 -3
- package/src/date-field.js.map +1 -1
- package/src/date-picker.d.ts +31 -40
- package/src/date-picker.js +3 -3
- package/src/date-picker.js.map +1 -1
- package/src/dialog.d.ts +45 -35
- package/src/dialog.js +12 -8
- package/src/dialog.js.map +1 -1
- package/src/direction.d.ts +1 -0
- package/src/direction.js.map +1 -1
- package/src/drawer.d.ts +3 -2
- package/src/element.d.ts +12 -0
- package/src/element.js +20 -0
- package/src/element.js.map +1 -0
- package/src/field.d.ts +24 -16
- package/src/field.js +9 -7
- package/src/field.js.map +1 -1
- package/src/fieldset.d.ts +10 -5
- package/src/fieldset.js +4 -5
- package/src/fieldset.js.map +1 -1
- package/src/form.d.ts +5 -2
- package/src/form.js +6 -6
- package/src/form.js.map +1 -1
- package/src/hover-card.d.ts +16 -10
- package/src/hover-card.js +1 -1
- package/src/hover-card.js.map +1 -1
- package/src/hover-popup.d.ts +24 -14
- package/src/hover-popup.js +5 -13
- package/src/hover-popup.js.map +1 -1
- package/src/index.d.ts +13 -3
- package/src/input.d.ts +4 -2
- package/src/input.js +3 -3
- package/src/input.js.map +1 -1
- package/src/label.d.ts +4 -1
- package/src/label.js +3 -3
- package/src/label.js.map +1 -1
- package/src/listbox.d.ts +23 -15
- package/src/listbox.js +4 -5
- package/src/listbox.js.map +1 -1
- package/src/menu.d.ts +83 -65
- package/src/menu.js +10 -18
- package/src/menu.js.map +1 -1
- package/src/menubar.d.ts +5 -3
- package/src/menubar.js +3 -3
- package/src/menubar.js.map +1 -1
- package/src/message-scroller.d.ts +15 -9
- package/src/message-scroller.js +3 -3
- package/src/message-scroller.js.map +1 -1
- package/src/meter.d.ts +18 -9
- package/src/meter.js +1 -1
- package/src/meter.js.map +1 -1
- package/src/navigation-menu.d.ts +50 -40
- package/src/navigation-menu.js +15 -24
- package/src/navigation-menu.js.map +1 -1
- package/src/number-field.d.ts +19 -12
- package/src/number-field.js +6 -10
- package/src/number-field.js.map +1 -1
- package/src/otp.d.ts +24 -15
- package/src/otp.js +7 -13
- package/src/otp.js.map +1 -1
- package/src/pagination.d.ts +26 -16
- package/src/pagination.js +3 -3
- package/src/pagination.js.map +1 -1
- package/src/popover.d.ts +30 -21
- package/src/popover.js +9 -13
- package/src/popover.js.map +1 -1
- package/src/progress.d.ts +18 -9
- package/src/progress.js +1 -1
- package/src/progress.js.map +1 -1
- package/src/qr-code.d.ts +12 -7
- package/src/qr-code.js +3 -3
- package/src/qr-code.js.map +1 -1
- package/src/radio-group.d.ts +17 -11
- package/src/radio-group.js +16 -19
- package/src/radio-group.js.map +1 -1
- package/src/resizable.d.ts +13 -8
- package/src/resizable.js +3 -3
- package/src/resizable.js.map +1 -1
- package/src/runtime.d.ts +89 -15
- package/src/runtime.js +112 -19
- package/src/runtime.js.map +1 -1
- package/src/scroll-area.d.ts +26 -15
- package/src/scroll-area.js +9 -6
- package/src/scroll-area.js.map +1 -1
- package/src/select.d.ts +65 -45
- package/src/select.js +40 -35
- package/src/select.js.map +1 -1
- package/src/separator.d.ts +4 -2
- package/src/separator.js +3 -3
- package/src/separator.js.map +1 -1
- package/src/slider.d.ts +35 -20
- package/src/slider.js +17 -18
- package/src/slider.js.map +1 -1
- package/src/switch.d.ts +10 -6
- package/src/switch.js +11 -9
- package/src/switch.js.map +1 -1
- package/src/tabs.d.ts +22 -14
- package/src/tabs.js +5 -6
- package/src/tabs.js.map +1 -1
- package/src/testing.d.ts +1 -0
- package/src/testing.js +1 -0
- package/src/toast.d.ts +59 -23
- package/src/toast.js +59 -13
- package/src/toast.js.map +1 -1
- package/src/toggle-group.d.ts +5 -2
- package/src/toggle-group.js +3 -3
- package/src/toggle-group.js.map +1 -1
- package/src/toggle.d.ts +4 -2
- package/src/toggle.js +3 -3
- package/src/toggle.js.map +1 -1
- package/src/toolbar.d.ts +26 -11
- package/src/toolbar.js +23 -13
- package/src/toolbar.js.map +1 -1
- package/src/tooltip.d.ts +16 -10
- package/src/tooltip.js +1 -1
- package/src/tooltip.js.map +1 -1
- package/src/use-render.d.ts +38 -0
- package/src/use-render.js +50 -0
- package/src/use-render.js.map +1 -0
- package/src/value-bar.d.ts +19 -11
- package/src/value-bar.js +8 -5
- package/src/value-bar.js.map +1 -1
package/src/calendar.d.ts
CHANGED
|
@@ -1,44 +1,65 @@
|
|
|
1
1
|
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { StateOf } from "@kirana-ui/core";
|
|
2
3
|
import { ReactElement, ReactNode } from "react";
|
|
3
4
|
import { Calendar as Calendar$1, CalendarDay, CalendarProps, CalendarWeekday } from "@kirana-ui/core/calendar";
|
|
5
|
+
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
|
+
type Parts = Vocabulary["calendar"];
|
|
7
|
+
/**
|
|
8
|
+
* The calendar its parts are inside. Exported for a component that is made of one (a date picker
|
|
9
|
+
* provides its own to the calendar's parts).
|
|
10
|
+
*/
|
|
4
11
|
declare const Context: import("react").Context<Calendar$1 | null>;
|
|
5
|
-
export type RootProps = Omit<CalendarProps, "id"> & {
|
|
12
|
+
export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<CalendarProps, "id"> & {
|
|
6
13
|
id?: string;
|
|
7
|
-
}
|
|
14
|
+
}>;
|
|
8
15
|
declare function Root({ value, defaultValue, onValueChange, mode, defaultFocusedValue, onMonthChange, locale, calendarSystem, min, max, isDateUnavailable, disabled, readOnly, fixedWeeks, id, ...rest }: RootProps): ReactElement;
|
|
16
|
+
export type HeadingProps = PartComponentProps<"div", StateOf<Parts["heading"]>>;
|
|
9
17
|
/** Names the month shown, unless it is given something else to say. */
|
|
10
|
-
declare function Heading({ children, ...props }:
|
|
11
|
-
|
|
12
|
-
declare const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
declare function Heading({ children, ...props }: HeadingProps): ReactElement;
|
|
19
|
+
export type PreviousProps = PartComponentProps<"button", StateOf<Parts["previous"]>>;
|
|
20
|
+
declare const Previous: (props: PreviousProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
21
|
+
export type NextProps = PartComponentProps<"button", StateOf<Parts["next"]>>;
|
|
22
|
+
declare const Next: (props: NextProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
23
|
+
export type GridProps = PartComponentProps<"table", StateOf<Parts["grid"]>>;
|
|
24
|
+
declare const Grid: (props: GridProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
25
|
+
export interface WeekdaysProps {
|
|
26
|
+
/** Draws one day of the week, once for each: its heading cell. */
|
|
16
27
|
children: (weekday: CalendarWeekday) => ReactNode;
|
|
17
|
-
}
|
|
18
|
-
/** Draws its child once for each
|
|
19
|
-
declare function
|
|
28
|
+
}
|
|
29
|
+
/** Draws its child once for each day of the week, in the locale's order. */
|
|
30
|
+
declare function Weekdays({ children }: WeekdaysProps): import("react").JSX.Element;
|
|
31
|
+
export interface WeeksProps {
|
|
32
|
+
/** Draws one week, once for each of the month shown: a row of its days. */
|
|
20
33
|
children: (week: readonly CalendarDay[]) => ReactNode;
|
|
21
|
-
}
|
|
22
|
-
|
|
34
|
+
}
|
|
35
|
+
/** Draws its child once for each week of the month shown. */
|
|
36
|
+
declare function Weeks({ children }: WeeksProps): import("react").JSX.Element;
|
|
37
|
+
export type HeadCellProps = PartComponentProps<"th", StateOf<Parts["headCell"]>, {
|
|
38
|
+
/** The day of the week it heads: an entry `Calendar.Weekdays` gave. */
|
|
23
39
|
weekday: CalendarWeekday;
|
|
24
|
-
}
|
|
25
|
-
declare function
|
|
40
|
+
}>;
|
|
41
|
+
declare function HeadCell({ weekday, ...props }: HeadCellProps): ReactElement;
|
|
42
|
+
export type CellProps = PartComponentProps<"td", StateOf<Parts["cell"]>, {
|
|
43
|
+
/** The day it holds, as `Calendar.Weeks` gave it: `day.date`. */
|
|
26
44
|
date: string;
|
|
27
|
-
}
|
|
28
|
-
declare function
|
|
45
|
+
}>;
|
|
46
|
+
declare function Cell({ date, ...props }: CellProps): ReactElement;
|
|
47
|
+
export type DayProps = PartComponentProps<"button", StateOf<Parts["day"]>, {
|
|
48
|
+
/** The day it is the button of, as `Calendar.Weeks` gave it: `day.date`. */
|
|
29
49
|
date: string;
|
|
30
|
-
}
|
|
50
|
+
}>;
|
|
51
|
+
declare function Day({ date, ...props }: DayProps): ReactElement;
|
|
31
52
|
export declare const Calendar: {
|
|
32
|
-
Root: typeof Root;
|
|
33
|
-
Heading: typeof Heading;
|
|
34
|
-
Previous: typeof Previous;
|
|
35
|
-
Next: typeof Next;
|
|
36
|
-
Grid: typeof Grid;
|
|
37
|
-
Weekdays: typeof Weekdays;
|
|
38
|
-
HeadCell: typeof HeadCell;
|
|
39
|
-
Weeks: typeof Weeks;
|
|
40
|
-
Cell: typeof Cell;
|
|
41
|
-
Day: typeof Day;
|
|
53
|
+
readonly Root: typeof Root;
|
|
54
|
+
readonly Heading: typeof Heading;
|
|
55
|
+
readonly Previous: typeof Previous;
|
|
56
|
+
readonly Next: typeof Next;
|
|
57
|
+
readonly Grid: typeof Grid;
|
|
58
|
+
readonly Weekdays: typeof Weekdays;
|
|
59
|
+
readonly HeadCell: typeof HeadCell;
|
|
60
|
+
readonly Weeks: typeof Weeks;
|
|
61
|
+
readonly Cell: typeof Cell;
|
|
62
|
+
readonly Day: typeof Day;
|
|
42
63
|
};
|
|
43
64
|
export { Context as CalendarContext };
|
|
44
65
|
//# sourceMappingURL=calendar.d.ts.map
|
package/src/calendar.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { DirectionContext } from "./direction-context.js";
|
|
2
|
-
import { useController, usePart, useSignal } from "./runtime.js";
|
|
2
|
+
import { parts, useController, usePart, useSignal } from "./runtime.js";
|
|
3
3
|
import { within } from "@kirana-ui/core";
|
|
4
4
|
import { Fragment, createContext, useContext, useMemo } from "react";
|
|
5
5
|
import { createCalendar } from "@kirana-ui/core/calendar";
|
|
6
6
|
import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
|
|
7
7
|
// src/calendar.tsx
|
|
8
|
+
/**
|
|
9
|
+
* The calendar its parts are inside. Exported for a component that is made of one (a date picker
|
|
10
|
+
* provides its own to the calendar's parts).
|
|
11
|
+
*/
|
|
8
12
|
const Context = createContext(null);
|
|
9
13
|
function useCalendar(part) {
|
|
10
14
|
const controller = useContext(Context);
|
|
@@ -68,7 +72,7 @@ function Cell({ date, ...props }) {
|
|
|
68
72
|
function Day({ date, ...props }) {
|
|
69
73
|
return usePart(useCalendar("Day").day(date), "button", props);
|
|
70
74
|
}
|
|
71
|
-
const Calendar = {
|
|
75
|
+
const Calendar = /* @__PURE__ */ parts("Calendar", {
|
|
72
76
|
Root,
|
|
73
77
|
Heading,
|
|
74
78
|
Previous,
|
|
@@ -79,7 +83,7 @@ const Calendar = {
|
|
|
79
83
|
Weeks,
|
|
80
84
|
Cell,
|
|
81
85
|
Day
|
|
82
|
-
};
|
|
86
|
+
});
|
|
83
87
|
export { Calendar, Context as CalendarContext };
|
|
84
88
|
|
|
85
89
|
//# sourceMappingURL=calendar.js.map
|
package/src/calendar.js.map
CHANGED
|
@@ -1 +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 }
|
|
1
|
+
{"version":3,"file":"calendar.js","names":[],"sources":["../../../../packages/react/src/calendar.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } 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 type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { Fragment, createContext, useContext, useMemo } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { parts, useController, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"calendar\"]\n\n/**\n * The calendar its parts are inside. Exported for a component that is made of one (a date picker\n * provides its own to the calendar's parts).\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 = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<CalendarProps, \"id\"> & { id?: string }\n>\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\nexport type HeadingProps = PartComponentProps<\"div\", StateOf<Parts[\"heading\"]>>\n\n/** Names the month shown, unless it is given something else to say. */\nfunction Heading({ children, ...props }: HeadingProps): ReactElement {\n const controller = useCalendar(\"Heading\")\n const title = useSignal(controller.title)\n return usePart(controller.heading, \"div\", { ...props, children: children ?? title })\n}\n\nexport type PreviousProps = PartComponentProps<\"button\", StateOf<Parts[\"previous\"]>>\n\nconst Previous = (props: PreviousProps) =>\n usePart(useCalendar(\"Previous\").previous, \"button\", props)\nexport type NextProps = PartComponentProps<\"button\", StateOf<Parts[\"next\"]>>\n\nconst Next = (props: NextProps) => usePart(useCalendar(\"Next\").next, \"button\", props)\nexport type GridProps = PartComponentProps<\"table\", StateOf<Parts[\"grid\"]>>\n\nconst Grid = (props: GridProps) => usePart(useCalendar(\"Grid\").grid, \"table\", props)\n\nexport interface WeekdaysProps {\n /** Draws one day of the week, once for each: its heading cell. */\n children: (weekday: CalendarWeekday) => ReactNode\n}\n\n/** Draws its child once for each day of the week, in the locale's order. */\nfunction Weekdays({ children }: WeekdaysProps) {\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\nexport interface WeeksProps {\n /** Draws one week, once for each of the month shown: a row of its days. */\n children: (week: readonly CalendarDay[]) => ReactNode\n}\n\n/** Draws its child once for each week of the month shown. */\nfunction Weeks({ children }: WeeksProps) {\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\nexport type HeadCellProps = PartComponentProps<\n \"th\",\n StateOf<Parts[\"headCell\"]>,\n {\n /** The day of the week it heads: an entry `Calendar.Weekdays` gave. */\n weekday: CalendarWeekday\n }\n>\n\nfunction HeadCell({ weekday, ...props }: HeadCellProps): ReactElement {\n const controller = useCalendar(\"HeadCell\")\n const part = useMemo(() => controller.headCell(weekday), [controller, weekday])\n return usePart(part, \"th\", props)\n}\n\nexport type CellProps = PartComponentProps<\n \"td\",\n StateOf<Parts[\"cell\"]>,\n {\n /** The day it holds, as `Calendar.Weeks` gave it: `day.date`. */\n date: string\n }\n>\n\nfunction Cell({ date, ...props }: CellProps): ReactElement {\n return usePart(useCalendar(\"Cell\").cell(date), \"td\", props)\n}\n\nexport type DayProps = PartComponentProps<\n \"button\",\n StateOf<Parts[\"day\"]>,\n {\n /** The day it is the button of, as `Calendar.Weeks` gave it: `day.date`. */\n date: string\n }\n>\n\nfunction Day({ date, ...props }: DayProps): ReactElement {\n return usePart(useCalendar(\"Day\").day(date), \"button\", props)\n}\n\nexport const Calendar = /* @__PURE__ */ parts(\"Calendar\", {\n Root,\n Heading,\n Previous,\n Next,\n Grid,\n Weekdays,\n HeadCell,\n Weeks,\n Cell,\n Day,\n})\n"],"mappings":";;;;;;;;;;;AAuBA,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;AAQA,SAAS,KAAK,EACZ,OACA,cACA,eACA,MACA,qBACA,eACA,QACA,gBACA,KACA,KACA,mBACA,UACA,UACA,YACA,IACA,GAAG,QACuB;CAC1B,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,aAAa,cACjB,OAAO,gBAAgB,EAAE,UAAU,CAAC,GACpC;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CACA,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CAAoB,CAAA;AAElG;;AAKA,SAAS,QAAQ,EAAE,UAAU,GAAG,SAAqC;CACnE,MAAM,aAAa,YAAY,SAAS;CACxC,MAAM,QAAQ,UAAU,WAAW,KAAK;CACxC,OAAO,QAAQ,WAAW,SAAS,OAAO;EAAE,GAAG;EAAO,UAAU,YAAY;CAAM,CAAC;AACrF;AAIA,MAAM,YAAY,UAChB,QAAQ,YAAY,UAAU,CAAC,CAAC,UAAU,UAAU,KAAK;AAG3D,MAAM,QAAQ,UAAqB,QAAQ,YAAY,MAAM,CAAC,CAAC,MAAM,UAAU,KAAK;AAGpF,MAAM,QAAQ,UAAqB,QAAQ,YAAY,MAAM,CAAC,CAAC,MAAM,SAAS,KAAK;;AAQnF,SAAS,SAAS,EAAE,YAA2B;CAC7C,MAAM,WAAW,UAAU,YAAY,UAAU,CAAC,CAAC,QAAQ;CAC3D,OACE,oBAAA,YAAA,EAAA,UACG,SAAS,KAAK,YACb,oBAAC,UAAD,EAAA,UAA+B,SAAS,OAAO,EAAY,GAA5C,QAAQ,KAAoC,CAC5D,EACD,CAAA;AAEN;;AAQA,SAAS,MAAM,EAAE,YAAwB;CACvC,MAAM,QAAQ,UAAU,YAAY,OAAO,CAAC,CAAC,KAAK;CAClD,OACE,oBAAA,YAAA,EAAA,UACG,MAAM,KAAK,SACV,oBAAC,UAAD,EAAA,UAA+B,SAAS,IAAI,EAAY,GAAzC,KAAK,EAAE,CAAE,IAAgC,CACzD,EACD,CAAA;AAEN;AAWA,SAAS,SAAS,EAAE,SAAS,GAAG,SAAsC;CACpE,MAAM,aAAa,YAAY,UAAU;CACzC,MAAM,OAAO,cAAc,WAAW,SAAS,OAAO,GAAG,CAAC,YAAY,OAAO,CAAC;CAC9E,OAAO,QAAQ,MAAM,MAAM,KAAK;AAClC;AAWA,SAAS,KAAK,EAAE,MAAM,GAAG,SAAkC;CACzD,OAAO,QAAQ,YAAY,MAAM,CAAC,CAAC,KAAK,IAAI,GAAG,MAAM,KAAK;AAC5D;AAWA,SAAS,IAAI,EAAE,MAAM,GAAG,SAAiC;CACvD,OAAO,QAAQ,YAAY,KAAK,CAAC,CAAC,IAAI,IAAI,GAAG,UAAU,KAAK;AAC9D;AAEA,MAAa,WAA2B,sBAAM,YAAY;CACxD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
|
package/src/carousel.d.ts
CHANGED
|
@@ -1,26 +1,36 @@
|
|
|
1
1
|
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { StateOf } from "@kirana-ui/core";
|
|
2
3
|
import { ReactElement } from "react";
|
|
3
4
|
import { CarouselProps } from "@kirana-ui/core/carousel";
|
|
4
|
-
|
|
5
|
+
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
|
+
type Parts = Vocabulary["carousel"];
|
|
7
|
+
export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<CarouselProps, "id"> & {
|
|
5
8
|
id?: string;
|
|
6
|
-
}
|
|
9
|
+
}>;
|
|
7
10
|
declare function Root({ index, defaultIndex, onIndexChange, orientation, loop, id, ...rest }: RootProps): ReactElement;
|
|
8
|
-
|
|
9
|
-
declare
|
|
11
|
+
export type ViewportProps = PartComponentProps<"div", StateOf<Parts["viewport"]>>;
|
|
12
|
+
declare const Viewport: (props: ViewportProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
13
|
+
export type ItemProps = PartComponentProps<"div", StateOf<Parts["item"]>, {
|
|
14
|
+
/** Its place among the slides, from 0. */
|
|
10
15
|
index: number;
|
|
11
|
-
}
|
|
12
|
-
declare
|
|
13
|
-
|
|
14
|
-
declare
|
|
16
|
+
}>;
|
|
17
|
+
declare function Item({ index, ...props }: ItemProps): ReactElement;
|
|
18
|
+
export type PreviousProps = PartComponentProps<"button", StateOf<Parts["previous"]>>;
|
|
19
|
+
declare const Previous: (props: PreviousProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
20
|
+
export type NextProps = PartComponentProps<"button", StateOf<Parts["next"]>>;
|
|
21
|
+
declare const Next: (props: NextProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
22
|
+
export type IndicatorProps = PartComponentProps<"button", StateOf<Parts["indicator"]>, {
|
|
23
|
+
/** The slide it goes to, from 0. */
|
|
15
24
|
index: number;
|
|
16
|
-
}
|
|
25
|
+
}>;
|
|
26
|
+
declare function Indicator({ index, ...props }: IndicatorProps): ReactElement;
|
|
17
27
|
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;
|
|
28
|
+
readonly Root: typeof Root;
|
|
29
|
+
readonly Viewport: typeof Viewport;
|
|
30
|
+
readonly Item: typeof Item;
|
|
31
|
+
readonly Previous: typeof Previous;
|
|
32
|
+
readonly Next: typeof Next;
|
|
33
|
+
readonly Indicator: typeof Indicator;
|
|
24
34
|
};
|
|
25
35
|
export {};
|
|
26
36
|
//# sourceMappingURL=carousel.d.ts.map
|
package/src/carousel.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DirectionContext } from "./direction-context.js";
|
|
2
|
-
import { useController, usePart } from "./runtime.js";
|
|
2
|
+
import { parts, useController, usePart } from "./runtime.js";
|
|
3
3
|
import { within } from "@kirana-ui/core";
|
|
4
4
|
import { createContext, useContext, useMemo } from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -39,14 +39,14 @@ function Indicator({ index, ...props }) {
|
|
|
39
39
|
const part = useMemo(() => controller.indicator(index), [controller, index]);
|
|
40
40
|
return usePart(part, "button", props);
|
|
41
41
|
}
|
|
42
|
-
const Carousel = {
|
|
42
|
+
const Carousel = /* @__PURE__ */ parts("Carousel", {
|
|
43
43
|
Root,
|
|
44
44
|
Viewport,
|
|
45
45
|
Item,
|
|
46
46
|
Previous,
|
|
47
47
|
Next,
|
|
48
48
|
Indicator
|
|
49
|
-
};
|
|
49
|
+
});
|
|
50
50
|
export { Carousel };
|
|
51
51
|
|
|
52
52
|
//# sourceMappingURL=carousel.js.map
|
package/src/carousel.js.map
CHANGED
|
@@ -1 +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 }
|
|
1
|
+
{"version":3,"file":"carousel.js","names":[],"sources":["../../../../packages/react/src/carousel.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createCarousel } from \"@kirana-ui/core/carousel\"\nimport type { Carousel as Controller, CarouselProps } from \"@kirana-ui/core/carousel\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { parts, useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"carousel\"]\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 = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<CarouselProps, \"id\"> & { id?: string }\n>\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\nexport type ViewportProps = PartComponentProps<\"div\", StateOf<Parts[\"viewport\"]>>\n\nconst Viewport = (props: ViewportProps) => usePart(useCarousel(\"Viewport\").viewport, \"div\", props)\n\nexport type ItemProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"item\"]>,\n {\n /** Its place among the slides, from 0. */\n index: number\n }\n>\n\nfunction Item({ index, ...props }: ItemProps): ReactElement {\n const controller = useCarousel(\"Item\")\n const part = useMemo(() => controller.item(index), [controller, index])\n return usePart(part, \"div\", props)\n}\n\nexport type PreviousProps = PartComponentProps<\"button\", StateOf<Parts[\"previous\"]>>\n\nconst Previous = (props: PreviousProps) =>\n usePart(useCarousel(\"Previous\").previous, \"button\", props)\nexport type NextProps = PartComponentProps<\"button\", StateOf<Parts[\"next\"]>>\n\nconst Next = (props: NextProps) => usePart(useCarousel(\"Next\").next, \"button\", props)\n\nexport type IndicatorProps = PartComponentProps<\n \"button\",\n StateOf<Parts[\"indicator\"]>,\n {\n /** The slide it goes to, from 0. */\n index: number\n }\n>\n\nfunction Indicator({ index, ...props }: IndicatorProps): 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 = /* @__PURE__ */ parts(\"Carousel\", {\n Root,\n Viewport,\n Item,\n Previous,\n Next,\n Indicator,\n})\n"],"mappings":";;;;;;;AAcA,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;AAQA,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;AAIA,MAAM,YAAY,UAAyB,QAAQ,YAAY,UAAU,CAAC,CAAC,UAAU,OAAO,KAAK;AAWjG,SAAS,KAAK,EAAE,OAAO,GAAG,SAAkC;CAC1D,MAAM,aAAa,YAAY,MAAM;CACrC,MAAM,OAAO,cAAc,WAAW,KAAK,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC;CACtE,OAAO,QAAQ,MAAM,OAAO,KAAK;AACnC;AAIA,MAAM,YAAY,UAChB,QAAQ,YAAY,UAAU,CAAC,CAAC,UAAU,UAAU,KAAK;AAG3D,MAAM,QAAQ,UAAqB,QAAQ,YAAY,MAAM,CAAC,CAAC,MAAM,UAAU,KAAK;AAWpF,SAAS,UAAU,EAAE,OAAO,GAAG,SAAuC;CACpE,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,WAA2B,sBAAM,YAAY;CACxD;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
|
package/src/checkbox.d.ts
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { StateOf } from "@kirana-ui/core";
|
|
2
3
|
import { ReactElement } from "react";
|
|
3
4
|
import { CheckboxProps } from "@kirana-ui/core/checkbox";
|
|
4
|
-
|
|
5
|
+
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
|
+
type Parts = Vocabulary["checkbox"];
|
|
7
|
+
export type RootProps = PartComponentProps<"span", StateOf<Parts["root"]>, Omit<CheckboxProps, "id"> & {
|
|
5
8
|
id?: string;
|
|
6
|
-
}
|
|
7
|
-
declare function Root({ checked, defaultChecked, onCheckedChange, indeterminate, disabled, readOnly, required, name, form, value, id,
|
|
8
|
-
export
|
|
9
|
+
}>;
|
|
10
|
+
declare function Root({ checked, defaultChecked, onCheckedChange, indeterminate, disabled, readOnly, required, name, form, value, id, ...rest }: RootProps): ReactElement;
|
|
11
|
+
export type IndicatorProps = PartComponentProps<"span", StateOf<Parts["indicator"]>, {
|
|
9
12
|
/** Keeps the mark in the page while the box is unchecked. */
|
|
10
13
|
keepMounted?: boolean;
|
|
11
|
-
}
|
|
14
|
+
}>;
|
|
12
15
|
declare function Indicator({ keepMounted, ...props }: IndicatorProps): ReactElement | null;
|
|
13
16
|
export declare const Checkbox: {
|
|
14
|
-
Root: typeof Root;
|
|
15
|
-
Indicator: typeof Indicator;
|
|
17
|
+
readonly Root: typeof Root;
|
|
18
|
+
readonly Indicator: typeof Indicator;
|
|
16
19
|
};
|
|
17
20
|
export {};
|
|
18
21
|
//# sourceMappingURL=checkbox.d.ts.map
|
package/src/checkbox.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FieldContext } from "./field-context.js";
|
|
2
|
-
import { useController, usePart, useSignal } from "./runtime.js";
|
|
2
|
+
import { PartElement, parts, useController, usePart, useSignal } from "./runtime.js";
|
|
3
3
|
import { within } from "@kirana-ui/core";
|
|
4
4
|
import { createContext, useContext } from "react";
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { createCheckbox } from "@kirana-ui/core/checkbox";
|
|
7
7
|
// src/checkbox.tsx
|
|
8
8
|
const Context = createContext(null);
|
|
@@ -11,7 +11,7 @@ function useCheckbox(part) {
|
|
|
11
11
|
if (!controller) throw new Error(`<Checkbox.${part}> must be inside <Checkbox.Root>`);
|
|
12
12
|
return controller;
|
|
13
13
|
}
|
|
14
|
-
function Root({ checked, defaultChecked, onCheckedChange, indeterminate, disabled, readOnly, required, name, form, value, id,
|
|
14
|
+
function Root({ checked, defaultChecked, onCheckedChange, indeterminate, disabled, readOnly, required, name, form, value, id, ...rest }) {
|
|
15
15
|
const field = useContext(FieldContext) ?? void 0;
|
|
16
16
|
const create = within(createCheckbox, { field });
|
|
17
17
|
const controller = useController(create, {
|
|
@@ -29,23 +29,29 @@ function Root({ checked, defaultChecked, onCheckedChange, indeterminate, disable
|
|
|
29
29
|
});
|
|
30
30
|
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
31
31
|
value: controller,
|
|
32
|
-
children: /* @__PURE__ */
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
children: /* @__PURE__ */ jsx(PartElement, {
|
|
33
|
+
of: controller.root,
|
|
34
|
+
tag: "span",
|
|
35
|
+
hold: withInput,
|
|
36
|
+
...rest
|
|
35
37
|
})
|
|
36
38
|
});
|
|
37
39
|
}
|
|
38
|
-
const
|
|
40
|
+
const withInput = (content) => /* @__PURE__ */ jsxs(Fragment$1, { children: [content, /* @__PURE__ */ jsx(Input, {})] });
|
|
39
41
|
const Input = () => usePart(useCheckbox("Root").input, "input", {});
|
|
40
42
|
function Indicator({ keepMounted, ...props }) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
const controller = useCheckbox("Indicator");
|
|
44
|
+
if (!useSignal(controller.indicatorMounted) && !keepMounted) return null;
|
|
45
|
+
return /* @__PURE__ */ jsx(PartElement, {
|
|
46
|
+
of: controller.indicator,
|
|
47
|
+
tag: "span",
|
|
48
|
+
...props
|
|
49
|
+
});
|
|
43
50
|
}
|
|
44
|
-
const
|
|
45
|
-
const Checkbox = {
|
|
51
|
+
const Checkbox = /* @__PURE__ */ parts("Checkbox", {
|
|
46
52
|
Root,
|
|
47
53
|
Indicator
|
|
48
|
-
};
|
|
54
|
+
});
|
|
49
55
|
export { Checkbox };
|
|
50
56
|
|
|
51
57
|
//# sourceMappingURL=checkbox.js.map
|
package/src/checkbox.js.map
CHANGED
|
@@ -1 +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 }
|
|
1
|
+
{"version":3,"file":"checkbox.js","names":[],"sources":["../../../../packages/react/src/checkbox.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createCheckbox } from \"@kirana-ui/core/checkbox\"\nimport type { Checkbox as Controller, CheckboxProps } from \"@kirana-ui/core/checkbox\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { FieldContext } from \"./field-context.ts\"\nimport { PartElement, parts, useController, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"checkbox\"]\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 = PartComponentProps<\n \"span\",\n StateOf<Parts[\"root\"]>,\n Omit<CheckboxProps, \"id\"> & { id?: string }\n>\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 ...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,\n id,\n })\n return (\n <Context.Provider value={controller}>\n <PartElement of={controller.root} tag=\"span\" hold={withInput} {...rest} />\n </Context.Provider>\n )\n}\n\n// Its native input is the element's last child, whatever element the caller asked for.\nconst withInput = (content: ReactNode) => (\n <>\n {content}\n <Input />\n </>\n)\n\nconst Input = () => usePart(useCheckbox(\"Root\").input, \"input\", {})\n\nexport type IndicatorProps = PartComponentProps<\n \"span\",\n StateOf<Parts[\"indicator\"]>,\n {\n /** Keeps the mark in the page while the box is unchecked. */\n keepMounted?: boolean\n }\n>\n\nfunction Indicator({ keepMounted, ...props }: IndicatorProps): ReactElement | null {\n const controller = useCheckbox(\"Indicator\")\n const mounted = useSignal(controller.indicatorMounted)\n if (!mounted && !keepMounted) return null\n return <PartElement of={controller.indicator} tag=\"span\" {...props} />\n}\n\nexport const Checkbox = /* @__PURE__ */ parts(\"Checkbox\", { Root, Indicator })\n"],"mappings":";;;;;;;AAcA,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;AAQA,SAAS,KAAK,EACZ,SACA,gBACA,iBACA,eACA,UACA,UACA,UACA,MACA,MACA,OACA,IACA,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;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EACvB,UAAA,oBAAC,aAAD;GAAa,IAAI,WAAW;GAAM,KAAI;GAAO,MAAM;GAAW,GAAI;EAAO,CAAA;CACzD,CAAA;AAEtB;AAGA,MAAM,aAAa,YACjB,qBAAA,YAAA,EAAA,UAAA,CACG,SACD,oBAAC,OAAD,CAAQ,CAAA,CACR,EAAA,CAAA;AAGJ,MAAM,cAAc,QAAQ,YAAY,MAAM,CAAC,CAAC,OAAO,SAAS,CAAC,CAAC;AAWlE,SAAS,UAAU,EAAE,aAAa,GAAG,SAA8C;CACjF,MAAM,aAAa,YAAY,WAAW;CAE1C,IAAI,CADY,UAAU,WAAW,gBAC1B,KAAK,CAAC,aAAa,OAAO;CACrC,OAAO,oBAAC,aAAD;EAAa,IAAI,WAAW;EAAW,KAAI;EAAO,GAAI;CAAQ,CAAA;AACvE;AAEA,MAAa,WAA2B,sBAAM,YAAY;CAAE;CAAM;AAAU,CAAC"}
|
package/src/collapsible.d.ts
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { StateOf } from "@kirana-ui/core";
|
|
2
3
|
import { ReactElement } from "react";
|
|
3
4
|
import { CollapsibleProps } from "@kirana-ui/core/collapsible";
|
|
4
|
-
|
|
5
|
+
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
|
+
type Parts = Vocabulary["collapsible"];
|
|
7
|
+
export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<CollapsibleProps, "id"> & {
|
|
5
8
|
id?: string;
|
|
6
|
-
}
|
|
9
|
+
}>;
|
|
7
10
|
declare function Root({ open, defaultOpen, onOpenChange, disabled, id, ...rest }: RootProps): ReactElement;
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
export type TriggerProps = PartComponentProps<"button", StateOf<Parts["trigger"]>>;
|
|
12
|
+
declare function Trigger(props: TriggerProps): ReactElement;
|
|
13
|
+
export type PanelProps = PartComponentProps<"div", StateOf<Parts["panel"]>, {
|
|
10
14
|
/** Keeps the closed panel in the page, `hidden`. */
|
|
11
15
|
keepMounted?: boolean;
|
|
12
|
-
}
|
|
16
|
+
}>;
|
|
13
17
|
declare function Panel({ keepMounted, ...props }: PanelProps): ReactElement | null;
|
|
14
18
|
export declare const Collapsible: {
|
|
15
|
-
Root: typeof Root;
|
|
16
|
-
Trigger: typeof Trigger;
|
|
17
|
-
Panel: typeof Panel;
|
|
19
|
+
readonly Root: typeof Root;
|
|
20
|
+
readonly Trigger: typeof Trigger;
|
|
21
|
+
readonly Panel: typeof Panel;
|
|
18
22
|
};
|
|
19
23
|
export {};
|
|
20
24
|
//# sourceMappingURL=collapsible.d.ts.map
|
package/src/collapsible.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useController, usePart, useSignal } from "./runtime.js";
|
|
1
|
+
import { PartElement, parts, useController, usePart, useSignal } from "./runtime.js";
|
|
2
2
|
import { createContext, useContext } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { createCollapsible } from "@kirana-ui/core/collapsible";
|
|
@@ -28,16 +28,17 @@ function Trigger(props) {
|
|
|
28
28
|
function Panel({ keepMounted, ...props }) {
|
|
29
29
|
const controller = useCollapsible("Panel");
|
|
30
30
|
if (!useSignal(controller.mounted) && !keepMounted) return null;
|
|
31
|
-
return /* @__PURE__ */ jsx(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
return /* @__PURE__ */ jsx(PartElement, {
|
|
32
|
+
of: controller.panel,
|
|
33
|
+
tag: "div",
|
|
34
|
+
...props
|
|
35
|
+
});
|
|
35
36
|
}
|
|
36
|
-
const Collapsible = {
|
|
37
|
+
const Collapsible = /* @__PURE__ */ parts("Collapsible", {
|
|
37
38
|
Root,
|
|
38
39
|
Trigger,
|
|
39
40
|
Panel
|
|
40
|
-
};
|
|
41
|
+
});
|
|
41
42
|
export { Collapsible };
|
|
42
43
|
|
|
43
44
|
//# sourceMappingURL=collapsible.js.map
|
package/src/collapsible.js.map
CHANGED
|
@@ -1 +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 }
|
|
1
|
+
{"version":3,"file":"collapsible.js","names":[],"sources":["../../../../packages/react/src/collapsible.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createCollapsible } from \"@kirana-ui/core/collapsible\"\nimport type { Collapsible as Controller, CollapsibleProps } from \"@kirana-ui/core/collapsible\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { PartElement, parts, useController, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"collapsible\"]\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 = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<CollapsibleProps, \"id\"> & { id?: string }\n>\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\nexport type TriggerProps = PartComponentProps<\"button\", StateOf<Parts[\"trigger\"]>>\n\nfunction Trigger(props: TriggerProps): ReactElement {\n return usePart(useCollapsible(\"Trigger\").trigger, \"button\", props)\n}\n\nexport type PanelProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"panel\"]>,\n {\n /** Keeps the closed panel in the page, `hidden`. */\n keepMounted?: boolean\n }\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 <PartElement of={controller.panel} tag=\"div\" {...props} />\n}\n\nexport const Collapsible = /* @__PURE__ */ parts(\"Collapsible\", { Root, Trigger, Panel })\n"],"mappings":";;;;;AAYA,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;AAQA,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;AAIA,SAAS,QAAQ,OAAmC;CAClD,OAAO,QAAQ,eAAe,SAAS,CAAC,CAAC,SAAS,UAAU,KAAK;AACnE;AAWA,SAAS,MAAM,EAAE,aAAa,GAAG,SAA0C;CACzE,MAAM,aAAa,eAAe,OAAO;CAEzC,IAAI,CADY,UAAU,WAAW,OAC1B,KAAK,CAAC,aAAa,OAAO;CACrC,OAAO,oBAAC,aAAD;EAAa,IAAI,WAAW;EAAO,KAAI;EAAM,GAAI;CAAQ,CAAA;AAClE;AAEA,MAAa,cAA8B,sBAAM,eAAe;CAAE;CAAM;CAAS;AAAM,CAAC"}
|