@kirana-ui/react 0.3.0 → 0.4.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 (137) hide show
  1. package/CHANGELOG.md +140 -0
  2. package/llms.txt +1507 -121
  3. package/package.json +44 -3
  4. package/skills/kirana-ui-primitives/SKILL.md +24 -4
  5. package/src/accordion.d.ts +2 -2
  6. package/src/accordion.js +3 -2
  7. package/src/accordion.js.map +1 -1
  8. package/src/autosize.d.ts +1 -1
  9. package/src/avatar.d.ts +2 -2
  10. package/src/avatar.js +3 -3
  11. package/src/avatar.js.map +1 -1
  12. package/src/button.d.ts +5 -2
  13. package/src/button.js +4 -1
  14. package/src/button.js.map +1 -1
  15. package/src/calendar.d.ts +6 -6
  16. package/src/calendar.js +13 -5
  17. package/src/calendar.js.map +1 -1
  18. package/src/carousel.d.ts +6 -3
  19. package/src/carousel.js +1 -1
  20. package/src/carousel.js.map +1 -1
  21. package/src/checkbox-group.d.ts +2 -1
  22. package/src/checkbox-group.js +1 -1
  23. package/src/checkbox-group.js.map +1 -1
  24. package/src/checkbox.d.ts +6 -1
  25. package/src/checkbox.js +1 -1
  26. package/src/checkbox.js.map +1 -1
  27. package/src/collapsible.d.ts +1 -1
  28. package/src/color-picker.d.ts +61 -0
  29. package/src/color-picker.js +119 -0
  30. package/src/color-picker.js.map +1 -0
  31. package/src/combobox.d.ts +13 -4
  32. package/src/combobox.js +13 -5
  33. package/src/combobox.js.map +1 -1
  34. package/src/command.d.ts +3 -3
  35. package/src/command.js.map +1 -1
  36. package/src/date-field.d.ts +2 -2
  37. package/src/date-field.js +3 -2
  38. package/src/date-field.js.map +1 -1
  39. package/src/date-picker.d.ts +29 -8
  40. package/src/date-picker.js +21 -5
  41. package/src/date-picker.js.map +1 -1
  42. package/src/dialog.d.ts +6 -6
  43. package/src/dialog.js +22 -7
  44. package/src/dialog.js.map +1 -1
  45. package/src/direction.d.ts +1 -1
  46. package/src/direction.js +1 -1
  47. package/src/editable.d.ts +32 -0
  48. package/src/editable.js +63 -0
  49. package/src/editable.js.map +1 -0
  50. package/src/field.d.ts +1 -1
  51. package/src/fieldset.d.ts +1 -1
  52. package/src/file-upload.d.ts +54 -0
  53. package/src/file-upload.js +96 -0
  54. package/src/file-upload.js.map +1 -0
  55. package/src/form.d.ts +1 -1
  56. package/src/hover-popup.d.ts +1 -1
  57. package/src/hover-popup.js +1 -1
  58. package/src/index.d.ts +26 -8
  59. package/src/index.js +11 -1
  60. package/src/input.d.ts +1 -1
  61. package/src/input.js +1 -1
  62. package/src/label.d.ts +1 -1
  63. package/src/listbox.d.ts +1 -1
  64. package/src/listbox.js +1 -1
  65. package/src/menu.d.ts +5 -5
  66. package/src/menu.js +14 -9
  67. package/src/menu.js.map +1 -1
  68. package/src/menubar.d.ts +2 -2
  69. package/src/menubar.js +4 -2
  70. package/src/menubar.js.map +1 -1
  71. package/src/message-scroller.d.ts +1 -1
  72. package/src/navigation-menu.d.ts +5 -5
  73. package/src/navigation-menu.js +14 -4
  74. package/src/navigation-menu.js.map +1 -1
  75. package/src/number-field.d.ts +2 -1
  76. package/src/number-field.js +1 -1
  77. package/src/number-field.js.map +1 -1
  78. package/src/otp.d.ts +3 -2
  79. package/src/otp.js +9 -2
  80. package/src/otp.js.map +1 -1
  81. package/src/pagination.d.ts +1 -1
  82. package/src/password-input.d.ts +23 -0
  83. package/src/password-input.js +40 -0
  84. package/src/password-input.js.map +1 -0
  85. package/src/popover.d.ts +1 -1
  86. package/src/popover.js +1 -1
  87. package/src/qr-code.d.ts +1 -1
  88. package/src/radio-group.d.ts +1 -1
  89. package/src/radio-group.js +1 -1
  90. package/src/rating.d.ts +28 -0
  91. package/src/rating.js +59 -0
  92. package/src/rating.js.map +1 -0
  93. package/src/resizable.d.ts +1 -1
  94. package/src/resizable.js +1 -1
  95. package/src/runtime.d.ts +10 -3
  96. package/src/runtime.js +18 -4
  97. package/src/runtime.js.map +1 -1
  98. package/src/scroll-area.d.ts +1 -1
  99. package/src/scroll-area.js +1 -1
  100. package/src/select.d.ts +17 -6
  101. package/src/select.js +6 -3
  102. package/src/select.js.map +1 -1
  103. package/src/separator.d.ts +1 -1
  104. package/src/slider.d.ts +1 -1
  105. package/src/slider.js +1 -1
  106. package/src/steps.d.ts +51 -0
  107. package/src/steps.js +69 -0
  108. package/src/steps.js.map +1 -0
  109. package/src/switch.d.ts +2 -1
  110. package/src/switch.js +1 -1
  111. package/src/switch.js.map +1 -1
  112. package/src/tabs.d.ts +2 -2
  113. package/src/tabs.js +4 -3
  114. package/src/tabs.js.map +1 -1
  115. package/src/tags-input.d.ts +47 -0
  116. package/src/tags-input.js +92 -0
  117. package/src/tags-input.js.map +1 -0
  118. package/src/time-field.d.ts +32 -0
  119. package/src/time-field.js +67 -0
  120. package/src/time-field.js.map +1 -0
  121. package/src/toast.d.ts +1 -1
  122. package/src/toggle-group.d.ts +2 -2
  123. package/src/toggle-group.js +4 -3
  124. package/src/toggle-group.js.map +1 -1
  125. package/src/toggle.d.ts +1 -1
  126. package/src/toggle.js +1 -1
  127. package/src/toolbar.d.ts +14 -6
  128. package/src/toolbar.js +19 -9
  129. package/src/toolbar.js.map +1 -1
  130. package/src/tour.d.ts +61 -0
  131. package/src/tour.js +68 -0
  132. package/src/tour.js.map +1 -0
  133. package/src/tree.d.ts +45 -0
  134. package/src/tree.js +93 -0
  135. package/src/tree.js.map +1 -0
  136. package/src/use-render.js +1 -1
  137. package/src/value-bar.d.ts +1 -1
@@ -0,0 +1,32 @@
1
+ import { PartComponentProps } from "./runtime.js";
2
+ import { ReactElement, ReactNode } from "react";
3
+ import { StateOf } from "@kirana-ui/core";
4
+ import { TimeFieldProps, TimeFieldSegment } from "@kirana-ui/core/time-field";
5
+ import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
+ type Parts = Vocabulary["timeField"];
7
+ export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<TimeFieldProps, "id"> & {
8
+ id?: string;
9
+ }>;
10
+ declare function Root({ value, defaultValue, onValueChange, granularity, hourCycle, locale, min, max, placeholders, disabled, readOnly, required, name, form, id, ...rest }: RootProps): ReactElement;
11
+ export interface SegmentsProps {
12
+ /** Draws one piece of the time, once for each: a part that is typed, or what stands between two. */
13
+ children: (segment: TimeFieldSegment) => ReactNode;
14
+ }
15
+ /** Draws its child once for each piece of the time, in the locale's order. */
16
+ declare function Segments({ children }: SegmentsProps): import("react").JSX.Element;
17
+ export type SegmentProps = PartComponentProps<"span", StateOf<Parts["segment"]>, {
18
+ /** The piece it is: an entry `TimeField.Segments` gave. */
19
+ segment: TimeFieldSegment;
20
+ }>;
21
+ /** One piece: a part that is typed, or what stands between two. It writes its own text. */
22
+ declare function Segment({ segment, ...props }: SegmentProps): ReactElement;
23
+ export type InputProps = PartComponentProps<"input", StateOf<Parts["input"]>>;
24
+ declare const Input: (props: InputProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
25
+ export declare const TimeField: {
26
+ readonly Root: typeof Root;
27
+ readonly Segments: typeof Segments;
28
+ readonly Segment: typeof Segment;
29
+ readonly Input: typeof Input;
30
+ };
31
+ export {};
32
+ //# sourceMappingURL=time-field.d.ts.map
@@ -0,0 +1,67 @@
1
+ import { DirectionContext } from "./direction-context.js";
2
+ import { FieldContext } from "./field-context.js";
3
+ import { parts, useController, usePart, useSignal } from "./runtime.js";
4
+ import { Fragment, createContext, useContext } from "react";
5
+ import { within } from "@kirana-ui/core";
6
+ import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
7
+ import { createTimeField } from "@kirana-ui/core/time-field";
8
+ // src/time-field.tsx
9
+ const Context = createContext(null);
10
+ function useTimeField(part) {
11
+ const controller = useContext(Context);
12
+ if (!controller) throw new Error(`<TimeField.${part}> must be inside <TimeField.Root>`);
13
+ return controller;
14
+ }
15
+ function Root({ value, defaultValue, onValueChange, granularity, hourCycle, locale, min, max, placeholders, disabled, readOnly, required, name, form, id, ...rest }) {
16
+ const direction = useContext(DirectionContext) ?? void 0;
17
+ const field = useContext(FieldContext) ?? void 0;
18
+ const controller = useController(within(createTimeField, {
19
+ direction,
20
+ field
21
+ }), {
22
+ value,
23
+ defaultValue,
24
+ onValueChange,
25
+ granularity,
26
+ hourCycle,
27
+ locale,
28
+ min,
29
+ max,
30
+ placeholders,
31
+ disabled,
32
+ readOnly,
33
+ required,
34
+ name,
35
+ form,
36
+ id
37
+ });
38
+ return /* @__PURE__ */ jsx(Context.Provider, {
39
+ value: controller,
40
+ children: usePart(controller.root, "div", rest)
41
+ });
42
+ }
43
+ /** Draws its child once for each piece of the time, in the locale's order. */
44
+ function Segments({ children }) {
45
+ const segments = useSignal(useTimeField("Segments").segments);
46
+ return /* @__PURE__ */ jsx(Fragment$1, { children: segments.map((segment) => /* @__PURE__ */ jsx(Fragment, { children: children(segment) }, `${segment.index}-${segment.type}`)) });
47
+ }
48
+ /** One piece: a part that is typed, or what stands between two. It writes its own text. */
49
+ function Segment({ segment, ...props }) {
50
+ const { part, text } = useTimeField("Segment").segment(segment);
51
+ const shown = useSignal(text);
52
+ return usePart(part, "span", {
53
+ ...props,
54
+ suppressContentEditableWarning: true,
55
+ children: shown
56
+ });
57
+ }
58
+ const Input = (props) => usePart(useTimeField("Input").input, "input", props);
59
+ const TimeField = /* @__PURE__ */ parts("TimeField", {
60
+ Root,
61
+ Segments,
62
+ Segment,
63
+ Input
64
+ });
65
+ export { TimeField };
66
+
67
+ //# sourceMappingURL=time-field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time-field.js","names":[],"sources":["../../../../packages/react/src/time-field.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createTimeField } from \"@kirana-ui/core/time-field\"\nimport type {\n TimeField as Controller,\n TimeFieldProps,\n TimeFieldSegment,\n} from \"@kirana-ui/core/time-field\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { Fragment, createContext, useContext } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { FieldContext } from \"./field-context.ts\"\nimport { parts, useController, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"timeField\"]\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useTimeField(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<TimeField.${part}> must be inside <TimeField.Root>`)\n return controller\n}\n\nexport type RootProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<TimeFieldProps, \"id\"> & { id?: string }\n>\n\nfunction Root({\n value,\n defaultValue,\n onValueChange,\n granularity,\n hourCycle,\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 field = useContext(FieldContext) ?? undefined\n const controller = useController<TimeFieldProps, Controller>(\n within(createTimeField, { direction, field }),\n {\n value,\n defaultValue,\n onValueChange,\n granularity,\n hourCycle,\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\nexport interface SegmentsProps {\n /** Draws one piece of the time, once for each: a part that is typed, or what stands between two. */\n children: (segment: TimeFieldSegment) => ReactNode\n}\n\n/** Draws its child once for each piece of the time, in the locale's order. */\nfunction Segments({ children }: SegmentsProps) {\n const segments = useSignal(useTimeField(\"Segments\").segments)\n return (\n <>\n {segments.map((segment) => (\n <Fragment key={`${segment.index}-${segment.type}`}>{children(segment)}</Fragment>\n ))}\n </>\n )\n}\n\nexport type SegmentProps = PartComponentProps<\n \"span\",\n StateOf<Parts[\"segment\"]>,\n {\n /** The piece it is: an entry `TimeField.Segments` gave. */\n segment: TimeFieldSegment\n }\n>\n\n/** One piece: a part that is typed, or what stands between two. It writes its own text. */\nfunction Segment({ segment, ...props }: SegmentProps): ReactElement {\n const { part, text } = useTimeField(\"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\nexport type InputProps = PartComponentProps<\"input\", StateOf<Parts[\"input\"]>>\n\nconst Input = (props: InputProps) => usePart(useTimeField(\"Input\").input, \"input\", props)\n\nexport const TimeField = /* @__PURE__ */ parts(\"TimeField\", { Root, Segments, Segment, Input })\n"],"mappings":";;;;;;;;AAmBA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,aAAa,MAA0B;CAC9C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,cAAc,KAAK,kCAAkC;CACtF,OAAO;AACT;AAQA,SAAS,KAAK,EACZ,OACA,cACA,eACA,aACA,WACA,QACA,KACA,KACA,cACA,UACA,UACA,UACA,MACA,MACA,IACA,GAAG,QACuB;CAC1B,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,QAAQ,WAAW,YAAY,KAAK,KAAA;CAC1C,MAAM,aAAa,cACjB,OAAO,iBAAiB;EAAE;EAAW;CAAM,CAAC,GAC5C;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;;AAQA,SAAS,SAAS,EAAE,YAA2B;CAC7C,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;;AAYA,SAAS,QAAQ,EAAE,SAAS,GAAG,SAAqC;CAClE,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;AAIA,MAAM,SAAS,UAAsB,QAAQ,aAAa,OAAO,CAAC,CAAC,OAAO,SAAS,KAAK;AAExF,MAAa,YAA4B,sBAAM,aAAa;CAAE;CAAM;CAAU;CAAS;AAAM,CAAC"}
package/src/toast.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PartComponentProps } from "./runtime.js";
2
- import { StateOf } from "@kirana-ui/core";
3
2
  import { ReactElement, ReactNode } from "react";
3
+ import { StateOf } from "@kirana-ui/core";
4
4
  import * as Core from "@kirana-ui/core/toast";
5
5
  import { ToasterOptions } from "@kirana-ui/core/toast";
6
6
  import { Vocabulary } from "@kirana-ui/core/vocabulary";
@@ -1,10 +1,10 @@
1
1
  import { PartComponentProps } from "./runtime.js";
2
- import { StateOf } from "@kirana-ui/core";
3
2
  import { ReactElement } from "react";
3
+ import { StateOf } from "@kirana-ui/core";
4
4
  import { ToggleGroupProps as ToggleGroupProps$1 } from "@kirana-ui/core/toggle-group";
5
5
  import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
6
  /** `Value` is what tells a toggle from the others: the type of `value`'s entries. */
7
7
  export type ToggleGroupProps<Value = unknown> = PartComponentProps<"div", StateOf<Vocabulary["toggleGroup"]["root"]>, ToggleGroupProps$1<Value>>;
8
8
  /** Toggles that are one control. Each `<Toggle value>` inside it is one of its toggles. */
9
- export declare const ToggleGroup: <Value = unknown>({ value, defaultValue, onValueChange, multiple, disabled, orientation, loop, ...rest }: ToggleGroupProps<Value>) => ReactElement;
9
+ export declare const ToggleGroup: <Value = unknown>({ value, defaultValue, onValueChange, multiple, disabled, orientation, loop, loopFocus, ...rest }: ToggleGroupProps<Value>) => ReactElement;
10
10
  //# sourceMappingURL=toggle-group.d.ts.map
@@ -1,13 +1,13 @@
1
1
  import { DirectionContext } from "./direction-context.js";
2
2
  import { component, useController, usePart } from "./runtime.js";
3
3
  import { ToggleGroupContext, ToolbarContext } from "./toolbar-context.js";
4
- import { within } from "@kirana-ui/core";
5
4
  import { useContext } from "react";
5
+ import { within } from "@kirana-ui/core";
6
6
  import { jsx } from "react/jsx-runtime";
7
7
  import { createToggleGroup } from "@kirana-ui/core/toggle-group";
8
8
  // src/toggle-group.tsx
9
9
  /** Toggles that are one control. Each `<Toggle value>` inside it is one of its toggles. */
10
- const ToggleGroup = /* @__PURE__ */ component("ToggleGroup", function ToggleGroup({ value, defaultValue, onValueChange, multiple, disabled, orientation, loop, ...rest }) {
10
+ const ToggleGroup = /* @__PURE__ */ component("ToggleGroup", function ToggleGroup({ value, defaultValue, onValueChange, multiple, disabled, orientation, loop, loopFocus, ...rest }) {
11
11
  const direction = useContext(DirectionContext) ?? void 0;
12
12
  const toolbar = useContext(ToolbarContext) ?? void 0;
13
13
  const controller = useController(within(createToggleGroup, {
@@ -20,7 +20,8 @@ const ToggleGroup = /* @__PURE__ */ component("ToggleGroup", function ToggleGrou
20
20
  multiple,
21
21
  disabled,
22
22
  orientation,
23
- loop
23
+ loop,
24
+ loopFocus
24
25
  });
25
26
  return /* @__PURE__ */ jsx(ToggleGroupContext.Provider, {
26
27
  value: controller,
@@ -1 +1 @@
1
- {"version":3,"file":"toggle-group.js","names":[],"sources":["../../../../packages/react/src/toggle-group.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createToggleGroup } from \"@kirana-ui/core/toggle-group\"\nimport type {\n ToggleGroup as Controller,\n ToggleGroupProps as CoreProps,\n} from \"@kirana-ui/core/toggle-group\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { component, useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\nimport { ToggleGroupContext, ToolbarContext } from \"./toolbar-context.ts\"\n\n/** `Value` is what tells a toggle from the others: the type of `value`'s entries. */\nexport type ToggleGroupProps<Value = unknown> = PartComponentProps<\n \"div\",\n StateOf<Vocabulary[\"toggleGroup\"][\"root\"]>,\n CoreProps<Value>\n>\n\n/** Toggles that are one control. Each `<Toggle value>` inside it is one of its toggles. */\nexport const ToggleGroup = /* @__PURE__ */ component(\"ToggleGroup\", function ToggleGroup<\n Value = unknown,\n>({ value, defaultValue, onValueChange, multiple, disabled, orientation, loop, ...rest }: ToggleGroupProps<Value>): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const toolbar = useContext(ToolbarContext) ?? undefined\n const controller: Controller = useController<CoreProps<Value>, Controller<Value>>(\n within(createToggleGroup<Value>, { direction, toolbar }),\n { value, defaultValue, onValueChange, multiple, disabled, orientation, loop }\n )\n return (\n <ToggleGroupContext.Provider value={controller}>\n {usePart(controller.root, \"div\", rest)}\n </ToggleGroupContext.Provider>\n )\n})\n"],"mappings":";;;;;;;;;AAwBA,MAAa,cAA8B,0BAAU,eAAe,SAAS,YAE3E,EAAE,OAAO,cAAc,eAAe,UAAU,UAAU,aAAa,MAAM,GAAG,QAA+C;CAC/H,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,UAAU,WAAW,cAAc,KAAK,KAAA;CAC9C,MAAM,aAAyB,cAC7B,OAAO,mBAA0B;EAAE;EAAW;CAAQ,CAAC,GACvD;EAAE;EAAO;EAAc;EAAe;EAAU;EAAU;EAAa;CAAK,CAC9E;CACA,OACE,oBAAC,mBAAmB,UAApB;EAA6B,OAAO;EACjC,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CACV,CAAA;AAEjC,CAAC"}
1
+ {"version":3,"file":"toggle-group.js","names":[],"sources":["../../../../packages/react/src/toggle-group.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createToggleGroup } from \"@kirana-ui/core/toggle-group\"\nimport type {\n ToggleGroup as Controller,\n ToggleGroupProps as CoreProps,\n} from \"@kirana-ui/core/toggle-group\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { component, useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\nimport { ToggleGroupContext, ToolbarContext } from \"./toolbar-context.ts\"\n\n/** `Value` is what tells a toggle from the others: the type of `value`'s entries. */\nexport type ToggleGroupProps<Value = unknown> = PartComponentProps<\n \"div\",\n StateOf<Vocabulary[\"toggleGroup\"][\"root\"]>,\n CoreProps<Value>\n>\n\n/** Toggles that are one control. Each `<Toggle value>` inside it is one of its toggles. */\nexport const ToggleGroup = /* @__PURE__ */ component(\"ToggleGroup\", function ToggleGroup<\n Value = unknown,\n>({ value, defaultValue, onValueChange, multiple, disabled, orientation, loop, loopFocus, ...rest }: ToggleGroupProps<Value>): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const toolbar = useContext(ToolbarContext) ?? undefined\n const controller: Controller = useController<CoreProps<Value>, Controller<Value>>(\n within(createToggleGroup<Value>, { direction, toolbar }),\n { value, defaultValue, onValueChange, multiple, disabled, orientation, loop, loopFocus }\n )\n return (\n <ToggleGroupContext.Provider value={controller}>\n {usePart(controller.root, \"div\", rest)}\n </ToggleGroupContext.Provider>\n )\n})\n"],"mappings":";;;;;;;;;AAwBA,MAAa,cAA8B,0BAAU,eAAe,SAAS,YAE3E,EAAE,OAAO,cAAc,eAAe,UAAU,UAAU,aAAa,MAAM,WAAW,GAAG,QAA+C;CAC1I,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,UAAU,WAAW,cAAc,KAAK,KAAA;CAC9C,MAAM,aAAyB,cAC7B,OAAO,mBAA0B;EAAE;EAAW;CAAQ,CAAC,GACvD;EAAE;EAAO;EAAc;EAAe;EAAU;EAAU;EAAa;EAAM;CAAU,CACzF;CACA,OACE,oBAAC,mBAAmB,UAApB;EAA6B,OAAO;EACjC,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CACV,CAAA;AAEjC,CAAC"}
package/src/toggle.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PartComponentProps } from "./runtime.js";
2
- import { StateOf } from "@kirana-ui/core";
3
2
  import { ReactElement } from "react";
3
+ import { StateOf } from "@kirana-ui/core";
4
4
  import { ToggleProps as ToggleProps$1 } from "@kirana-ui/core/toggle";
5
5
  import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
6
  export type ToggleProps = PartComponentProps<"button", StateOf<Vocabulary["toggle"]["root"]>, ToggleProps$1>;
package/src/toggle.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { component, useController, usePart } from "./runtime.js";
2
2
  import { ToggleGroupContext, ToolbarContext } from "./toolbar-context.js";
3
- import { within } from "@kirana-ui/core";
4
3
  import { useContext } from "react";
4
+ import { within } from "@kirana-ui/core";
5
5
  import { createToggle } from "@kirana-ui/core/toggle";
6
6
  // src/toggle.tsx
7
7
  /** Inside a `<ToggleGroup>`, `value` makes it one of the group's toggles. */
package/src/toolbar.d.ts CHANGED
@@ -1,23 +1,31 @@
1
1
  import { PartComponentProps } from "./runtime.js";
2
- import { StateOf } from "@kirana-ui/core";
3
2
  import { ReactElement } from "react";
3
+ import { StateOf } from "@kirana-ui/core";
4
4
  import { ToolbarProps } from "@kirana-ui/core/toolbar";
5
5
  import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
6
  type Parts = Vocabulary["toolbar"];
7
7
  export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, ToolbarProps>;
8
- declare function Root({ orientation, loop, disabled, ...rest }: RootProps): ReactElement;
8
+ declare function Root({ orientation, loop, loopFocus, disabled, ...rest }: RootProps): ReactElement;
9
9
  /** What an item of the toolbar takes of its own. */
10
10
  export interface ItemOptions {
11
11
  /** Disables this control. */
12
12
  disabled?: boolean;
13
13
  }
14
- export type ButtonProps = PartComponentProps<"button", StateOf<Parts["button"]>, ItemOptions>;
15
- export type InputProps = PartComponentProps<"input", StateOf<Parts["input"]>, ItemOptions>;
14
+ /** What a button or an input of the toolbar takes of its own. */
15
+ export interface ControlOptions extends ItemOptions {
16
+ /**
17
+ * Keeps it focusable while disabled, as Base UI's: the arrows still reach it, and a press does
18
+ * nothing. Default `true`; with `false` it is disabled the element's own way.
19
+ */
20
+ focusableWhenDisabled?: boolean;
21
+ }
22
+ export type ButtonProps = PartComponentProps<"button", StateOf<Parts["button"]>, ControlOptions>;
23
+ export type InputProps = PartComponentProps<"input", StateOf<Parts["input"]>, ControlOptions>;
16
24
  export type GroupProps = PartComponentProps<"div", StateOf<Parts["group"]>, ItemOptions>;
17
25
  /** @deprecated The item's own: `ButtonProps`, `InputProps` or `GroupProps`. */
18
26
  export type ItemProps = PartComponentProps<"div", StateOf<Parts["group"]>, ItemOptions>;
19
- declare function Button({ disabled, ...props }: ButtonProps): ReactElement;
20
- declare function Input({ disabled, ...props }: InputProps): ReactElement;
27
+ declare function Button({ disabled, focusableWhenDisabled, ...props }: ButtonProps): ReactElement;
28
+ declare function Input({ disabled, focusableWhenDisabled, ...props }: InputProps): ReactElement;
21
29
  declare function Group({ disabled, ...props }: GroupProps): ReactElement;
22
30
  export type LinkProps = PartComponentProps<"a", StateOf<Parts["link"]>>;
23
31
  declare function Link(props: LinkProps): ReactElement;
package/src/toolbar.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { DirectionContext } from "./direction-context.js";
2
2
  import { parts, useController, useOptions, usePart } from "./runtime.js";
3
3
  import { ToggleGroupContext, ToolbarContext } from "./toolbar-context.js";
4
- import { defined, within } from "@kirana-ui/core";
5
4
  import { useContext, useMemo } from "react";
5
+ import { defined, within } from "@kirana-ui/core";
6
6
  import { jsx } from "react/jsx-runtime";
7
7
  import { createToolbar } from "@kirana-ui/core/toolbar";
8
8
  // src/toolbar.tsx
@@ -11,11 +11,12 @@ function useToolbar(part) {
11
11
  if (!controller) throw new Error(`<Toolbar.${part}> must be inside <Toolbar.Root>`);
12
12
  return controller;
13
13
  }
14
- function Root({ orientation, loop, disabled, ...rest }) {
14
+ function Root({ orientation, loop, loopFocus, disabled, ...rest }) {
15
15
  const direction = useContext(DirectionContext) ?? void 0;
16
16
  const controller = useController(within(createToolbar, { direction }), {
17
17
  orientation,
18
18
  loop,
19
+ loopFocus,
19
20
  disabled
20
21
  });
21
22
  return /* @__PURE__ */ jsx(ToolbarContext.Provider, {
@@ -26,23 +27,32 @@ function Root({ orientation, loop, disabled, ...rest }) {
26
27
  })
27
28
  });
28
29
  }
29
- function useItem(name, disabled) {
30
+ function useItem(name, { disabled, focusableWhenDisabled }) {
30
31
  const controller = useToolbar(name);
31
- const options = useOptions({ disabled });
32
+ const options = useOptions({
33
+ disabled,
34
+ focusableWhenDisabled
35
+ });
32
36
  return useMemo(() => controller[name](() => defined(options.get())), [
33
37
  controller,
34
38
  name,
35
39
  options
36
40
  ]);
37
41
  }
38
- function Button({ disabled, ...props }) {
39
- return usePart(useItem("button", disabled), "button", props);
42
+ function Button({ disabled, focusableWhenDisabled, ...props }) {
43
+ return usePart(useItem("button", {
44
+ disabled,
45
+ focusableWhenDisabled
46
+ }), "button", props);
40
47
  }
41
- function Input({ disabled, ...props }) {
42
- return usePart(useItem("input", disabled), "input", props);
48
+ function Input({ disabled, focusableWhenDisabled, ...props }) {
49
+ return usePart(useItem("input", {
50
+ disabled,
51
+ focusableWhenDisabled
52
+ }), "input", props);
43
53
  }
44
54
  function Group({ disabled, ...props }) {
45
- return usePart(useItem("group", disabled), "div", props);
55
+ return usePart(useItem("group", { disabled }), "div", props);
46
56
  }
47
57
  function Link(props) {
48
58
  const controller = useToolbar("Link");
@@ -1 +1 @@
1
- {"version":3,"file":"toolbar.js","names":[],"sources":["../../../../packages/react/src/toolbar.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { Part, StateOf } from \"@kirana-ui/core\"\nimport { createToolbar } from \"@kirana-ui/core/toolbar\"\nimport type { Toolbar as Controller, ToolbarProps } from \"@kirana-ui/core/toolbar\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { useContext, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { parts, useController, useOptions, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\nimport { ToggleGroupContext, ToolbarContext } from \"./toolbar-context.ts\"\n\ntype Parts = Vocabulary[\"toolbar\"]\n\nfunction useToolbar(part: string): Controller {\n const controller = useContext(ToolbarContext)\n if (!controller) throw new Error(`<Toolbar.${part}> must be inside <Toolbar.Root>`)\n return controller\n}\n\nexport type RootProps = PartComponentProps<\"div\", StateOf<Parts[\"root\"]>, ToolbarProps>\n\nfunction Root({ orientation, loop, disabled, ...rest }: RootProps): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const controller = useController<ToolbarProps, Controller>(within(createToolbar, { direction }), {\n orientation,\n loop,\n disabled,\n })\n return (\n <ToolbarContext.Provider value={controller}>\n {/* A toggle group around the toolbar is not the group of the toolbar's toggles. */}\n <ToggleGroupContext.Provider value={null}>\n {usePart(controller.root, \"div\", rest)}\n </ToggleGroupContext.Provider>\n </ToolbarContext.Provider>\n )\n}\n\n/** What an item of the toolbar takes of its own. */\nexport interface ItemOptions {\n /** Disables this control. */\n disabled?: boolean\n}\n\nexport type ButtonProps = PartComponentProps<\"button\", StateOf<Parts[\"button\"]>, ItemOptions>\nexport type InputProps = PartComponentProps<\"input\", StateOf<Parts[\"input\"]>, ItemOptions>\nexport type GroupProps = PartComponentProps<\"div\", StateOf<Parts[\"group\"]>, ItemOptions>\n/** @deprecated The item's own: `ButtonProps`, `InputProps` or `GroupProps`. */\nexport type ItemProps = PartComponentProps<\"div\", StateOf<Parts[\"group\"]>, ItemOptions>\n\nfunction useItem(name: \"button\" | \"input\" | \"group\", disabled: boolean | undefined): Part {\n const controller = useToolbar(name)\n const options = useOptions({ disabled })\n return useMemo(() => controller[name](() => defined(options.get())), [controller, name, options])\n}\n\nfunction Button({ disabled, ...props }: ButtonProps): ReactElement {\n return usePart(useItem(\"button\", disabled), \"button\", props)\n}\n\nfunction Input({ disabled, ...props }: InputProps): ReactElement {\n return usePart(useItem(\"input\", disabled), \"input\", props)\n}\n\nfunction Group({ disabled, ...props }: GroupProps): ReactElement {\n return usePart(useItem(\"group\", disabled), \"div\", props)\n}\n\nexport type LinkProps = PartComponentProps<\"a\", StateOf<Parts[\"link\"]>>\n\nfunction Link(props: LinkProps): ReactElement {\n const controller = useToolbar(\"Link\")\n const part = useMemo(() => controller.link(), [controller])\n return usePart(part, \"a\", props)\n}\n\nexport type SeparatorProps = PartComponentProps<\"div\", StateOf<Parts[\"separator\"]>>\n\nconst Separator = (props: SeparatorProps) =>\n usePart(useToolbar(\"Separator\").separator, \"div\", props)\n\nexport const Toolbar = /* @__PURE__ */ parts(\"Toolbar\", {\n Root,\n Button,\n Link,\n Input,\n Group,\n Separator,\n})\n"],"mappings":";;;;;;;;AAeA,SAAS,WAAW,MAA0B;CAC5C,MAAM,aAAa,WAAW,cAAc;CAC5C,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,YAAY,KAAK,gCAAgC;CAClF,OAAO;AACT;AAIA,SAAS,KAAK,EAAE,aAAa,MAAM,UAAU,GAAG,QAAiC;CAC/E,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,aAAa,cAAwC,OAAO,eAAe,EAAE,UAAU,CAAC,GAAG;EAC/F;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,eAAe,UAAhB;EAAyB,OAAO;EAE9B,UAAA,oBAAC,mBAAmB,UAApB;GAA6B,OAAO;GACjC,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;EACV,CAAA;CACN,CAAA;AAE7B;AAcA,SAAS,QAAQ,MAAoC,UAAqC;CACxF,MAAM,aAAa,WAAW,IAAI;CAClC,MAAM,UAAU,WAAW,EAAE,SAAS,CAAC;CACvC,OAAO,cAAc,WAAW,KAAK,OAAO,QAAQ,QAAQ,IAAI,CAAC,CAAC,GAAG;EAAC;EAAY;EAAM;CAAO,CAAC;AAClG;AAEA,SAAS,OAAO,EAAE,UAAU,GAAG,SAAoC;CACjE,OAAO,QAAQ,QAAQ,UAAU,QAAQ,GAAG,UAAU,KAAK;AAC7D;AAEA,SAAS,MAAM,EAAE,UAAU,GAAG,SAAmC;CAC/D,OAAO,QAAQ,QAAQ,SAAS,QAAQ,GAAG,SAAS,KAAK;AAC3D;AAEA,SAAS,MAAM,EAAE,UAAU,GAAG,SAAmC;CAC/D,OAAO,QAAQ,QAAQ,SAAS,QAAQ,GAAG,OAAO,KAAK;AACzD;AAIA,SAAS,KAAK,OAAgC;CAC5C,MAAM,aAAa,WAAW,MAAM;CACpC,MAAM,OAAO,cAAc,WAAW,KAAK,GAAG,CAAC,UAAU,CAAC;CAC1D,OAAO,QAAQ,MAAM,KAAK,KAAK;AACjC;AAIA,MAAM,aAAa,UACjB,QAAQ,WAAW,WAAW,CAAC,CAAC,WAAW,OAAO,KAAK;AAEzD,MAAa,UAA0B,sBAAM,WAAW;CACtD;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
1
+ {"version":3,"file":"toolbar.js","names":[],"sources":["../../../../packages/react/src/toolbar.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { Part, StateOf } from \"@kirana-ui/core\"\nimport { createToolbar } from \"@kirana-ui/core/toolbar\"\nimport type { Toolbar as Controller, ToolbarProps } from \"@kirana-ui/core/toolbar\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { useContext, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { parts, useController, useOptions, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\nimport { ToggleGroupContext, ToolbarContext } from \"./toolbar-context.ts\"\n\ntype Parts = Vocabulary[\"toolbar\"]\n\nfunction useToolbar(part: string): Controller {\n const controller = useContext(ToolbarContext)\n if (!controller) throw new Error(`<Toolbar.${part}> must be inside <Toolbar.Root>`)\n return controller\n}\n\nexport type RootProps = PartComponentProps<\"div\", StateOf<Parts[\"root\"]>, ToolbarProps>\n\nfunction Root({ orientation, loop, loopFocus, disabled, ...rest }: RootProps): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const controller = useController<ToolbarProps, Controller>(within(createToolbar, { direction }), {\n orientation,\n loop,\n loopFocus,\n disabled,\n })\n return (\n <ToolbarContext.Provider value={controller}>\n {/* A toggle group around the toolbar is not the group of the toolbar's toggles. */}\n <ToggleGroupContext.Provider value={null}>\n {usePart(controller.root, \"div\", rest)}\n </ToggleGroupContext.Provider>\n </ToolbarContext.Provider>\n )\n}\n\n/** What an item of the toolbar takes of its own. */\nexport interface ItemOptions {\n /** Disables this control. */\n disabled?: boolean\n}\n\n/** What a button or an input of the toolbar takes of its own. */\nexport interface ControlOptions extends ItemOptions {\n /**\n * Keeps it focusable while disabled, as Base UI's: the arrows still reach it, and a press does\n * nothing. Default `true`; with `false` it is disabled the element's own way.\n */\n focusableWhenDisabled?: boolean\n}\n\nexport type ButtonProps = PartComponentProps<\"button\", StateOf<Parts[\"button\"]>, ControlOptions>\nexport type InputProps = PartComponentProps<\"input\", StateOf<Parts[\"input\"]>, ControlOptions>\nexport type GroupProps = PartComponentProps<\"div\", StateOf<Parts[\"group\"]>, ItemOptions>\n/** @deprecated The item's own: `ButtonProps`, `InputProps` or `GroupProps`. */\nexport type ItemProps = PartComponentProps<\"div\", StateOf<Parts[\"group\"]>, ItemOptions>\n\nfunction useItem(\n name: \"button\" | \"input\" | \"group\",\n { disabled, focusableWhenDisabled }: ControlOptions\n): Part {\n const controller = useToolbar(name)\n const options = useOptions({ disabled, focusableWhenDisabled })\n return useMemo(() => controller[name](() => defined(options.get())), [controller, name, options])\n}\n\nfunction Button({ disabled, focusableWhenDisabled, ...props }: ButtonProps): ReactElement {\n return usePart(useItem(\"button\", { disabled, focusableWhenDisabled }), \"button\", props)\n}\n\nfunction Input({ disabled, focusableWhenDisabled, ...props }: InputProps): ReactElement {\n return usePart(useItem(\"input\", { disabled, focusableWhenDisabled }), \"input\", props)\n}\n\nfunction Group({ disabled, ...props }: GroupProps): ReactElement {\n return usePart(useItem(\"group\", { disabled }), \"div\", props)\n}\n\nexport type LinkProps = PartComponentProps<\"a\", StateOf<Parts[\"link\"]>>\n\nfunction Link(props: LinkProps): ReactElement {\n const controller = useToolbar(\"Link\")\n const part = useMemo(() => controller.link(), [controller])\n return usePart(part, \"a\", props)\n}\n\nexport type SeparatorProps = PartComponentProps<\"div\", StateOf<Parts[\"separator\"]>>\n\nconst Separator = (props: SeparatorProps) =>\n usePart(useToolbar(\"Separator\").separator, \"div\", props)\n\nexport const Toolbar = /* @__PURE__ */ parts(\"Toolbar\", {\n Root,\n Button,\n Link,\n Input,\n Group,\n Separator,\n})\n"],"mappings":";;;;;;;;AAeA,SAAS,WAAW,MAA0B;CAC5C,MAAM,aAAa,WAAW,cAAc;CAC5C,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,YAAY,KAAK,gCAAgC;CAClF,OAAO;AACT;AAIA,SAAS,KAAK,EAAE,aAAa,MAAM,WAAW,UAAU,GAAG,QAAiC;CAC1F,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,aAAa,cAAwC,OAAO,eAAe,EAAE,UAAU,CAAC,GAAG;EAC/F;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,eAAe,UAAhB;EAAyB,OAAO;EAE9B,UAAA,oBAAC,mBAAmB,UAApB;GAA6B,OAAO;GACjC,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;EACV,CAAA;CACN,CAAA;AAE7B;AAuBA,SAAS,QACP,MACA,EAAE,UAAU,yBACN;CACN,MAAM,aAAa,WAAW,IAAI;CAClC,MAAM,UAAU,WAAW;EAAE;EAAU;CAAsB,CAAC;CAC9D,OAAO,cAAc,WAAW,KAAK,OAAO,QAAQ,QAAQ,IAAI,CAAC,CAAC,GAAG;EAAC;EAAY;EAAM;CAAO,CAAC;AAClG;AAEA,SAAS,OAAO,EAAE,UAAU,uBAAuB,GAAG,SAAoC;CACxF,OAAO,QAAQ,QAAQ,UAAU;EAAE;EAAU;CAAsB,CAAC,GAAG,UAAU,KAAK;AACxF;AAEA,SAAS,MAAM,EAAE,UAAU,uBAAuB,GAAG,SAAmC;CACtF,OAAO,QAAQ,QAAQ,SAAS;EAAE;EAAU;CAAsB,CAAC,GAAG,SAAS,KAAK;AACtF;AAEA,SAAS,MAAM,EAAE,UAAU,GAAG,SAAmC;CAC/D,OAAO,QAAQ,QAAQ,SAAS,EAAE,SAAS,CAAC,GAAG,OAAO,KAAK;AAC7D;AAIA,SAAS,KAAK,OAAgC;CAC5C,MAAM,aAAa,WAAW,MAAM;CACpC,MAAM,OAAO,cAAc,WAAW,KAAK,GAAG,CAAC,UAAU,CAAC;CAC1D,OAAO,QAAQ,MAAM,KAAK,KAAK;AACjC;AAIA,MAAM,aAAa,UACjB,QAAQ,WAAW,WAAW,CAAC,CAAC,WAAW,OAAO,KAAK;AAEzD,MAAa,UAA0B,sBAAM,WAAW;CACtD;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
package/src/tour.d.ts ADDED
@@ -0,0 +1,61 @@
1
+ import { PartComponentProps, PortalProps, PositionerOptions } from "./runtime.js";
2
+ import { ReactElement, ReactNode } from "react";
3
+ import { StateOf } from "@kirana-ui/core";
4
+ import { TourProps, TourStep } from "@kirana-ui/core/tour";
5
+ import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
+ type Parts = Vocabulary["tour"];
7
+ /** `Step` is what each step is: a `TourStep` with whatever the page draws it from. */
8
+ export type RootProps<Step extends TourStep = TourStep> = Omit<TourProps<Step>, "id"> & {
9
+ id?: string;
10
+ children?: ReactNode;
11
+ };
12
+ declare function Root<Step extends TourStep = TourStep>({ children, ...props }: RootProps<Step>): ReactElement;
13
+ declare function Portal({ children }: PortalProps): ReactElement | null;
14
+ export type SpotlightProps = PartComponentProps<"div", StateOf<Parts["spotlight"]>>;
15
+ declare const Spotlight: (props: SpotlightProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
16
+ export type PositionerProps = PartComponentProps<"div", StateOf<Parts["positioner"]>, PositionerOptions>;
17
+ declare function Positioner(props: PositionerProps): ReactElement;
18
+ /** What the popup's `children` is told of the step it shows, to draw it. */
19
+ export interface TourShownStep<Step extends TourStep = TourStep> {
20
+ /** The step shown, as the page gave it; `undefined` while none is. */
21
+ step: Step | undefined;
22
+ /** Its index, from 0. */
23
+ index: number;
24
+ /** Its place, from 1: the "2" of "2 of 5". */
25
+ current: number;
26
+ /** How many steps there are: the "5" of "2 of 5". */
27
+ total: number;
28
+ }
29
+ export type PopupProps<Step extends TourStep = TourStep> = PartComponentProps<"div", StateOf<Parts["popup"]>, {
30
+ /** What the popup holds, or a function given the step shown that draws it. */
31
+ children?: ReactNode | ((shown: TourShownStep<Step>) => ReactNode);
32
+ }>;
33
+ /** The step: its children, or what a function of the step shown draws. */
34
+ declare function Popup<Step extends TourStep = TourStep>({ children, ...props }: PopupProps<Step>): ReactElement;
35
+ export type ArrowProps = PartComponentProps<"div", StateOf<Parts["arrow"]>>;
36
+ export type TitleProps = PartComponentProps<"h2", StateOf<Parts["title"]>>;
37
+ export type DescriptionProps = PartComponentProps<"p", StateOf<Parts["description"]>>;
38
+ export type PreviousProps = PartComponentProps<"button", StateOf<Parts["previous"]>>;
39
+ export type NextProps = PartComponentProps<"button", StateOf<Parts["next"]>>;
40
+ export type CloseProps = PartComponentProps<"button", StateOf<Parts["close"]>>;
41
+ declare const Arrow: (props: ArrowProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
42
+ declare const Title: (props: TitleProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
43
+ declare const Description: (props: DescriptionProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
44
+ declare const Previous: (props: PreviousProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
45
+ declare const Next: (props: NextProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
46
+ declare const Close: (props: CloseProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
47
+ export declare const Tour: {
48
+ readonly Root: typeof Root;
49
+ readonly Portal: typeof Portal;
50
+ readonly Spotlight: typeof Spotlight;
51
+ readonly Positioner: typeof Positioner;
52
+ readonly Popup: typeof Popup;
53
+ readonly Arrow: typeof Arrow;
54
+ readonly Title: typeof Title;
55
+ readonly Description: typeof Description;
56
+ readonly Previous: typeof Previous;
57
+ readonly Next: typeof Next;
58
+ readonly Close: typeof Close;
59
+ };
60
+ export type { PortalProps };
61
+ //# sourceMappingURL=tour.d.ts.map
package/src/tour.js ADDED
@@ -0,0 +1,68 @@
1
+ import { DirectionContext } from "./direction-context.js";
2
+ import { Portal as Portal$1, parts, useController, usePart, usePositioning, useSignal } from "./runtime.js";
3
+ import { createContext, useContext } from "react";
4
+ import { within } from "@kirana-ui/core";
5
+ import { jsx } from "react/jsx-runtime";
6
+ import { createTour } from "@kirana-ui/core/tour";
7
+ // src/tour.tsx
8
+ const Context = createContext(null);
9
+ function useTour(part) {
10
+ const controller = useContext(Context);
11
+ if (!controller) throw new Error(`<Tour.${part}> must be inside <Tour.Root>`);
12
+ return controller;
13
+ }
14
+ function Root({ children, ...props }) {
15
+ const direction = useContext(DirectionContext) ?? void 0;
16
+ const controller = useController(within(createTour, { direction }), props);
17
+ return /* @__PURE__ */ jsx(Context.Provider, {
18
+ value: controller,
19
+ children
20
+ });
21
+ }
22
+ function Portal({ children }) {
23
+ return useSignal(useTour("Portal").mounted) ? /* @__PURE__ */ jsx(Portal$1, { children }) : null;
24
+ }
25
+ const Spotlight = (props) => usePart(useTour("Spotlight").spotlight, "div", props);
26
+ function Positioner(props) {
27
+ const controller = useTour("Positioner");
28
+ return usePart(controller.positioner, "div", usePositioning(controller.positioning, props));
29
+ }
30
+ /** The step: its children, or what a function of the step shown draws. */
31
+ function Popup({ children, ...props }) {
32
+ const controller = useTour("Popup");
33
+ const step = useSignal(controller.shown);
34
+ const index = useSignal(controller.index);
35
+ const current = useSignal(controller.current);
36
+ const total = useSignal(controller.total);
37
+ return usePart(controller.popup, "div", {
38
+ ...props,
39
+ children: typeof children === "function" ? children({
40
+ step,
41
+ index,
42
+ current,
43
+ total
44
+ }) : children
45
+ });
46
+ }
47
+ const Arrow = (props) => usePart(useTour("Arrow").arrow, "div", props);
48
+ const Title = (props) => usePart(useTour("Title").title, "h2", props);
49
+ const Description = (props) => usePart(useTour("Description").description, "p", props);
50
+ const Previous = (props) => usePart(useTour("Previous").previous, "button", props);
51
+ const Next = (props) => usePart(useTour("Next").next, "button", props);
52
+ const Close = (props) => usePart(useTour("Close").close, "button", props);
53
+ const Tour = /* @__PURE__ */ parts("Tour", {
54
+ Root,
55
+ Portal,
56
+ Spotlight,
57
+ Positioner,
58
+ Popup,
59
+ Arrow,
60
+ Title,
61
+ Description,
62
+ Previous,
63
+ Next,
64
+ Close
65
+ });
66
+ export { Tour };
67
+
68
+ //# sourceMappingURL=tour.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tour.js","names":["BodyPortal"],"sources":["../../../../packages/react/src/tour.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createTour } from \"@kirana-ui/core/tour\"\nimport type { Tour as Controller, TourProps, TourStep } from \"@kirana-ui/core/tour\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport {\n Portal as BodyPortal,\n parts,\n useController,\n usePart,\n usePositioning,\n useSignal,\n} from \"./runtime.tsx\"\nimport type { PartComponentProps, PortalProps, PositionerOptions } from \"./runtime.tsx\"\n\nexport type { PortalProps }\n\ntype Parts = Vocabulary[\"tour\"]\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useTour(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Tour.${part}> must be inside <Tour.Root>`)\n return controller\n}\n\n/** `Step` is what each step is: a `TourStep` with whatever the page draws it from. */\nexport type RootProps<Step extends TourStep = TourStep> = Omit<TourProps<Step>, \"id\"> & {\n id?: string\n children?: ReactNode\n}\n\nfunction Root<Step extends TourStep = TourStep>({\n children,\n ...props\n}: RootProps<Step>): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const controller = useController(within(createTour<Step>, { direction }), props)\n return <Context.Provider value={controller as Controller}>{children}</Context.Provider>\n}\n\nfunction Portal({ children }: PortalProps): ReactElement | null {\n const mounted = useSignal(useTour(\"Portal\").mounted)\n return mounted ? <BodyPortal>{children}</BodyPortal> : null\n}\n\nexport type SpotlightProps = PartComponentProps<\"div\", StateOf<Parts[\"spotlight\"]>>\n\nconst Spotlight = (props: SpotlightProps) => usePart(useTour(\"Spotlight\").spotlight, \"div\", props)\n\nexport type PositionerProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"positioner\"]>,\n PositionerOptions\n>\n\nfunction Positioner(props: PositionerProps): ReactElement {\n const controller = useTour(\"Positioner\")\n return usePart(controller.positioner, \"div\", usePositioning(controller.positioning, props))\n}\n\n/** What the popup's `children` is told of the step it shows, to draw it. */\nexport interface TourShownStep<Step extends TourStep = TourStep> {\n /** The step shown, as the page gave it; `undefined` while none is. */\n step: Step | undefined\n /** Its index, from 0. */\n index: number\n /** Its place, from 1: the \"2\" of \"2 of 5\". */\n current: number\n /** How many steps there are: the \"5\" of \"2 of 5\". */\n total: number\n}\n\nexport type PopupProps<Step extends TourStep = TourStep> = PartComponentProps<\n \"div\",\n StateOf<Parts[\"popup\"]>,\n {\n /** What the popup holds, or a function given the step shown that draws it. */\n children?: ReactNode | ((shown: TourShownStep<Step>) => ReactNode)\n }\n>\n\n/** The step: its children, or what a function of the step shown draws. */\nfunction Popup<Step extends TourStep = TourStep>({\n children,\n ...props\n}: PopupProps<Step>): ReactElement {\n const controller = useTour(\"Popup\")\n const step = useSignal(controller.shown) as Step | undefined\n const index = useSignal(controller.index)\n const current = useSignal(controller.current)\n const total = useSignal(controller.total)\n return usePart(controller.popup, \"div\", {\n ...props,\n children: typeof children === \"function\" ? children({ step, index, current, total }) : children,\n })\n}\n\nexport type ArrowProps = PartComponentProps<\"div\", StateOf<Parts[\"arrow\"]>>\nexport type TitleProps = PartComponentProps<\"h2\", StateOf<Parts[\"title\"]>>\nexport type DescriptionProps = PartComponentProps<\"p\", StateOf<Parts[\"description\"]>>\nexport type PreviousProps = PartComponentProps<\"button\", StateOf<Parts[\"previous\"]>>\nexport type NextProps = PartComponentProps<\"button\", StateOf<Parts[\"next\"]>>\nexport type CloseProps = PartComponentProps<\"button\", StateOf<Parts[\"close\"]>>\n\nconst Arrow = (props: ArrowProps) => usePart(useTour(\"Arrow\").arrow, \"div\", props)\nconst Title = (props: TitleProps) => usePart(useTour(\"Title\").title, \"h2\", props)\nconst Description = (props: DescriptionProps) =>\n usePart(useTour(\"Description\").description, \"p\", props)\nconst Previous = (props: PreviousProps) => usePart(useTour(\"Previous\").previous, \"button\", props)\nconst Next = (props: NextProps) => usePart(useTour(\"Next\").next, \"button\", props)\nconst Close = (props: CloseProps) => usePart(useTour(\"Close\").close, \"button\", props)\n\nexport const Tour = /* @__PURE__ */ parts(\"Tour\", {\n Root,\n Portal,\n Spotlight,\n Positioner,\n Popup,\n Arrow,\n Title,\n Description,\n Previous,\n Next,\n Close,\n})\n"],"mappings":";;;;;;;AAuBA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,QAAQ,MAA0B;CACzC,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,SAAS,KAAK,6BAA6B;CAC5E,OAAO;AACT;AAQA,SAAS,KAAuC,EAC9C,UACA,GAAG,SAC6B;CAChC,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,aAAa,cAAc,OAAO,YAAkB,EAAE,UAAU,CAAC,GAAG,KAAK;CAC/E,OAAO,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAA2B;CAA2B,CAAA;AACxF;AAEA,SAAS,OAAO,EAAE,YAA8C;CAE9D,OADgB,UAAU,QAAQ,QAAQ,CAAC,CAAC,OAC/B,IAAI,oBAACA,UAAD,EAAa,SAAqB,CAAA,IAAI;AACzD;AAIA,MAAM,aAAa,UAA0B,QAAQ,QAAQ,WAAW,CAAC,CAAC,WAAW,OAAO,KAAK;AAQjG,SAAS,WAAW,OAAsC;CACxD,MAAM,aAAa,QAAQ,YAAY;CACvC,OAAO,QAAQ,WAAW,YAAY,OAAO,eAAe,WAAW,aAAa,KAAK,CAAC;AAC5F;;AAwBA,SAAS,MAAwC,EAC/C,UACA,GAAG,SAC8B;CACjC,MAAM,aAAa,QAAQ,OAAO;CAClC,MAAM,OAAO,UAAU,WAAW,KAAK;CACvC,MAAM,QAAQ,UAAU,WAAW,KAAK;CACxC,MAAM,UAAU,UAAU,WAAW,OAAO;CAC5C,MAAM,QAAQ,UAAU,WAAW,KAAK;CACxC,OAAO,QAAQ,WAAW,OAAO,OAAO;EACtC,GAAG;EACH,UAAU,OAAO,aAAa,aAAa,SAAS;GAAE;GAAM;GAAO;GAAS;EAAM,CAAC,IAAI;CACzF,CAAC;AACH;AASA,MAAM,SAAS,UAAsB,QAAQ,QAAQ,OAAO,CAAC,CAAC,OAAO,OAAO,KAAK;AACjF,MAAM,SAAS,UAAsB,QAAQ,QAAQ,OAAO,CAAC,CAAC,OAAO,MAAM,KAAK;AAChF,MAAM,eAAe,UACnB,QAAQ,QAAQ,aAAa,CAAC,CAAC,aAAa,KAAK,KAAK;AACxD,MAAM,YAAY,UAAyB,QAAQ,QAAQ,UAAU,CAAC,CAAC,UAAU,UAAU,KAAK;AAChG,MAAM,QAAQ,UAAqB,QAAQ,QAAQ,MAAM,CAAC,CAAC,MAAM,UAAU,KAAK;AAChF,MAAM,SAAS,UAAsB,QAAQ,QAAQ,OAAO,CAAC,CAAC,OAAO,UAAU,KAAK;AAEpF,MAAa,OAAuB,sBAAM,QAAQ;CAChD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
package/src/tree.d.ts ADDED
@@ -0,0 +1,45 @@
1
+ import { PartComponentProps } from "./runtime.js";
2
+ import { ReactElement } from "react";
3
+ import { StateOf } from "@kirana-ui/core";
4
+ import { TreeProps } from "@kirana-ui/core/tree";
5
+ import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
+ type Parts = Vocabulary["tree"];
7
+ /** `Value` is what tells a node from the others: the type of the values' entries. */
8
+ export type RootProps<Value = unknown> = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<TreeProps<Value>, "id"> & {
9
+ id?: string;
10
+ }>;
11
+ declare function Root<Value = unknown>({ expandedValue, defaultExpandedValue, onExpandedChange, selectionMode, selectedValue, defaultSelectedValue, onSelectedChange, expandOnClick, id, ...rest }: RootProps<Value>): ReactElement;
12
+ export type ItemProps = PartComponentProps<"div", StateOf<Parts["item"]>, {
13
+ /** What tells this node from the others in the tree: what the values hold. */
14
+ value: unknown;
15
+ /** A branch: it has children, drawn in its `Tree.Group`, and opens and closes. */
16
+ branch?: boolean;
17
+ /** Disables this node: it cannot be chosen, opened or closed, and the keys pass over it. */
18
+ disabled?: boolean;
19
+ /** A branch whose children are being loaded. */
20
+ loading?: boolean;
21
+ /** What typing matches, when it is not the node's text. */
22
+ label?: string;
23
+ }>;
24
+ declare function Item({ value, branch, disabled, loading, label, ...rest }: ItemProps): ReactElement;
25
+ export type ItemRowProps = PartComponentProps<"div", StateOf<Parts["itemRow"]>>;
26
+ export type ItemIndicatorProps = PartComponentProps<"span", StateOf<Parts["itemIndicator"]>>;
27
+ export type ItemTextProps = PartComponentProps<"span", StateOf<Parts["itemText"]>>;
28
+ declare const ItemRow: (props: ItemRowProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
29
+ declare const ItemIndicator: (props: ItemIndicatorProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
30
+ declare const ItemText: (props: ItemTextProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
31
+ export type GroupProps = PartComponentProps<"div", StateOf<Parts["group"]>, {
32
+ /** Keeps the closed group in the page, `hidden`. */
33
+ keepMounted?: boolean;
34
+ }>;
35
+ declare function Group({ keepMounted, ...props }: GroupProps): ReactElement | null;
36
+ export declare const Tree: {
37
+ readonly Root: typeof Root;
38
+ readonly Item: typeof Item;
39
+ readonly ItemRow: typeof ItemRow;
40
+ readonly ItemIndicator: typeof ItemIndicator;
41
+ readonly ItemText: typeof ItemText;
42
+ readonly Group: typeof Group;
43
+ };
44
+ export {};
45
+ //# sourceMappingURL=tree.d.ts.map
package/src/tree.js ADDED
@@ -0,0 +1,93 @@
1
+ import { DirectionContext } from "./direction-context.js";
2
+ import { PartElement, parts, useController, useMount, useOptions, usePart, useSignal } from "./runtime.js";
3
+ import { createContext, useContext, useMemo } from "react";
4
+ import { defined, within } from "@kirana-ui/core";
5
+ import { jsx } from "react/jsx-runtime";
6
+ import { createTree } from "@kirana-ui/core/tree";
7
+ // src/tree.tsx
8
+ const Context = createContext(null);
9
+ const ItemContext = createContext(null);
10
+ const LevelContext = createContext(0);
11
+ function useTree(part) {
12
+ const controller = useContext(Context);
13
+ if (!controller) throw new Error(`<Tree.${part}> must be inside <Tree.Root>`);
14
+ return controller;
15
+ }
16
+ function useItem(part) {
17
+ const item = useContext(ItemContext);
18
+ if (!item) throw new Error(`<Tree.${part}> must be inside <Tree.Item>`);
19
+ return item;
20
+ }
21
+ function Root({ expandedValue, defaultExpandedValue, onExpandedChange, selectionMode, selectedValue, defaultSelectedValue, onSelectedChange, expandOnClick, id, ...rest }) {
22
+ const direction = useContext(DirectionContext) ?? void 0;
23
+ const create = within(createTree, { direction });
24
+ const controller = useController(create, {
25
+ expandedValue,
26
+ defaultExpandedValue,
27
+ onExpandedChange,
28
+ selectionMode,
29
+ selectedValue,
30
+ defaultSelectedValue,
31
+ onSelectedChange,
32
+ expandOnClick,
33
+ id
34
+ });
35
+ return /* @__PURE__ */ jsx(Context.Provider, {
36
+ value: controller,
37
+ children: /* @__PURE__ */ jsx(LevelContext.Provider, {
38
+ value: 0,
39
+ children: usePart(controller.root, "div", rest)
40
+ })
41
+ });
42
+ }
43
+ function Item({ value, branch, disabled, loading, label, ...rest }) {
44
+ const controller = useTree("Item");
45
+ const level = useContext(LevelContext) + 1;
46
+ const options = useOptions({
47
+ branch,
48
+ disabled,
49
+ loading,
50
+ label,
51
+ level
52
+ });
53
+ const item = useMemo(() => controller.item(value, () => defined(options.get())), [
54
+ controller,
55
+ value,
56
+ options
57
+ ]);
58
+ useMount(item);
59
+ return /* @__PURE__ */ jsx(ItemContext.Provider, {
60
+ value: item,
61
+ children: /* @__PURE__ */ jsx(LevelContext.Provider, {
62
+ value: level,
63
+ children: /* @__PURE__ */ jsx(PartElement, {
64
+ of: item.root,
65
+ tag: "div",
66
+ ...rest
67
+ })
68
+ })
69
+ });
70
+ }
71
+ const ItemRow = (props) => usePart(useItem("ItemRow").row, "div", props);
72
+ const ItemIndicator = (props) => usePart(useItem("ItemIndicator").indicator, "span", props);
73
+ const ItemText = (props) => usePart(useItem("ItemText").text, "span", props);
74
+ function Group({ keepMounted, ...props }) {
75
+ const item = useItem("Group");
76
+ if (!useSignal(item.mounted) && !keepMounted) return null;
77
+ return /* @__PURE__ */ jsx(PartElement, {
78
+ of: item.group,
79
+ tag: "div",
80
+ ...props
81
+ });
82
+ }
83
+ const Tree = /* @__PURE__ */ parts("Tree", {
84
+ Root,
85
+ Item,
86
+ ItemRow,
87
+ ItemIndicator,
88
+ ItemText,
89
+ Group
90
+ });
91
+ export { Tree };
92
+
93
+ //# sourceMappingURL=tree.js.map