@kirana-ui/react 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/llms.txt +3216 -0
  2. package/package.json +124 -2
  3. package/skills/kirana-ui-primitives/SKILL.md +142 -0
  4. package/src/accordion.d.ts +26 -15
  5. package/src/accordion.js +12 -11
  6. package/src/accordion.js.map +1 -1
  7. package/src/agent.d.ts +1 -0
  8. package/src/agent.js +1 -0
  9. package/src/alert-dialog.d.ts +3 -2
  10. package/src/autocomplete.d.ts +3 -0
  11. package/src/autocomplete.js +1 -0
  12. package/src/autosize.d.ts +12 -0
  13. package/src/autosize.js +12 -0
  14. package/src/autosize.js.map +1 -0
  15. package/src/avatar.d.ts +12 -8
  16. package/src/avatar.js +19 -10
  17. package/src/avatar.js.map +1 -1
  18. package/src/button.d.ts +4 -2
  19. package/src/button.js +3 -3
  20. package/src/button.js.map +1 -1
  21. package/src/calendar.d.ts +65 -0
  22. package/src/calendar.js +89 -0
  23. package/src/calendar.js.map +1 -0
  24. package/src/carousel.d.ts +36 -0
  25. package/src/carousel.js +52 -0
  26. package/src/carousel.js.map +1 -0
  27. package/src/checkbox.d.ts +10 -7
  28. package/src/checkbox.js +19 -12
  29. package/src/checkbox.js.map +1 -1
  30. package/src/collapsible.d.ts +12 -8
  31. package/src/collapsible.js +8 -7
  32. package/src/collapsible.js.map +1 -1
  33. package/src/combobox.d.ts +119 -0
  34. package/src/combobox.js +177 -0
  35. package/src/combobox.js.map +1 -0
  36. package/src/command.d.ts +53 -0
  37. package/src/command.js +95 -0
  38. package/src/command.js.map +1 -0
  39. package/src/context-menu.d.ts +3 -0
  40. package/src/context-menu.js +1 -0
  41. package/src/date-field.d.ts +37 -0
  42. package/src/date-field.js +64 -0
  43. package/src/date-field.js.map +1 -0
  44. package/src/date-picker.d.ts +44 -0
  45. package/src/date-picker.js +62 -0
  46. package/src/date-picker.js.map +1 -0
  47. package/src/dialog.d.ts +54 -27
  48. package/src/dialog.js +23 -6
  49. package/src/dialog.js.map +1 -1
  50. package/src/direction.d.ts +1 -0
  51. package/src/direction.js +1 -1
  52. package/src/direction.js.map +1 -1
  53. package/src/drawer.d.ts +3 -0
  54. package/src/drawer.js +1 -0
  55. package/src/element.d.ts +12 -0
  56. package/src/element.js +20 -0
  57. package/src/element.js.map +1 -0
  58. package/src/field.d.ts +24 -16
  59. package/src/field.js +11 -9
  60. package/src/field.js.map +1 -1
  61. package/src/fieldset.d.ts +10 -5
  62. package/src/fieldset.js +4 -5
  63. package/src/fieldset.js.map +1 -1
  64. package/src/form.d.ts +5 -2
  65. package/src/form.js +6 -6
  66. package/src/form.js.map +1 -1
  67. package/src/hover-card.d.ts +16 -10
  68. package/src/hover-card.js +1 -1
  69. package/src/hover-card.js.map +1 -1
  70. package/src/hover-popup.d.ts +26 -12
  71. package/src/hover-popup.js +12 -12
  72. package/src/hover-popup.js.map +1 -1
  73. package/src/index.d.ts +37 -3
  74. package/src/index.js +26 -2
  75. package/src/input.d.ts +12 -0
  76. package/src/input.js +21 -0
  77. package/src/input.js.map +1 -0
  78. package/src/label.d.ts +8 -0
  79. package/src/label.js +14 -0
  80. package/src/label.js.map +1 -0
  81. package/src/listbox.d.ts +36 -0
  82. package/src/listbox.js +88 -0
  83. package/src/listbox.js.map +1 -0
  84. package/src/menu.d.ts +107 -0
  85. package/src/menu.js +206 -0
  86. package/src/menu.js.map +1 -0
  87. package/src/menubar-context.d.ts +4 -0
  88. package/src/menubar-context.js +7 -0
  89. package/src/menubar-context.js.map +1 -0
  90. package/src/menubar.d.ts +11 -0
  91. package/src/menubar.js +25 -0
  92. package/src/menubar.js.map +1 -0
  93. package/src/message-scroller.d.ts +24 -0
  94. package/src/message-scroller.js +35 -0
  95. package/src/message-scroller.js.map +1 -0
  96. package/src/meter.d.ts +18 -9
  97. package/src/meter.js +1 -1
  98. package/src/meter.js.map +1 -1
  99. package/src/navigation-menu.d.ts +58 -0
  100. package/src/navigation-menu.js +106 -0
  101. package/src/navigation-menu.js.map +1 -0
  102. package/src/number-field.d.ts +28 -0
  103. package/src/number-field.js +58 -0
  104. package/src/number-field.js.map +1 -0
  105. package/src/otp.d.ts +35 -0
  106. package/src/otp.js +64 -0
  107. package/src/otp.js.map +1 -0
  108. package/src/pagination.d.ts +37 -0
  109. package/src/pagination.js +50 -0
  110. package/src/pagination.js.map +1 -0
  111. package/src/popover.d.ts +32 -22
  112. package/src/popover.js +10 -14
  113. package/src/popover.js.map +1 -1
  114. package/src/progress.d.ts +18 -9
  115. package/src/progress.js +1 -1
  116. package/src/progress.js.map +1 -1
  117. package/src/qr-code.d.ts +21 -0
  118. package/src/qr-code.js +32 -0
  119. package/src/qr-code.js.map +1 -0
  120. package/src/radio-group.d.ts +17 -11
  121. package/src/radio-group.js +20 -22
  122. package/src/radio-group.js.map +1 -1
  123. package/src/resizable.d.ts +24 -0
  124. package/src/resizable.js +51 -0
  125. package/src/resizable.js.map +1 -0
  126. package/src/runtime.d.ts +114 -13
  127. package/src/runtime.js +205 -24
  128. package/src/runtime.js.map +1 -1
  129. package/src/scroll-area.d.ts +36 -0
  130. package/src/scroll-area.js +64 -0
  131. package/src/scroll-area.js.map +1 -0
  132. package/src/select.d.ts +79 -31
  133. package/src/select.js +86 -23
  134. package/src/select.js.map +1 -1
  135. package/src/separator.d.ts +4 -2
  136. package/src/separator.js +3 -3
  137. package/src/separator.js.map +1 -1
  138. package/src/slider.d.ts +35 -20
  139. package/src/slider.js +20 -19
  140. package/src/slider.js.map +1 -1
  141. package/src/switch.d.ts +10 -6
  142. package/src/switch.js +12 -9
  143. package/src/switch.js.map +1 -1
  144. package/src/tabs.d.ts +22 -14
  145. package/src/tabs.js +7 -8
  146. package/src/tabs.js.map +1 -1
  147. package/src/testing.d.ts +1 -0
  148. package/src/testing.js +1 -0
  149. package/src/toast.d.ts +68 -0
  150. package/src/toast.js +107 -0
  151. package/src/toast.js.map +1 -0
  152. package/src/toggle-group.d.ts +10 -0
  153. package/src/toggle-group.js +32 -0
  154. package/src/toggle-group.js.map +1 -0
  155. package/src/toggle.d.ts +5 -2
  156. package/src/toggle.js +15 -5
  157. package/src/toggle.js.map +1 -1
  158. package/src/toolbar-context.d.ts +7 -0
  159. package/src/toolbar-context.js +9 -0
  160. package/src/toolbar-context.js.map +1 -0
  161. package/src/toolbar.d.ts +35 -0
  162. package/src/toolbar.js +63 -0
  163. package/src/toolbar.js.map +1 -0
  164. package/src/tooltip.d.ts +16 -10
  165. package/src/tooltip.js +1 -1
  166. package/src/tooltip.js.map +1 -1
  167. package/src/use-render.d.ts +38 -0
  168. package/src/use-render.js +50 -0
  169. package/src/use-render.js.map +1 -0
  170. package/src/value-bar.d.ts +19 -11
  171. package/src/value-bar.js +8 -5
  172. package/src/value-bar.js.map +1 -1
package/src/button.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import { PartComponentProps } from "./runtime.js";
2
+ import { StateOf } from "@kirana-ui/core";
2
3
  import { ReactElement } from "react";
3
4
  import { ButtonProps as ButtonProps$1 } from "@kirana-ui/core/button";
4
- export type ButtonProps = ButtonProps$1 & PartComponentProps;
5
+ import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
+ export type ButtonProps = PartComponentProps<"button", StateOf<Vocabulary["button"]["root"]>, ButtonProps$1>;
5
7
  /** A `<button>`, or with `render` and `nativeButton={false}` another element that acts as one. */
6
- export declare function Button({ disabled, focusableWhenDisabled, nativeButton, ...rest }: ButtonProps): ReactElement;
8
+ export declare const Button: ({ disabled, focusableWhenDisabled, nativeButton, ...rest }: ButtonProps) => ReactElement;
7
9
  //# sourceMappingURL=button.d.ts.map
package/src/button.js CHANGED
@@ -1,15 +1,15 @@
1
- import { useController, usePart } from "./runtime.js";
1
+ import { component, useController, usePart } from "./runtime.js";
2
2
  import { createButton } from "@kirana-ui/core/button";
3
3
  // src/button.tsx
4
4
  /** A `<button>`, or with `render` and `nativeButton={false}` another element that acts as one. */
5
- function Button({ disabled, focusableWhenDisabled, nativeButton, ...rest }) {
5
+ const Button = /* @__PURE__ */ component("Button", function Button({ disabled, focusableWhenDisabled, nativeButton, ...rest }) {
6
6
  const controller = useController(createButton, {
7
7
  disabled,
8
8
  focusableWhenDisabled,
9
9
  nativeButton
10
10
  });
11
11
  return usePart(controller.root, "button", rest);
12
- }
12
+ });
13
13
  export { Button };
14
14
 
15
15
  //# sourceMappingURL=button.js.map
package/src/button.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"button.js","names":[],"sources":["../../../../packages/react/src/button.tsx"],"sourcesContent":["import { createButton } from \"@kirana-ui/core/button\"\nimport type { ButtonProps as CoreProps } from \"@kirana-ui/core/button\"\nimport type { ReactElement } from \"react\"\n\nimport { useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nexport type ButtonProps = CoreProps & PartComponentProps\n\n/** A `<button>`, or with `render` and `nativeButton={false}` another element that acts as one. */\nexport function Button({\n disabled,\n focusableWhenDisabled,\n nativeButton,\n ...rest\n}: ButtonProps): ReactElement {\n const controller = useController(createButton, { disabled, focusableWhenDisabled, nativeButton })\n return usePart(controller.root, \"button\", rest)\n}\n"],"mappings":";;;;AAUA,SAAgB,OAAO,EACrB,UACA,uBACA,cACA,GAAG,QACyB;CAC5B,MAAM,aAAa,cAAc,cAAc;EAAE;EAAU;EAAuB;CAAa,CAAC;CAChG,OAAO,QAAQ,WAAW,MAAM,UAAU,IAAI;AAChD"}
1
+ {"version":3,"file":"button.js","names":[],"sources":["../../../../packages/react/src/button.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createButton } from \"@kirana-ui/core/button\"\nimport type { ButtonProps as CoreProps } from \"@kirana-ui/core/button\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport type { ReactElement } from \"react\"\n\nimport { component, useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nexport type ButtonProps = PartComponentProps<\n \"button\",\n StateOf<Vocabulary[\"button\"][\"root\"]>,\n CoreProps\n>\n\n/** A `<button>`, or with `render` and `nativeButton={false}` another element that acts as one. */\nexport const Button = /* @__PURE__ */ component(\n \"Button\",\n function Button({\n disabled,\n focusableWhenDisabled,\n nativeButton,\n ...rest\n }: ButtonProps): ReactElement {\n const controller = useController(createButton, {\n disabled,\n focusableWhenDisabled,\n nativeButton,\n })\n return usePart(controller.root, \"button\", rest)\n }\n)\n"],"mappings":";;;;AAgBA,MAAa,SAAyB,0BACpC,UACA,SAAS,OAAO,EACd,UACA,uBACA,cACA,GAAG,QACyB;CAC5B,MAAM,aAAa,cAAc,cAAc;EAC7C;EACA;EACA;CACF,CAAC;CACD,OAAO,QAAQ,WAAW,MAAM,UAAU,IAAI;AAChD,CACF"}
@@ -0,0 +1,65 @@
1
+ import { PartComponentProps } from "./runtime.js";
2
+ import { StateOf } from "@kirana-ui/core";
3
+ import { ReactElement, ReactNode } from "react";
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
+ */
11
+ declare const Context: import("react").Context<Calendar$1 | null>;
12
+ export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<CalendarProps, "id"> & {
13
+ id?: string;
14
+ }>;
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"]>>;
17
+ /** Names the month shown, unless it is given something else to say. */
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. */
27
+ children: (weekday: CalendarWeekday) => ReactNode;
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. */
33
+ children: (week: readonly CalendarDay[]) => ReactNode;
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. */
39
+ weekday: CalendarWeekday;
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`. */
44
+ date: string;
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`. */
49
+ date: string;
50
+ }>;
51
+ declare function Day({ date, ...props }: DayProps): ReactElement;
52
+ export declare const Calendar: {
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;
63
+ };
64
+ export { Context as CalendarContext };
65
+ //# sourceMappingURL=calendar.d.ts.map
@@ -0,0 +1,89 @@
1
+ import { DirectionContext } from "./direction-context.js";
2
+ import { parts, useController, usePart, useSignal } from "./runtime.js";
3
+ import { within } from "@kirana-ui/core";
4
+ import { Fragment, createContext, useContext, useMemo } from "react";
5
+ import { createCalendar } from "@kirana-ui/core/calendar";
6
+ import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
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
+ */
12
+ const Context = createContext(null);
13
+ function useCalendar(part) {
14
+ const controller = useContext(Context);
15
+ if (!controller) throw new Error(`<Calendar.${part}> must be inside <Calendar.Root>`);
16
+ return controller;
17
+ }
18
+ function Root({ value, defaultValue, onValueChange, mode, defaultFocusedValue, onMonthChange, locale, calendarSystem, min, max, isDateUnavailable, disabled, readOnly, fixedWeeks, id, ...rest }) {
19
+ const direction = useContext(DirectionContext) ?? void 0;
20
+ const controller = useController(within(createCalendar, { direction }), {
21
+ value,
22
+ defaultValue,
23
+ onValueChange,
24
+ mode,
25
+ defaultFocusedValue,
26
+ onMonthChange,
27
+ locale,
28
+ calendarSystem,
29
+ min,
30
+ max,
31
+ isDateUnavailable,
32
+ disabled,
33
+ readOnly,
34
+ fixedWeeks,
35
+ id
36
+ });
37
+ return /* @__PURE__ */ jsx(Context.Provider, {
38
+ value: controller,
39
+ children: usePart(controller.root, "div", rest)
40
+ });
41
+ }
42
+ /** Names the month shown, unless it is given something else to say. */
43
+ function Heading({ children, ...props }) {
44
+ const controller = useCalendar("Heading");
45
+ const title = useSignal(controller.title);
46
+ return usePart(controller.heading, "div", {
47
+ ...props,
48
+ children: children ?? title
49
+ });
50
+ }
51
+ const Previous = (props) => usePart(useCalendar("Previous").previous, "button", props);
52
+ const Next = (props) => usePart(useCalendar("Next").next, "button", props);
53
+ const Grid = (props) => usePart(useCalendar("Grid").grid, "table", props);
54
+ /** Draws its child once for each day of the week, in the locale's order. */
55
+ function Weekdays({ children }) {
56
+ const weekdays = useSignal(useCalendar("Weekdays").weekdays);
57
+ return /* @__PURE__ */ jsx(Fragment$1, { children: weekdays.map((weekday) => /* @__PURE__ */ jsx(Fragment, { children: children(weekday) }, weekday.index)) });
58
+ }
59
+ /** Draws its child once for each week of the month shown. */
60
+ function Weeks({ children }) {
61
+ const weeks = useSignal(useCalendar("Weeks").weeks);
62
+ return /* @__PURE__ */ jsx(Fragment$1, { children: weeks.map((week) => /* @__PURE__ */ jsx(Fragment, { children: children(week) }, week[0].date)) });
63
+ }
64
+ function HeadCell({ weekday, ...props }) {
65
+ const controller = useCalendar("HeadCell");
66
+ const part = useMemo(() => controller.headCell(weekday), [controller, weekday]);
67
+ return usePart(part, "th", props);
68
+ }
69
+ function Cell({ date, ...props }) {
70
+ return usePart(useCalendar("Cell").cell(date), "td", props);
71
+ }
72
+ function Day({ date, ...props }) {
73
+ return usePart(useCalendar("Day").day(date), "button", props);
74
+ }
75
+ const Calendar = /* @__PURE__ */ parts("Calendar", {
76
+ Root,
77
+ Heading,
78
+ Previous,
79
+ Next,
80
+ Grid,
81
+ Weekdays,
82
+ HeadCell,
83
+ Weeks,
84
+ Cell,
85
+ Day
86
+ });
87
+ export { Calendar, Context as CalendarContext };
88
+
89
+ //# sourceMappingURL=calendar.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,36 @@
1
+ import { PartComponentProps } from "./runtime.js";
2
+ import { StateOf } from "@kirana-ui/core";
3
+ import { ReactElement } from "react";
4
+ import { CarouselProps } from "@kirana-ui/core/carousel";
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"> & {
8
+ id?: string;
9
+ }>;
10
+ declare function Root({ index, defaultIndex, onIndexChange, orientation, loop, id, ...rest }: RootProps): ReactElement;
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. */
15
+ index: number;
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. */
24
+ index: number;
25
+ }>;
26
+ declare function Indicator({ index, ...props }: IndicatorProps): ReactElement;
27
+ export declare const Carousel: {
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;
34
+ };
35
+ export {};
36
+ //# sourceMappingURL=carousel.d.ts.map
@@ -0,0 +1,52 @@
1
+ import { DirectionContext } from "./direction-context.js";
2
+ import { parts, 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 = /* @__PURE__ */ parts("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 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
- export type RootProps = Omit<CheckboxProps, "id"> & {
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
- } & PartComponentProps;
7
- declare function Root({ checked, defaultChecked, onCheckedChange, indeterminate, disabled, readOnly, required, name, value, id, children, ...rest }: RootProps): ReactElement;
8
- export interface IndicatorProps extends PartComponentProps {
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, value, id, children, ...rest }) {
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, {
@@ -23,28 +23,35 @@ function Root({ checked, defaultChecked, onCheckedChange, indeterminate, disable
23
23
  readOnly,
24
24
  required,
25
25
  name,
26
+ form,
26
27
  value,
27
28
  id
28
29
  });
29
30
  return /* @__PURE__ */ jsx(Context.Provider, {
30
31
  value: controller,
31
- children: /* @__PURE__ */ jsxs(RootElement, {
32
- ...rest,
33
- children: [children, /* @__PURE__ */ jsx(Input, {})]
32
+ children: /* @__PURE__ */ jsx(PartElement, {
33
+ of: controller.root,
34
+ tag: "span",
35
+ hold: withInput,
36
+ ...rest
34
37
  })
35
38
  });
36
39
  }
37
- const RootElement = (props) => usePart(useCheckbox("Root").root, "span", props);
40
+ const withInput = (content) => /* @__PURE__ */ jsxs(Fragment$1, { children: [content, /* @__PURE__ */ jsx(Input, {})] });
38
41
  const Input = () => usePart(useCheckbox("Root").input, "input", {});
39
42
  function Indicator({ keepMounted, ...props }) {
40
- if (!useSignal(useCheckbox("Indicator").indicatorMounted) && !keepMounted) return null;
41
- return /* @__PURE__ */ jsx(IndicatorElement, { ...props });
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
+ });
42
50
  }
43
- const IndicatorElement = (props) => usePart(useCheckbox("Indicator").indicator, "span", props);
44
- const Checkbox = {
51
+ const Checkbox = /* @__PURE__ */ parts("Checkbox", {
45
52
  Root,
46
53
  Indicator
47
- };
54
+ });
48
55
  export { Checkbox };
49
56
 
50
57
  //# sourceMappingURL=checkbox.js.map
@@ -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 } & PartComponentProps\n\nfunction Root({\n checked,\n defaultChecked,\n onCheckedChange,\n indeterminate,\n disabled,\n readOnly,\n required,\n name,\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 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,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;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"}
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"}
@@ -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
- export type RootProps = Omit<CollapsibleProps, "id"> & {
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
- } & PartComponentProps;
9
+ }>;
7
10
  declare function Root({ open, defaultOpen, onOpenChange, disabled, id, ...rest }: RootProps): ReactElement;
8
- declare function Trigger(props: PartComponentProps): ReactElement;
9
- export interface PanelProps extends PartComponentProps {
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
@@ -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(PanelElement, { ...props });
32
- }
33
- function PanelElement(props) {
34
- return usePart(useCollapsible("Panel").panel, "div", props);
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
@@ -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 } & 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"}
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"}