@ui-sdk/react 0.0.0-stage → 0.1.0-beta.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 (247) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +10 -2
  3. package/dist/accordion.d.ts +331 -0
  4. package/dist/accordion.js +25 -0
  5. package/dist/agent.d.ts +2 -0
  6. package/dist/agent.js +8 -0
  7. package/dist/alert-dialog.d.ts +56 -0
  8. package/dist/alert-dialog.js +45 -0
  9. package/dist/async-options.d.ts +22 -0
  10. package/dist/async-options.js +56 -0
  11. package/dist/autocomplete.d.ts +102 -0
  12. package/dist/autocomplete.js +195 -0
  13. package/dist/avatar.d.ts +301 -0
  14. package/dist/avatar.js +17 -0
  15. package/dist/button.d.ts +21 -0
  16. package/dist/button.js +45 -0
  17. package/dist/calendar-context.d.ts +10 -0
  18. package/dist/calendar-context.js +9 -0
  19. package/dist/calendar.d.ts +80 -0
  20. package/dist/calendar.js +257 -0
  21. package/dist/carousel.d.ts +52 -0
  22. package/dist/carousel.js +151 -0
  23. package/dist/checkbox.d.ts +24 -0
  24. package/dist/checkbox.js +98 -0
  25. package/dist/children.d.ts +38 -0
  26. package/dist/children.js +63 -0
  27. package/dist/collapsible.d.ts +302 -0
  28. package/dist/collapsible.js +19 -0
  29. package/dist/color-picker.d.ts +72 -0
  30. package/dist/color-picker.js +133 -0
  31. package/dist/color.d.ts +2 -0
  32. package/dist/color.js +22 -0
  33. package/dist/combobox.d.ts +152 -0
  34. package/dist/combobox.js +338 -0
  35. package/dist/command.d.ts +88 -0
  36. package/dist/command.js +233 -0
  37. package/dist/controller-target.d.ts +3 -0
  38. package/dist/controller-target.js +59 -0
  39. package/dist/date-input.d.ts +19 -0
  40. package/dist/date-input.js +58 -0
  41. package/dist/date-picker.d.ts +47 -0
  42. package/dist/date-picker.js +310 -0
  43. package/dist/date.d.ts +2 -0
  44. package/dist/date.js +60 -0
  45. package/dist/dialog-parts.d.ts +23 -0
  46. package/dist/dialog-parts.js +142 -0
  47. package/dist/dialog.d.ts +57 -0
  48. package/dist/dialog.js +32 -0
  49. package/dist/drawer.d.ts +70 -0
  50. package/dist/drawer.js +158 -0
  51. package/dist/editor-context.d.ts +4 -0
  52. package/dist/editor-context.js +9 -0
  53. package/dist/field-context.d.ts +47 -0
  54. package/dist/field-context.js +87 -0
  55. package/dist/field.d.ts +49 -0
  56. package/dist/field.js +169 -0
  57. package/dist/file-input.d.ts +46 -0
  58. package/dist/file-input.js +170 -0
  59. package/dist/form-inputs.d.ts +5 -0
  60. package/dist/form-inputs.js +22 -0
  61. package/dist/gesture.d.ts +1 -0
  62. package/dist/gesture.js +16 -0
  63. package/dist/history.d.ts +2 -0
  64. package/dist/history.js +12 -0
  65. package/dist/hover-card.d.ts +33 -0
  66. package/dist/hover-card.js +84 -0
  67. package/dist/image-cropper.d.ts +333 -0
  68. package/dist/image-cropper.js +37 -0
  69. package/dist/image.d.ts +2 -0
  70. package/dist/image.js +6 -0
  71. package/dist/input.d.ts +22 -0
  72. package/dist/input.js +51 -0
  73. package/dist/label.d.ts +294 -0
  74. package/dist/label.js +9 -0
  75. package/dist/list-items.d.ts +15 -0
  76. package/dist/list-items.js +39 -0
  77. package/dist/list-text.d.ts +4 -0
  78. package/dist/list-text.js +15 -0
  79. package/dist/listbox.d.ts +56 -0
  80. package/dist/listbox.js +122 -0
  81. package/dist/menu.d.ts +116 -0
  82. package/dist/menu.js +426 -0
  83. package/dist/menubar-context.d.ts +4 -0
  84. package/dist/menubar-context.js +7 -0
  85. package/dist/menubar.d.ts +11 -0
  86. package/dist/menubar.js +32 -0
  87. package/dist/meter.d.ts +312 -0
  88. package/dist/meter.js +30 -0
  89. package/dist/navigation-menu.d.ts +61 -0
  90. package/dist/navigation-menu.js +169 -0
  91. package/dist/number-input.d.ts +44 -0
  92. package/dist/number-input.js +185 -0
  93. package/dist/number.d.ts +2 -0
  94. package/dist/number.js +40 -0
  95. package/dist/observe.d.ts +2 -0
  96. package/dist/observe.js +8 -0
  97. package/dist/otp-input.d.ts +29 -0
  98. package/dist/otp-input.js +94 -0
  99. package/dist/overlays.d.ts +26 -0
  100. package/dist/overlays.js +82 -0
  101. package/dist/pagination.d.ts +336 -0
  102. package/dist/pagination.js +71 -0
  103. package/dist/password-input.d.ts +23 -0
  104. package/dist/password-input.js +65 -0
  105. package/dist/popover.d.ts +54 -0
  106. package/dist/popover.js +151 -0
  107. package/dist/popup.d.ts +41 -0
  108. package/dist/popup.js +180 -0
  109. package/dist/preferences.d.ts +35 -0
  110. package/dist/preferences.js +93 -0
  111. package/dist/primitive.d.ts +2 -0
  112. package/dist/primitive.js +14 -0
  113. package/dist/progress.d.ts +312 -0
  114. package/dist/progress.js +30 -0
  115. package/dist/radio.d.ts +22 -0
  116. package/dist/radio.js +86 -0
  117. package/dist/rating.d.ts +20 -0
  118. package/dist/rating.js +94 -0
  119. package/dist/render-element.d.ts +35 -0
  120. package/dist/render-element.js +103 -0
  121. package/dist/resizable.d.ts +302 -0
  122. package/dist/resizable.js +23 -0
  123. package/dist/scroll-area.d.ts +324 -0
  124. package/dist/scroll-area.js +49 -0
  125. package/dist/segmented-control.d.ts +24 -0
  126. package/dist/segmented-control.js +78 -0
  127. package/dist/segmented-input.d.ts +15 -0
  128. package/dist/segmented-input.js +48 -0
  129. package/dist/select.d.ts +125 -0
  130. package/dist/select.js +330 -0
  131. package/dist/separator.d.ts +290 -0
  132. package/dist/separator.js +9 -0
  133. package/dist/shortcuts.d.ts +32 -0
  134. package/dist/shortcuts.js +61 -0
  135. package/dist/slider.d.ts +38 -0
  136. package/dist/slider.js +163 -0
  137. package/dist/switch.d.ts +15 -0
  138. package/dist/switch.js +39 -0
  139. package/dist/tabs.d.ts +331 -0
  140. package/dist/tabs.js +28 -0
  141. package/dist/text-control.d.ts +22 -0
  142. package/dist/text-control.js +24 -0
  143. package/dist/text-match.d.ts +2 -0
  144. package/dist/text-match.js +8 -0
  145. package/dist/textarea.d.ts +10 -0
  146. package/dist/textarea.js +48 -0
  147. package/dist/time-input.d.ts +19 -0
  148. package/dist/time-input.js +63 -0
  149. package/dist/timeline.d.ts +327 -0
  150. package/dist/timeline.js +31 -0
  151. package/dist/toast-parts.d.ts +63 -0
  152. package/dist/toast-parts.js +144 -0
  153. package/dist/toast.d.ts +2 -0
  154. package/dist/toast.js +22 -0
  155. package/dist/toggle.d.ts +23 -0
  156. package/dist/toggle.js +76 -0
  157. package/dist/token-input.d.ts +35 -0
  158. package/dist/token-input.js +100 -0
  159. package/dist/toolbar-context.d.ts +6 -0
  160. package/dist/toolbar-context.js +16 -0
  161. package/dist/toolbar.d.ts +38 -0
  162. package/dist/toolbar.js +63 -0
  163. package/dist/tooltip.d.ts +39 -0
  164. package/dist/tooltip.js +108 -0
  165. package/dist/tree.d.ts +51 -0
  166. package/dist/tree.js +150 -0
  167. package/dist/trigger-menu.d.ts +83 -0
  168. package/dist/trigger-menu.js +167 -0
  169. package/dist/use-primitive.d.ts +178 -0
  170. package/dist/use-primitive.js +674 -0
  171. package/dist/waterfall.d.ts +80 -0
  172. package/dist/waterfall.js +108 -0
  173. package/docs/README.md +89 -0
  174. package/docs/agents.md +1523 -0
  175. package/docs/components/accordion.md +1391 -0
  176. package/docs/components/alert-dialog.md +850 -0
  177. package/docs/components/autocomplete.md +1963 -0
  178. package/docs/components/avatar.md +252 -0
  179. package/docs/components/button.md +444 -0
  180. package/docs/components/calendar.md +1687 -0
  181. package/docs/components/carousel.md +1244 -0
  182. package/docs/components/checkbox.md +1069 -0
  183. package/docs/components/collapsible.md +567 -0
  184. package/docs/components/color-picker.md +736 -0
  185. package/docs/components/combobox.md +3647 -0
  186. package/docs/components/command.md +1573 -0
  187. package/docs/components/date-input.md +608 -0
  188. package/docs/components/date-picker.md +1266 -0
  189. package/docs/components/dialog.md +1469 -0
  190. package/docs/components/drawer.md +1197 -0
  191. package/docs/components/field.md +549 -0
  192. package/docs/components/file-input.md +609 -0
  193. package/docs/components/hover-card.md +514 -0
  194. package/docs/components/image-cropper.md +579 -0
  195. package/docs/components/input.md +301 -0
  196. package/docs/components/label.md +217 -0
  197. package/docs/components/listbox.md +1130 -0
  198. package/docs/components/menu.md +1286 -0
  199. package/docs/components/menubar.md +455 -0
  200. package/docs/components/meter.md +304 -0
  201. package/docs/components/navigation-menu.md +1581 -0
  202. package/docs/components/number-input.md +1086 -0
  203. package/docs/components/otp-input.md +565 -0
  204. package/docs/components/pagination.md +648 -0
  205. package/docs/components/password-input.md +737 -0
  206. package/docs/components/popover.md +1552 -0
  207. package/docs/components/preferences.md +220 -0
  208. package/docs/components/progress.md +443 -0
  209. package/docs/components/radio.md +846 -0
  210. package/docs/components/rating.md +458 -0
  211. package/docs/components/resizable.md +982 -0
  212. package/docs/components/scroll-area.md +980 -0
  213. package/docs/components/segmented-control.md +465 -0
  214. package/docs/components/select.md +2133 -0
  215. package/docs/components/separator.md +243 -0
  216. package/docs/components/slider.md +1169 -0
  217. package/docs/components/switch.md +613 -0
  218. package/docs/components/tabs.md +1014 -0
  219. package/docs/components/textarea.md +318 -0
  220. package/docs/components/time-input.md +231 -0
  221. package/docs/components/timeline.md +677 -0
  222. package/docs/components/toast.md +1395 -0
  223. package/docs/components/toggle.md +541 -0
  224. package/docs/components/token-input.md +1007 -0
  225. package/docs/components/toolbar.md +787 -0
  226. package/docs/components/tooltip.md +884 -0
  227. package/docs/components/tree.md +1346 -0
  228. package/docs/components/trigger-menu.md +1257 -0
  229. package/docs/components/waterfall.md +754 -0
  230. package/docs/controllers.md +89 -0
  231. package/docs/core.md +8027 -0
  232. package/docs/custom-parts.md +120 -0
  233. package/docs/first-component.md +83 -0
  234. package/docs/forms.md +148 -0
  235. package/docs/hooks/async-options.md +366 -0
  236. package/docs/hooks/shortcuts.md +221 -0
  237. package/docs/installation.md +45 -0
  238. package/docs/introduction.md +32 -0
  239. package/docs/lists-and-menus.md +170 -0
  240. package/docs/llms.txt +1844 -0
  241. package/docs/parts-and-composition.md +93 -0
  242. package/docs/popups.md +117 -0
  243. package/docs/rendering.md +121 -0
  244. package/docs/server-rendering.md +253 -0
  245. package/docs/state-and-events.md +105 -0
  246. package/docs/styling-and-animation.md +176 -0
  247. package/package.json +333 -3
@@ -0,0 +1,257 @@
1
+ "use client";
2
+ // src/calendar.tsx
3
+ import {
4
+ calendar as calendarPrimitive
5
+ } from "@ui-sdk/core/calendar";
6
+ import * as React from "react";
7
+ import { CalendarContext, GridContext } from "./calendar-context.js";
8
+ import {
9
+ renderElement,
10
+ slotIn,
11
+ usePart,
12
+ usePrimitive
13
+ } from "./use-primitive.js";
14
+ import { createCalendarController } from "@ui-sdk/core/calendar";
15
+ import { Fragment as Fragment2, jsx, jsxs } from "react/jsx-runtime";
16
+ function useCalendar(part) {
17
+ const context = React.useContext(CalendarContext);
18
+ if (!context) {
19
+ throw new Error(
20
+ `${part} must be used inside <Calendar> or <DatePickerContent>.`
21
+ );
22
+ }
23
+ return context;
24
+ }
25
+ function useGrid(part) {
26
+ const context = React.useContext(GridContext);
27
+ if (!context) {
28
+ throw new Error(`${part} must be used inside <CalendarGrid>.`);
29
+ }
30
+ return context;
31
+ }
32
+ function Calendar({
33
+ mode,
34
+ value,
35
+ defaultValue,
36
+ onValueChange,
37
+ month,
38
+ defaultMonth,
39
+ onMonthChange,
40
+ min,
41
+ max,
42
+ unavailable,
43
+ disabled,
44
+ readOnly,
45
+ deselectable,
46
+ onFocusedChange,
47
+ onAnchorChange,
48
+ months,
49
+ pageBy,
50
+ locale,
51
+ weekStartsOn,
52
+ weekdayFormat,
53
+ monthFormat,
54
+ fixedWeeks,
55
+ showOutsideDays,
56
+ today,
57
+ timeZone,
58
+ minDays,
59
+ maxDays,
60
+ allowUnavailable,
61
+ controller,
62
+ debug,
63
+ children,
64
+ ...props
65
+ }) {
66
+ const calendar = usePrimitive(calendarPrimitive, {
67
+ mode,
68
+ value,
69
+ defaultValue,
70
+ onValueChange,
71
+ month,
72
+ defaultMonth,
73
+ onMonthChange,
74
+ min,
75
+ max,
76
+ unavailable,
77
+ disabled,
78
+ readOnly,
79
+ deselectable,
80
+ onFocusedChange,
81
+ onAnchorChange,
82
+ months,
83
+ pageBy,
84
+ locale,
85
+ weekStartsOn,
86
+ weekdayFormat,
87
+ monthFormat,
88
+ fixedWeeks,
89
+ showOutsideDays,
90
+ today,
91
+ timeZone,
92
+ minDays,
93
+ maxDays,
94
+ allowUnavailable,
95
+ controller,
96
+ debug
97
+ });
98
+ const content = children === void 0 ? /* @__PURE__ */ jsxs(Fragment2, { children: [
99
+ /* @__PURE__ */ jsxs("div", { children: [
100
+ /* @__PURE__ */ jsx(CalendarPrevious, {}),
101
+ /* @__PURE__ */ jsx(CalendarHeading, {}),
102
+ /* @__PURE__ */ jsx(CalendarNext, {})
103
+ ] }),
104
+ Array.from(
105
+ { length: Math.max(1, Math.floor(months ?? 1) || 1) },
106
+ (_, offset) => /* @__PURE__ */ jsx(CalendarGrid, { offset }, offset)
107
+ )
108
+ ] }) : children;
109
+ return (
110
+ // In a context of its own, since a Date Picker renders the same parts over its own primitive.
111
+ /* @__PURE__ */ jsx(CalendarContext.Provider, { value: calendar, children: usePart(calendar, "root", {}, { ...props, children: content }) })
112
+ );
113
+ }
114
+ function CalendarHeading({
115
+ children = label,
116
+ ...props
117
+ }) {
118
+ return usePart(
119
+ useCalendar("CalendarHeading"),
120
+ "heading",
121
+ {},
122
+ { ...props, children },
123
+ "h2"
124
+ );
125
+ }
126
+ var label = (state) => state.label;
127
+ function useSelect(name, part, { render, children = options, ...props }) {
128
+ const select = ({ value, ...attrs }, state) => renderElement("select", { ...attrs, defaultValue: value }, render, state);
129
+ return usePart(
130
+ useCalendar(part),
131
+ name,
132
+ {},
133
+ { ...props, children, render: select },
134
+ "select"
135
+ );
136
+ }
137
+ var options = (state) => state.options.map((option) => /* @__PURE__ */ jsx("option", { value: option.value, disabled: option.disabled, children: option.label }, option.value));
138
+ function CalendarMonthSelect(props) {
139
+ return useSelect("month-select", "CalendarMonthSelect", props);
140
+ }
141
+ function CalendarYearSelect(props) {
142
+ return useSelect("year-select", "CalendarYearSelect", props);
143
+ }
144
+ function useStep(name, part, { children, ...props }) {
145
+ const content = children ?? (name === "previous" ? "\u2039" : "\u203A");
146
+ return usePart(
147
+ useCalendar(part),
148
+ name,
149
+ {},
150
+ { ...props, children: content },
151
+ "button"
152
+ );
153
+ }
154
+ function CalendarPrevious(props) {
155
+ return useStep("previous", "CalendarPrevious", props);
156
+ }
157
+ function CalendarNext(props) {
158
+ return useStep("next", "CalendarNext", props);
159
+ }
160
+ function CalendarGrid({
161
+ offset = 0,
162
+ children = defaultGrid,
163
+ ...props
164
+ }) {
165
+ const content = (state) => /* @__PURE__ */ jsx(GridScope, { offset, state, children: typeof children === "function" ? children(state) : children });
166
+ return usePart(
167
+ useCalendar("CalendarGrid"),
168
+ "grid",
169
+ { offset, id: String(offset) },
170
+ { ...props, children: content },
171
+ "table"
172
+ );
173
+ }
174
+ var defaultGrid = /* @__PURE__ */ jsxs(Fragment2, { children: [
175
+ /* @__PURE__ */ jsx(CalendarWeekdays, {}),
176
+ /* @__PURE__ */ jsx(CalendarWeeks, {})
177
+ ] });
178
+ function GridScope({
179
+ offset,
180
+ state,
181
+ children
182
+ }) {
183
+ const grid = React.useMemo(
184
+ () => ({ offset, state }),
185
+ [offset, state.month, state.weeks]
186
+ );
187
+ return /* @__PURE__ */ jsx(GridContext.Provider, { value: grid, children });
188
+ }
189
+ function CalendarWeekdays({
190
+ children,
191
+ ...props
192
+ }) {
193
+ const calendar = useCalendar("CalendarWeekdays");
194
+ const { offset, state } = useGrid("CalendarWeekdays");
195
+ return /* @__PURE__ */ jsx("thead", { ...props, children: /* @__PURE__ */ jsx("tr", { ...slotIn(calendar, "weekdays", { id: String(offset) }), children: state.weekdays.map((weekday, index) => /* @__PURE__ */ jsx(React.Fragment, { children: children ? children(index) : /* @__PURE__ */ jsx(CalendarWeekday, { index }) }, weekday)) }) });
196
+ }
197
+ function CalendarWeekday({
198
+ index,
199
+ children = label,
200
+ ...props
201
+ }) {
202
+ const { offset } = useGrid("CalendarWeekday");
203
+ const part = { index, id: `${offset}-${index}` };
204
+ return usePart(
205
+ useCalendar("CalendarWeekday"),
206
+ "weekday",
207
+ part,
208
+ { scope: "col", ...props, children },
209
+ "th"
210
+ );
211
+ }
212
+ function CalendarWeeks({
213
+ children,
214
+ ...props
215
+ }) {
216
+ const calendar = useCalendar("CalendarWeeks");
217
+ const { offset, state } = useGrid("CalendarWeeks");
218
+ return /* @__PURE__ */ jsx("tbody", { ...props, children: state.weeks.map((week, index) => /* @__PURE__ */ jsx(
219
+ "tr",
220
+ {
221
+ ...slotIn(calendar, "week", { id: `${offset}-${index}` }),
222
+ children: week.map(
223
+ (cell) => cell.hidden ? /* @__PURE__ */ jsx("td", {}, cell.date) : /* @__PURE__ */ jsx(React.Fragment, { children: children ? children(cell) : /* @__PURE__ */ jsx(CalendarDay, { value: cell.date }) }, cell.date)
224
+ )
225
+ },
226
+ week[0].date
227
+ )) });
228
+ }
229
+ function CalendarDay({
230
+ value,
231
+ children = label,
232
+ ...props
233
+ }) {
234
+ const grid = React.useContext(GridContext);
235
+ const part = { value, offset: grid?.offset ?? 0 };
236
+ return usePart(
237
+ useCalendar("CalendarDay"),
238
+ "day",
239
+ part,
240
+ { ...props, children },
241
+ "td"
242
+ );
243
+ }
244
+ export {
245
+ Calendar,
246
+ CalendarDay,
247
+ CalendarGrid,
248
+ CalendarHeading,
249
+ CalendarMonthSelect,
250
+ CalendarNext,
251
+ CalendarPrevious,
252
+ CalendarWeekday,
253
+ CalendarWeekdays,
254
+ CalendarWeeks,
255
+ CalendarYearSelect,
256
+ createCalendarController
257
+ };
@@ -0,0 +1,52 @@
1
+ import { type CarouselControlProps, type CarouselIndicatorGroupState, type CarouselIndicatorProps, type CarouselIndicatorState, type CarouselOptions, type CarouselPlayToggleState, type CarouselState, type CarouselStepState } from "@ui-sdk/core/carousel";
2
+ import { type PartProps } from "./use-primitive.js";
3
+ /**
4
+ * A region of slides that scroll a page at a time. Name it with `aria-label`.
5
+ * @stable
6
+ */
7
+ declare function Carousel({ page, defaultPage, onPageChange, onPageChangeComplete, playing, defaultPlaying, onPlayingChange, interval, orientation, align, slidesPerPage, loop, skipSnaps, dragFree, drag, controller, debug, ...props }: CarouselOptions & PartProps<"div", CarouselState>): import("react").JSX.Element | null;
8
+ /**
9
+ * The scrolling window onto the slides. Touch, wheels and keys scroll it natively.
10
+ * @stable
11
+ */
12
+ declare const CarouselViewport: import("./use-primitive.js").PartComponent<import("@ui-sdk/core/carousel").CarouselPrimitive, "viewport", "div">;
13
+ /**
14
+ * The row, or column, of slides inside the viewport.
15
+ * @stable
16
+ */
17
+ declare const CarouselContent: import("./use-primitive.js").PartComponent<import("@ui-sdk/core/carousel").CarouselPrimitive, "content", "div">;
18
+ /**
19
+ * One slide. It's labelled "1 of 5" unless it has an `aria-label`, and inert while out of view.
20
+ * @stable
21
+ */
22
+ declare const CarouselItem: import("./use-primitive.js").PartComponent<import("@ui-sdk/core/carousel").CarouselPrimitive, "item", "div">;
23
+ type StepProps = Omit<PartProps<"button", CarouselStepState>, "value" | "defaultValue" | "onChange"> & CarouselControlProps;
24
+ /**
25
+ * Goes to the previous page. `aria-disabled` on the first page without `loop`, where it stays focusable.
26
+ * @stable
27
+ */
28
+ declare const CarouselPrevious: ({ controller, ...props }: StepProps) => import("react").JSX.Element;
29
+ /**
30
+ * Goes to the next page. `aria-disabled` on the last page without `loop`, where it stays focusable.
31
+ * @stable
32
+ */
33
+ declare const CarouselNext: ({ controller, ...props }: StepProps) => import("react").JSX.Element;
34
+ /**
35
+ * The indicators, as a tablist with one tab stop. Its children can be a function of the state.
36
+ * @stable
37
+ */
38
+ declare function CarouselIndicatorGroup({ controller, ...props }: PartProps<"div", CarouselIndicatorGroupState> & CarouselControlProps): import("react").JSX.Element;
39
+ type IndicatorProps = Omit<PartProps<"button", CarouselIndicatorState>, "value" | "defaultValue" | "onChange"> & CarouselIndicatorProps;
40
+ /**
41
+ * Shows a page and goes to it. Indicators past the page count hide themselves.
42
+ * @stable
43
+ */
44
+ declare function CarouselIndicator(props: IndicatorProps): import("react").JSX.Element;
45
+ /**
46
+ * Starts and stops rotation. Label it from `playing` in its state, as the carousel pattern asks.
47
+ * @stable
48
+ */
49
+ declare function CarouselPlayToggle({ controller, ...props }: Omit<PartProps<"button", CarouselPlayToggleState>, "value" | "defaultValue" | "onChange"> & CarouselControlProps): import("react").JSX.Element;
50
+ export { createCarouselController } from "@ui-sdk/core/carousel";
51
+ export type { CarouselAlign, CarouselApi, CarouselContentState, CarouselControlProps, CarouselController, CarouselIndicatorGroupState, CarouselIndicatorProps, CarouselIndicatorState, CarouselItemState, CarouselNextState, CarouselOptions, CarouselOrientation, CarouselPageChangeReason, CarouselPageOptions, CarouselPlayToggleState, CarouselPlayingChangeReason, CarouselPlayingOptions, CarouselPreviousState, CarouselPrimitive, CarouselSlidesPerPage, CarouselState, CarouselStepState, CarouselViewportState, } from "@ui-sdk/core/carousel";
52
+ export { Carousel, CarouselContent, CarouselIndicator, CarouselIndicatorGroup, CarouselItem, CarouselNext, CarouselPlayToggle, CarouselPrevious, CarouselViewport, };
@@ -0,0 +1,151 @@
1
+ "use client";
2
+ // src/carousel.tsx
3
+ import {
4
+ carousel
5
+ } from "@ui-sdk/core/carousel";
6
+ import { useControllerEntry } from "./controller-target.js";
7
+ import { Connected } from "./popup.js";
8
+ import {
9
+ createParts,
10
+ renderElement,
11
+ useNearest,
12
+ usePart,
13
+ usePrimitive
14
+ } from "./use-primitive.js";
15
+ import { createCarouselController } from "@ui-sdk/core/carousel";
16
+ import { jsx } from "react/jsx-runtime";
17
+ var parts = createParts(carousel, {
18
+ viewport: "div",
19
+ content: "div",
20
+ item: "div",
21
+ previous: "button",
22
+ next: "button",
23
+ "indicator-group": "div",
24
+ indicator: "button",
25
+ "play-toggle": "button"
26
+ });
27
+ function Carousel({
28
+ page,
29
+ defaultPage,
30
+ onPageChange,
31
+ onPageChangeComplete,
32
+ playing,
33
+ defaultPlaying,
34
+ onPlayingChange,
35
+ interval,
36
+ orientation,
37
+ align,
38
+ slidesPerPage,
39
+ loop,
40
+ skipSnaps,
41
+ dragFree,
42
+ drag,
43
+ controller,
44
+ debug,
45
+ ...props
46
+ }) {
47
+ const handle = usePrimitive(carousel, {
48
+ page,
49
+ defaultPage,
50
+ onPageChange,
51
+ onPageChangeComplete,
52
+ playing,
53
+ defaultPlaying,
54
+ onPlayingChange,
55
+ interval,
56
+ orientation,
57
+ align,
58
+ slidesPerPage,
59
+ loop,
60
+ skipSnaps,
61
+ dragFree,
62
+ drag,
63
+ controller,
64
+ debug
65
+ });
66
+ useControllerEntry(controller, handle);
67
+ return usePart(handle, "root", {}, props);
68
+ }
69
+ var CarouselViewport = parts.Viewport;
70
+ var CarouselContent = parts.Content;
71
+ var CarouselItem = parts.Item;
72
+ var unconnected = { disabled: true };
73
+ function connectedStep(Step) {
74
+ return function CarouselStep({ controller, ...props }) {
75
+ const { render, ...rest } = props;
76
+ return /* @__PURE__ */ jsx(
77
+ Connected,
78
+ {
79
+ primitive: carousel,
80
+ controller,
81
+ fallback: () => renderElement(
82
+ "button",
83
+ { type: "button", ...rest },
84
+ render,
85
+ unconnected
86
+ ),
87
+ children: /* @__PURE__ */ jsx(Step, { ...props })
88
+ }
89
+ );
90
+ };
91
+ }
92
+ var CarouselPrevious = connectedStep(parts.Previous);
93
+ var CarouselNext = connectedStep(parts.Next);
94
+ function CarouselIndicatorGroup({
95
+ controller,
96
+ ...props
97
+ }) {
98
+ const { render, ...rest } = props;
99
+ return /* @__PURE__ */ jsx(
100
+ Connected,
101
+ {
102
+ primitive: carousel,
103
+ controller,
104
+ fallback: () => renderElement("div", rest, render, { page: 1, pageCount: null }),
105
+ children: /* @__PURE__ */ jsx(parts.IndicatorGroup, { ...props })
106
+ }
107
+ );
108
+ }
109
+ function CarouselIndicator(props) {
110
+ if (!useNearest(carousel)) {
111
+ const { page, render, ...rest } = props;
112
+ return renderElement("button", { type: "button", ...rest }, render, {
113
+ page: page ?? 0,
114
+ selected: false
115
+ });
116
+ }
117
+ return /* @__PURE__ */ jsx(parts.Indicator, { ...props });
118
+ }
119
+ function CarouselPlayToggle({
120
+ controller,
121
+ ...props
122
+ }) {
123
+ const { render, ...rest } = props;
124
+ const unconnectedState = { playing: false, paused: false };
125
+ return /* @__PURE__ */ jsx(
126
+ Connected,
127
+ {
128
+ primitive: carousel,
129
+ controller,
130
+ fallback: () => renderElement(
131
+ "button",
132
+ { type: "button", ...rest },
133
+ render,
134
+ unconnectedState
135
+ ),
136
+ children: /* @__PURE__ */ jsx(parts.PlayToggle, { ...props })
137
+ }
138
+ );
139
+ }
140
+ export {
141
+ Carousel,
142
+ CarouselContent,
143
+ CarouselIndicator,
144
+ CarouselIndicatorGroup,
145
+ CarouselItem,
146
+ CarouselNext,
147
+ CarouselPlayToggle,
148
+ CarouselPrevious,
149
+ CarouselViewport,
150
+ createCarouselController
151
+ };
@@ -0,0 +1,24 @@
1
+ import { type CheckboxGroupOptions, type CheckboxGroupState, type CheckboxOptions, type CheckboxState } from "@ui-sdk/core/checkbox";
2
+ import * as React from "react";
3
+ import { type ButtonControlProps } from "./field-context.js";
4
+ import { type PartProps } from "./use-primitive.js";
5
+ /**
6
+ * The control and the hidden native input that takes part in the form.
7
+ * @stable
8
+ */
9
+ declare function Checkbox({ disabled, name, render, ...props }: Omit<CheckboxOptions, "group"> & ButtonControlProps<CheckboxState>): React.JSX.Element;
10
+ /**
11
+ * The check inside the checkbox. Rendered while it's checked or indeterminate, or always with `keepMounted`.
12
+ * @stable
13
+ */
14
+ declare const CheckboxIndicator: import("./use-primitive.js").PartComponent<import("@ui-sdk/core/checkbox").CheckboxPrimitive, "indicator", "span">;
15
+ /**
16
+ * Checkboxes that share a name and a list of checked values. The group, not
17
+ * each checkbox, sits in a field.
18
+ * `T` is inferred from `value`, `defaultValue` or `onValueChange`.
19
+ * @stable
20
+ */
21
+ declare function CheckboxGroup<T extends string = string>({ value, defaultValue, onValueChange, allValues, readOnly, disabled, required, name, form, controller, debug, render, ...props }: CheckboxGroupOptions<T> & Omit<PartProps<"div", CheckboxGroupState>, "defaultValue" | "onChange" | "onSelect">): React.JSX.Element;
22
+ export { createCheckboxController, createCheckboxGroupController, } from "@ui-sdk/core/checkbox";
23
+ export type { CheckboxApi, CheckboxChangeOptions, CheckboxCheckedChangeReason, CheckboxController, CheckboxGroupApi, CheckboxGroupChangeOptions, CheckboxGroupController, CheckboxGroupOptions, CheckboxGroupPrimitive, CheckboxGroupState, CheckboxGroupValueChangeReason, CheckboxIndicatorProps, CheckboxIndicatorState, CheckboxOptions, CheckboxPrimitive, CheckboxState, CheckedState, } from "@ui-sdk/core/checkbox";
24
+ export { Checkbox, CheckboxGroup, CheckboxIndicator };
@@ -0,0 +1,98 @@
1
+ "use client";
2
+ // src/checkbox.tsx
3
+ import {
4
+ checkbox,
5
+ checkboxGroup
6
+ } from "@ui-sdk/core/checkbox";
7
+ import * as React from "react";
8
+ import {
9
+ controlRender,
10
+ useFieldControl
11
+ } from "./field-context.js";
12
+ import {
13
+ createParts,
14
+ reading,
15
+ usePart,
16
+ usePrimitive
17
+ } from "./use-primitive.js";
18
+ import {
19
+ createCheckboxController,
20
+ createCheckboxGroupController
21
+ } from "@ui-sdk/core/checkbox";
22
+ import { jsx } from "react/jsx-runtime";
23
+ var parts = createParts(checkbox, { root: "button", indicator: "span" });
24
+ var CheckboxGroupContext = React.createContext(null);
25
+ function CheckboxInput() {
26
+ return usePart(checkbox, "input", {}, {}, "input");
27
+ }
28
+ function GroupInput() {
29
+ return usePart(checkboxGroup, "group-input", {}, {}, "input");
30
+ }
31
+ function Checkbox({
32
+ disabled,
33
+ name,
34
+ render,
35
+ ...props
36
+ }) {
37
+ const group = React.useContext(CheckboxGroupContext);
38
+ const field = useFieldControl();
39
+ const fieldControl = group ? null : field;
40
+ return /* @__PURE__ */ jsx(
41
+ parts.Root,
42
+ {
43
+ ...props,
44
+ disabled: disabled || fieldControl?.disabled,
45
+ name: name ?? fieldControl?.name,
46
+ group: group ? reading(group, () => group.api) : void 0,
47
+ render: controlRender(fieldControl, "button", render, /* @__PURE__ */ jsx(CheckboxInput, {}))
48
+ }
49
+ );
50
+ }
51
+ var CheckboxIndicator = parts.Indicator;
52
+ function CheckboxGroup({
53
+ value,
54
+ defaultValue,
55
+ onValueChange,
56
+ allValues,
57
+ readOnly,
58
+ disabled,
59
+ required,
60
+ name,
61
+ form,
62
+ controller,
63
+ debug,
64
+ render,
65
+ ...props
66
+ }) {
67
+ const field = useFieldControl();
68
+ const group = usePrimitive(checkboxGroup, {
69
+ value,
70
+ defaultValue,
71
+ onValueChange,
72
+ allValues,
73
+ disabled: disabled || field?.disabled,
74
+ readOnly,
75
+ required,
76
+ name: name ?? field?.name,
77
+ form,
78
+ controller,
79
+ debug
80
+ });
81
+ return /* @__PURE__ */ jsx(CheckboxGroupContext, { value: group, children: usePart(
82
+ group,
83
+ "group",
84
+ {},
85
+ {
86
+ ...props,
87
+ render: controlRender(field, "div", render, /* @__PURE__ */ jsx(GroupInput, {}))
88
+ },
89
+ "div"
90
+ ) });
91
+ }
92
+ export {
93
+ Checkbox,
94
+ CheckboxGroup,
95
+ CheckboxIndicator,
96
+ createCheckboxController,
97
+ createCheckboxGroupController
98
+ };
@@ -0,0 +1,38 @@
1
+ import * as React from "react";
2
+ declare function hasChild(children: React.ReactNode, type: React.ElementType): boolean;
3
+ /**
4
+ * For a root that renders its own content part when the app places none:
5
+ * whether one is placed, and the value of the provider its children go in.
6
+ * Its own part goes in `<Placed value={null}>`, so it doesn't count. `wanted`
7
+ * is whether the root would render its own part now. Only then do placed
8
+ * parts register, so a root whose content is a direct child, or that has no
9
+ * items to show, renders once instead of again when its content mounts.
10
+ */
11
+ declare function usePlacedContent(wanted: boolean): readonly [boolean, (() => () => void) | null];
12
+ declare const Placed: React.Provider<(() => () => void) | null>;
13
+ /** Called by a content part, so its root doesn't render one of its own as well. */
14
+ declare function usePlaceContent(): void;
15
+ /**
16
+ * Marks a part inside an item that isn't its label, like an icon, so
17
+ * `learnLabels` skips its text. A pure call, so a page that never renders the
18
+ * part still drops it, which a set of parts in the root couldn't do.
19
+ */
20
+ declare function notLabel<Part extends object>(part: Part): Part;
21
+ /**
22
+ * Tells a listbox the labels of its value from the items among `children`,
23
+ * so the server's markup and the render that hydrates it show the label, not
24
+ * the value, before the items mount. The listbox looks only on its first
25
+ * render. An item is any component element with a selected `value`, so a
26
+ * component of your own that takes the value and the label as props counts
27
+ * too: its `label`, or else its text, without hidden parts, parts of the
28
+ * types in `skip`, like its indicator, or parts marked with `notLabel`. Items a component renders from
29
+ * elsewhere, like its own list, aren't found.
30
+ */
31
+ declare function learnLabels(internal: {
32
+ keyOf: (value: unknown) => string;
33
+ learnLabels: (find: (keys: ReadonlySet<string>) => {
34
+ value: unknown;
35
+ label: string;
36
+ }[]) => void;
37
+ }, children: React.ReactNode, skip: ReadonlySet<unknown>): void;
38
+ export { hasChild, learnLabels, notLabel, Placed, usePlaceContent, usePlacedContent, };
@@ -0,0 +1,63 @@
1
+ "use client";
2
+ // src/children.ts
3
+ import * as React from "react";
4
+ function hasChild(children, type) {
5
+ for (const child of React.Children.toArray(children)) {
6
+ if (React.isValidElement(child) && (child.type === type || hasChild(child.props.children, type))) {
7
+ return true;
8
+ }
9
+ }
10
+ return false;
11
+ }
12
+ var PlacedContext = React.createContext(null);
13
+ function usePlacedContent(wanted) {
14
+ const [count, setCount] = React.useState(0);
15
+ const register = React.useCallback(() => {
16
+ setCount((count2) => count2 + 1);
17
+ return () => setCount((count2) => count2 - 1);
18
+ }, []);
19
+ return [count > 0, wanted ? register : null];
20
+ }
21
+ var Placed = PlacedContext.Provider;
22
+ function usePlaceContent() {
23
+ const register = React.useContext(PlacedContext);
24
+ React.useLayoutEffect(() => register?.(), [register]);
25
+ }
26
+ var notLabelKey = /* @__PURE__ */ Symbol.for("ui-sdk.not-label");
27
+ function notLabel(part) {
28
+ ;
29
+ part[notLabelKey] = true;
30
+ return part;
31
+ }
32
+ function learnLabels(internal, children, skip) {
33
+ internal.learnLabels((keys) => {
34
+ const found = [];
35
+ const text = (node) => typeof node === "string" || typeof node === "number" ? String(node) : Array.isArray(node) ? node.map(text).join("") : React.isValidElement(node) && !skip.has(node.type) && !node.type[notLabelKey] && !node.props["aria-hidden"] ? text(node.props.children) : "";
36
+ const visit = (node) => {
37
+ if (Array.isArray(node)) {
38
+ return node.forEach(visit);
39
+ }
40
+ if (!React.isValidElement(node)) {
41
+ return;
42
+ }
43
+ const { value, label, children: children2 } = node.props;
44
+ if (value === void 0 || typeof node.type === "string" || !keys.has(internal.keyOf(value))) {
45
+ return visit(children2);
46
+ }
47
+ const shown = typeof label === "string" ? label : text(children2).replace(/\s+/g, " ").trim();
48
+ if (shown) {
49
+ found.push({ value, label: shown });
50
+ }
51
+ };
52
+ visit(children);
53
+ return found;
54
+ });
55
+ }
56
+ export {
57
+ Placed,
58
+ hasChild,
59
+ learnLabels,
60
+ notLabel,
61
+ usePlaceContent,
62
+ usePlacedContent
63
+ };