@g4rcez/components 3.0.0 → 3.0.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 (176) hide show
  1. package/dist/ai/SKILL.md +266 -0
  2. package/dist/ai/docs/Alert.md +167 -0
  3. package/dist/ai/docs/AnimatedList.md +205 -0
  4. package/dist/ai/docs/Autocomplete.md +225 -0
  5. package/dist/ai/docs/Button.md +182 -0
  6. package/dist/ai/docs/Calendar.md +219 -0
  7. package/dist/ai/docs/Card.md +174 -0
  8. package/dist/ai/docs/Checkbox.md +199 -0
  9. package/dist/ai/docs/CommandPalette.md +293 -0
  10. package/dist/ai/docs/DatePicker.md +171 -0
  11. package/dist/ai/docs/Dropdown.md +223 -0
  12. package/dist/ai/docs/Empty.md +163 -0
  13. package/dist/ai/docs/Expand.md +143 -0
  14. package/dist/ai/docs/FileUpload.md +225 -0
  15. package/dist/ai/docs/Form.md +107 -0
  16. package/dist/ai/docs/FormReset.md +117 -0
  17. package/dist/ai/docs/Heading.md +88 -0
  18. package/dist/ai/docs/Input.md +237 -0
  19. package/dist/ai/docs/InputField.md +170 -0
  20. package/dist/ai/docs/List.md +205 -0
  21. package/dist/ai/docs/Menu.md +166 -0
  22. package/dist/ai/docs/Modal.md +280 -0
  23. package/dist/ai/docs/MultiSelect.md +196 -0
  24. package/dist/ai/docs/Notifications.md +231 -0
  25. package/dist/ai/docs/PageCalendar.md +271 -0
  26. package/dist/ai/docs/Polymorph.md +159 -0
  27. package/dist/ai/docs/Progress.md +145 -0
  28. package/dist/ai/docs/Radiobox.md +128 -0
  29. package/dist/ai/docs/RenderOnView.md +138 -0
  30. package/dist/ai/docs/Resizable.md +159 -0
  31. package/dist/ai/docs/Select.md +284 -0
  32. package/dist/ai/docs/Shortcut.md +105 -0
  33. package/dist/ai/docs/Skeleton.md +166 -0
  34. package/dist/ai/docs/Slider.md +144 -0
  35. package/dist/ai/docs/Slot.md +173 -0
  36. package/dist/ai/docs/Spinner.md +118 -0
  37. package/dist/ai/docs/Stats.md +137 -0
  38. package/dist/ai/docs/Step.md +159 -0
  39. package/dist/ai/docs/Switch.md +167 -0
  40. package/dist/ai/docs/Table.md +298 -0
  41. package/dist/ai/docs/Tabs.md +191 -0
  42. package/dist/ai/docs/Tag.md +224 -0
  43. package/dist/ai/docs/TaskList.md +144 -0
  44. package/dist/ai/docs/Textarea.md +167 -0
  45. package/dist/ai/docs/Timeline.md +210 -0
  46. package/dist/ai/docs/Toolbar.md +132 -0
  47. package/dist/ai/docs/Tooltip.md +231 -0
  48. package/dist/ai/docs/TransferList.md +142 -0
  49. package/dist/ai/docs/Typography.md +187 -0
  50. package/dist/ai/docs/Wizard.md +213 -0
  51. package/dist/ai/docs/index.md +183 -0
  52. package/dist/components/core/tag.d.ts +1 -1
  53. package/dist/components/core/tag.d.ts.map +1 -1
  54. package/dist/components/display/list.d.ts.map +1 -1
  55. package/dist/components/floating/dropdown.d.ts +1 -0
  56. package/dist/components/floating/dropdown.d.ts.map +1 -1
  57. package/dist/components/floating/menu.d.ts.map +1 -1
  58. package/dist/config/default-translations.d.ts +4 -4
  59. package/dist/hooks/use-translations.d.ts +4 -4
  60. package/dist/hooks/use-translations.d.ts.map +1 -1
  61. package/dist/index.css +1 -1
  62. package/dist/index.js +28 -20
  63. package/dist/index.js.map +1 -1
  64. package/dist/index.mjs +2463 -2458
  65. package/dist/index.mjs.map +1 -1
  66. package/dist/index.umd.js +12 -12
  67. package/dist/index.umd.js.map +1 -1
  68. package/package.json +4 -4
  69. package/dist/components/core/button.jsx +0 -79
  70. package/dist/components/core/heading.jsx +0 -4
  71. package/dist/components/core/polymorph.jsx +0 -5
  72. package/dist/components/core/render-on-view.jsx +0 -31
  73. package/dist/components/core/resizable.jsx +0 -51
  74. package/dist/components/core/slot.jsx +0 -156
  75. package/dist/components/core/tag.jsx +0 -51
  76. package/dist/components/core/typography.jsx +0 -22
  77. package/dist/components/display/alert.jsx +0 -58
  78. package/dist/components/display/calendar.jsx +0 -299
  79. package/dist/components/display/card.jsx +0 -43
  80. package/dist/components/display/empty.jsx +0 -11
  81. package/dist/components/display/list.jsx +0 -81
  82. package/dist/components/display/notifications.jsx +0 -126
  83. package/dist/components/display/progress.jsx +0 -11
  84. package/dist/components/display/shortcut.jsx +0 -23
  85. package/dist/components/display/skeleton.jsx +0 -12
  86. package/dist/components/display/spinner.jsx +0 -7
  87. package/dist/components/display/stats.jsx +0 -20
  88. package/dist/components/display/step.jsx +0 -131
  89. package/dist/components/display/tabs.jsx +0 -98
  90. package/dist/components/display/timeline.jsx +0 -25
  91. package/dist/components/floating/command-palette.jsx +0 -194
  92. package/dist/components/floating/dropdown.jsx +0 -53
  93. package/dist/components/floating/expand.jsx +0 -44
  94. package/dist/components/floating/menu.jsx +0 -147
  95. package/dist/components/floating/modal.jsx +0 -299
  96. package/dist/components/floating/toolbar.jsx +0 -5
  97. package/dist/components/floating/tooltip.jsx +0 -58
  98. package/dist/components/floating/wizard.jsx +0 -161
  99. package/dist/components/form/autocomplete.jsx +0 -279
  100. package/dist/components/form/checkbox.jsx +0 -12
  101. package/dist/components/form/date-picker.jsx +0 -115
  102. package/dist/components/form/file-upload.jsx +0 -133
  103. package/dist/components/form/form.jsx +0 -10
  104. package/dist/components/form/formReset.jsx +0 -17
  105. package/dist/components/form/free-text.jsx +0 -41
  106. package/dist/components/form/input-field.jsx +0 -56
  107. package/dist/components/form/input.jsx +0 -36
  108. package/dist/components/form/multi-select.jsx +0 -328
  109. package/dist/components/form/radiobox.jsx +0 -6
  110. package/dist/components/form/select.jsx +0 -42
  111. package/dist/components/form/slider.jsx +0 -45
  112. package/dist/components/form/switch.jsx +0 -46
  113. package/dist/components/form/task-list.jsx +0 -26
  114. package/dist/components/form/textarea.jsx +0 -12
  115. package/dist/components/form/transfer-list.jsx +0 -39
  116. package/dist/components/index.js +0 -45
  117. package/dist/components/page-calendar/calendar-header.jsx +0 -81
  118. package/dist/components/page-calendar/day-view.jsx +0 -87
  119. package/dist/components/page-calendar/event-pill.jsx +0 -25
  120. package/dist/components/page-calendar/index.js +0 -2
  121. package/dist/components/page-calendar/month-view.jsx +0 -47
  122. package/dist/components/page-calendar/page-calendar.jsx +0 -41
  123. package/dist/components/page-calendar/page-calendar.types.js +0 -1
  124. package/dist/components/page-calendar/page-calendar.utils.js +0 -71
  125. package/dist/components/page-calendar/week-view.jsx +0 -64
  126. package/dist/components/table/filter.jsx +0 -141
  127. package/dist/components/table/group.jsx +0 -68
  128. package/dist/components/table/index.jsx +0 -60
  129. package/dist/components/table/inner-table.jsx +0 -104
  130. package/dist/components/table/metadata.jsx +0 -36
  131. package/dist/components/table/pagination.jsx +0 -73
  132. package/dist/components/table/row.jsx +0 -58
  133. package/dist/components/table/sort.jsx +0 -105
  134. package/dist/components/table/table-lib.js +0 -83
  135. package/dist/components/table/table.context.jsx +0 -4
  136. package/dist/components/table/thead.jsx +0 -103
  137. package/dist/config/context.js +0 -12
  138. package/dist/config/default-translations.jsx +0 -83
  139. package/dist/config/default-tweaks.js +0 -4
  140. package/dist/constants.js +0 -2
  141. package/dist/hooks/use-click-outside.js +0 -17
  142. package/dist/hooks/use-color-parser.js +0 -9
  143. package/dist/hooks/use-components-provider.jsx +0 -19
  144. package/dist/hooks/use-debounce.js +0 -12
  145. package/dist/hooks/use-floating-ref.js +0 -6
  146. package/dist/hooks/use-form.js +0 -550
  147. package/dist/hooks/use-hover.js +0 -18
  148. package/dist/hooks/use-input-id.js +0 -5
  149. package/dist/hooks/use-is-coarse-device.js +0 -12
  150. package/dist/hooks/use-locale.js +0 -10
  151. package/dist/hooks/use-media-query.js +0 -25
  152. package/dist/hooks/use-on-event.js +0 -7
  153. package/dist/hooks/use-parent.js +0 -21
  154. package/dist/hooks/use-preferences.js +0 -23
  155. package/dist/hooks/use-previous.js +0 -9
  156. package/dist/hooks/use-reactive.js +0 -9
  157. package/dist/hooks/use-remove-scroll.js +0 -61
  158. package/dist/hooks/use-resize-observer.js +0 -17
  159. package/dist/hooks/use-stable-ref.js +0 -9
  160. package/dist/hooks/use-swipe.js +0 -17
  161. package/dist/hooks/use-translations.js +0 -9
  162. package/dist/hooks/use-tweaks.js +0 -9
  163. package/dist/hooks/use-window-size.js +0 -14
  164. package/dist/lib/combi-keys.js +0 -60
  165. package/dist/lib/dict.js +0 -39
  166. package/dist/lib/dom.js +0 -62
  167. package/dist/lib/fns.js +0 -46
  168. package/dist/lib/fzf.js +0 -117
  169. package/dist/lib/keyboard-area.js +0 -14
  170. package/dist/styles/common.js +0 -29
  171. package/dist/styles/dark.js +0 -214
  172. package/dist/styles/design-tokens.js +0 -69
  173. package/dist/styles/light.js +0 -214
  174. package/dist/styles/theme.js +0 -4
  175. package/dist/styles/theme.types.js +0 -1
  176. package/dist/types.js +0 -1
@@ -1,299 +0,0 @@
1
- "use client";
2
- import { add, eachDayOfInterval, endOfWeek, isAfter, isBefore, isSameMonth, isToday, setYear, startOfDay, startOfMonth, startOfWeek, sub, format, set, } from "date-fns";
3
- import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
4
- import { AnimatePresence, motion, MotionConfig } from "motion/react";
5
- import React, { useEffect, useRef } from "react";
6
- import { Is } from "sidekicker";
7
- import TheMaskInput from "the-mask-input";
8
- import { useReducer } from "use-typed-reducer";
9
- import { useDebounce } from "../../hooks/use-debounce";
10
- import { useLocale } from "../../hooks/use-locale";
11
- import { useSwipe } from "../../hooks/use-swipe";
12
- import { useTranslations } from "../../hooks/use-translations";
13
- import { css } from "../../lib/dom";
14
- import { splitInto, uuid } from "../../lib/fns";
15
- import { Input } from "../form/input";
16
- const timeRegex = /^(?<hour>\d\d):(?<min>\d\d)$/;
17
- const transition = { type: "spring", bounce: 0.3, duration: 0.6 };
18
- const dir = (mod) => (n = 1) => ({ x: `${100 * mod * n}%`, opacity: 0.25 });
19
- const variants = {
20
- enter: dir(1),
21
- exit: dir(-1),
22
- middle: { x: "0%", opacity: 1 },
23
- };
24
- const removeImmediately = { exit: { visibility: "hidden" } };
25
- const createDays = (month) => {
26
- const start = startOfWeek(startOfMonth(month));
27
- return eachDayOfInterval({ start, end: add(start, { days: 41 }) });
28
- };
29
- const formatMonth = (d, locale) => d.toLocaleDateString(locale, { month: "long" });
30
- const getOptionsMonth = (id, date, locale) => Array.from({ length: 12 }).map((_, i) => {
31
- const month = startOfMonth(new Date(1970, i, 1).setMonth(i));
32
- const label = formatMonth(month, locale);
33
- return (<option value={label} key={`${id}-${label}`} data-index={i}>
34
- {label}
35
- </option>);
36
- });
37
- const onChangeUsingKeyboard = {
38
- ArrowLeft: (date, duration) => (duration === "days" ? sub(date, { days: 1 }) : sub(date, { months: 1 })),
39
- ArrowRight: (date, duration) => (duration === "days" ? add(date, { days: 1 }) : add(date, { months: 1 })),
40
- ArrowUp: (date, duration) => (duration === "days" ? sub(date, { weeks: 1 }) : sub(date, { years: 1 })),
41
- ArrowDown: (date, duration) => (duration === "days" ? add(date, { weeks: 1 }) : add(date, { years: 1 })),
42
- };
43
- const focusDate = (origin, root, next, delay = 0) => {
44
- const d = next.toISOString();
45
- const select = () => {
46
- if (origin?.dataset.focustrap) {
47
- const el = root.current?.querySelector(`button[data-focustrap="${origin?.dataset.focustrap}"]`);
48
- return setTimeout(() => el?.focus({ preventScroll: true }), delay);
49
- }
50
- if (root.current) {
51
- const element = root.current.querySelector(`button[data-date="${d}"]`);
52
- if (element)
53
- return element.focus({ preventScroll: true });
54
- }
55
- };
56
- if (delay === 0)
57
- select();
58
- setTimeout(select, delay);
59
- };
60
- const formatYear = (now) => now.getFullYear().toString().padStart(4, "0");
61
- const inRange = (start, middle, end) => {
62
- if (start === undefined || end === undefined)
63
- return false;
64
- return isAfter(middle, start) && isBefore(middle, end);
65
- };
66
- const CalendarBody = (props) => {
67
- const translate = useTranslations();
68
- return (<motion.tbody layout variants={variants} custom={props.direction} onKeyDown={props.onKeyDown} className={css(props.styles?.week)}>
69
- {props.zip.map((week, index) => {
70
- const weekClassName = Is.function(props.styles?.week) ? props.styles?.week(week) : props.styles?.week;
71
- return (<tr key={`week-${week.length}-${index}`} className={weekClassName}>
72
- {week.map((day) => {
73
- const key = day.toISOString();
74
- const isSelected = props.rangeMode
75
- ? key === props.range?.to?.toISOString() || key === props.range?.from?.toISOString()
76
- : key === (props.date ? startOfDay(props.date).toISOString() : undefined);
77
- const today = isToday(day) && props.markToday;
78
- const disabledByFn = props.disabledDate?.(day) || false;
79
- const sameMonth = isSameMonth(day, props.stateDate);
80
- const disableDate = !sameMonth || disabledByFn;
81
- const isInRange = props.rangeMode ? inRange(props.range?.from, day, props.range?.to) : false;
82
- return (<td key={key} align="center" className={css("relative p-1", Is.function(props.styles?.dayFrame) ? props.styles?.dayFrame(day) : props.styles?.dayFrame)}>
83
- <button type="button" data-date={key} disabled={disabledByFn} data-samemonth={sameMonth} data-range={props.rangeMode} onClick={props.dispatch.onSelectDate} data-view={props.stateDate.getMonth().toString()} className={css(`relative flex size-9 items-center justify-center rounded-full proportional-nums disabled:cursor-not-allowed ${today ? "text-emphasis" : ""} ${disableDate ? "text-disabled" : ""} ${isSelected ? "bg-primary text-primary-foreground" : ""}`, isInRange && props.markRange ? "size-9 border border-dashed border-card-border" : "", Is.function(props.styles?.day) ? props.styles?.day(day) : props.styles?.day)}>
84
- <div></div>
85
- {day.getDate()}
86
- {isSelected && props.stateRange.from?.toISOString() === key ? (<span className="absolute -top-2 left-0 h-full w-full">
87
- <span className="text-xs text-foreground">
88
- {props.labelRange?.from ?? translate.calendarFromDate}
89
- </span>
90
- </span>) : null}
91
- {isSelected && props.stateRange.to?.toISOString() === key ? (<span className="absolute -top-2 left-0 h-full w-full">
92
- <span className="text-xs text-foreground">{props.labelRange?.to ?? translate.calendarToDate}</span>
93
- </span>) : null}
94
- </button>
95
- {props.RenderOnDay ? <props.RenderOnDay date={day}/> : null}
96
- </td>);
97
- })}
98
- </tr>);
99
- })}
100
- </motion.tbody>);
101
- };
102
- const getToday = () => startOfDay(new Date());
103
- export const Calendar = ({ RenderOnDay, changeOnlyOnClick = false, labelRange, disabledDate, locale, markToday = true, onChangeMonth, onChangeYear, rangeMode = false, onChange, styles, markRange = true, type = "date", datetimeTitle, ...props }) => {
104
- const id = useRef(uuid());
105
- const translations = useTranslations();
106
- const currentLocale = useLocale(locale);
107
- const root = useRef(null);
108
- const { date, range } = props;
109
- const providedDate = date || new Date();
110
- const monthClicked = useRef(null);
111
- const [state, dispatch] = useReducer({
112
- date: providedDate,
113
- isAnimating: false,
114
- year: formatYear(providedDate),
115
- direction: undefined,
116
- range: { from: range?.from, to: range?.to },
117
- months: getOptionsMonth(id.current, providedDate, currentLocale),
118
- selectMode: (rangeMode ? "from" : undefined),
119
- week: eachDayOfInterval({ start: startOfWeek(providedDate), end: endOfWeek(providedDate) }),
120
- }, (get) => ({
121
- onChangeYear: (year) => ({ year }),
122
- onExitComplete: () => {
123
- focusDate(monthClicked.current || null, root, get.state().date, 200);
124
- monthClicked.current = null;
125
- return { isAnimating: false };
126
- },
127
- date: (callback) => {
128
- const newDate = callback(get.state().date);
129
- return { date: newDate, year: formatYear(newDate) };
130
- },
131
- nextMonth: (e) => {
132
- if (e)
133
- monthClicked.current = e.currentTarget;
134
- const state = get.state();
135
- if (state.isAnimating)
136
- return state;
137
- const date = add(state.date, { months: 1 });
138
- return { date, isAnimating: true, direction: 1, year: formatYear(date) };
139
- },
140
- previousMonth: (e) => {
141
- if (e)
142
- monthClicked.current = e.currentTarget;
143
- const state = get.state();
144
- if (state.isAnimating)
145
- return state;
146
- const date = sub(state.date, { months: 1 });
147
- return { date, isAnimating: true, direction: -1, year: formatYear(date) };
148
- },
149
- onSelectDate: (e) => {
150
- const state = get.state();
151
- const isRangeMode = e.currentTarget.dataset.range === "true";
152
- const d = e.currentTarget.dataset.date || "";
153
- const date = new Date(d);
154
- return {
155
- date,
156
- year: formatYear(date),
157
- selectMode: state.selectMode === undefined ? undefined : state.selectMode === "from" ? "to" : "from",
158
- range: !isRangeMode
159
- ? state.range
160
- : {
161
- from: state.selectMode === "from" ? date : state.range.from,
162
- to: state.selectMode === "to" ? date : state.range.to,
163
- },
164
- };
165
- },
166
- onChangeMonth: (e) => {
167
- const value = e.target.value;
168
- const array = Array.from(e.target.options);
169
- const month = array.find((x) => x.value === value);
170
- const state = get.state();
171
- if (month) {
172
- const i = month.dataset.index || "";
173
- const d = new Date(get.state().date);
174
- d.setMonth(+i);
175
- return { ...state, date: d, year: formatYear(d) };
176
- }
177
- return state;
178
- },
179
- onKeyDown: (e) => {
180
- const key = e.key;
181
- const state = get.state();
182
- if (key in onChangeUsingKeyboard) {
183
- if (key === "ArrowUp" || key === "ArrowDown")
184
- e.preventDefault();
185
- const prev = get.state().date;
186
- const date = Is.keyof(onChangeUsingKeyboard, key) ? onChangeUsingKeyboard[key](prev, e.shiftKey ? "month" : "days") : null;
187
- if (date !== null) {
188
- focusDate(e.target, root, date);
189
- return { ...state, date, year: formatYear(date) };
190
- }
191
- }
192
- return get.state();
193
- },
194
- }), {
195
- props: { onChangeMonth, onChangeYear },
196
- postMiddleware: [
197
- (state, _, args) => {
198
- const isValidMethod = args.method === "onChangeMonth" || args.method === "previousMonth" || args.method === "nextMonth";
199
- if (isValidMethod)
200
- args.props.onChangeMonth?.(state.date);
201
- return state;
202
- },
203
- (state, _, args) => {
204
- const isValidMethod = args.method === "onChangeYear";
205
- if (isValidMethod)
206
- args.props.onChangeYear?.(state.date);
207
- return state;
208
- },
209
- (state, _, args) => {
210
- const isValidMethod = args.method === "onSelectDate" || args.method === "setToday" || args.method === "onKeyDown";
211
- if (rangeMode && isValidMethod && changeOnlyOnClick) {
212
- onChange?.(state.range);
213
- return state;
214
- }
215
- if (isValidMethod && changeOnlyOnClick)
216
- onChange?.(state.date);
217
- return state;
218
- },
219
- ],
220
- });
221
- const allDaysOfMonth = createDays(state.date);
222
- const zip = splitInto(allDaysOfMonth, 7);
223
- const currentAsString = state.date.toISOString();
224
- const monthString = formatMonth(state.date, currentLocale);
225
- useEffect(() => {
226
- if (!changeOnlyOnClick)
227
- onChange?.(state.date);
228
- }, [currentAsString, changeOnlyOnClick]);
229
- const defer = useDebounce((y) => dispatch.date((prev) => setYear(new Date(prev), +y)), 1200);
230
- const internalOnChangeYear = (e) => {
231
- const value = e.currentTarget.value;
232
- dispatch.onChangeYear(value);
233
- onChangeYear?.(new Date(value));
234
- defer(value);
235
- };
236
- const swipe = useSwipe((event, direction) => {
237
- event.preventDefault();
238
- return direction === "right" ? dispatch.previousMonth() : dispatch.nextMonth();
239
- }, 10);
240
- const onSetToday = () => {
241
- const d = getToday();
242
- dispatch.date(() => d);
243
- onChange?.(d);
244
- };
245
- return (<MotionConfig transition={transition}>
246
- <div ref={root} data-component="calendar" onTouchEnd={swipe.onTouchEnd} onTouchStart={swipe.onTouchStart} className={css("relative overflow-hidden", Is.function(styles?.calendar) ? styles?.calendar(allDaysOfMonth) : styles?.calendar)}>
247
- <div className="flex flex-col justify-center rounded text-center">
248
- <AnimatePresence initial={false} mode="popLayout" custom={state.direction} onExitComplete={dispatch.onExitComplete}>
249
- <motion.div key={monthString} initial="enter" animate="middle" exit="exit">
250
- <header className="relative flex justify-between">
251
- <motion.button layout type="button" data-focustrap="prev" variants={removeImmediately} onClick={dispatch.previousMonth} title={translations.calendarBackMonth} className="z-calendar rounded-full p-1.5 hover:bg-primary hover:text-primary-foreground">
252
- <ChevronLeftIcon className="h-4 w-4"/>
253
- </motion.button>
254
- <motion.span layout variants={variants} custom={state.direction} className="absolute inset-0 isolate z-normal flex items-center justify-center font-semibold">
255
- <span className="flex w-fit items-center justify-center gap-0.5 py-1">
256
- <select value={monthString} onChange={dispatch.onChangeMonth} aria-label={translations.calendarMonthLabel} style={{ width: `${monthString.length + 1}ch` }} className="cursor-pointer appearance-none bg-transparent capitalize proportional-nums hover:text-primary">
257
- {state.months}
258
- </select>
259
- <TheMaskInput mask="int" maxLength={4} placeholder="YYYY" value={state.year} onChange={internalOnChangeYear} style={{ width: `${state.year.length}ch` }} className="w-16 cursor-pointer appearance-none bg-transparent hover:text-primary"/>
260
- </span>
261
- </motion.span>
262
- <motion.button layout type="button" data-focustrap="next" variants={removeImmediately} onClick={dispatch.nextMonth} title={translations.calendarNextMonth} className="z-calendar rounded-full p-1.5 hover:bg-primary hover:text-primary-foreground">
263
- <ChevronRightIcon className="h-4 w-4"/>
264
- </motion.button>
265
- </header>
266
- <motion.table className="mt-2 table min-w-full table-auto border-0">
267
- <thead>
268
- <tr>
269
- {state.week.map((dayOfWeek) => (<th role="columnheader" key={dayOfWeek.toString()} className={css("py-2 text-sm font-medium capitalize", Is.function(styles?.weekDay) ? styles.weekDay(dayOfWeek) : styles?.weekDay)}>
270
- {dayOfWeek.toLocaleDateString(currentLocale, { weekday: "short" })}
271
- </th>))}
272
- </tr>
273
- </thead>
274
- <CalendarBody zip={zip} range={range} styles={styles} date={date || null} dispatch={dispatch} markRange={markRange} markToday={markToday} rangeMode={rangeMode} stateDate={state.date} labelRange={labelRange} stateRange={state.range} RenderOnDay={RenderOnDay} direction={state.direction} disabledDate={disabledDate} onKeyDown={dispatch.onKeyDown}/>
275
- </motion.table>
276
- </motion.div>
277
- </AnimatePresence>
278
- </div>
279
- {type === "datetime" ? (<section className="my-4 grid items-center">
280
- <Input info={null} mask="time" optionalText=" " container="w-full" reportStatus={false} defaultValue={date ? format(date, "HH:mm") : undefined} title={datetimeTitle || translations.calendarDatetimeTitle} onChange={(e) => {
281
- const value = e.target.value;
282
- const match = timeRegex.exec(value);
283
- if (!match)
284
- return;
285
- const hour = match.groups.hour;
286
- const min = match.groups.min;
287
- const d = set(state.date, { hours: Number(hour), minutes: Number(min), seconds: 0 });
288
- dispatch.date(() => d);
289
- onChange?.(d);
290
- }}/>
291
- </section>) : null}
292
- <footer className="mt-2 text-center text-primary">
293
- <button type="button" onClick={onSetToday} className="transition-transform duration-300 hover:scale-105">
294
- {translations.calendarToday}
295
- </button>
296
- </footer>
297
- </div>
298
- </MotionConfig>);
299
- };
@@ -1,43 +0,0 @@
1
- import { InfoIcon } from "lucide-react";
2
- import React from "react";
3
- import { Is } from "sidekicker";
4
- import { css } from "../../lib/dom";
5
- import { Polymorph } from "../core/polymorph";
6
- import { Skeleton } from "./skeleton";
7
- export const Card = ({ title, loading, children, as, header = null, container = "", titleClassName = "", ...props }) => (<Polymorph {...props} as={as || "div"} data-component="card" className={css("flex w-full flex-col gap-4 rounded-card border border-card-border bg-card-background py-3 shadow-shadow-card", container)}>
8
- {title ? (<header data-component="card-title" className={css("mb-2 w-full border-b border-card-border px-6 pb-2 text-xl font-medium", titleClassName)}>
9
- {title}
10
- </header>) : (header)}
11
- <div data-component="card-body" className={css("min-w-full px-6", props.className)}>
12
- {loading ? (<div className="flex flex-col gap-4">
13
- <Skeleton className="w-full"/>
14
- <Skeleton className="w-8/12"/>
15
- <Skeleton className="w-10/12"/>
16
- <Skeleton className="w-1/2"/>
17
- </div>) : (children)}
18
- </div>
19
- </Polymorph>);
20
- Card.Title = ({ as, titleTag, navTag, children, ...props }) => {
21
- const Component = (as || "div");
22
- const Title = (titleTag || "h2");
23
- const Nav = (navTag || "nav");
24
- return (<Component {...props} title={Is.string(props.title) ? props.title : undefined} className={css("flex w-full flex-col flex-wrap items-start justify-between gap-base sm:flex-row sm:items-center", props.className)}>
25
- <Title className="font-semibold">{props.title}</Title>
26
- {children ? (<Nav className="gap-kilo flex flex-col items-start justify-start sm:flex-row sm:items-center sm:justify-end">{children}</Nav>) : null}
27
- </Component>);
28
- };
29
- export const StatsCard = (props) => {
30
- const interactive = props.interactive ?? true;
31
- const Icon = props.Icon ?? InfoIcon;
32
- return (<Card {...props} title={null} loading={undefined} container="px-0 py-0" className="flex items-center gap-4 px-0">
33
- <div className={`flex w-full items-center gap-4 rounded-card px-0 lg:px-0 ${interactive ? "transition-colors duration-300 ease-linear hover:bg-primary-hover/10" : ""}`}>
34
- <div className={css("flex aspect-square h-[stretch] w-20 items-center justify-center rounded-l-card bg-primary p-4 text-primary-foreground", props.mark)}>
35
- {<Icon size={48}/>}
36
- </div>
37
- <div className="flex flex-col justify-center gap-2 py-2">
38
- <p className="text-lg">{props.title}</p>
39
- {props.loading ? <Skeleton className="h-10"/> : <p className="text-4xl font-bold tracking-wide">{props.value}</p>}
40
- </div>
41
- </div>
42
- </Card>);
43
- };
@@ -1,11 +0,0 @@
1
- import { FileIcon } from "lucide-react";
2
- import React from "react";
3
- import { useTranslations } from "../../hooks/use-translations";
4
- export const Empty = (props) => {
5
- const Icon = props.Icon ?? FileIcon;
6
- const translate = useTranslations();
7
- return (<div className="flex w-full flex-col items-center justify-center gap-4 px-8 py-12">
8
- <Icon size={64} className="text-disabled"/>
9
- <p className="text-disabled">{props.message ?? translate.emptyDataMessage}</p>
10
- </div>);
11
- };
@@ -1,81 +0,0 @@
1
- "use client";
2
- import { FloatingFocusManager, FloatingOverlay, FloatingPortal, useClick, useDismiss, useFloating, useInteractions, useRole, } from "@floating-ui/react";
3
- import { AnimatePresence, motion, MotionConfig } from "motion/react";
4
- import { XIcon } from "lucide-react";
5
- import React, { Fragment, useCallback, useId, useState } from "react";
6
- const FloatItem = ({ item, context, setter, get, refs }) => (<FloatingPortal>
7
- <MotionConfig reducedMotion="user" transition={{ type: "tween", stiffness: 25, duration: 0.3 }}>
8
- <AnimatePresence presenceAffectsLayout>
9
- {item ? (<motion.div exit={{ opacity: 0 }} animate={{ opacity: 1 }} initial={{ opacity: 0 }} className="pointer-events-none fixed inset-0 top-0 z-overlay h-screen w-screen bg-floating-overlay/70"/>) : null}
10
- {item ? (<FloatingOverlay lockScroll className="absolute inset-0 z-floating flex items-center justify-center">
11
- <FloatingFocusManager visuallyHiddenDismiss modal closeOnFocusOut context={context}>
12
- <motion.div layout layoutId={`item-${item.id}`} className="relative flex h-min w-min min-w-xs flex-col gap-4 rounded-card border border-card-border bg-card-background p-6 py-4 pb-8 shadow-shadow-card" ref={refs.setFloating} {...get()}>
13
- <nav className="absolute right-4 top-1 lg:right-2">
14
- <button type="button" onClick={setter} className="p-1 opacity-70 transition-colors hover:text-danger hover:opacity-100 focus:text-danger">
15
- <XIcon />
16
- </button>
17
- </nav>
18
- <header className="flex w-full flex-wrap items-center justify-between gap-2">
19
- <h3 className="min-w-full text-balance text-2xl font-medium">{item.title}</h3>
20
- <p className="text-sm leading-snug text-secondary">{item.description}</p>
21
- </header>
22
- {item.children}
23
- </motion.div>
24
- </FloatingFocusManager>
25
- </FloatingOverlay>) : null}
26
- </AnimatePresence>
27
- </MotionConfig>
28
- </FloatingPortal>);
29
- export const AnimatedList = (props) => {
30
- const [selected, setSelected] = useState(null);
31
- const id = useId();
32
- const { context, refs } = useFloating({
33
- open: selected !== null,
34
- transform: true,
35
- onOpenChange: (open) => (open ? undefined : setSelected(null)),
36
- });
37
- const click = useClick(context);
38
- const role = useRole(context, { role: "dialog" });
39
- const dismiss = useDismiss(context, { escapeKey: true, referencePress: true, outsidePress: true });
40
- const { getFloatingProps } = useInteractions([click, role, dismiss]);
41
- const clear = useCallback(() => {
42
- setSelected(null);
43
- }, []);
44
- const items = React.Children.toArray(props.children);
45
- return (<Fragment>
46
- <FloatItem refs={refs} context={context} get={getFloatingProps} item={selected} setter={clear}/>
47
- <ul role="list">
48
- {items.map((x, index) => {
49
- const item = x.props;
50
- const innerId = `${id}-${index}`;
51
- const setter = () => setSelected({ ...item, id: innerId });
52
- const Leading = item.leading;
53
- return (<motion.li layout key={innerId} layoutId={`item-${innerId}`} className={`border-b border-card-border py-2 last:border-transparent`}>
54
- <motion.div layoutId={`toast-${innerId}`} className="relative">
55
- <div className="relative flex items-start space-x-3">
56
- <Fragment>
57
- {item.avatar ? (<div>
58
- <div className="relative px-1">
59
- <button onClick={setter} className="flex size-10 items-center justify-center ring-primary">
60
- {item.avatar}
61
- </button>
62
- </div>
63
- </div>) : null}
64
- <div className="min-w-0 flex-1 py-1 text-foreground">
65
- <div className="flex flex-row flex-nowrap justify-between gap-4">
66
- <button onClick={setter} className="cursor-pointer text-left transition-all ease-out hover:text-primary">
67
- <h3>{item.title}</h3>
68
- <p className="text-sm leading-snug text-secondary">{item.description}</p>
69
- </button>
70
- {Leading ? <Leading open={setter}/> : null}
71
- </div>
72
- </div>
73
- </Fragment>
74
- </div>
75
- </motion.div>
76
- </motion.li>);
77
- })}
78
- </ul>
79
- </Fragment>);
80
- };
81
- export const AnimatedListItem = (props) => <Fragment>{props.children}</Fragment>;
@@ -1,126 +0,0 @@
1
- "use client";
2
- import { Toast as Base } from "@base-ui/react/toast";
3
- import { cva } from "class-variance-authority";
4
- import { XIcon, CheckCircleIcon, TriangleAlertIcon, InfoIcon, Loader2Icon } from "lucide-react";
5
- import { AnimatePresence, motion } from "motion/react";
6
- import { createContext, useCallback, useContext, useRef } from "react";
7
- import { useHover } from "../../hooks/use-hover";
8
- import { css } from "../../lib/dom";
9
- const variants = cva("relative isolate z-tooltip flex w-full flex-col overflow-hidden rounded-xl border bg-card-background backdrop-blur-md text-sm shadow-notification transition-all duration-300", {
10
- variants: {
11
- theme: {
12
- default: "border-card-border text-foreground shadow-black/5",
13
- info: "bg-alert-info-bg text-alert-info-text border-alert-info-border",
14
- warn: "bg-alert-warn-bg text-alert-warn-text border-alert-warn-border",
15
- muted: "bg-alert-muted-bg text-alert-muted-text border-alert-muted-border",
16
- danger: "bg-alert-danger-bg text-alert-danger-text border-alert-danger-border",
17
- success: "bg-alert-success-bg text-alert-success-text border-alert-success-border",
18
- secondary: "bg-alert-secondary-bg text-alert-secondary-text border-alert-secondary-border",
19
- },
20
- },
21
- defaultVariants: { theme: "default" },
22
- });
23
- const themeIcons = {
24
- default: InfoIcon,
25
- info: InfoIcon,
26
- warn: TriangleAlertIcon,
27
- muted: InfoIcon,
28
- danger: TriangleAlertIcon,
29
- success: CheckCircleIcon,
30
- secondary: InfoIcon,
31
- };
32
- const NotificationContext = createContext(() => {
33
- throw new Error("Not implemented");
34
- });
35
- export const useNotification = () => useContext(NotificationContext);
36
- function Notification(props) {
37
- const closable = props.toast.data?.closable ?? true;
38
- const loading = props.toast.data?.loading ?? false;
39
- const theme = props.toast.data?.theme || "default";
40
- const className = variants({ theme });
41
- const Icon = loading ? Loader2Icon : themeIcons[theme] || InfoIcon;
42
- return (<Base.Root toast={props.toast} swipeDirection="right">
43
- <motion.li layout initial={{ opacity: 0, y: -20, scale: 0.95 }} animate={{ opacity: 1, y: 0, scale: 1 }} exit={{ opacity: 0, scale: 0.9, y: -20, transition: { duration: 0.2 } }} transition={{
44
- type: "spring",
45
- damping: 25,
46
- stiffness: 300,
47
- }} className="pointer-events-auto w-full list-none">
48
- <Base.Content className={css(className, "shadow-lg")}>
49
- <div className="flex items-start gap-3 p-4">
50
- <div className={css("mt-0.5 shrink-0 opacity-80", loading && "animate-spin")}>
51
- <Icon className="size-4"/>
52
- </div>
53
-
54
- <div className="flex flex-1 flex-col gap-1 overflow-hidden">
55
- {props.toast.title ? <Base.Title className="select-text truncate font-semibold leading-tight tracking-tight"/> : null}
56
- <Base.Description className="line-clamp-2 select-text text-xs font-medium leading-relaxed opacity-90"/>
57
- </div>
58
-
59
- {closable && !loading ? (<Base.Close className="-mr-1 -mt-1 shrink-0 rounded-lg p-1.5 text-foreground/40 transition hover:bg-foreground/10 hover:text-foreground">
60
- <XIcon className="size-3.5"/>
61
- </Base.Close>) : null}
62
- </div>
63
- </Base.Content>
64
- </motion.li>
65
- </Base.Root>);
66
- }
67
- function NotificationsViewport({ max = 5 }) {
68
- const ref = useRef(null);
69
- const hover = useHover(ref);
70
- const toastManager = Base.useToastManager();
71
- const allToasts = max ? toastManager.toasts.slice(0, max) : toastManager.toasts;
72
- const visibleToasts = hover ? allToasts : allToasts.slice(0, 3);
73
- const hiddenCount = allToasts.length - visibleToasts.length;
74
- return (<Base.Viewport ref={ref} className="pointer-events-none fixed left-1/2 top-6 z-[100] flex w-full max-w-[380px] -translate-x-1/2 flex-col gap-3 overflow-visible outline-none">
75
- <AnimatePresence mode="popLayout" initial={false}>
76
- {visibleToasts.map((toast) => (<Notification key={toast.id} toast={toast}/>))}
77
- </AnimatePresence>
78
-
79
- {!hover && hiddenCount > 0 && (<motion.div layout initial={{ opacity: 0, y: -10 }} animate={{ opacity: 1, y: 0 }} exit={{ opacity: 0, y: -10 }} className="pointer-events-auto cursor-default self-center rounded-full border border-card-border bg-card-background/80 px-3 py-1 text-[10px] font-bold uppercase tracking-wider text-foreground/50 shadow-sm backdrop-blur transition-all hover:bg-card-background hover:text-foreground/80">
80
- +{hiddenCount} more
81
- </motion.div>)}
82
- </Base.Viewport>);
83
- }
84
- function NotificationsInner({ children, max = 5 }) {
85
- const toastManager = Base.useToastManager();
86
- const clear = useCallback(() => {
87
- toastManager.toasts.forEach((t) => toastManager.close(t.id));
88
- }, [toastManager]);
89
- const notify = useCallback((description, args) => {
90
- const data = { theme: args?.theme, closable: args?.closable, loading: args?.loading };
91
- if (args?.id) {
92
- const existing = toastManager.toasts.find((t) => t.id === args.id);
93
- if (existing) {
94
- toastManager.update(args.id, {
95
- description,
96
- title: args.title,
97
- timeout: args.timeout,
98
- data,
99
- });
100
- return { close: () => toastManager.close(args.id), clear };
101
- }
102
- }
103
- const id = toastManager.add({
104
- description,
105
- id: args?.id,
106
- title: args?.title,
107
- timeout: args?.timeout,
108
- data,
109
- });
110
- return {
111
- close: () => toastManager.close(id),
112
- clear,
113
- };
114
- }, [toastManager, clear]);
115
- return (<NotificationContext.Provider value={notify}>
116
- {children}
117
- <Base.Portal>
118
- <NotificationsViewport max={max}/>
119
- </Base.Portal>
120
- </NotificationContext.Provider>);
121
- }
122
- export function Notifications({ children, max = 5, timeout = 5000 }) {
123
- return (<Base.Provider limit={max} timeout={timeout}>
124
- <NotificationsInner max={max}>{children}</NotificationsInner>
125
- </Base.Provider>);
126
- }
@@ -1,11 +0,0 @@
1
- import { Is } from "sidekicker";
2
- import { Progress as RadixProgress } from "@base-ui/react/progress";
3
- import { css } from "../../lib/dom";
4
- export const Progress = (props) => {
5
- return (<RadixProgress.Root max={props.max} value={props.percent ?? null} style={{ transform: "translateZ(0)" }} className={css("relative h-6 w-full overflow-hidden rounded-full bg-background", props.container)}>
6
- <RadixProgress.Indicator style={{ transform: Is.number(props.percent) ? `translateX(-${100 - props.percent}%)` : undefined }} className={css("size-full bg-primary transition-transform duration-500 ease-in-out", props.className)}/>
7
- {Is.number(props.percent) ? (<p className={css("absolute inset-0 flex w-full items-center justify-center font-semibold tabular-nums text-primary-foreground", props.textClassName)}>
8
- {props.label ? props.label : `${props.percent} %`}
9
- </p>) : null}
10
- </RadixProgress.Root>);
11
- };
@@ -1,23 +0,0 @@
1
- import { CommandIcon, OptionIcon } from "lucide-react";
2
- import { Fragment } from "react";
3
- import { isMac } from "../../lib/combi-keys";
4
- const remap = (x) => {
5
- x = x.trim();
6
- if (x === "Alt")
7
- return isMac() ? <OptionIcon aria-label="Option" size={12}/> : "Alt";
8
- if (x === "Mod")
9
- return isMac() ? <CommandIcon aria-label="Command" size={12}/> : "Ctrl";
10
- return x;
11
- };
12
- export const Shortcut = (props) => {
13
- const p = props.value.trim().split("+");
14
- return (<span className="flex items-center gap-1 text-sm">
15
- {p.map((x, i) => {
16
- const isLast = p.length - 1 === i;
17
- return (<Fragment key={`${props.value}-${x}-key-${i}`}>
18
- <kbd aria-label={x}>{remap(x)}</kbd>
19
- {isLast ? null : <span>+</span>}
20
- </Fragment>);
21
- })}
22
- </span>);
23
- };
@@ -1,12 +0,0 @@
1
- import React, { useRef } from "react";
2
- import { css } from "../../lib/dom";
3
- import { Polymorph } from "../core/polymorph";
4
- export const SkeletonCell = <div className="h-6 w-10/12 animate-pulse rounded bg-muted"/>;
5
- export const Skeleton = (props) => (<Polymorph {...props} as={props.as || "span"} className={css("block h-8 w-32 animate-pulse rounded bg-muted", props.className)}/>);
6
- export const SkeletonList = (props) => {
7
- const items = useRef(Array.from({ length: props.rows }).map((_, i) => {
8
- const rand = Math.max(100, Math.random() * 99);
9
- return <Skeleton key={`skeleton-${rand}-${i}`} style={{ width: `${rand}%` }} as="li"/>;
10
- }));
11
- return <ul className={css("flex flex-col gap-6", props.className)}>{items.current}</ul>;
12
- };
@@ -1,7 +0,0 @@
1
- import { css } from "../../lib/dom";
2
- export const Spinner = (props) => (<span aria-busy="true" aria-description="Carregando..." className={css("box-border inline-block aspect-square size-12 animate-spin rounded-full border-4 border-background border-b-primary", props.className)}/>);
3
- export const Loading = () => {
4
- return (<div className="flex h-full w-full items-center justify-center p-12">
5
- <Spinner />
6
- </div>);
7
- };
@@ -1,20 +0,0 @@
1
- import React from "react";
2
- import { css } from "../../lib/dom";
3
- export const Stats = (props) => {
4
- return (<div className="divide-y divide-card-border rounded-card border border-card-border bg-card-background shadow-shadow-card">
5
- <header className="flex items-start gap-4 p-6">
6
- <div className={css("flex aspect-square size-10 items-center justify-center rounded-card bg-primary p-8", props.iconContainer)}>
7
- <div>
8
- <props.Icon className="aspect-square size-10 text-primary-foreground"/>
9
- </div>
10
- </div>
11
- <div className="flex flex-col gap-1">
12
- <header>
13
- <h3 className="text-base leading-none">{props.title}</h3>
14
- </header>
15
- <p className="text-4xl font-semibold">{props.children}</p>
16
- </div>
17
- </header>
18
- {props.footer ? <footer className="px-6 py-2">{props.footer}</footer> : null}
19
- </div>);
20
- };