@g4rcez/components 3.0.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 (265) 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/button.d.ts +2 -8
  53. package/dist/components/core/button.d.ts.map +1 -1
  54. package/dist/components/core/polymorph.d.ts.map +1 -1
  55. package/dist/components/core/slot.d.ts +1 -1
  56. package/dist/components/core/slot.d.ts.map +1 -1
  57. package/dist/components/core/tag.d.ts +2 -2
  58. package/dist/components/core/tag.d.ts.map +1 -1
  59. package/dist/components/core/typography.d.ts.map +1 -1
  60. package/dist/components/display/alert.d.ts.map +1 -1
  61. package/dist/components/display/calendar.d.ts.map +1 -1
  62. package/dist/components/display/card.d.ts.map +1 -1
  63. package/dist/components/display/list.d.ts.map +1 -1
  64. package/dist/components/display/notifications.d.ts +2 -0
  65. package/dist/components/display/notifications.d.ts.map +1 -1
  66. package/dist/components/display/progress.d.ts.map +1 -1
  67. package/dist/components/display/skeleton.d.ts.map +1 -1
  68. package/dist/components/display/step.d.ts.map +1 -1
  69. package/dist/components/display/tabs.d.ts.map +1 -1
  70. package/dist/components/floating/command-palette.d.ts +1 -0
  71. package/dist/components/floating/command-palette.d.ts.map +1 -1
  72. package/dist/components/floating/dropdown.d.ts +1 -0
  73. package/dist/components/floating/dropdown.d.ts.map +1 -1
  74. package/dist/components/floating/menu.d.ts +2 -2
  75. package/dist/components/floating/menu.d.ts.map +1 -1
  76. package/dist/components/floating/modal.d.ts +20 -53
  77. package/dist/components/floating/modal.d.ts.map +1 -1
  78. package/dist/components/floating/tooltip.d.ts.map +1 -1
  79. package/dist/components/floating/wizard.d.ts +1 -1
  80. package/dist/components/floating/wizard.d.ts.map +1 -1
  81. package/dist/components/form/autocomplete.d.ts.map +1 -1
  82. package/dist/components/form/date-picker.d.ts.map +1 -1
  83. package/dist/components/form/free-text.d.ts.map +1 -1
  84. package/dist/components/form/input-field.d.ts +3 -2
  85. package/dist/components/form/input-field.d.ts.map +1 -1
  86. package/dist/components/form/multi-select.d.ts.map +1 -1
  87. package/dist/components/form/select.d.ts.map +1 -1
  88. package/dist/components/form/slider.d.ts.map +1 -1
  89. package/dist/components/index.d.ts +2 -0
  90. package/dist/components/index.d.ts.map +1 -1
  91. package/dist/components/page-calendar/calendar-header.d.ts +16 -0
  92. package/dist/components/page-calendar/calendar-header.d.ts.map +1 -0
  93. package/dist/components/page-calendar/day-view.d.ts +12 -0
  94. package/dist/components/page-calendar/day-view.d.ts.map +1 -0
  95. package/dist/components/page-calendar/event-pill.d.ts +9 -0
  96. package/dist/components/page-calendar/event-pill.d.ts.map +1 -0
  97. package/dist/components/page-calendar/index.d.ts +4 -0
  98. package/dist/components/page-calendar/index.d.ts.map +1 -0
  99. package/dist/components/page-calendar/month-view.d.ts +11 -0
  100. package/dist/components/page-calendar/month-view.d.ts.map +1 -0
  101. package/dist/components/page-calendar/page-calendar.d.ts +18 -0
  102. package/dist/components/page-calendar/page-calendar.d.ts.map +1 -0
  103. package/dist/components/page-calendar/page-calendar.types.d.ts +18 -0
  104. package/dist/components/page-calendar/page-calendar.types.d.ts.map +1 -0
  105. package/dist/components/page-calendar/page-calendar.utils.d.ts +18 -0
  106. package/dist/components/page-calendar/page-calendar.utils.d.ts.map +1 -0
  107. package/dist/components/page-calendar/week-view.d.ts +11 -0
  108. package/dist/components/page-calendar/week-view.d.ts.map +1 -0
  109. package/dist/components/table/index.d.ts.map +1 -1
  110. package/dist/components/table/inner-table.d.ts.map +1 -1
  111. package/dist/components/table/metadata.d.ts.map +1 -1
  112. package/dist/components/table/row.d.ts.map +1 -1
  113. package/dist/components/table/table-lib.d.ts.map +1 -1
  114. package/dist/components/table/thead.d.ts.map +1 -1
  115. package/dist/config/context.d.ts.map +1 -1
  116. package/dist/config/default-translations.d.ts +21 -4
  117. package/dist/config/default-translations.d.ts.map +1 -1
  118. package/dist/constants.d.ts.map +1 -1
  119. package/dist/hooks/use-components-provider.d.ts.map +1 -1
  120. package/dist/hooks/use-form.d.ts +11 -11
  121. package/dist/hooks/use-form.d.ts.map +1 -1
  122. package/dist/hooks/use-input-id.d.ts.map +1 -1
  123. package/dist/hooks/use-preferences.d.ts.map +1 -1
  124. package/dist/hooks/use-previous.d.ts.map +1 -1
  125. package/dist/hooks/use-reactive.d.ts.map +1 -1
  126. package/dist/hooks/use-resize-observer.d.ts.map +1 -1
  127. package/dist/hooks/use-stable-ref.d.ts.map +1 -1
  128. package/dist/hooks/use-swipe.d.ts.map +1 -1
  129. package/dist/hooks/use-translations.d.ts +21 -4
  130. package/dist/hooks/use-translations.d.ts.map +1 -1
  131. package/dist/index.css +1 -0
  132. package/dist/index.d.ts.map +1 -1
  133. package/dist/index.js +28 -20
  134. package/dist/index.js.map +1 -1
  135. package/dist/index.mjs +13862 -12512
  136. package/dist/index.mjs.map +1 -1
  137. package/dist/index.umd.js +24 -17
  138. package/dist/index.umd.js.map +1 -1
  139. package/dist/lib/dom.d.ts +1 -0
  140. package/dist/lib/dom.d.ts.map +1 -1
  141. package/dist/lib/fns.d.ts.map +1 -1
  142. package/dist/preset/plugin.tailwind.d.ts +9 -0
  143. package/dist/preset/plugin.tailwind.d.ts.map +1 -0
  144. package/dist/preset/plugin.tailwind.js +27 -0
  145. package/dist/preset/preset.tailwind.d.ts +8 -0
  146. package/dist/preset/preset.tailwind.d.ts.map +1 -0
  147. package/dist/preset/preset.tailwind.js +54 -0
  148. package/dist/preset/src/styles/common.d.ts +2 -14
  149. package/dist/preset/src/styles/common.d.ts.map +1 -1
  150. package/dist/preset/src/styles/common.js +1 -0
  151. package/dist/preset/src/styles/dark.d.ts.map +1 -1
  152. package/dist/preset/src/styles/dark.js +119 -114
  153. package/dist/preset/src/styles/light.d.ts.map +1 -1
  154. package/dist/preset/src/styles/light.js +111 -106
  155. package/dist/preset/src/styles/theme.types.d.ts +17 -8
  156. package/dist/preset/src/styles/theme.types.d.ts.map +1 -1
  157. package/dist/styles/common.d.ts +2 -14
  158. package/dist/styles/common.d.ts.map +1 -1
  159. package/dist/styles/dark.d.ts.map +1 -1
  160. package/dist/styles/light.d.ts.map +1 -1
  161. package/dist/styles/theme.types.d.ts +17 -8
  162. package/dist/styles/theme.types.d.ts.map +1 -1
  163. package/package.json +299 -301
  164. package/dist/components/core/button.jsx +0 -86
  165. package/dist/components/core/heading.jsx +0 -4
  166. package/dist/components/core/polymorph.jsx +0 -5
  167. package/dist/components/core/render-on-view.jsx +0 -31
  168. package/dist/components/core/resizable.jsx +0 -51
  169. package/dist/components/core/slot.jsx +0 -163
  170. package/dist/components/core/tag.jsx +0 -51
  171. package/dist/components/core/typography.jsx +0 -26
  172. package/dist/components/display/alert.jsx +0 -56
  173. package/dist/components/display/calendar.jsx +0 -301
  174. package/dist/components/display/card.jsx +0 -43
  175. package/dist/components/display/empty.jsx +0 -11
  176. package/dist/components/display/list.jsx +0 -81
  177. package/dist/components/display/notifications.jsx +0 -98
  178. package/dist/components/display/progress.jsx +0 -13
  179. package/dist/components/display/shortcut.jsx +0 -23
  180. package/dist/components/display/skeleton.jsx +0 -14
  181. package/dist/components/display/spinner.jsx +0 -7
  182. package/dist/components/display/stats.jsx +0 -20
  183. package/dist/components/display/step.jsx +0 -131
  184. package/dist/components/display/tabs.jsx +0 -100
  185. package/dist/components/display/timeline.jsx +0 -25
  186. package/dist/components/floating/command-palette.jsx +0 -172
  187. package/dist/components/floating/dropdown.jsx +0 -53
  188. package/dist/components/floating/expand.jsx +0 -44
  189. package/dist/components/floating/menu.jsx +0 -147
  190. package/dist/components/floating/modal.jsx +0 -241
  191. package/dist/components/floating/toolbar.jsx +0 -5
  192. package/dist/components/floating/tooltip.jsx +0 -64
  193. package/dist/components/floating/wizard.jsx +0 -164
  194. package/dist/components/form/autocomplete.jsx +0 -275
  195. package/dist/components/form/checkbox.jsx +0 -12
  196. package/dist/components/form/date-picker.jsx +0 -115
  197. package/dist/components/form/file-upload.jsx +0 -133
  198. package/dist/components/form/form.jsx +0 -10
  199. package/dist/components/form/formReset.jsx +0 -17
  200. package/dist/components/form/free-text.jsx +0 -41
  201. package/dist/components/form/input-field.jsx +0 -54
  202. package/dist/components/form/input.jsx +0 -36
  203. package/dist/components/form/multi-select.jsx +0 -328
  204. package/dist/components/form/radiobox.jsx +0 -6
  205. package/dist/components/form/select.jsx +0 -42
  206. package/dist/components/form/slider.jsx +0 -45
  207. package/dist/components/form/switch.jsx +0 -46
  208. package/dist/components/form/task-list.jsx +0 -26
  209. package/dist/components/form/textarea.jsx +0 -12
  210. package/dist/components/form/transfer-list.jsx +0 -39
  211. package/dist/components/index.js +0 -43
  212. package/dist/components/table/filter.jsx +0 -141
  213. package/dist/components/table/group.jsx +0 -68
  214. package/dist/components/table/index.jsx +0 -60
  215. package/dist/components/table/inner-table.jsx +0 -104
  216. package/dist/components/table/metadata.jsx +0 -37
  217. package/dist/components/table/pagination.jsx +0 -73
  218. package/dist/components/table/row.jsx +0 -58
  219. package/dist/components/table/sort.jsx +0 -105
  220. package/dist/components/table/table-lib.js +0 -84
  221. package/dist/components/table/table.context.jsx +0 -4
  222. package/dist/components/table/thead.jsx +0 -103
  223. package/dist/config/context.js +0 -12
  224. package/dist/config/default-translations.jsx +0 -66
  225. package/dist/config/default-tweaks.js +0 -4
  226. package/dist/constants.js +0 -2
  227. package/dist/hooks/use-click-outside.js +0 -17
  228. package/dist/hooks/use-color-parser.js +0 -9
  229. package/dist/hooks/use-components-provider.jsx +0 -16
  230. package/dist/hooks/use-debounce.js +0 -12
  231. package/dist/hooks/use-floating-ref.js +0 -6
  232. package/dist/hooks/use-form.js +0 -549
  233. package/dist/hooks/use-hover.js +0 -18
  234. package/dist/hooks/use-input-id.js +0 -5
  235. package/dist/hooks/use-is-coarse-device.js +0 -12
  236. package/dist/hooks/use-locale.js +0 -10
  237. package/dist/hooks/use-media-query.js +0 -25
  238. package/dist/hooks/use-on-event.js +0 -7
  239. package/dist/hooks/use-parent.js +0 -21
  240. package/dist/hooks/use-preferences.js +0 -23
  241. package/dist/hooks/use-previous.js +0 -8
  242. package/dist/hooks/use-reactive.js +0 -8
  243. package/dist/hooks/use-remove-scroll.js +0 -61
  244. package/dist/hooks/use-resize-observer.js +0 -17
  245. package/dist/hooks/use-stable-ref.js +0 -8
  246. package/dist/hooks/use-swipe.js +0 -16
  247. package/dist/hooks/use-translations.js +0 -9
  248. package/dist/hooks/use-tweaks.js +0 -9
  249. package/dist/hooks/use-window-size.js +0 -14
  250. package/dist/lib/combi-keys.js +0 -60
  251. package/dist/lib/dict.js +0 -39
  252. package/dist/lib/dom.js +0 -44
  253. package/dist/lib/fns.js +0 -46
  254. package/dist/lib/fzf.js +0 -117
  255. package/dist/lib/keyboard-area.js +0 -14
  256. package/dist/preset/tailwindcssv4.d.ts +0 -3
  257. package/dist/preset/tailwindcssv4.d.ts.map +0 -1
  258. package/dist/preset/tailwindcssv4.js +0 -75
  259. package/dist/styles/common.js +0 -28
  260. package/dist/styles/dark.js +0 -209
  261. package/dist/styles/design-tokens.js +0 -69
  262. package/dist/styles/light.js +0 -209
  263. package/dist/styles/theme.js +0 -4
  264. package/dist/styles/theme.types.js +0 -1
  265. package/dist/types.js +0 -1
@@ -1,86 +0,0 @@
1
- import { cva } from "class-variance-authority";
2
- import React, { forwardRef } from "react";
3
- import { css } from "../../lib/dom";
4
- import { Polymorph } from "./polymorph";
5
- /**
6
- * Button variant definitions for styling
7
- * @internal
8
- */
9
- const variants = {
10
- size: {
11
- icon: "p-1",
12
- big: "h-12 px-6 py-4",
13
- default: "h-10 px-4 py-2",
14
- min: "h-7 px-3 py-1 text-sm",
15
- small: "h-8 px-4 py-2 text-sm",
16
- tiny: "h-6 px-2 py-1 text-sm",
17
- },
18
- rounded: {
19
- rough: "rounded-xs",
20
- squared: "rounded-none",
21
- default: "rounded-button",
22
- circle: "rounded-full aspect-square",
23
- },
24
- theme: {
25
- raw: "",
26
- disabled: "bg-disabled opacity-70",
27
- loading: "animate-pulse bg-disabled",
28
- main: "bg-button-primary-bg text-button-primary-text",
29
- info: "bg-button-info-bg text-button-info-text",
30
- warn: "bg-button-warn-bg text-button-warn-text",
31
- muted: "bg-button-muted-bg text-button-muted-text",
32
- danger: "bg-button-danger-bg text-button-danger-text",
33
- neutral: "bg-transparent border-2 border-card-border",
34
- primary: "bg-button-primary-bg text-button-primary-text",
35
- success: "bg-button-success-bg text-button-success-text",
36
- secondary: "bg-button-secondary-bg text-button-secondary-text",
37
- "ghost-info": "bg-transparent hover:bg-info/20 border border-info text-info",
38
- "ghost-warn": "bg-transparent hover:bg-warn/20 border border-warn text-warn",
39
- "ghost-danger": "bg-transparent hover:bg-danger/20 border border-danger text-danger",
40
- "ghost-primary": "bg-transparent hover:bg-primary/20 border border-primary text-primary",
41
- "ghost-success": "bg-transparent hover:bg-success/20 border border-success text-success",
42
- "ghost-secondary": "bg-transparent hover:bg-secondary/20 border border-secondary text-secondary",
43
- },
44
- };
45
- /**
46
- * Class variance authority configuration for button styling
47
- * Handles all visual states and variants of the button component
48
- * @internal
49
- */
50
- const buttonVariants = cva("relative overflow-hidden inline-flex duration-500 enabled:hover:bg-opacity-70 enabled:focus:bg-opacity-70 data-[loading=true]:opacity-30 data-[loading=true]:animate-pulse gap-1.5 items-center justify-center align-middle cursor-pointer whitespace-nowrap font-medium transition-colors ease-in disabled:cursor-not-allowed disabled:bg-opacity-40 disabled:text-opacity-80 focus-visible:outline-hidden focus-visible:ring-4 focus-visible:ring-ring", {
51
- variants,
52
- defaultVariants: { theme: "main", size: "default", rounded: "default" },
53
- });
54
- /**
55
- * A versatile button component with multiple variants, sizes, and states.
56
- *
57
- * @example
58
- * ```tsx
59
- * // Basic usage
60
- * <Button>Click me</Button>
61
- *
62
- * // With variants
63
- * <Button theme="primary" size="big">Primary Button</Button>
64
- *
65
- * // Loading state
66
- * <Button loading>Saving...</Button>
67
- *
68
- * // With icon
69
- * <Button icon={<Icon name="plus" />}>Add Item</Button>
70
- *
71
- * // As different element
72
- * <Button as="a" href="/link">Link Button</Button>
73
- * ```
74
- *
75
- * @template T - The HTML element type to render as
76
- * @param props - Button props including theme, size, loading state, etc.
77
- * @param ref - Forwarded ref to the button element
78
- * @returns A styled button component
79
- */
80
- export const Button = forwardRef(function Button({ className, icon, loading, theme, type = "button", size, rounded, ...props }, ref) {
81
- const disabled = loading || props.disabled;
82
- return (<Polymorph {...props} ref={ref} type={type} data-theme={theme} disabled={disabled} data-loading={loading} data-component="button" aria-disabled={disabled} as={props.as ?? "button"} aria-busy={disabled || loading} onClick={disabled ? undefined : props.onClick} className={css(buttonVariants({ size, rounded, theme }), className)}>
83
- {icon}
84
- {props.children}
85
- </Polymorph>);
86
- });
@@ -1,4 +0,0 @@
1
- import { Polymorph } from "./polymorph";
2
- export const Heading = (props) => {
3
- return <Polymorph as="h2">{props.children}</Polymorph>;
4
- };
@@ -1,5 +0,0 @@
1
- import { forwardRef } from "react";
2
- export const Polymorph = forwardRef(function InnerPolymorph(props, ref) {
3
- const Element = props.as || "span";
4
- return <Element ref={ref} {...props} as={undefined}/>;
5
- });
@@ -1,31 +0,0 @@
1
- "use client";
2
- import React, { useLayoutEffect, useRef, useState } from "react";
3
- import { useStableRef } from "../../hooks/use-stable-ref";
4
- function isInViewport(el) {
5
- const rect = el.getBoundingClientRect();
6
- return (rect.top >= 0 &&
7
- rect.left >= 0 &&
8
- rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
9
- rect.right <= (window.innerWidth || document.documentElement.clientWidth) /* or $(window).width() */);
10
- }
11
- export const RenderOnView = ({ children, ...props }) => {
12
- const onIntersect = useStableRef(props.onIntersection);
13
- const ref = useRef(null);
14
- const [shouldRender, setShouldRender] = useState(() => (ref.current === null ? false : isInViewport(ref.current)));
15
- useLayoutEffect(() => {
16
- const div = ref.current;
17
- if (div === null)
18
- return;
19
- const observer = new IntersectionObserver((args) => {
20
- const first = args[0];
21
- if (first.isIntersecting)
22
- onIntersect.current?.();
23
- return setShouldRender((prev) => (first.isIntersecting ? true : prev));
24
- });
25
- observer.observe(div);
26
- return () => observer.disconnect();
27
- }, []);
28
- return (<div {...props} ref={ref}>
29
- {shouldRender ? children : null}
30
- </div>);
31
- };
@@ -1,51 +0,0 @@
1
- "use client";
2
- import { motion, useMotionValue } from "motion/react";
3
- import React, { useEffect, useMemo, useState } from "react";
4
- import { isSsr } from "../../lib/fns";
5
- const defaultState = {
6
- x: 0,
7
- y: 0,
8
- width: 0,
9
- height: 0,
10
- top: 0,
11
- left: 0,
12
- bottom: 0,
13
- right: 0,
14
- };
15
- const useElementRect = () => {
16
- const [element, ref] = useState(null);
17
- const motion = useMotionValue(defaultState);
18
- const observer = useMemo(() => isSsr()
19
- ? null
20
- : new window.ResizeObserver((entries) => {
21
- if (entries[0]) {
22
- const rect = entries[0].contentRect;
23
- motion.set({
24
- x: rect.x,
25
- y: rect.y,
26
- width: rect.width,
27
- height: rect.height,
28
- top: rect.top,
29
- left: rect.left,
30
- bottom: rect.bottom,
31
- right: rect.right,
32
- });
33
- }
34
- }), []);
35
- useEffect(() => {
36
- if (!element)
37
- return;
38
- if (observer === null)
39
- return;
40
- observer.observe(element);
41
- return () => observer.disconnect();
42
- }, [element]);
43
- return [ref, motion];
44
- };
45
- export const Resizable = ({ children }) => {
46
- const [ref, bounds] = useElementRect();
47
- const h = bounds.get().height;
48
- return (<motion.div animate={{ height: h > 0 ? h : "auto" }}>
49
- <div ref={ref}>{children}</div>
50
- </motion.div>);
51
- };
@@ -1,163 +0,0 @@
1
- import * as React from 'react';
2
- const REACT_LAZY_TYPE = Symbol.for('react.lazy');
3
- function setRef(ref, value) {
4
- if (typeof ref === 'function') {
5
- return ref(value);
6
- }
7
- else if (ref !== null && ref !== undefined) {
8
- ref.current = value;
9
- }
10
- }
11
- function composeRefs(...refs) {
12
- return (node) => {
13
- let hasCleanup = false;
14
- const cleanups = refs.map((ref) => {
15
- const cleanup = setRef(ref, node);
16
- if (!hasCleanup && typeof cleanup == 'function') {
17
- hasCleanup = true;
18
- }
19
- return cleanup;
20
- });
21
- if (hasCleanup) {
22
- return () => {
23
- for (let i = 0; i < cleanups.length; i++) {
24
- const cleanup = cleanups[i];
25
- if (typeof cleanup == 'function') {
26
- cleanup();
27
- }
28
- else {
29
- setRef(refs[i], null);
30
- }
31
- }
32
- };
33
- }
34
- };
35
- }
36
- const use = React[' use '.trim().toString()];
37
- function isPromiseLike(value) {
38
- return typeof value === 'object' && value !== null && 'then' in value;
39
- }
40
- function isLazyComponent(element) {
41
- return (element != null &&
42
- typeof element === 'object' &&
43
- '$$typeof' in element &&
44
- element.$$typeof === REACT_LAZY_TYPE &&
45
- '_payload' in element &&
46
- isPromiseLike(element._payload));
47
- }
48
- export function createSlot(ownerName) {
49
- const SlotClone = createSlotClone(ownerName);
50
- const Slot = React.forwardRef((props, forwardedRef) => {
51
- let { children, ...slotProps } = props;
52
- if (isLazyComponent(children) && typeof use === 'function') {
53
- children = use(children._payload);
54
- }
55
- const childrenArray = React.Children.toArray(children);
56
- const slottable = childrenArray.find(isSlottable);
57
- if (slottable) {
58
- // the new element to render is the one passed as a child of `Slottable`
59
- const newElement = slottable.props.children;
60
- const newChildren = childrenArray.map((child) => {
61
- if (child === slottable) {
62
- // because the new element will be the one rendered, we are only interested
63
- // in grabbing its children (`newElement.props.children`)
64
- if (React.Children.count(newElement) > 1)
65
- return React.Children.only(null);
66
- return React.isValidElement(newElement)
67
- ? newElement.props.children
68
- : null;
69
- }
70
- else {
71
- return child;
72
- }
73
- });
74
- return (<SlotClone {...slotProps} ref={forwardedRef}>
75
- {React.isValidElement(newElement)
76
- ? React.cloneElement(newElement, undefined, newChildren)
77
- : null}
78
- </SlotClone>);
79
- }
80
- return (<SlotClone {...slotProps} ref={forwardedRef}>
81
- {children}
82
- </SlotClone>);
83
- });
84
- Slot.displayName = `${ownerName}.Slot`;
85
- return Slot;
86
- }
87
- export const Slot = createSlot('Slot');
88
- function createSlotClone(ownerName) {
89
- const SlotClone = React.forwardRef((props, forwardedRef) => {
90
- let { children, ...slotProps } = props;
91
- if (isLazyComponent(children) && typeof use === 'function') {
92
- children = use(children._payload);
93
- }
94
- if (React.isValidElement(children)) {
95
- const childrenRef = getElementRef(children);
96
- const props = mergeProps(slotProps, children.props);
97
- // do not pass ref to React.Fragment for React 19 compatibility
98
- if (children.type !== React.Fragment) {
99
- props.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
100
- }
101
- return React.cloneElement(children, props);
102
- }
103
- return React.Children.count(children) > 1 ? React.Children.only(null) : null;
104
- });
105
- SlotClone.displayName = `${ownerName}.SlotClone`;
106
- return SlotClone;
107
- }
108
- const SLOTTABLE_IDENTIFIER = Symbol('radix.slottable');
109
- export function createSlottable(ownerName) {
110
- const Slottable = ({ children }) => {
111
- return <>{children}</>;
112
- };
113
- Slottable.displayName = `${ownerName}.Slottable`;
114
- Slottable.__radixId = SLOTTABLE_IDENTIFIER;
115
- return Slottable;
116
- }
117
- const Slottable = createSlottable('Slottable');
118
- function isSlottable(child) {
119
- return (React.isValidElement(child) &&
120
- typeof child.type === 'function' &&
121
- '__radixId' in child.type &&
122
- child.type.__radixId === SLOTTABLE_IDENTIFIER);
123
- }
124
- function mergeProps(slotProps, childProps) {
125
- const overrideProps = { ...childProps };
126
- for (const propName in childProps) {
127
- const slotPropValue = slotProps[propName];
128
- const childPropValue = childProps[propName];
129
- const isHandler = /^on[A-Z]/.test(propName);
130
- if (isHandler) {
131
- if (slotPropValue && childPropValue) {
132
- overrideProps[propName] = (...args) => {
133
- const result = childPropValue(...args);
134
- slotPropValue(...args);
135
- return result;
136
- };
137
- }
138
- else if (slotPropValue) {
139
- overrideProps[propName] = slotPropValue;
140
- }
141
- }
142
- else if (propName === 'style') {
143
- overrideProps[propName] = { ...slotPropValue, ...childPropValue };
144
- }
145
- else if (propName === 'className') {
146
- overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ');
147
- }
148
- }
149
- return { ...slotProps, ...overrideProps };
150
- }
151
- function getElementRef(element) {
152
- let getter = Object.getOwnPropertyDescriptor(element.props, 'ref')?.get;
153
- let mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;
154
- if (mayWarn) {
155
- return element.ref;
156
- }
157
- getter = Object.getOwnPropertyDescriptor(element, 'ref')?.get;
158
- mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;
159
- if (mayWarn) {
160
- return element.props.ref;
161
- }
162
- return element.props.ref || element.ref;
163
- }
@@ -1,51 +0,0 @@
1
- import { cva } from "class-variance-authority";
2
- import React, { forwardRef } from "react";
3
- import { css } from "../../lib/dom";
4
- import { Polymorph } from "./polymorph";
5
- const variants = {
6
- size: {
7
- icon: "p-1",
8
- big: "h-12 px-6 py-4",
9
- default: "h-8 px-4 py-2",
10
- small: "h-6 p-2 px-3 text-sm",
11
- tiny: "h-6 p-2 px-3 text-xs",
12
- },
13
- theme: {
14
- custom: "",
15
- info: "bg-tag-info-bg text-tag-info-text",
16
- warn: "bg-tag-warn-bg text-tag-warn-text",
17
- muted: "bg-tag-muted-bg text-tag-muted-text",
18
- danger: "bg-tag-danger-bg text-tag-danger-text",
19
- disabled: "bg-disabled duration-700 opacity-70",
20
- primary: "bg-tag-primary-bg text-tag-primary-text",
21
- success: "bg-tag-success-bg text-tag-success-text",
22
- neutral: "bg-transparent border border-card-border",
23
- secondary: "bg-tag-secondary-bg text-tag-secondary-text",
24
- loading: "animate-pulse bg-disabled duration-700 opacity-70",
25
- },
26
- };
27
- const indicatorVariant = cva("size-2.5 aspect-square rounded-full border-0", {
28
- variants: {
29
- theme: {
30
- info: "bg-info",
31
- warn: "bg-warn",
32
- muted: "bg-muted",
33
- danger: "bg-danger",
34
- neutral: "bg-muted",
35
- primary: "bg-primary",
36
- success: "bg-success",
37
- secondary: "bg-secondary",
38
- },
39
- },
40
- });
41
- const tagVariants = cva("inline-flex rounded-pill gap-1.5 border-0 items-center justify-center align-middle whitespace-nowrap", {
42
- variants,
43
- defaultVariants: { theme: "primary", size: "default" },
44
- });
45
- export const Tag = forwardRef(function Tag({ className, indicator = undefined, icon, loading, theme, size, ...props }, ref) {
46
- return (<Polymorph {...props} ref={ref} data-theme={theme} data-component="tag" as={props.as ?? "span"} className={css(tagVariants({ size, theme: loading ? "loading" : theme }), className)}>
47
- {indicator ? <span aria-hidden="true" className={indicatorVariant({ theme: indicator })}/> : null}
48
- {icon}
49
- {props.children}
50
- </Polymorph>);
51
- });
@@ -1,26 +0,0 @@
1
- import React, { Fragment } from "react";
2
- import { css } from "../../lib/dom";
3
- export const Paragraph = (props) => (<p {...props} className={css("text-base leading-snug", props.className)}/>);
4
- export const Description = (props) => (<p {...props} className={css("mb-kilo text-sm text-secondary", props.className)}/>);
5
- export const Info = (props) => (<div className={css(`flex ${props.row ? "flex-row items-center" : "flex-col"} gap-1`, props.className)}>
6
- <Fragment>
7
- <span className="text-sm font-medium tracking-wide">{props.row ? `${props.label}:` : props.label}</span>
8
- <span className={`w-fit ${props.disabled ? "text-disabled" : ""} ${props.row ? "text-base" : "text-lg"}`}>
9
- {props.children}
10
- </span>
11
- </Fragment>
12
- </div>);
13
- export const PageTitle = (props) => (<div>
14
- <h2 className="text-3xl font-bold typography tracking-wide">{props.title}</h2>
15
- <p className="text-secondary typography">{props.children}</p>
16
- </div>);
17
- export const PageHeader = (props) => {
18
- return (<header className="flex flex-row flex-wrap justify-between items-center gap-mega">
19
- <div>
20
- <PageTitle title={props.title}>{props.description}</PageTitle>
21
- </div>
22
- <div className="flex gap-kilo items-center flex-wrap">
23
- {props.children}
24
- </div>
25
- </header>);
26
- };
@@ -1,56 +0,0 @@
1
- "use client";
2
- import { cva } from "class-variance-authority";
3
- import { AnimatePresence, motion } from "motion/react";
4
- import { CheckCircleIcon, InfoIcon, TriangleAlertIcon, XIcon } from "lucide-react";
5
- import React, { forwardRef } from "react";
6
- import { css } from "../../lib/dom";
7
- import { Polymorph } from "../core/polymorph";
8
- const variants = {
9
- true: { opacity: 1, height: "auto" },
10
- false: { opacity: [0.7, 0.3, 0], height: 0 },
11
- };
12
- const transition = {
13
- type: "tween",
14
- duration: 0.7,
15
- ease: [0.04, 0.62, 0.23, 0.98],
16
- };
17
- export const Collapse = (props) => (<motion.div {...props} layout layoutRoot layoutScroll initial={false} variants={variants} exit={variants.false} transition={transition} aria-hidden={!props.open} data-component="collapse" animate={props.open.toString()} className={css("aria-hidden:pointer-events-none", props.className)}>
18
- {props.children}
19
- </motion.div>);
20
- const themeVariants = {
21
- theme: {
22
- primary: "bg-alert-primary-bg text-alert-primary-text border-alert-primary-border",
23
- danger: "bg-alert-danger-bg text-alert-danger-text border-alert-danger-border",
24
- info: "bg-alert-info-bg text-alert-info-text border-alert-info-border",
25
- success: "bg-alert-success-bg text-alert-success-text border-alert-success-border",
26
- secondary: "bg-alert-secondary-bg text-alert-secondary-text border-alert-secondary-border",
27
- warn: "bg-alert-warn-bg text-alert-warn-text border-alert-warn-border",
28
- neutral: "bg-transparent border border-card-border text-alert-primary-text",
29
- },
30
- };
31
- const alertVariants = cva("p-4 w-full block border relative rounded-lg text-sm", {
32
- variants: themeVariants,
33
- defaultVariants: { theme: "neutral" },
34
- });
35
- export const Alert = forwardRef(function Alert({ className, theme, Icon, onClose, open = true, ...props }, ref) {
36
- const close = () => onClose?.(false);
37
- return (<AnimatePresence presenceAffectsLayout propagate mode="sync">
38
- {open ? <motion.div data-open={!!open} aria-hidden={!open} data-component="alert" className={css("isolate w-full", open ? "pointer-events-auto" : "pointer-events-none")}>
39
- <Collapse data-open={!!open} open={!!open}>
40
- <Polymorph {...props} ref={ref} role="alert" data-theme={theme} as={props.as ?? "div"} className={css(alertVariants({ theme }), className)}>
41
- <h4 className="flex gap-2 items-center mb-2">
42
- {!Icon && theme === "success" ? <CheckCircleIcon aria-hidden="true" size={20}/> : null}
43
- {!Icon && theme === "info" ? <InfoIcon aria-hidden="true" size={20}/> : null}
44
- {!Icon && theme === "danger" ? <TriangleAlertIcon aria-hidden="true" size={20}/> : null}
45
- {Icon}
46
- <span className="text-lg font-semibold tracking-3 text-balance">{props.title}</span>
47
- </h4>
48
- {props.children}
49
- {onClose !== undefined && open ? (<button type="button" onClick={close} className="absolute top-3 right-3 transition-colors duration-300 ease-in-out text-foreground hover:text-danger">
50
- <XIcon size={20}/>
51
- </button>) : null}
52
- </Polymorph>
53
- </Collapse>
54
- </motion.div> : null}
55
- </AnimatePresence>);
56
- });