@kirana-ui/react 0.0.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/LICENSE +1 -1
  2. package/llms.txt +1838 -0
  3. package/package.json +231 -6
  4. package/src/accordion.d.ts +28 -0
  5. package/src/accordion.js +81 -0
  6. package/src/accordion.js.map +1 -0
  7. package/src/alert-dialog.d.ts +2 -0
  8. package/src/alert-dialog.js +1 -0
  9. package/src/autocomplete.d.ts +2 -0
  10. package/src/autocomplete.js +1 -0
  11. package/src/autosize.d.ts +9 -0
  12. package/src/autosize.js +12 -0
  13. package/src/autosize.js.map +1 -0
  14. package/src/avatar.d.ts +16 -0
  15. package/src/avatar.js +42 -0
  16. package/src/avatar.js.map +1 -0
  17. package/src/button.d.ts +7 -0
  18. package/src/button.js +15 -0
  19. package/src/button.js.map +1 -0
  20. package/src/calendar.d.ts +44 -0
  21. package/src/calendar.js +85 -0
  22. package/src/calendar.js.map +1 -0
  23. package/src/carousel.d.ts +26 -0
  24. package/src/carousel.js +52 -0
  25. package/src/carousel.js.map +1 -0
  26. package/src/checkbox.d.ts +18 -0
  27. package/src/checkbox.js +51 -0
  28. package/src/checkbox.js.map +1 -0
  29. package/src/collapsible.d.ts +20 -0
  30. package/src/collapsible.js +43 -0
  31. package/src/collapsible.js.map +1 -0
  32. package/src/combobox.d.ts +91 -0
  33. package/src/combobox.js +164 -0
  34. package/src/combobox.js.map +1 -0
  35. package/src/command.d.ts +44 -0
  36. package/src/command.js +88 -0
  37. package/src/command.js.map +1 -0
  38. package/src/context-menu.d.ts +2 -0
  39. package/src/context-menu.js +1 -0
  40. package/src/date-field.d.ts +25 -0
  41. package/src/date-field.js +60 -0
  42. package/src/date-field.js.map +1 -0
  43. package/src/date-picker.d.ts +53 -0
  44. package/src/date-picker.js +62 -0
  45. package/src/date-picker.js.map +1 -0
  46. package/src/dialog.d.ts +63 -0
  47. package/src/dialog.js +66 -0
  48. package/src/dialog.js.map +1 -0
  49. package/src/direction-context.d.ts +4 -0
  50. package/src/direction-context.js +7 -0
  51. package/src/direction-context.js.map +1 -0
  52. package/src/direction.d.ts +15 -0
  53. package/src/direction.js +27 -0
  54. package/src/direction.js.map +1 -0
  55. package/src/drawer.d.ts +2 -0
  56. package/src/drawer.js +1 -0
  57. package/src/field-context.d.ts +4 -0
  58. package/src/field-context.js +7 -0
  59. package/src/field-context.js.map +1 -0
  60. package/src/field.d.ts +31 -0
  61. package/src/field.js +71 -0
  62. package/src/field.js.map +1 -0
  63. package/src/fieldset.d.ts +15 -0
  64. package/src/fieldset.js +31 -0
  65. package/src/fieldset.js.map +1 -0
  66. package/src/form.d.ts +8 -0
  67. package/src/form.js +27 -0
  68. package/src/form.js.map +1 -0
  69. package/src/hover-card.d.ts +13 -0
  70. package/src/hover-card.js +7 -0
  71. package/src/hover-card.js.map +1 -0
  72. package/src/hover-popup.d.ts +25 -0
  73. package/src/hover-popup.js +57 -0
  74. package/src/hover-popup.js.map +1 -0
  75. package/src/index.d.ts +48 -0
  76. package/src/index.js +47 -0
  77. package/src/input.d.ts +10 -0
  78. package/src/input.js +21 -0
  79. package/src/input.js.map +1 -0
  80. package/src/label.d.ts +5 -0
  81. package/src/label.js +14 -0
  82. package/src/label.js.map +1 -0
  83. package/src/listbox.d.ts +28 -0
  84. package/src/listbox.js +89 -0
  85. package/src/listbox.js.map +1 -0
  86. package/src/menu.d.ts +89 -0
  87. package/src/menu.js +214 -0
  88. package/src/menu.js.map +1 -0
  89. package/src/menubar-context.d.ts +4 -0
  90. package/src/menubar-context.js +7 -0
  91. package/src/menubar-context.js.map +1 -0
  92. package/src/menubar.d.ts +9 -0
  93. package/src/menubar.js +25 -0
  94. package/src/menubar.js.map +1 -0
  95. package/src/message-scroller.d.ts +18 -0
  96. package/src/message-scroller.js +35 -0
  97. package/src/message-scroller.js.map +1 -0
  98. package/src/meter.d.ts +13 -0
  99. package/src/meter.js +7 -0
  100. package/src/meter.js.map +1 -0
  101. package/src/navigation-menu.d.ts +48 -0
  102. package/src/navigation-menu.js +115 -0
  103. package/src/navigation-menu.js.map +1 -0
  104. package/src/number-field.d.ts +21 -0
  105. package/src/number-field.js +62 -0
  106. package/src/number-field.js.map +1 -0
  107. package/src/otp.d.ts +26 -0
  108. package/src/otp.js +70 -0
  109. package/src/otp.js.map +1 -0
  110. package/src/pagination.d.ts +27 -0
  111. package/src/pagination.js +50 -0
  112. package/src/pagination.js.map +1 -0
  113. package/src/popover.d.ts +32 -0
  114. package/src/popover.js +51 -0
  115. package/src/popover.js.map +1 -0
  116. package/src/progress.d.ts +13 -0
  117. package/src/progress.js +7 -0
  118. package/src/progress.js.map +1 -0
  119. package/src/qr-code.d.ts +16 -0
  120. package/src/qr-code.js +32 -0
  121. package/src/qr-code.js.map +1 -0
  122. package/src/radio-group.d.ts +24 -0
  123. package/src/radio-group.js +87 -0
  124. package/src/radio-group.js.map +1 -0
  125. package/src/resizable.d.ts +19 -0
  126. package/src/resizable.js +51 -0
  127. package/src/resizable.js.map +1 -0
  128. package/src/runtime.d.ts +61 -0
  129. package/src/runtime.js +208 -0
  130. package/src/runtime.js.map +1 -0
  131. package/src/scroll-area.d.ts +25 -0
  132. package/src/scroll-area.js +61 -0
  133. package/src/scroll-area.js.map +1 -0
  134. package/src/select.d.ts +74 -0
  135. package/src/select.js +149 -0
  136. package/src/select.js.map +1 -0
  137. package/src/separator.d.ts +6 -0
  138. package/src/separator.js +10 -0
  139. package/src/separator.js.map +1 -0
  140. package/src/slider.d.ts +29 -0
  141. package/src/slider.js +84 -0
  142. package/src/slider.js.map +1 -0
  143. package/src/switch.d.ts +14 -0
  144. package/src/switch.js +46 -0
  145. package/src/switch.js.map +1 -0
  146. package/src/tabs.d.ts +30 -0
  147. package/src/tabs.js +73 -0
  148. package/src/tabs.js.map +1 -0
  149. package/src/toast.d.ts +32 -0
  150. package/src/toast.js +61 -0
  151. package/src/toast.js.map +1 -0
  152. package/src/toggle-group.d.ts +7 -0
  153. package/src/toggle-group.js +32 -0
  154. package/src/toggle-group.js.map +1 -0
  155. package/src/toggle.d.ts +7 -0
  156. package/src/toggle.js +25 -0
  157. package/src/toggle.js.map +1 -0
  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 +20 -0
  162. package/src/toolbar.js +53 -0
  163. package/src/toolbar.js.map +1 -0
  164. package/src/tooltip.d.ts +13 -0
  165. package/src/tooltip.js +7 -0
  166. package/src/tooltip.js.map +1 -0
  167. package/src/value-bar.d.ts +17 -0
  168. package/src/value-bar.js +51 -0
  169. package/src/value-bar.js.map +1 -0
  170. package/README.md +0 -7
  171. package/index.js +0 -5
package/src/command.js ADDED
@@ -0,0 +1,88 @@
1
+ import { useController, useOptions, useOwnText, usePart, useSignal } from "./runtime.js";
2
+ import { createContext, useContext, useId, useMemo } from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { createCommand } from "@kirana-ui/core/command";
5
+ // src/command.tsx
6
+ const Context = createContext(null);
7
+ const GroupContext = createContext(void 0);
8
+ function useCommand(part) {
9
+ const controller = useContext(Context);
10
+ if (!controller) throw new Error(`<Command.${part}> must be inside <Command.Root>`);
11
+ return controller;
12
+ }
13
+ function Root({ inputValue, defaultInputValue, onInputValueChange, onSelect, filter, loop, disabled, id, ...rest }) {
14
+ const controller = useController(createCommand, {
15
+ inputValue,
16
+ defaultInputValue,
17
+ onInputValueChange,
18
+ onSelect,
19
+ filter,
20
+ loop,
21
+ disabled,
22
+ id
23
+ });
24
+ return /* @__PURE__ */ jsx(Context.Provider, {
25
+ value: controller,
26
+ children: /* @__PURE__ */ jsx(RootElement, { ...rest })
27
+ });
28
+ }
29
+ const RootElement = (props) => usePart(useCommand("Root").root, "div", props);
30
+ const Input = (props) => usePart(useOwnText(useCommand("Input").input), "input", props);
31
+ const List = (props) => usePart(useCommand("List").list, "div", props);
32
+ const EmptyElement = (props) => usePart(useCommand("Empty").emptyPart, "div", props);
33
+ /** Drawn while no item is shown for what was typed. */
34
+ function Empty(props) {
35
+ return useSignal(useCommand("Empty").empty) ? /* @__PURE__ */ jsx(EmptyElement, { ...props }) : null;
36
+ }
37
+ /** Items under a `<Command.GroupHeading>`. Hidden while none of them is shown. */
38
+ function Group({ id, ...props }) {
39
+ const controller = useCommand("Group");
40
+ const generated = useId();
41
+ const name = id ?? generated;
42
+ const group = useMemo(() => controller.group(name), [controller, name]);
43
+ return /* @__PURE__ */ jsx(GroupContext.Provider, {
44
+ value: group,
45
+ children: usePart(group.part, "div", props)
46
+ });
47
+ }
48
+ function GroupHeading(props) {
49
+ const lone = useCommand("GroupHeading").heading;
50
+ return usePart(useContext(GroupContext)?.heading ?? lone, "div", props);
51
+ }
52
+ function Item({ value, disabled, label, keywords, id, ...props }) {
53
+ const controller = useCommand("Item");
54
+ const group = useContext(GroupContext);
55
+ const generated = useId();
56
+ const options = useOptions({
57
+ disabled,
58
+ label,
59
+ keywords,
60
+ id: id ?? generated
61
+ });
62
+ const part = useMemo(() => controller.item(value, () => options.get(), group), [
63
+ controller,
64
+ value,
65
+ options,
66
+ group
67
+ ]);
68
+ return usePart(part, "div", props);
69
+ }
70
+ function Separator({ alwaysRender, ...props }) {
71
+ const controller = useCommand("Separator");
72
+ const options = useOptions({ alwaysRender });
73
+ const part = useMemo(() => controller.separator(() => options.get().alwaysRender), [controller, options]);
74
+ return usePart(part, "div", props);
75
+ }
76
+ const Command = {
77
+ Root,
78
+ Input,
79
+ List,
80
+ Empty,
81
+ Group,
82
+ GroupHeading,
83
+ Item,
84
+ Separator
85
+ };
86
+ export { Command };
87
+
88
+ //# sourceMappingURL=command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.js","names":[],"sources":["../../../../packages/react/src/command.tsx"],"sourcesContent":["import { createCommand } from \"@kirana-ui/core/command\"\nimport type { CommandGroup, CommandProps, Command as Controller } from \"@kirana-ui/core/command\"\nimport { createContext, useContext, useId, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { useController, useOptions, useOwnText, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nconst Context = createContext<Controller | null>(null)\nconst GroupContext = createContext<CommandGroup | undefined>(undefined)\n\nfunction useCommand(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Command.${part}> must be inside <Command.Root>`)\n return controller\n}\n\nexport type RootProps = Omit<CommandProps, \"id\"> & { id?: string } & PartComponentProps\n\nfunction Root({\n inputValue,\n defaultInputValue,\n onInputValueChange,\n onSelect,\n filter,\n loop,\n disabled,\n id,\n ...rest\n}: RootProps): ReactElement {\n const controller = useController<CommandProps, Controller>(createCommand, {\n inputValue,\n defaultInputValue,\n onInputValueChange,\n onSelect,\n filter,\n loop,\n disabled,\n id,\n })\n return (\n <Context.Provider value={controller}>\n <RootElement {...rest} />\n </Context.Provider>\n )\n}\n\nconst RootElement = (props: PartComponentProps) => usePart(useCommand(\"Root\").root, \"div\", props)\nconst Input = (props: PartComponentProps) =>\n usePart(useOwnText(useCommand(\"Input\").input), \"input\", props)\nconst List = (props: PartComponentProps) => usePart(useCommand(\"List\").list, \"div\", props)\n\nconst EmptyElement = (props: PartComponentProps) =>\n usePart(useCommand(\"Empty\").emptyPart, \"div\", props)\n\n/** Drawn while no item is shown for what was typed. */\nfunction Empty(props: PartComponentProps): ReactElement | null {\n const empty = useSignal(useCommand(\"Empty\").empty)\n return empty ? <EmptyElement {...props} /> : null\n}\n\n/** Items under a `<Command.GroupHeading>`. Hidden while none of them is shown. */\nfunction Group({ id, ...props }: PartComponentProps & { id?: string }): ReactElement {\n const controller = useCommand(\"Group\")\n const generated = useId()\n const name = id ?? generated\n const group = useMemo(() => controller.group(name), [controller, name])\n return (\n <GroupContext.Provider value={group}>{usePart(group.part, \"div\", props)}</GroupContext.Provider>\n )\n}\n\nfunction GroupHeading(props: PartComponentProps): ReactElement {\n const lone = useCommand(\"GroupHeading\").heading\n return usePart(useContext(GroupContext)?.heading ?? lone, \"div\", props)\n}\n\nexport interface ItemProps extends PartComponentProps {\n /** What `onSelect` is told. */\n value: string\n disabled?: boolean\n /** What is filtered; the item's text when left out. */\n label?: string\n /** Other words the item answers to. */\n keywords?: readonly string[]\n id?: string\n}\n\nfunction Item({ value, disabled, label, keywords, id, ...props }: ItemProps): ReactElement {\n const controller = useCommand(\"Item\")\n const group = useContext(GroupContext)\n const generated = useId()\n const options = useOptions({ disabled, label, keywords, id: id ?? generated })\n const part = useMemo(\n () => controller.item(value, () => options.get(), group),\n [controller, value, options, group]\n )\n return usePart(part, \"div\", props)\n}\n\nexport interface SeparatorProps extends PartComponentProps {\n /** Stays while something is typed. */\n alwaysRender?: boolean\n}\n\nfunction Separator({ alwaysRender, ...props }: SeparatorProps): ReactElement {\n const controller = useCommand(\"Separator\")\n const options = useOptions({ alwaysRender })\n const part = useMemo(\n () => controller.separator(() => options.get().alwaysRender),\n [controller, options]\n )\n return usePart(part, \"div\", props)\n}\n\nexport const Command = { Root, Input, List, Empty, Group, GroupHeading, Item, Separator }\n"],"mappings":";;;;;AAQA,MAAM,UAAU,cAAiC,IAAI;AACrD,MAAM,eAAe,cAAwC,KAAA,CAAS;AAEtE,SAAS,WAAW,MAA0B;CAC5C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,YAAY,KAAK,gCAAgC;CAClF,OAAO;AACT;AAIA,SAAS,KAAK,EACZ,YACA,mBACA,oBACA,UACA,QACA,MACA,UACA,IACA,GAAG,QACuB;CAC1B,MAAM,aAAa,cAAwC,eAAe;EACxE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EACvB,UAAA,oBAAC,aAAD,EAAa,GAAI,KAAO,CAAA;CACR,CAAA;AAEtB;AAEA,MAAM,eAAe,UAA8B,QAAQ,WAAW,MAAM,CAAC,CAAC,MAAM,OAAO,KAAK;AAChG,MAAM,SAAS,UACb,QAAQ,WAAW,WAAW,OAAO,CAAC,CAAC,KAAK,GAAG,SAAS,KAAK;AAC/D,MAAM,QAAQ,UAA8B,QAAQ,WAAW,MAAM,CAAC,CAAC,MAAM,OAAO,KAAK;AAEzF,MAAM,gBAAgB,UACpB,QAAQ,WAAW,OAAO,CAAC,CAAC,WAAW,OAAO,KAAK;;AAGrD,SAAS,MAAM,OAAgD;CAE7D,OADc,UAAU,WAAW,OAAO,CAAC,CAAC,KACjC,IAAI,oBAAC,cAAD,EAAc,GAAI,MAAQ,CAAA,IAAI;AAC/C;;AAGA,SAAS,MAAM,EAAE,IAAI,GAAG,SAA6D;CACnF,MAAM,aAAa,WAAW,OAAO;CACrC,MAAM,YAAY,MAAM;CACxB,MAAM,OAAO,MAAM;CACnB,MAAM,QAAQ,cAAc,WAAW,MAAM,IAAI,GAAG,CAAC,YAAY,IAAI,CAAC;CACtE,OACE,oBAAC,aAAa,UAAd;EAAuB,OAAO;EAAQ,UAAA,QAAQ,MAAM,MAAM,OAAO,KAAK;CAAyB,CAAA;AAEnG;AAEA,SAAS,aAAa,OAAyC;CAC7D,MAAM,OAAO,WAAW,cAAc,CAAC,CAAC;CACxC,OAAO,QAAQ,WAAW,YAAY,CAAC,EAAE,WAAW,MAAM,OAAO,KAAK;AACxE;AAaA,SAAS,KAAK,EAAE,OAAO,UAAU,OAAO,UAAU,IAAI,GAAG,SAAkC;CACzF,MAAM,aAAa,WAAW,MAAM;CACpC,MAAM,QAAQ,WAAW,YAAY;CACrC,MAAM,YAAY,MAAM;CACxB,MAAM,UAAU,WAAW;EAAE;EAAU;EAAO;EAAU,IAAI,MAAM;CAAU,CAAC;CAC7E,MAAM,OAAO,cACL,WAAW,KAAK,aAAa,QAAQ,IAAI,GAAG,KAAK,GACvD;EAAC;EAAY;EAAO;EAAS;CAAK,CACpC;CACA,OAAO,QAAQ,MAAM,OAAO,KAAK;AACnC;AAOA,SAAS,UAAU,EAAE,cAAc,GAAG,SAAuC;CAC3E,MAAM,aAAa,WAAW,WAAW;CACzC,MAAM,UAAU,WAAW,EAAE,aAAa,CAAC;CAC3C,MAAM,OAAO,cACL,WAAW,gBAAgB,QAAQ,IAAI,CAAC,CAAC,YAAY,GAC3D,CAAC,YAAY,OAAO,CACtB;CACA,OAAO,QAAQ,MAAM,OAAO,KAAK;AACnC;AAEA,MAAa,UAAU;CAAE;CAAM;CAAO;CAAM;CAAO;CAAO;CAAc;CAAM;AAAU"}
@@ -0,0 +1,2 @@
1
+ import { ContextMenu } from "./menu.js";
2
+ export { ContextMenu };
@@ -0,0 +1 @@
1
+ export { ContextMenu } from "./menu.js";
@@ -0,0 +1,25 @@
1
+ import { PartComponentProps } from "./runtime.js";
2
+ import { ReactElement, ReactNode } from "react";
3
+ import { DateField as DateField$1, DateFieldProps, DateFieldSegment } from "@kirana-ui/core/date-field";
4
+ declare const Context: import("react").Context<DateField$1 | null>;
5
+ export type RootProps = Omit<DateFieldProps, "id"> & {
6
+ id?: string;
7
+ } & PartComponentProps;
8
+ declare function Root({ value, defaultValue, onValueChange, locale, min, max, placeholders, disabled, readOnly, required, name, form, id, ...rest }: RootProps): ReactElement;
9
+ /** Draws its child once for each piece of the date, in the locale's order. */
10
+ declare function Segments({ children }: {
11
+ children: (segment: DateFieldSegment) => ReactNode;
12
+ }): import("react").JSX.Element;
13
+ /** One piece: a part that is typed, or what stands between two. It writes its own text. */
14
+ declare function Segment({ segment, ...props }: PartComponentProps & {
15
+ segment: DateFieldSegment;
16
+ }): ReactElement;
17
+ declare const Input: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
18
+ export declare const DateField: {
19
+ Root: typeof Root;
20
+ Segments: typeof Segments;
21
+ Segment: typeof Segment;
22
+ Input: typeof Input;
23
+ };
24
+ export { Context as DateFieldContext };
25
+ //# sourceMappingURL=date-field.d.ts.map
@@ -0,0 +1,60 @@
1
+ import { DirectionContext } from "./direction-context.js";
2
+ import { useController, usePart, useSignal } from "./runtime.js";
3
+ import { within } from "@kirana-ui/core";
4
+ import { Fragment, createContext, useContext } from "react";
5
+ import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
6
+ import { createDateField } from "@kirana-ui/core/date-field";
7
+ // src/date-field.tsx
8
+ const Context = createContext(null);
9
+ function useDateField(part) {
10
+ const controller = useContext(Context);
11
+ if (!controller) throw new Error(`<DateField.${part}> must be inside <DateField.Root>`);
12
+ return controller;
13
+ }
14
+ function Root({ value, defaultValue, onValueChange, locale, min, max, placeholders, disabled, readOnly, required, name, form, id, ...rest }) {
15
+ const direction = useContext(DirectionContext) ?? void 0;
16
+ const controller = useController(within(createDateField, { direction }), {
17
+ value,
18
+ defaultValue,
19
+ onValueChange,
20
+ locale,
21
+ min,
22
+ max,
23
+ placeholders,
24
+ disabled,
25
+ readOnly,
26
+ required,
27
+ name,
28
+ form,
29
+ id
30
+ });
31
+ return /* @__PURE__ */ jsx(Context.Provider, {
32
+ value: controller,
33
+ children: usePart(controller.root, "div", rest)
34
+ });
35
+ }
36
+ /** Draws its child once for each piece of the date, in the locale's order. */
37
+ function Segments({ children }) {
38
+ const segments = useSignal(useDateField("Segments").segments);
39
+ return /* @__PURE__ */ jsx(Fragment$1, { children: segments.map((segment) => /* @__PURE__ */ jsx(Fragment, { children: children(segment) }, `${segment.index}-${segment.type}`)) });
40
+ }
41
+ /** One piece: a part that is typed, or what stands between two. It writes its own text. */
42
+ function Segment({ segment, ...props }) {
43
+ const { part, text } = useDateField("Segment").segment(segment);
44
+ const shown = useSignal(text);
45
+ return usePart(part, "span", {
46
+ ...props,
47
+ suppressContentEditableWarning: true,
48
+ children: shown
49
+ });
50
+ }
51
+ const Input = (props) => usePart(useDateField("Input").input, "input", props);
52
+ const DateField = {
53
+ Root,
54
+ Segments,
55
+ Segment,
56
+ Input
57
+ };
58
+ export { DateField, Context as DateFieldContext };
59
+
60
+ //# sourceMappingURL=date-field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-field.js","names":[],"sources":["../../../../packages/react/src/date-field.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport { createDateField } from \"@kirana-ui/core/date-field\"\nimport type {\n DateField as Controller,\n DateFieldProps,\n DateFieldSegment,\n} from \"@kirana-ui/core/date-field\"\nimport { Fragment, createContext, useContext } 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 DateFieldContext }\n\nfunction useDateField(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<DateField.${part}> must be inside <DateField.Root>`)\n return controller\n}\n\nexport type RootProps = Omit<DateFieldProps, \"id\"> & { id?: string } & PartComponentProps\n\nfunction Root({\n value,\n defaultValue,\n onValueChange,\n locale,\n min,\n max,\n placeholders,\n disabled,\n readOnly,\n required,\n name,\n form,\n id,\n ...rest\n}: RootProps): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const controller = useController<DateFieldProps, Controller>(\n within(createDateField, { direction }),\n {\n value,\n defaultValue,\n onValueChange,\n locale,\n min,\n max,\n placeholders,\n disabled,\n readOnly,\n required,\n name,\n form,\n id,\n }\n )\n return (\n <Context.Provider value={controller}>{usePart(controller.root, \"div\", rest)}</Context.Provider>\n )\n}\n\n/** Draws its child once for each piece of the date, in the locale's order. */\nfunction Segments({ children }: { children: (segment: DateFieldSegment) => ReactNode }) {\n const segments = useSignal(useDateField(\"Segments\").segments)\n return (\n <>\n {segments.map((segment) => (\n <Fragment key={`${segment.index}-${segment.type}`}>{children(segment)}</Fragment>\n ))}\n </>\n )\n}\n\n/** One piece: a part that is typed, or what stands between two. It writes its own text. */\nfunction Segment({\n segment,\n ...props\n}: PartComponentProps & { segment: DateFieldSegment }): ReactElement {\n const { part, text } = useDateField(\"Segment\").segment(segment)\n const shown = useSignal(text)\n // Its text is the field's to write: the browser never edits it, whatever React fears.\n return usePart(part, \"span\", { ...props, suppressContentEditableWarning: true, children: shown })\n}\n\nconst Input = (props: PartComponentProps) => usePart(useDateField(\"Input\").input, \"input\", props)\n\nexport const DateField = { Root, Segments, Segment, Input }\n"],"mappings":";;;;;;;AAcA,MAAM,UAAU,cAAiC,IAAI;AAIrD,SAAS,aAAa,MAA0B;CAC9C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,cAAc,KAAK,kCAAkC;CACtF,OAAO;AACT;AAIA,SAAS,KAAK,EACZ,OACA,cACA,eACA,QACA,KACA,KACA,cACA,UACA,UACA,UACA,MACA,MACA,IACA,GAAG,QACuB;CAC1B,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,aAAa,cACjB,OAAO,iBAAiB,EAAE,UAAU,CAAC,GACrC;EACE;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;;AAGA,SAAS,SAAS,EAAE,YAAoE;CACtF,MAAM,WAAW,UAAU,aAAa,UAAU,CAAC,CAAC,QAAQ;CAC5D,OACE,oBAAA,YAAA,EAAA,UACG,SAAS,KAAK,YACb,oBAAC,UAAD,EAAA,UAAoD,SAAS,OAAO,EAAY,GAAjE,GAAG,QAAQ,MAAM,GAAG,QAAQ,MAAqC,CACjF,EACD,CAAA;AAEN;;AAGA,SAAS,QAAQ,EACf,SACA,GAAG,SACgE;CACnE,MAAM,EAAE,MAAM,SAAS,aAAa,SAAS,CAAC,CAAC,QAAQ,OAAO;CAC9D,MAAM,QAAQ,UAAU,IAAI;CAE5B,OAAO,QAAQ,MAAM,QAAQ;EAAE,GAAG;EAAO,gCAAgC;EAAM,UAAU;CAAM,CAAC;AAClG;AAEA,MAAM,SAAS,UAA8B,QAAQ,aAAa,OAAO,CAAC,CAAC,OAAO,SAAS,KAAK;AAEhG,MAAa,YAAY;CAAE;CAAM;CAAU;CAAS;AAAM"}
@@ -0,0 +1,53 @@
1
+ import { PositionerProps } from "./popover.js";
2
+ import { PartComponentProps } from "./runtime.js";
3
+ import { DatePickerProps } from "@kirana-ui/core/date-picker";
4
+ import { ReactElement, ReactNode } from "react";
5
+ export type RootProps = Omit<DatePickerProps, "id"> & {
6
+ id?: string;
7
+ children?: ReactNode;
8
+ };
9
+ /** A date field, and a calendar in a popover, with one value between them. It draws nothing. */
10
+ declare function Root({ children, ...props }: RootProps): ReactElement;
11
+ /** The typed date: what holds its segments and its hidden input. */
12
+ declare const Field: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
13
+ /** The calendar: what holds its heading, its buttons and its grid. */
14
+ declare const CalendarRoot: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
15
+ export declare const DatePicker: {
16
+ Root: typeof Root;
17
+ Field: typeof Field;
18
+ Segments: ({ children }: {
19
+ children: (segment: import("@kirana-ui/core/date-field").DateFieldSegment) => ReactNode;
20
+ }) => import("react").JSX.Element;
21
+ Segment: ({ segment, ...props }: PartComponentProps & {
22
+ segment: import("@kirana-ui/core/date-field").DateFieldSegment;
23
+ }) => ReactElement;
24
+ Input: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
25
+ Trigger: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
26
+ Portal: ({ children }: {
27
+ children?: ReactNode;
28
+ }) => ReactElement | null;
29
+ Positioner: ({ side, align, sideOffset, alignOffset, collisionPadding, ...props }: PositionerProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
30
+ Popup: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
31
+ Calendar: typeof CalendarRoot;
32
+ Heading: ({ children, ...props }: PartComponentProps) => ReactElement;
33
+ Previous: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
34
+ Next: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
35
+ Grid: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
36
+ Weekdays: ({ children }: {
37
+ children: (weekday: import("@kirana-ui/core/calendar").CalendarWeekday) => ReactNode;
38
+ }) => import("react").JSX.Element;
39
+ HeadCell: ({ weekday, ...props }: PartComponentProps & {
40
+ weekday: import("@kirana-ui/core/calendar").CalendarWeekday;
41
+ }) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
42
+ Weeks: ({ children }: {
43
+ children: (week: readonly import("@kirana-ui/core/calendar").CalendarDay[]) => ReactNode;
44
+ }) => import("react").JSX.Element;
45
+ Cell: ({ date, ...props }: PartComponentProps & {
46
+ date: string;
47
+ }) => ReactElement;
48
+ Day: ({ date, ...props }: PartComponentProps & {
49
+ date: string;
50
+ }) => ReactElement;
51
+ };
52
+ export {};
53
+ //# sourceMappingURL=date-picker.d.ts.map
@@ -0,0 +1,62 @@
1
+ import { Calendar, CalendarContext as Context$1 } from "./calendar.js";
2
+ import { DateField, DateFieldContext as Context$2 } from "./date-field.js";
3
+ import { DirectionContext } from "./direction-context.js";
4
+ import { Popover, PopoverContext as Context$3 } from "./popover.js";
5
+ import { useController, usePart } from "./runtime.js";
6
+ import { within } from "@kirana-ui/core";
7
+ import { createDatePicker } from "@kirana-ui/core/date-picker";
8
+ import { createContext, useContext } from "react";
9
+ import { jsx } from "react/jsx-runtime";
10
+ // src/date-picker.tsx
11
+ const Context = createContext(null);
12
+ function useDatePicker(part) {
13
+ const controller = useContext(Context);
14
+ if (!controller) throw new Error(`<DatePicker.${part}> must be inside <DatePicker.Root>`);
15
+ return controller;
16
+ }
17
+ /** A date field, and a calendar in a popover, with one value between them. It draws nothing. */
18
+ function Root({ children, ...props }) {
19
+ const direction = useContext(DirectionContext) ?? void 0;
20
+ const controller = useController(within(createDatePicker, { direction }), props);
21
+ return /* @__PURE__ */ jsx(Context.Provider, {
22
+ value: controller,
23
+ children: /* @__PURE__ */ jsx(Context$2.Provider, {
24
+ value: controller.field,
25
+ children: /* @__PURE__ */ jsx(Context$3.Provider, {
26
+ value: controller.popover,
27
+ children: /* @__PURE__ */ jsx(Context$1.Provider, {
28
+ value: controller.calendar,
29
+ children
30
+ })
31
+ })
32
+ })
33
+ });
34
+ }
35
+ /** The typed date: what holds its segments and its hidden input. */
36
+ const Field = (props) => usePart(useDatePicker("Field").field.root, "div", props);
37
+ /** The calendar: what holds its heading, its buttons and its grid. */
38
+ const CalendarRoot = (props) => usePart(useDatePicker("Calendar").calendar.root, "div", props);
39
+ const DatePicker = {
40
+ Root,
41
+ Field,
42
+ Segments: DateField.Segments,
43
+ Segment: DateField.Segment,
44
+ Input: DateField.Input,
45
+ Trigger: Popover.Trigger,
46
+ Portal: Popover.Portal,
47
+ Positioner: Popover.Positioner,
48
+ Popup: Popover.Popup,
49
+ Calendar: CalendarRoot,
50
+ Heading: Calendar.Heading,
51
+ Previous: Calendar.Previous,
52
+ Next: Calendar.Next,
53
+ Grid: Calendar.Grid,
54
+ Weekdays: Calendar.Weekdays,
55
+ HeadCell: Calendar.HeadCell,
56
+ Weeks: Calendar.Weeks,
57
+ Cell: Calendar.Cell,
58
+ Day: Calendar.Day
59
+ };
60
+ export { DatePicker };
61
+
62
+ //# sourceMappingURL=date-picker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-picker.js","names":["DateFieldContext","PopoverContext","CalendarContext"],"sources":["../../../../packages/react/src/date-picker.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport { createDatePicker } from \"@kirana-ui/core/date-picker\"\nimport type { DatePicker as Controller, DatePickerProps } from \"@kirana-ui/core/date-picker\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { Calendar, CalendarContext } from \"./calendar.tsx\"\nimport { DateField, DateFieldContext } from \"./date-field.tsx\"\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { Popover, PopoverContext } from \"./popover.tsx\"\nimport { useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useDatePicker(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<DatePicker.${part}> must be inside <DatePicker.Root>`)\n return controller\n}\n\nexport type RootProps = Omit<DatePickerProps, \"id\"> & { id?: string; children?: ReactNode }\n\n/** A date field, and a calendar in a popover, with one value between them. It draws nothing. */\nfunction Root({ children, ...props }: RootProps): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const controller = useController<DatePickerProps, Controller>(\n within(createDatePicker, { direction }),\n props\n )\n return (\n <Context.Provider value={controller}>\n <DateFieldContext.Provider value={controller.field}>\n <PopoverContext.Provider value={controller.popover}>\n <CalendarContext.Provider value={controller.calendar}>\n {children}\n </CalendarContext.Provider>\n </PopoverContext.Provider>\n </DateFieldContext.Provider>\n </Context.Provider>\n )\n}\n\n/** The typed date: what holds its segments and its hidden input. */\nconst Field = (props: PartComponentProps) =>\n usePart(useDatePicker(\"Field\").field.root, \"div\", props)\n/** The calendar: what holds its heading, its buttons and its grid. */\nconst CalendarRoot = (props: PartComponentProps) =>\n usePart(useDatePicker(\"Calendar\").calendar.root, \"div\", props)\n\nexport const DatePicker = {\n Root,\n Field,\n Segments: DateField.Segments,\n Segment: DateField.Segment,\n Input: DateField.Input,\n Trigger: Popover.Trigger,\n Portal: Popover.Portal,\n Positioner: Popover.Positioner,\n Popup: Popover.Popup,\n Calendar: CalendarRoot,\n Heading: Calendar.Heading,\n Previous: Calendar.Previous,\n Next: Calendar.Next,\n Grid: Calendar.Grid,\n Weekdays: Calendar.Weekdays,\n HeadCell: Calendar.HeadCell,\n Weeks: Calendar.Weeks,\n Cell: Calendar.Cell,\n Day: Calendar.Day,\n}\n"],"mappings":";;;;;;;;;;AAaA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,cAAc,MAA0B;CAC/C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,eAAe,KAAK,mCAAmC;CACxF,OAAO;AACT;;AAKA,SAAS,KAAK,EAAE,UAAU,GAAG,SAAkC;CAC7D,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,aAAa,cACjB,OAAO,kBAAkB,EAAE,UAAU,CAAC,GACtC,KACF;CACA,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EACvB,UAAA,oBAACA,UAAiB,UAAlB;GAA2B,OAAO,WAAW;GAC3C,UAAA,oBAACC,UAAe,UAAhB;IAAyB,OAAO,WAAW;IACzC,UAAA,oBAACC,UAAgB,UAAjB;KAA0B,OAAO,WAAW;KACzC;IACuB,CAAA;GACH,CAAA;EACA,CAAA;CACX,CAAA;AAEtB;;AAGA,MAAM,SAAS,UACb,QAAQ,cAAc,OAAO,CAAC,CAAC,MAAM,MAAM,OAAO,KAAK;;AAEzD,MAAM,gBAAgB,UACpB,QAAQ,cAAc,UAAU,CAAC,CAAC,SAAS,MAAM,OAAO,KAAK;AAE/D,MAAa,aAAa;CACxB;CACA;CACA,UAAU,UAAU;CACpB,SAAS,UAAU;CACnB,OAAO,UAAU;CACjB,SAAS,QAAQ;CACjB,QAAQ,QAAQ;CAChB,YAAY,QAAQ;CACpB,OAAO,QAAQ;CACf,UAAU;CACV,SAAS,SAAS;CAClB,UAAU,SAAS;CACnB,MAAM,SAAS;CACf,MAAM,SAAS;CACf,UAAU,SAAS;CACnB,UAAU,SAAS;CACnB,OAAO,SAAS;CAChB,MAAM,SAAS;CACf,KAAK,SAAS;AAChB"}
@@ -0,0 +1,63 @@
1
+ import { PartComponentProps } from "./runtime.js";
2
+ import { ReactElement, ReactNode } from "react";
3
+ import { AlertDialogProps } from "@kirana-ui/core/alert-dialog";
4
+ import { DialogProps } from "@kirana-ui/core/dialog";
5
+ import { DrawerProps } from "@kirana-ui/core/drawer";
6
+ export type RootProps = Omit<DialogProps, "id"> & {
7
+ id?: string;
8
+ children?: ReactNode;
9
+ };
10
+ declare function Root({ children, ...props }: RootProps): ReactElement;
11
+ declare function Portal({ children }: {
12
+ children?: ReactNode;
13
+ }): ReactElement | null;
14
+ declare const Trigger: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
15
+ declare const Backdrop: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
16
+ declare const Popup: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
17
+ declare const Title: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
18
+ declare const Description: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
19
+ declare const Close: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
20
+ export declare const Dialog: {
21
+ Root: typeof Root;
22
+ Trigger: typeof Trigger;
23
+ Portal: typeof Portal;
24
+ Backdrop: typeof Backdrop;
25
+ Popup: typeof Popup;
26
+ Title: typeof Title;
27
+ Description: typeof Description;
28
+ Close: typeof Close;
29
+ };
30
+ export type AlertRootProps = Omit<AlertDialogProps, "id"> & {
31
+ id?: string;
32
+ children?: ReactNode;
33
+ };
34
+ declare function AlertRoot({ children, ...props }: AlertRootProps): ReactElement;
35
+ /** A dialog that asks for an answer: a press outside it does not close it. Its parts are a dialog's. */
36
+ export declare const AlertDialog: {
37
+ Trigger: typeof Trigger;
38
+ Portal: typeof Portal;
39
+ Backdrop: typeof Backdrop;
40
+ Popup: typeof Popup;
41
+ Title: typeof Title;
42
+ Description: typeof Description;
43
+ Close: typeof Close;
44
+ Root: typeof AlertRoot;
45
+ };
46
+ export type DrawerRootProps = Omit<DrawerProps, "id"> & {
47
+ id?: string;
48
+ children?: ReactNode;
49
+ };
50
+ declare function DrawerRoot({ children, ...props }: DrawerRootProps): ReactElement;
51
+ /** A dialog that comes from an edge and is dragged back to it. Its parts are a dialog's. */
52
+ export declare const Drawer: {
53
+ Trigger: typeof Trigger;
54
+ Portal: typeof Portal;
55
+ Backdrop: typeof Backdrop;
56
+ Popup: typeof Popup;
57
+ Title: typeof Title;
58
+ Description: typeof Description;
59
+ Close: typeof Close;
60
+ Root: typeof DrawerRoot;
61
+ };
62
+ export {};
63
+ //# sourceMappingURL=dialog.d.ts.map
package/src/dialog.js ADDED
@@ -0,0 +1,66 @@
1
+ import { Portal as Portal$1, useController, usePart, useSignal } from "./runtime.js";
2
+ import { createContext, useContext } from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { createAlertDialog } from "@kirana-ui/core/alert-dialog";
5
+ import { createDialog } from "@kirana-ui/core/dialog";
6
+ import { createDrawer } from "@kirana-ui/core/drawer";
7
+ // src/dialog.tsx
8
+ const Context = createContext(null);
9
+ function useDialog(part) {
10
+ const controller = useContext(Context);
11
+ if (!controller) throw new Error(`<Dialog.${part}> must be inside <Dialog.Root>`);
12
+ return controller;
13
+ }
14
+ function Root({ children, ...props }) {
15
+ const controller = useController(createDialog, props);
16
+ return /* @__PURE__ */ jsx(Context.Provider, {
17
+ value: controller,
18
+ children
19
+ });
20
+ }
21
+ function Portal({ children }) {
22
+ return useSignal(useDialog("Portal").mounted) ? /* @__PURE__ */ jsx(Portal$1, { children }) : null;
23
+ }
24
+ const Trigger = (props) => usePart(useDialog("Trigger").trigger, "button", props);
25
+ const Backdrop = (props) => usePart(useDialog("Backdrop").backdrop, "div", props);
26
+ const Popup = (props) => usePart(useDialog("Popup").popup, "div", props);
27
+ const Title = (props) => usePart(useDialog("Title").title, "h2", props);
28
+ const Description = (props) => usePart(useDialog("Description").description, "p", props);
29
+ const Close = (props) => usePart(useDialog("Close").close, "button", props);
30
+ const Dialog = {
31
+ Root,
32
+ Trigger,
33
+ Portal,
34
+ Backdrop,
35
+ Popup,
36
+ Title,
37
+ Description,
38
+ Close
39
+ };
40
+ function AlertRoot({ children, ...props }) {
41
+ const controller = useController(createAlertDialog, props);
42
+ return /* @__PURE__ */ jsx(Context.Provider, {
43
+ value: controller,
44
+ children
45
+ });
46
+ }
47
+ /** A dialog that asks for an answer: a press outside it does not close it. Its parts are a dialog's. */
48
+ const AlertDialog = {
49
+ ...Dialog,
50
+ Root: AlertRoot
51
+ };
52
+ function DrawerRoot({ children, ...props }) {
53
+ const controller = useController(createDrawer, props);
54
+ return /* @__PURE__ */ jsx(Context.Provider, {
55
+ value: controller,
56
+ children
57
+ });
58
+ }
59
+ /** A dialog that comes from an edge and is dragged back to it. Its parts are a dialog's. */
60
+ const Drawer = {
61
+ ...Dialog,
62
+ Root: DrawerRoot
63
+ };
64
+ export { AlertDialog, Dialog, Drawer };
65
+
66
+ //# sourceMappingURL=dialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialog.js","names":["BodyPortal"],"sources":["../../../../packages/react/src/dialog.tsx"],"sourcesContent":["import { createAlertDialog } from \"@kirana-ui/core/alert-dialog\"\nimport type { AlertDialogProps } from \"@kirana-ui/core/alert-dialog\"\nimport { createDialog } from \"@kirana-ui/core/dialog\"\nimport { createDrawer } from \"@kirana-ui/core/drawer\"\nimport type { DrawerProps } from \"@kirana-ui/core/drawer\"\nimport type { Dialog as Controller, DialogProps } from \"@kirana-ui/core/dialog\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { Portal as BodyPortal, useController, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useDialog(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Dialog.${part}> must be inside <Dialog.Root>`)\n return controller\n}\n\nexport type RootProps = Omit<DialogProps, \"id\"> & { id?: string; children?: ReactNode }\n\nfunction Root({ children, ...props }: RootProps): ReactElement {\n const controller = useController(createDialog, props)\n return <Context.Provider value={controller}>{children}</Context.Provider>\n}\n\nfunction Portal({ children }: { children?: ReactNode }): ReactElement | null {\n const mounted = useSignal(useDialog(\"Portal\").mounted)\n return mounted ? <BodyPortal>{children}</BodyPortal> : null\n}\n\nconst Trigger = (props: PartComponentProps) =>\n usePart(useDialog(\"Trigger\").trigger, \"button\", props)\nconst Backdrop = (props: PartComponentProps) =>\n usePart(useDialog(\"Backdrop\").backdrop, \"div\", props)\nconst Popup = (props: PartComponentProps) => usePart(useDialog(\"Popup\").popup, \"div\", props)\nconst Title = (props: PartComponentProps) => usePart(useDialog(\"Title\").title, \"h2\", props)\nconst Description = (props: PartComponentProps) =>\n usePart(useDialog(\"Description\").description, \"p\", props)\nconst Close = (props: PartComponentProps) => usePart(useDialog(\"Close\").close, \"button\", props)\n\nexport const Dialog = { Root, Trigger, Portal, Backdrop, Popup, Title, Description, Close }\n\nexport type AlertRootProps = Omit<AlertDialogProps, \"id\"> & { id?: string; children?: ReactNode }\n\nfunction AlertRoot({ children, ...props }: AlertRootProps): ReactElement {\n const controller = useController(createAlertDialog, props)\n return <Context.Provider value={controller}>{children}</Context.Provider>\n}\n\n/** A dialog that asks for an answer: a press outside it does not close it. Its parts are a dialog's. */\nexport const AlertDialog = { ...Dialog, Root: AlertRoot }\n\nexport type DrawerRootProps = Omit<DrawerProps, \"id\"> & { id?: string; children?: ReactNode }\n\nfunction DrawerRoot({ children, ...props }: DrawerRootProps): ReactElement {\n const controller = useController(createDrawer, props)\n return <Context.Provider value={controller}>{children}</Context.Provider>\n}\n\n/** A dialog that comes from an edge and is dragged back to it. Its parts are a dialog's. */\nexport const Drawer = { ...Dialog, Root: DrawerRoot }\n"],"mappings":";;;;;;;AAYA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,UAAU,MAA0B;CAC3C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,WAAW,KAAK,+BAA+B;CAChF,OAAO;AACT;AAIA,SAAS,KAAK,EAAE,UAAU,GAAG,SAAkC;CAC7D,MAAM,aAAa,cAAc,cAAc,KAAK;CACpD,OAAO,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa;CAA2B,CAAA;AAC1E;AAEA,SAAS,OAAO,EAAE,YAA2D;CAE3E,OADgB,UAAU,UAAU,QAAQ,CAAC,CAAC,OACjC,IAAI,oBAACA,UAAD,EAAa,SAAqB,CAAA,IAAI;AACzD;AAEA,MAAM,WAAW,UACf,QAAQ,UAAU,SAAS,CAAC,CAAC,SAAS,UAAU,KAAK;AACvD,MAAM,YAAY,UAChB,QAAQ,UAAU,UAAU,CAAC,CAAC,UAAU,OAAO,KAAK;AACtD,MAAM,SAAS,UAA8B,QAAQ,UAAU,OAAO,CAAC,CAAC,OAAO,OAAO,KAAK;AAC3F,MAAM,SAAS,UAA8B,QAAQ,UAAU,OAAO,CAAC,CAAC,OAAO,MAAM,KAAK;AAC1F,MAAM,eAAe,UACnB,QAAQ,UAAU,aAAa,CAAC,CAAC,aAAa,KAAK,KAAK;AAC1D,MAAM,SAAS,UAA8B,QAAQ,UAAU,OAAO,CAAC,CAAC,OAAO,UAAU,KAAK;AAE9F,MAAa,SAAS;CAAE;CAAM;CAAS;CAAQ;CAAU;CAAO;CAAO;CAAa;AAAM;AAI1F,SAAS,UAAU,EAAE,UAAU,GAAG,SAAuC;CACvE,MAAM,aAAa,cAAc,mBAAmB,KAAK;CACzD,OAAO,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa;CAA2B,CAAA;AAC1E;;AAGA,MAAa,cAAc;CAAE,GAAG;CAAQ,MAAM;AAAU;AAIxD,SAAS,WAAW,EAAE,UAAU,GAAG,SAAwC;CACzE,MAAM,aAAa,cAAc,cAAc,KAAK;CACpD,OAAO,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa;CAA2B,CAAA;AAC1E;;AAGA,MAAa,SAAS;CAAE,GAAG;CAAQ,MAAM;AAAW"}
@@ -0,0 +1,4 @@
1
+ import { Direction, ReadonlySignal } from "@kirana-ui/core";
2
+ /** The reading direction a provider states, if a component is inside one. */
3
+ export declare const DirectionContext: import("react").Context<ReadonlySignal<Direction> | null>;
4
+ //# sourceMappingURL=direction-context.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { createContext } from "react";
2
+ // src/direction-context.ts
3
+ /** The reading direction a provider states, if a component is inside one. */
4
+ const DirectionContext = createContext(null);
5
+ export { DirectionContext };
6
+
7
+ //# sourceMappingURL=direction-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"direction-context.js","names":[],"sources":["../../../../packages/react/src/direction-context.ts"],"sourcesContent":["import type { Direction, ReadonlySignal } from \"@kirana-ui/core\"\nimport { createContext } from \"react\"\n\n/** The reading direction a provider states, if a component is inside one. */\nexport const DirectionContext = createContext<ReadonlySignal<Direction> | null>(null)\n"],"mappings":";;;AAIA,MAAa,mBAAmB,cAAgD,IAAI"}
@@ -0,0 +1,15 @@
1
+ import { Direction } from "@kirana-ui/core";
2
+ import { ReactElement, ReactNode } from "react";
3
+ export interface DirectionProviderProps {
4
+ /** The reading direction of what is inside. `ltr` when left out. */
5
+ direction?: Direction;
6
+ children?: ReactNode;
7
+ }
8
+ /**
9
+ * States the reading direction for the components inside. It draws nothing: set the page's own
10
+ * `dir` attribute with it.
11
+ */
12
+ export declare function DirectionProvider({ direction, children }: DirectionProviderProps): ReactElement;
13
+ /** The direction the nearest provider states; `ltr` outside one. */
14
+ export declare function useDirection(): Direction;
15
+ //# sourceMappingURL=direction.d.ts.map
@@ -0,0 +1,27 @@
1
+ import { DirectionContext } from "./direction-context.js";
2
+ import { useController, useSignal } from "./runtime.js";
3
+ import { signal } from "@kirana-ui/core";
4
+ import { useContext, useState } from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+ import { createDirection } from "@kirana-ui/core/direction";
7
+ // src/direction.tsx
8
+ /**
9
+ * States the reading direction for the components inside. It draws nothing: set the page's own
10
+ * `dir` attribute with it.
11
+ */
12
+ function DirectionProvider({ direction, children }) {
13
+ const controller = useController(createDirection, { direction });
14
+ return /* @__PURE__ */ jsx(DirectionContext.Provider, {
15
+ value: controller.direction,
16
+ children
17
+ });
18
+ }
19
+ /** The direction the nearest provider states; `ltr` outside one. */
20
+ function useDirection() {
21
+ const given = useContext(DirectionContext);
22
+ const [fallback] = useState(() => signal("ltr"));
23
+ return useSignal(given ?? fallback);
24
+ }
25
+ export { DirectionProvider, useDirection };
26
+
27
+ //# sourceMappingURL=direction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"direction.js","names":[],"sources":["../../../../packages/react/src/direction.tsx"],"sourcesContent":["import { signal } from \"@kirana-ui/core\"\nimport type { Direction } from \"@kirana-ui/core\"\nimport { createDirection } from \"@kirana-ui/core/direction\"\nimport { useContext, useState } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { useController, useSignal } from \"./runtime.tsx\"\n\nexport interface DirectionProviderProps {\n /** The reading direction of what is inside. `ltr` when left out. */\n direction?: Direction\n children?: ReactNode\n}\n\n/**\n * States the reading direction for the components inside. It draws nothing: set the page's own\n * `dir` attribute with it.\n */\nexport function DirectionProvider({ direction, children }: DirectionProviderProps): ReactElement {\n const controller = useController(createDirection, { direction })\n return (\n <DirectionContext.Provider value={controller.direction}>{children}</DirectionContext.Provider>\n )\n}\n\n/** The direction the nearest provider states; `ltr` outside one. */\nexport function useDirection(): Direction {\n const given = useContext(DirectionContext)\n const [fallback] = useState(() => signal<Direction>(\"ltr\"))\n return useSignal(given ?? fallback)\n}\n"],"mappings":";;;;;;;;;;;AAmBA,SAAgB,kBAAkB,EAAE,WAAW,YAAkD;CAC/F,MAAM,aAAa,cAAc,iBAAiB,EAAE,UAAU,CAAC;CAC/D,OACE,oBAAC,iBAAiB,UAAlB;EAA2B,OAAO,WAAW;EAAY;CAAoC,CAAA;AAEjG;;AAGA,SAAgB,eAA0B;CACxC,MAAM,QAAQ,WAAW,gBAAgB;CACzC,MAAM,CAAC,YAAY,eAAe,OAAkB,KAAK,CAAC;CAC1D,OAAO,UAAU,SAAS,QAAQ;AACpC"}
@@ -0,0 +1,2 @@
1
+ import { Drawer } from "./dialog.js";
2
+ export { Drawer };
package/src/drawer.js ADDED
@@ -0,0 +1 @@
1
+ export { Drawer } from "./dialog.js";
@@ -0,0 +1,4 @@
1
+ import { Field } from "@kirana-ui/core/field";
2
+ /** The field a part or a control is in, if it is in one. */
3
+ export declare const FieldContext: import("react").Context<Field | null>;
4
+ //# sourceMappingURL=field-context.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { createContext } from "react";
2
+ // src/field-context.ts
3
+ /** The field a part or a control is in, if it is in one. */
4
+ const FieldContext = createContext(null);
5
+ export { FieldContext };
6
+
7
+ //# sourceMappingURL=field-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-context.js","names":[],"sources":["../../../../packages/react/src/field-context.ts"],"sourcesContent":["import type { Field } from \"@kirana-ui/core/field\"\nimport { createContext } from \"react\"\n\n/** The field a part or a control is in, if it is in one. */\nexport const FieldContext = createContext<Field | null>(null)\n"],"mappings":";;;AAIA,MAAa,eAAe,cAA4B,IAAI"}
package/src/field.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ import { PartComponentProps } from "./runtime.js";
2
+ import { ReactElement, ReactNode } from "react";
3
+ import { FieldProps, FieldValidity, ValidityKey } from "@kirana-ui/core/field";
4
+ export type RootProps = Omit<FieldProps, "id"> & {
5
+ id?: string;
6
+ } & PartComponentProps;
7
+ declare function Root({ name, disabled, invalid, validate, validationMode, validationDebounceTime, id, ...rest }: RootProps): ReactElement;
8
+ declare const Label: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
9
+ /** An `<input>`; a `<textarea>` or a `<select>` through `render`. */
10
+ declare const Control: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
11
+ declare const Description: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
12
+ export interface ErrorProps extends PartComponentProps {
13
+ /** One of the browser's findings (`"valueMissing"`) to show for only that; `true` to show always. */
14
+ match?: ValidityKey | boolean;
15
+ }
16
+ /** What is wrong, or `children` in its place. In the page while it applies. */
17
+ declare function FieldError({ match, children, ...rest }: ErrorProps): ReactElement | null;
18
+ /** Draws nothing itself: `children` is given the field's validity. */
19
+ declare function Validity({ children }: {
20
+ children: (validity: FieldValidity) => ReactNode;
21
+ }): ReactNode;
22
+ export declare const Field: {
23
+ Root: typeof Root;
24
+ Label: typeof Label;
25
+ Control: typeof Control;
26
+ Description: typeof Description;
27
+ Error: typeof FieldError;
28
+ Validity: typeof Validity;
29
+ };
30
+ export {};
31
+ //# sourceMappingURL=field.d.ts.map