@journ/nude 0.1.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 (263) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +59 -0
  3. package/dist/accordion-parts.d.ts +15 -0
  4. package/dist/accordion-parts.js +19 -0
  5. package/dist/accordion.d.ts +10 -0
  6. package/dist/accordion.js +10 -0
  7. package/dist/alert-dialog-parts.d.ts +13 -0
  8. package/dist/alert-dialog-parts.js +15 -0
  9. package/dist/alert-dialog.d.ts +14 -0
  10. package/dist/alert-dialog.js +15 -0
  11. package/dist/alert.d.ts +11 -0
  12. package/dist/alert.js +12 -0
  13. package/dist/animated-size.d.ts +18 -0
  14. package/dist/animated-size.js +55 -0
  15. package/dist/avatar-parts.d.ts +10 -0
  16. package/dist/avatar-parts.js +14 -0
  17. package/dist/avatar.d.ts +9 -0
  18. package/dist/avatar.js +9 -0
  19. package/dist/badge.d.ts +4 -0
  20. package/dist/badge.js +5 -0
  21. package/dist/breadcrumbs.d.ts +11 -0
  22. package/dist/breadcrumbs.js +15 -0
  23. package/dist/bulk-bar.d.ts +8 -0
  24. package/dist/bulk-bar.js +9 -0
  25. package/dist/button.d.ts +13 -0
  26. package/dist/button.js +21 -0
  27. package/dist/calendar-parts.d.ts +81 -0
  28. package/dist/calendar-parts.js +213 -0
  29. package/dist/calendar.d.ts +17 -0
  30. package/dist/calendar.js +17 -0
  31. package/dist/card.d.ts +12 -0
  32. package/dist/card.js +13 -0
  33. package/dist/carousel-parts.d.ts +29 -0
  34. package/dist/carousel-parts.js +98 -0
  35. package/dist/carousel.d.ts +11 -0
  36. package/dist/carousel.js +11 -0
  37. package/dist/checkbox-parts.d.ts +7 -0
  38. package/dist/checkbox-parts.js +9 -0
  39. package/dist/checkbox.d.ts +7 -0
  40. package/dist/checkbox.js +8 -0
  41. package/dist/chip.d.ts +22 -0
  42. package/dist/chip.js +29 -0
  43. package/dist/collapsible-parts.d.ts +7 -0
  44. package/dist/collapsible-parts.js +9 -0
  45. package/dist/collapsible.d.ts +8 -0
  46. package/dist/collapsible.js +9 -0
  47. package/dist/combobox-parts.d.ts +85 -0
  48. package/dist/combobox-parts.js +61 -0
  49. package/dist/combobox.d.ts +84 -0
  50. package/dist/combobox.js +21 -0
  51. package/dist/command-palette-parts.d.ts +22 -0
  52. package/dist/command-palette-parts.js +56 -0
  53. package/dist/command-palette.d.ts +64 -0
  54. package/dist/command-palette.js +18 -0
  55. package/dist/composer.d.ts +7 -0
  56. package/dist/composer.js +8 -0
  57. package/dist/context-menu-parts.d.ts +8 -0
  58. package/dist/context-menu-parts.js +10 -0
  59. package/dist/context-menu.d.ts +12 -0
  60. package/dist/context-menu.js +13 -0
  61. package/dist/currency-input-parts.d.ts +22 -0
  62. package/dist/currency-input-parts.js +57 -0
  63. package/dist/currency-input.d.ts +8 -0
  64. package/dist/currency-input.js +8 -0
  65. package/dist/data-table-parts.d.ts +101 -0
  66. package/dist/data-table-parts.js +220 -0
  67. package/dist/data-table.d.ts +12 -0
  68. package/dist/data-table.js +12 -0
  69. package/dist/date-input-parts.d.ts +15 -0
  70. package/dist/date-input-parts.js +54 -0
  71. package/dist/date-input.d.ts +8 -0
  72. package/dist/date-input.js +8 -0
  73. package/dist/date-picker-parts.d.ts +29 -0
  74. package/dist/date-picker-parts.js +33 -0
  75. package/dist/date-picker.d.ts +29 -0
  76. package/dist/date-picker.js +15 -0
  77. package/dist/date-range-picker-parts.d.ts +37 -0
  78. package/dist/date-range-picker-parts.js +63 -0
  79. package/dist/date-range-picker.d.ts +29 -0
  80. package/dist/date-range-picker.js +15 -0
  81. package/dist/description-list.d.ts +8 -0
  82. package/dist/description-list.js +9 -0
  83. package/dist/dialog-parts.d.ts +12 -0
  84. package/dist/dialog-parts.js +14 -0
  85. package/dist/dialog.d.ts +14 -0
  86. package/dist/dialog.js +15 -0
  87. package/dist/divider.d.ts +5 -0
  88. package/dist/divider.js +9 -0
  89. package/dist/drawer-parts.d.ts +24 -0
  90. package/dist/drawer-parts.js +14 -0
  91. package/dist/drawer.d.ts +27 -0
  92. package/dist/drawer.js +15 -0
  93. package/dist/dropdown-menu-parts.d.ts +8 -0
  94. package/dist/dropdown-menu-parts.js +10 -0
  95. package/dist/dropdown-menu.d.ts +12 -0
  96. package/dist/dropdown-menu.js +13 -0
  97. package/dist/empty-state.d.ts +10 -0
  98. package/dist/empty-state.js +11 -0
  99. package/dist/field-parts.d.ts +15 -0
  100. package/dist/field-parts.js +63 -0
  101. package/dist/field.d.ts +11 -0
  102. package/dist/field.js +11 -0
  103. package/dist/file-dropzone-parts.d.ts +34 -0
  104. package/dist/file-dropzone-parts.js +108 -0
  105. package/dist/file-dropzone.d.ts +10 -0
  106. package/dist/file-dropzone.js +10 -0
  107. package/dist/heading.d.ts +9 -0
  108. package/dist/heading.js +12 -0
  109. package/dist/hover-card-parts.d.ts +8 -0
  110. package/dist/hover-card-parts.js +12 -0
  111. package/dist/hover-card.d.ts +9 -0
  112. package/dist/hover-card.js +9 -0
  113. package/dist/icon-button.d.ts +6 -0
  114. package/dist/icon-button.js +5 -0
  115. package/dist/icon.d.ts +7 -0
  116. package/dist/icon.js +12 -0
  117. package/dist/index.d.ts +94 -0
  118. package/dist/index.js +87 -0
  119. package/dist/input.d.ts +4 -0
  120. package/dist/input.js +5 -0
  121. package/dist/lib/commit-on.d.ts +15 -0
  122. package/dist/lib/commit-on.js +17 -0
  123. package/dist/lib/menu-parts.d.ts +21 -0
  124. package/dist/lib/menu-parts.js +23 -0
  125. package/dist/lib/modal-content.d.ts +17 -0
  126. package/dist/lib/modal-content.js +17 -0
  127. package/dist/lib/modal-parts.d.ts +6 -0
  128. package/dist/lib/modal-parts.js +7 -0
  129. package/dist/lib/part.d.ts +6 -0
  130. package/dist/lib/part.js +13 -0
  131. package/dist/lib/picker.d.ts +44 -0
  132. package/dist/lib/picker.js +75 -0
  133. package/dist/lib/visually-hidden.d.ts +6 -0
  134. package/dist/lib/visually-hidden.js +15 -0
  135. package/dist/link.d.ts +9 -0
  136. package/dist/link.js +12 -0
  137. package/dist/markdown.d.ts +10 -0
  138. package/dist/markdown.js +10 -0
  139. package/dist/message.d.ts +13 -0
  140. package/dist/message.js +15 -0
  141. package/dist/month-picker-parts.d.ts +19 -0
  142. package/dist/month-picker-parts.js +38 -0
  143. package/dist/month-picker.d.ts +15 -0
  144. package/dist/month-picker.js +15 -0
  145. package/dist/month-stepper-parts.d.ts +16 -0
  146. package/dist/month-stepper-parts.js +52 -0
  147. package/dist/month-stepper.d.ts +10 -0
  148. package/dist/month-stepper.js +10 -0
  149. package/dist/multiple-selector-parts.d.ts +39 -0
  150. package/dist/multiple-selector-parts.js +118 -0
  151. package/dist/multiple-selector.d.ts +76 -0
  152. package/dist/multiple-selector.js +23 -0
  153. package/dist/nav-bar.d.ts +7 -0
  154. package/dist/nav-bar.js +8 -0
  155. package/dist/navigation-menu-parts.d.ts +18 -0
  156. package/dist/navigation-menu-parts.js +25 -0
  157. package/dist/navigation-menu.d.ts +12 -0
  158. package/dist/navigation-menu.js +12 -0
  159. package/dist/otp-input-parts.d.ts +9 -0
  160. package/dist/otp-input-parts.js +11 -0
  161. package/dist/otp-input.d.ts +8 -0
  162. package/dist/otp-input.js +9 -0
  163. package/dist/page-header.d.ts +8 -0
  164. package/dist/page-header.js +9 -0
  165. package/dist/page.d.ts +8 -0
  166. package/dist/page.js +9 -0
  167. package/dist/pagination.d.ts +13 -0
  168. package/dist/pagination.js +24 -0
  169. package/dist/pill-select.d.ts +4 -0
  170. package/dist/pill-select.js +5 -0
  171. package/dist/popover-parts.d.ts +9 -0
  172. package/dist/popover-parts.js +13 -0
  173. package/dist/popover.d.ts +10 -0
  174. package/dist/popover.js +10 -0
  175. package/dist/portal.d.ts +15 -0
  176. package/dist/portal.js +20 -0
  177. package/dist/progress-parts.d.ts +11 -0
  178. package/dist/progress-parts.js +32 -0
  179. package/dist/progress.d.ts +8 -0
  180. package/dist/progress.js +8 -0
  181. package/dist/quantity-input-parts.d.ts +21 -0
  182. package/dist/quantity-input-parts.js +86 -0
  183. package/dist/quantity-input.d.ts +10 -0
  184. package/dist/quantity-input.js +10 -0
  185. package/dist/radio-parts.d.ts +13 -0
  186. package/dist/radio-parts.js +17 -0
  187. package/dist/radio.d.ts +8 -0
  188. package/dist/radio.js +8 -0
  189. package/dist/scroll-area-parts.d.ts +17 -0
  190. package/dist/scroll-area-parts.js +21 -0
  191. package/dist/scroll-area.d.ts +10 -0
  192. package/dist/scroll-area.js +10 -0
  193. package/dist/select-parts.d.ts +26 -0
  194. package/dist/select-parts.js +38 -0
  195. package/dist/select.d.ts +14 -0
  196. package/dist/select.js +14 -0
  197. package/dist/sheet-parts.d.ts +15 -0
  198. package/dist/sheet-parts.js +15 -0
  199. package/dist/sheet.d.ts +14 -0
  200. package/dist/sheet.js +16 -0
  201. package/dist/sidebar.d.ts +14 -0
  202. package/dist/sidebar.js +17 -0
  203. package/dist/skeleton.d.ts +4 -0
  204. package/dist/skeleton.js +5 -0
  205. package/dist/slider-parts.d.ts +9 -0
  206. package/dist/slider-parts.js +11 -0
  207. package/dist/slider.d.ts +9 -0
  208. package/dist/slider.js +10 -0
  209. package/dist/spinner.d.ts +6 -0
  210. package/dist/spinner.js +23 -0
  211. package/dist/stack-parts.d.ts +22 -0
  212. package/dist/stack-parts.js +125 -0
  213. package/dist/stack.d.ts +10 -0
  214. package/dist/stack.js +10 -0
  215. package/dist/stat.d.ts +9 -0
  216. package/dist/stat.js +10 -0
  217. package/dist/step-button.d.ts +11 -0
  218. package/dist/step-button.js +13 -0
  219. package/dist/stepper-parts.d.ts +19 -0
  220. package/dist/stepper-parts.js +44 -0
  221. package/dist/stepper.d.ts +11 -0
  222. package/dist/stepper.js +11 -0
  223. package/dist/switch-parts.d.ts +6 -0
  224. package/dist/switch-parts.js +8 -0
  225. package/dist/switch.d.ts +7 -0
  226. package/dist/switch.js +8 -0
  227. package/dist/table.d.ts +12 -0
  228. package/dist/table.js +13 -0
  229. package/dist/tabs-parts.d.ts +8 -0
  230. package/dist/tabs-parts.js +10 -0
  231. package/dist/tabs.d.ts +9 -0
  232. package/dist/tabs.js +10 -0
  233. package/dist/tag-input-parts.d.ts +30 -0
  234. package/dist/tag-input-parts.js +99 -0
  235. package/dist/tag-input.d.ts +10 -0
  236. package/dist/tag-input.js +10 -0
  237. package/dist/text-morph.d.ts +17 -0
  238. package/dist/text-morph.js +62 -0
  239. package/dist/text-shimmer.d.ts +9 -0
  240. package/dist/text-shimmer.js +8 -0
  241. package/dist/text.d.ts +4 -0
  242. package/dist/text.js +5 -0
  243. package/dist/textarea.d.ts +4 -0
  244. package/dist/textarea.js +5 -0
  245. package/dist/time-range-parts.d.ts +22 -0
  246. package/dist/time-range-parts.js +56 -0
  247. package/dist/time-range.d.ts +10 -0
  248. package/dist/time-range.js +10 -0
  249. package/dist/toast-parts.d.ts +12 -0
  250. package/dist/toast-parts.js +21 -0
  251. package/dist/toast.d.ts +13 -0
  252. package/dist/toast.js +12 -0
  253. package/dist/toggle-group-parts.d.ts +6 -0
  254. package/dist/toggle-group-parts.js +8 -0
  255. package/dist/toggle-group.d.ts +7 -0
  256. package/dist/toggle-group.js +8 -0
  257. package/dist/tooltip-parts.d.ts +10 -0
  258. package/dist/tooltip-parts.js +17 -0
  259. package/dist/tooltip.d.ts +10 -0
  260. package/dist/tooltip.js +10 -0
  261. package/dist/touch-target.d.ts +6 -0
  262. package/dist/touch-target.js +10 -0
  263. package/package.json +83 -0
@@ -0,0 +1,213 @@
1
+ "use client";
2
+ import { StepButton } from "./step-button.js";
3
+ import { useState, useSyncExternalStore } from "react";
4
+ import { jsx } from "react/jsx-runtime";
5
+ import { createRequiredContext, useControllableState } from "@journ/lift";
6
+ import { addMonths, formatMonthYear, startOfMonth } from "@journ/fitter-happier";
7
+ //#region src/calendar-parts.tsx
8
+ const YEAR_PAGE_SIZE = 12;
9
+ const dayKey = (date) => `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`;
10
+ const isSameDay = (a, b) => b !== null && dayKey(a) === dayKey(b);
11
+ const isSameMonth = (a, b) => b !== null && a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth();
12
+ const yearPageStart = (month) => Math.floor(month.getFullYear() / 12) * 12;
13
+ const monthGrid = (month, weekStartsOn) => {
14
+ const offset = (month.getDay() - weekStartsOn + 7) % 7;
15
+ return Array.from({ length: 42 }, (_, index) => new Date(month.getFullYear(), month.getMonth(), index - offset + 1));
16
+ };
17
+ const noopSubscribe = () => () => void 0;
18
+ const useToday = () => {
19
+ const key = useSyncExternalStore(noopSubscribe, () => dayKey(/* @__PURE__ */ new Date()), () => null);
20
+ if (key === null) return null;
21
+ const [year, month, date] = key.split("-").map(Number);
22
+ return new Date(year ?? 0, month ?? 0, date ?? 1);
23
+ };
24
+ const [CalendarContext, useCalendar] = createRequiredContext("Calendar.Provider or Calendar.Root");
25
+ const Provider = ({ state, actions, meta, children }) => /* @__PURE__ */ jsx(CalendarContext, {
26
+ value: {
27
+ state,
28
+ actions,
29
+ meta
30
+ },
31
+ children
32
+ });
33
+ /** Month, view and paging shared by every calendar-based picker. */
34
+ const useCalendarNavigation = (initialMonth, initialView = "days") => {
35
+ const [month, setMonth] = useState(() => startOfMonth(initialMonth));
36
+ const [view, setView] = useState(initialView);
37
+ const step = view === "days" ? 1 : view === "months" ? 12 : 144;
38
+ return {
39
+ month,
40
+ view,
41
+ navigation: {
42
+ showMonth: (next) => setMonth(startOfMonth(next)),
43
+ showView: setView,
44
+ previous: () => setMonth(addMonths(month, -step)),
45
+ next: () => setMonth(addMonths(month, step))
46
+ }
47
+ };
48
+ };
49
+ /** A fixed default keeps server and client output identical; pass `locale` to localize. */
50
+ const DEFAULT_LOCALE = "en";
51
+ const Root = ({ value, defaultValue = null, onValueChange, defaultMonth, locale = DEFAULT_LOCALE, weekStartsOn = 0, children }) => {
52
+ const [selected, setSelected] = useControllableState(value, defaultValue, onValueChange);
53
+ const { month, view, navigation } = useCalendarNavigation(defaultMonth ?? selected ?? /* @__PURE__ */ new Date());
54
+ const actions = {
55
+ ...navigation,
56
+ select: (date) => {
57
+ setSelected(date);
58
+ if (!isSameMonth(date, month)) navigation.showMonth(date);
59
+ }
60
+ };
61
+ return /* @__PURE__ */ jsx(Provider, {
62
+ state: {
63
+ selected,
64
+ month,
65
+ view
66
+ },
67
+ actions,
68
+ meta: {
69
+ locale,
70
+ weekStartsOn
71
+ },
72
+ children
73
+ });
74
+ };
75
+ const Frame = (props) => /* @__PURE__ */ jsx("div", {
76
+ "data-slot": "calendar",
77
+ ...props
78
+ });
79
+ const Header = (props) => /* @__PURE__ */ jsx("div", {
80
+ "data-slot": "calendar-header",
81
+ ...props
82
+ });
83
+ const Heading = ({ onClick, ...props }) => {
84
+ const { state, actions, meta } = useCalendar();
85
+ const start = yearPageStart(state.month);
86
+ const label = state.view === "days" ? formatMonthYear(state.month, meta.locale) : state.view === "months" ? String(state.month.getFullYear()) : `${start} – ${start + 12 - 1}`;
87
+ return /* @__PURE__ */ jsx("button", {
88
+ type: "button",
89
+ "data-slot": "calendar-heading",
90
+ "aria-live": "polite",
91
+ disabled: state.view === "years",
92
+ ...props,
93
+ onClick: (event) => {
94
+ onClick?.(event);
95
+ actions.showView(state.view === "days" ? "months" : "years");
96
+ },
97
+ children: label
98
+ });
99
+ };
100
+ const Previous = (props) => {
101
+ const { actions } = useCalendar();
102
+ return /* @__PURE__ */ jsx(StepButton, {
103
+ "data-slot": "calendar-previous",
104
+ "aria-label": "Previous",
105
+ ...props,
106
+ onStep: actions.previous
107
+ });
108
+ };
109
+ const Next = (props) => {
110
+ const { actions } = useCalendar();
111
+ return /* @__PURE__ */ jsx(StepButton, {
112
+ "data-slot": "calendar-next",
113
+ "aria-label": "Next",
114
+ ...props,
115
+ onStep: actions.next
116
+ });
117
+ };
118
+ const cellState = (selected, today, inRange = false) => selected ? "selected" : inRange ? "inRange" : today ? "today" : "idle";
119
+ const isInRange = (date, range) => range?.to != null && date.getTime() > range.from.getTime() && date.getTime() < range.to.getTime();
120
+ const Weekdays = ({ classNames, ...props }) => {
121
+ const { state, meta } = useCalendar();
122
+ if (state.view !== "days") return null;
123
+ const format = new Intl.DateTimeFormat(meta.locale, { weekday: "short" });
124
+ return /* @__PURE__ */ jsx("div", {
125
+ "data-slot": "calendar-weekdays",
126
+ "aria-hidden": true,
127
+ ...props,
128
+ children: monthGrid(state.month, meta.weekStartsOn).slice(0, 7).map((date) => /* @__PURE__ */ jsx("span", {
129
+ "data-slot": "calendar-weekday",
130
+ className: classNames?.weekday,
131
+ children: format.format(date)
132
+ }, date.getDay()))
133
+ });
134
+ };
135
+ const Days = ({ classNames, ...props }) => {
136
+ const { state, actions, meta } = useCalendar();
137
+ const today = useToday();
138
+ if (state.view !== "days") return null;
139
+ const format = new Intl.DateTimeFormat(meta.locale, { dateStyle: "full" });
140
+ const isEdge = (date) => state.range ? isSameDay(date, state.range.from) || isSameDay(date, state.range.to) : isSameDay(date, state.selected);
141
+ return /* @__PURE__ */ jsx("div", {
142
+ "data-slot": "calendar-days",
143
+ ...props,
144
+ children: monthGrid(state.month, meta.weekStartsOn).map((date) => {
145
+ const current = cellState(isEdge(date), isSameDay(date, today), isInRange(date, state.range));
146
+ return /* @__PURE__ */ jsx("button", {
147
+ type: "button",
148
+ "data-slot": "calendar-day",
149
+ "data-state": current,
150
+ "aria-label": format.format(date),
151
+ "aria-pressed": isEdge(date),
152
+ "aria-current": isSameDay(date, today) ? "date" : void 0,
153
+ "data-outside": date.getMonth() !== state.month.getMonth(),
154
+ onClick: () => actions.select(date),
155
+ className: classNames?.day?.(current),
156
+ children: date.getDate()
157
+ }, dayKey(date));
158
+ })
159
+ });
160
+ };
161
+ const Months = ({ classNames, ...props }) => {
162
+ const { state, actions, meta } = useCalendar();
163
+ const today = useToday();
164
+ if (state.view !== "months") return null;
165
+ const format = new Intl.DateTimeFormat(meta.locale, { month: "short" });
166
+ const year = state.month.getFullYear();
167
+ return /* @__PURE__ */ jsx("div", {
168
+ "data-slot": "calendar-months",
169
+ ...props,
170
+ children: Array.from({ length: 12 }, (_, index) => new Date(year, index, 1)).map((date) => {
171
+ const current = cellState(isSameMonth(date, state.selected), isSameMonth(date, today));
172
+ return /* @__PURE__ */ jsx("button", {
173
+ type: "button",
174
+ "data-slot": "calendar-month",
175
+ "data-state": current,
176
+ "aria-pressed": isSameMonth(date, state.selected),
177
+ onClick: () => {
178
+ actions.showMonth(date);
179
+ actions.showView("days");
180
+ },
181
+ className: classNames?.month?.(current),
182
+ children: format.format(date)
183
+ }, date.getMonth());
184
+ })
185
+ });
186
+ };
187
+ const Years = ({ classNames, ...props }) => {
188
+ const { state, actions } = useCalendar();
189
+ const today = useToday();
190
+ if (state.view !== "years") return null;
191
+ const start = yearPageStart(state.month);
192
+ return /* @__PURE__ */ jsx("div", {
193
+ "data-slot": "calendar-years",
194
+ ...props,
195
+ children: Array.from({ length: 12 }, (_, index) => start + index).map((year) => {
196
+ const current = cellState(state.selected?.getFullYear() === year, today?.getFullYear() === year);
197
+ return /* @__PURE__ */ jsx("button", {
198
+ type: "button",
199
+ "data-slot": "calendar-year",
200
+ "data-state": current,
201
+ "aria-pressed": state.selected?.getFullYear() === year,
202
+ onClick: () => {
203
+ actions.showMonth(new Date(year, state.month.getMonth(), 1));
204
+ actions.showView("months");
205
+ },
206
+ className: classNames?.year?.(current),
207
+ children: year
208
+ }, year);
209
+ })
210
+ });
211
+ };
212
+ //#endregion
213
+ export { Days, Frame, Header, Heading, Months, Next, Previous, Provider, Root, Weekdays, YEAR_PAGE_SIZE, Years, useCalendar, useCalendarNavigation };
@@ -0,0 +1,17 @@
1
+ import { CalendarActions, CalendarContextValue, CalendarMeta, CalendarRange, CalendarState, CalendarView, Days, Frame, Header, Heading, Months, Next, Previous, Provider, Root, RootProps, Weekday, Weekdays, Years, useCalendar } from "./calendar-parts.js";
2
+ //#region src/calendar.d.ts
3
+ declare const Calendar: {
4
+ Provider: typeof Provider;
5
+ Root: typeof Root;
6
+ Frame: typeof Frame;
7
+ Header: typeof Header;
8
+ Heading: typeof Heading;
9
+ Previous: typeof Previous;
10
+ Next: typeof Next;
11
+ Weekdays: typeof Weekdays;
12
+ Days: typeof Days;
13
+ Months: typeof Months;
14
+ Years: typeof Years;
15
+ };
16
+ //#endregion
17
+ export { Calendar, type CalendarActions, type CalendarContextValue, type CalendarMeta, type RootProps as CalendarProps, type CalendarRange, type CalendarState, type CalendarView, type Weekday, useCalendar };
@@ -0,0 +1,17 @@
1
+ import { Days, Frame, Header, Heading, Months, Next, Previous, Provider, Root, Weekdays, Years, useCalendar } from "./calendar-parts.js";
2
+ //#region src/calendar.tsx
3
+ const Calendar = {
4
+ Provider,
5
+ Root,
6
+ Frame,
7
+ Header,
8
+ Heading,
9
+ Previous,
10
+ Next,
11
+ Weekdays,
12
+ Days,
13
+ Months,
14
+ Years
15
+ };
16
+ //#endregion
17
+ export { Calendar, useCalendar };
package/dist/card.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ //#region src/card.d.ts
2
+ declare const Card: {
3
+ Root: (props: import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>) => import("react").ReactNode;
4
+ Icon: (props: import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>) => import("react").ReactNode;
5
+ Header: (props: import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>) => import("react").ReactNode;
6
+ Title: (props: import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>) => import("react").ReactNode;
7
+ Description: (props: import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>) => import("react").ReactNode;
8
+ Content: (props: import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>) => import("react").ReactNode;
9
+ Footer: (props: import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>) => import("react").ReactNode;
10
+ };
11
+ //#endregion
12
+ export { Card };
package/dist/card.js ADDED
@@ -0,0 +1,13 @@
1
+ import { part } from "./lib/part.js";
2
+ //#region src/card.tsx
3
+ const Card = {
4
+ Root: part("div", "card"),
5
+ Icon: part("span", "card-icon"),
6
+ Header: part("div", "card-header"),
7
+ Title: part("h3", "card-title"),
8
+ Description: part("p", "card-description"),
9
+ Content: part("div", "card-content"),
10
+ Footer: part("footer", "card-footer")
11
+ };
12
+ //#endregion
13
+ export { Card };
@@ -0,0 +1,29 @@
1
+ import { IconButtonProps } from "./icon-button.js";
2
+ import { ComponentPropsWithRef, ReactNode } from "react";
3
+ import useEmblaCarousel from "embla-carousel-react";
4
+ //#region src/carousel-parts.d.ts
5
+ type Orientation = 'horizontal' | 'vertical';
6
+ type Options = Parameters<typeof useEmblaCarousel>[0];
7
+ type Plugins = Parameters<typeof useEmblaCarousel>[1];
8
+ declare const useCarousel: any;
9
+ type RootProps = Omit<ComponentPropsWithRef<'div'>, 'children'> & {
10
+ /** Embla options such as `loop` and `align`. */
11
+ opts?: Options;
12
+ plugins?: Plugins;
13
+ orientation?: Orientation;
14
+ children?: ReactNode;
15
+ };
16
+ /** Slides with Embla. Arrow keys move between slides. */
17
+ declare const Root: ({ opts, plugins, orientation, children, onKeyDownCapture, ...props }: RootProps) => import("react").JSX.Element;
18
+ type ContentProps = ComponentPropsWithRef<'div'> & {
19
+ classNames?: {
20
+ viewport?: string;
21
+ };
22
+ };
23
+ /** The track of slides, inside the viewport Embla scrolls. Embla needs the viewport to clip and the track to be a flex row or column. */
24
+ declare const Content: ({ classNames, ...props }: ContentProps) => import("react").JSX.Element;
25
+ declare const Item: (props: ComponentPropsWithRef<'div'>) => import("react").JSX.Element;
26
+ declare const Previous: (props: IconButtonProps) => import("react").JSX.Element;
27
+ declare const Next: (props: IconButtonProps) => import("react").JSX.Element;
28
+ //#endregion
29
+ export { Content, Item, Next, Previous, Root, type RootProps, useCarousel };
@@ -0,0 +1,98 @@
1
+ "use client";
2
+ import { StepButton } from "./step-button.js";
3
+ import { useEffect, useState } from "react";
4
+ import { jsx } from "react/jsx-runtime";
5
+ import { createRequiredContext } from "@journ/lift";
6
+ import useEmblaCarousel from "embla-carousel-react";
7
+ //#region src/carousel-parts.tsx
8
+ const [CarouselContext, useCarousel] = createRequiredContext("Carousel.Root");
9
+ /** Slides with Embla. Arrow keys move between slides. */
10
+ const Root = ({ opts, plugins, orientation = "horizontal", children, onKeyDownCapture, ...props }) => {
11
+ const [viewport, api] = useEmblaCarousel({
12
+ ...opts,
13
+ axis: orientation === "horizontal" ? "x" : "y"
14
+ }, plugins);
15
+ const [canPrevious, setCanPrevious] = useState(false);
16
+ const [canNext, setCanNext] = useState(false);
17
+ useEffect(() => {
18
+ if (!api) return;
19
+ const update = () => {
20
+ setCanPrevious(api.canScrollPrev());
21
+ setCanNext(api.canScrollNext());
22
+ };
23
+ update();
24
+ api.on("select", update);
25
+ api.on("reInit", update);
26
+ return () => {
27
+ api.off("select", update);
28
+ api.off("reInit", update);
29
+ };
30
+ }, [api]);
31
+ const previous = () => api?.scrollPrev();
32
+ const next = () => api?.scrollNext();
33
+ const [back, forward] = orientation === "horizontal" ? ["ArrowLeft", "ArrowRight"] : ["ArrowUp", "ArrowDown"];
34
+ return /* @__PURE__ */ jsx(CarouselContext, {
35
+ value: {
36
+ viewport,
37
+ orientation,
38
+ canPrevious,
39
+ canNext,
40
+ previous,
41
+ next
42
+ },
43
+ children: /* @__PURE__ */ jsx("div", {
44
+ "data-slot": "carousel",
45
+ "data-orientation": orientation,
46
+ role: "region",
47
+ "aria-roledescription": "carousel",
48
+ ...props,
49
+ onKeyDownCapture: (event) => {
50
+ onKeyDownCapture?.(event);
51
+ if (event.key === back) event.preventDefault(), previous();
52
+ if (event.key === forward) event.preventDefault(), next();
53
+ },
54
+ children
55
+ })
56
+ });
57
+ };
58
+ /** The track of slides, inside the viewport Embla scrolls. Embla needs the viewport to clip and the track to be a flex row or column. */
59
+ const Content = ({ classNames, ...props }) => {
60
+ const { viewport } = useCarousel();
61
+ return /* @__PURE__ */ jsx("div", {
62
+ ref: viewport,
63
+ "data-slot": "carousel-viewport",
64
+ className: classNames?.viewport,
65
+ children: /* @__PURE__ */ jsx("div", {
66
+ "data-slot": "carousel-content",
67
+ ...props
68
+ })
69
+ });
70
+ };
71
+ const Item = (props) => /* @__PURE__ */ jsx("div", {
72
+ "data-slot": "carousel-item",
73
+ role: "group",
74
+ "aria-roledescription": "slide",
75
+ ...props
76
+ });
77
+ const Previous = (props) => {
78
+ const { canPrevious, previous } = useCarousel();
79
+ return /* @__PURE__ */ jsx(StepButton, {
80
+ "data-slot": "carousel-previous",
81
+ "aria-label": "Previous slide",
82
+ disabled: !canPrevious,
83
+ ...props,
84
+ onStep: previous
85
+ });
86
+ };
87
+ const Next = (props) => {
88
+ const { canNext, next } = useCarousel();
89
+ return /* @__PURE__ */ jsx(StepButton, {
90
+ "data-slot": "carousel-next",
91
+ "aria-label": "Next slide",
92
+ disabled: !canNext,
93
+ ...props,
94
+ onStep: next
95
+ });
96
+ };
97
+ //#endregion
98
+ export { Content, Item, Next, Previous, Root, useCarousel };
@@ -0,0 +1,11 @@
1
+ import { Content, Item, Next, Previous, Root, RootProps, useCarousel } from "./carousel-parts.js";
2
+ //#region src/carousel.d.ts
3
+ declare const Carousel: {
4
+ Root: typeof Root;
5
+ Content: typeof Content;
6
+ Item: typeof Item;
7
+ Previous: typeof Previous;
8
+ Next: typeof Next;
9
+ };
10
+ //#endregion
11
+ export { Carousel, type RootProps as CarouselProps, useCarousel };
@@ -0,0 +1,11 @@
1
+ import { Content, Item, Next, Previous, Root, useCarousel } from "./carousel-parts.js";
2
+ //#region src/carousel.tsx
3
+ const Carousel = {
4
+ Root,
5
+ Content,
6
+ Item,
7
+ Previous,
8
+ Next
9
+ };
10
+ //#endregion
11
+ export { Carousel, useCarousel };
@@ -0,0 +1,7 @@
1
+ import * as RadixCheckbox from "@radix-ui/react-checkbox";
2
+ //#region src/checkbox-parts.d.ts
3
+ declare const Root: (props: RadixCheckbox.CheckboxProps & import("react").RefAttributes<HTMLButtonElement>) => import("react").ReactNode;
4
+ /** Shown while the root is checked or indeterminate. */
5
+ declare const Indicator: (props: RadixCheckbox.CheckboxIndicatorProps & import("react").RefAttributes<HTMLSpanElement>) => import("react").ReactNode;
6
+ //#endregion
7
+ export { Indicator, Root };
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ import { part } from "./lib/part.js";
3
+ import * as RadixCheckbox from "@radix-ui/react-checkbox";
4
+ //#region src/checkbox-parts.tsx
5
+ const Root = part(RadixCheckbox.Root, "checkbox");
6
+ /** Shown while the root is checked or indeterminate. */
7
+ const Indicator = part(RadixCheckbox.Indicator, "checkbox-indicator");
8
+ //#endregion
9
+ export { Indicator, Root };
@@ -0,0 +1,7 @@
1
+ //#region src/checkbox.d.ts
2
+ declare const Checkbox: {
3
+ Root: (props: import("@radix-ui/react-checkbox").CheckboxProps & import("react").RefAttributes<HTMLButtonElement>) => import("react").ReactNode;
4
+ Indicator: (props: import("@radix-ui/react-checkbox").CheckboxIndicatorProps & import("react").RefAttributes<HTMLSpanElement>) => import("react").ReactNode;
5
+ };
6
+ //#endregion
7
+ export { Checkbox };
@@ -0,0 +1,8 @@
1
+ import { Indicator, Root } from "./checkbox-parts.js";
2
+ //#region src/checkbox.tsx
3
+ const Checkbox = {
4
+ Root,
5
+ Indicator
6
+ };
7
+ //#endregion
8
+ export { Checkbox };
package/dist/chip.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { ComponentPropsWithRef } from "react";
2
+ //#region src/chip.d.ts
3
+ declare const Root: (props: import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>) => import("react").ReactNode;
4
+ /** A small close button for chips that can be dismissed. `label` is the accessible name. */
5
+ declare const Remove: ({ label, ...props }: ComponentPropsWithRef<'button'> & {
6
+ label: string;
7
+ }) => import("react").JSX.Element;
8
+ type TagProps = ComponentPropsWithRef<typeof Root> & {
9
+ /** Shows a remove button when given. Leave it out for a chip that cannot be dismissed. */
10
+ onRemove?: () => void;
11
+ removeLabel?: string;
12
+ };
13
+ /** A chip with a remove button: the shape of a selected value. */
14
+ declare const Tag: ({ onRemove, removeLabel, children, ...props }: TagProps) => import("react").JSX.Element;
15
+ declare const Chip: {
16
+ Root: (props: import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>) => import("react").ReactNode;
17
+ Dot: (props: import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>) => import("react").ReactNode;
18
+ Remove: typeof Remove;
19
+ Tag: typeof Tag;
20
+ };
21
+ //#endregion
22
+ export { Chip, type TagProps as ChipTagProps };
package/dist/chip.js ADDED
@@ -0,0 +1,29 @@
1
+ import { part } from "./lib/part.js";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ //#region src/chip.tsx
4
+ const Root = part("span", "chip");
5
+ const Dot = part("span", "chip-dot", { "aria-hidden": true });
6
+ /** A small close button for chips that can be dismissed. `label` is the accessible name. */
7
+ const Remove = ({ label, ...props }) => /* @__PURE__ */ jsx("button", {
8
+ type: "button",
9
+ "data-slot": "chip-remove",
10
+ "aria-label": label,
11
+ ...props
12
+ });
13
+ /** A chip with a remove button: the shape of a selected value. */
14
+ const Tag = ({ onRemove, removeLabel = "Remove", children, ...props }) => /* @__PURE__ */ jsxs(Root, {
15
+ "data-slot": "chip-tag",
16
+ ...props,
17
+ children: [children, onRemove && /* @__PURE__ */ jsx(Remove, {
18
+ label: removeLabel,
19
+ onClick: onRemove
20
+ })]
21
+ });
22
+ const Chip = {
23
+ Root,
24
+ Dot,
25
+ Remove,
26
+ Tag
27
+ };
28
+ //#endregion
29
+ export { Chip };
@@ -0,0 +1,7 @@
1
+ import * as RadixCollapsible from "@radix-ui/react-collapsible";
2
+ //#region src/collapsible-parts.d.ts
3
+ declare const Root: import("react").ForwardRefExoticComponent<RadixCollapsible.CollapsibleProps & import("react").RefAttributes<HTMLDivElement>>;
4
+ declare const Trigger: import("react").ForwardRefExoticComponent<RadixCollapsible.CollapsibleTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
5
+ declare const Content: (props: RadixCollapsible.CollapsibleContentProps & import("react").RefAttributes<HTMLDivElement>) => import("react").ReactNode;
6
+ //#endregion
7
+ export { Content, Root, Trigger };
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ import { part } from "./lib/part.js";
3
+ import * as RadixCollapsible from "@radix-ui/react-collapsible";
4
+ //#region src/collapsible-parts.tsx
5
+ const Root = RadixCollapsible.Root;
6
+ const Trigger = RadixCollapsible.Trigger;
7
+ const Content = part(RadixCollapsible.Content, "collapsible-content");
8
+ //#endregion
9
+ export { Content, Root, Trigger };
@@ -0,0 +1,8 @@
1
+ //#region src/collapsible.d.ts
2
+ declare const Collapsible: {
3
+ Root: import("react").ForwardRefExoticComponent<import("@radix-ui/react-collapsible").CollapsibleProps & import("react").RefAttributes<HTMLDivElement>>;
4
+ Trigger: import("react").ForwardRefExoticComponent<import("@radix-ui/react-collapsible").CollapsibleTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
5
+ Content: (props: import("@radix-ui/react-collapsible").CollapsibleContentProps & import("react").RefAttributes<HTMLDivElement>) => import("react").ReactNode;
6
+ };
7
+ //#endregion
8
+ export { Collapsible };
@@ -0,0 +1,9 @@
1
+ import { Content, Root, Trigger } from "./collapsible-parts.js";
2
+ //#region src/collapsible.tsx
3
+ const Collapsible = {
4
+ Root,
5
+ Trigger,
6
+ Content
7
+ };
8
+ //#endregion
9
+ export { Collapsible };
@@ -0,0 +1,85 @@
1
+ import { PickerActions, PickerContextValue, PickerProviderProps, PickerState } from "./lib/picker.js";
2
+ import { ComponentPropsWithRef, ReactNode } from "react";
3
+ import { Command } from "cmdk";
4
+ //#region src/combobox-parts.d.ts
5
+ type ComboboxState = PickerState<string>;
6
+ type ComboboxActions = PickerActions<string>;
7
+ type ComboboxContextValue = Omit<PickerContextValue<string, object>, 'meta'>;
8
+ declare const ContextProvider: ({ state, actions, meta, children }: PickerProviderProps<string, object>) => import("react").JSX.Element, Provider: ({ children, ...props }: PickerProviderProps<string, object>) => import("react").JSX.Element, Trigger: (props: ComponentPropsWithRef<'button'>) => import("react").JSX.Element, Value: ({ placeholder, children, ...props }: import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement> & {
9
+ placeholder?: string;
10
+ }) => import("react").JSX.Element, useCombobox: any;
11
+ type RootProps = {
12
+ value?: string | null;
13
+ defaultValue?: string | null;
14
+ onValueChange?: (value: string) => void;
15
+ children?: ReactNode;
16
+ };
17
+ declare const Root: ({ value, defaultValue, onValueChange, children }: RootProps) => import("react").JSX.Element;
18
+ /** Matches without accents or case, against the item's keywords when it has any. */
19
+ declare const Frame: (props: {
20
+ children?: React.ReactNode;
21
+ } & Pick<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
22
+ ref?: React.Ref<HTMLDivElement>;
23
+ } & {
24
+ asChild?: boolean;
25
+ }, "asChild" | "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
26
+ label?: string;
27
+ shouldFilter?: boolean;
28
+ filter?: (value: string, search: string, keywords?: string[]) => number;
29
+ defaultValue?: string;
30
+ value?: string;
31
+ onValueChange?: (value: string) => void;
32
+ loop?: boolean;
33
+ disablePointerSelection?: boolean;
34
+ vimBindings?: boolean;
35
+ } & import("react").RefAttributes<HTMLDivElement>) => ReactNode;
36
+ declare const Input: (props: Omit<Pick<Pick<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "key" | keyof import("react").InputHTMLAttributes<HTMLInputElement>> & {
37
+ ref?: React.Ref<HTMLInputElement>;
38
+ } & {
39
+ asChild?: boolean;
40
+ }, "asChild" | "key" | keyof import("react").InputHTMLAttributes<HTMLInputElement>>, "onChange" | "type" | "value"> & {
41
+ value?: string;
42
+ onValueChange?: (search: string) => void;
43
+ } & import("react").RefAttributes<HTMLInputElement>) => ReactNode;
44
+ declare const List: (props: {
45
+ children?: React.ReactNode;
46
+ } & Pick<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
47
+ ref?: React.Ref<HTMLDivElement>;
48
+ } & {
49
+ asChild?: boolean;
50
+ }, "asChild" | "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
51
+ label?: string;
52
+ } & import("react").RefAttributes<HTMLDivElement>) => ReactNode;
53
+ declare const Empty: (props: {
54
+ children?: React.ReactNode;
55
+ } & Pick<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
56
+ ref?: React.Ref<HTMLDivElement>;
57
+ } & {
58
+ asChild?: boolean;
59
+ }, "asChild" | "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & import("react").RefAttributes<HTMLDivElement>) => ReactNode;
60
+ declare const Group: (props: {
61
+ children?: React.ReactNode;
62
+ } & Omit<Pick<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
63
+ ref?: React.Ref<HTMLDivElement>;
64
+ } & {
65
+ asChild?: boolean;
66
+ }, "asChild" | "key" | keyof import("react").HTMLAttributes<HTMLDivElement>>, "heading" | "value"> & {
67
+ heading?: React.ReactNode;
68
+ value?: string;
69
+ forceMount?: boolean;
70
+ } & import("react").RefAttributes<HTMLDivElement>) => ReactNode;
71
+ type ItemProps = Omit<ComponentPropsWithRef<typeof Command.Item>, 'value'> & {
72
+ value: string;
73
+ };
74
+ type OptionProps = ItemProps & {
75
+ checked: boolean;
76
+ /** Runs with the option's value when it is chosen. */
77
+ onPick: (value: string) => void;
78
+ };
79
+ /** An option that knows nothing about the picker around it. Combobox, MultipleSelector and others build their items from it. */
80
+ declare const Option: ({ value, checked, onPick, onSelect, ...props }: OptionProps) => import("react").JSX.Element;
81
+ declare const Item: (props: ItemProps) => import("react").JSX.Element;
82
+ /** Rendered only inside the checked item. */
83
+ declare const ItemIndicator: (props: ComponentPropsWithRef<'span'>) => import("react").JSX.Element | null;
84
+ //#endregion
85
+ export { type ComboboxActions, type ComboboxContextValue, type ComboboxState, ContextProvider, Empty, Frame, Group, Input, Item, ItemIndicator, type ItemProps, List, Option, type OptionProps, Provider, Root, type RootProps, Trigger, Value, useCombobox };