@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
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@g4rcez/components",
3
3
  "description": "Customizable react components.",
4
- "version": "3.0.0",
4
+ "version": "3.0.1",
5
5
  "sideEffects": false,
6
6
  "private": false,
7
7
  "packageManager": "pnpm@10.12.3",
@@ -24,7 +24,7 @@
24
24
  "scripts": {
25
25
  "watch": "vite build --watch --minify false",
26
26
  "prepublishOnly": "npm run build",
27
- "build": "rm -rf ./dist; vite build; npm run lib:types; npm run preset; npm run lib:css",
27
+ "build": "rm -rf ./dist; vite build; npm run lib:types; npm run preset; npm run lib:css; cp -r ai dist",
28
28
  "format": "npx prettier --write .",
29
29
  "lib:css": "BUILD_LIB=true tailwind -i ./src/index.css -o ./dist/index.css --minify",
30
30
  "lib:tailwind": "tsc -p tsconfig.tailwind.json",
@@ -93,7 +93,7 @@
93
93
  "files": [
94
94
  "dist",
95
95
  "dist/index.css",
96
- "docs"
96
+ "dist/ai"
97
97
  ],
98
98
  "exports": {
99
99
  ".": {
@@ -297,6 +297,6 @@
297
297
  "require": "./dist/components/display/alert.js",
298
298
  "default": "./dist/components/display/alert.js"
299
299
  },
300
- "./docs/*": "./docs/*.md"
300
+ "./ai/*": "./**"
301
301
  }
302
302
  }
@@ -1,79 +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-10 px-4 py-2",
10
- min: "h-7 px-3 py-1 text-sm",
11
- small: "h-8 px-4 py-2 text-sm",
12
- tiny: "h-6 px-2 py-1 text-sm",
13
- },
14
- rounded: {
15
- rough: "rounded-sm",
16
- squared: "rounded-none",
17
- default: "rounded-button",
18
- circle: "rounded-full aspect-square",
19
- },
20
- theme: {
21
- raw: "",
22
- disabled: "bg-disabled opacity-70",
23
- loading: "animate-pulse bg-disabled",
24
- main: "bg-button-primary-bg text-button-primary-text",
25
- info: "bg-button-info-bg text-button-info-text",
26
- warn: "bg-button-warn-bg text-button-warn-text",
27
- muted: "bg-button-muted-bg text-button-muted-text",
28
- danger: "bg-button-danger-bg text-button-danger-text",
29
- neutral: "bg-transparent border-1 border-card-border",
30
- primary: "bg-button-primary-bg text-button-primary-text",
31
- success: "bg-button-success-bg text-button-success-text",
32
- secondary: "bg-button-secondary-bg text-button-secondary-text",
33
- "ghost-info": "bg-transparent hover:bg-info/20 border-0 border-transparent text-info",
34
- "ghost-warn": "bg-transparent hover:bg-warn/20 border-0 border-transparent text-warn",
35
- "ghost-danger": "bg-transparent hover:bg-danger/20 border-0 border-transparent text-danger",
36
- "ghost-primary": "bg-transparent hover:bg-primary/20 border-0 border-transparent text-primary",
37
- "ghost-success": "bg-transparent hover:bg-success/20 border-0 border-transparent text-success",
38
- "ghost-secondary": "bg-transparent hover:bg-secondary/20 border-0 border-transparent text-secondary",
39
- "ghost-muted": "bg-transparent hover:bg-muted/20 border-0 border-transparent text-muted-foreground",
40
- "ghost-neutral": "bg-transparent border-0 border-card-border",
41
- },
42
- };
43
- const buttonVariants = cva("relative overflow-hidden inline-flex duration-300 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-linear disabled:cursor-not-allowed disabled:bg-opacity-40 disabled:text-opacity-80 focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-ring", {
44
- variants,
45
- defaultVariants: { theme: "main", size: "default", rounded: "default" },
46
- });
47
- /**
48
- * A versatile button component with multiple variants, sizes, and states.
49
- *
50
- * @example
51
- * ```tsx
52
- * // Basic usage
53
- * <Button>Click me</Button>
54
- *
55
- * // With variants
56
- * <Button theme="primary" size="big">Primary Button</Button>
57
- *
58
- * // Loading state
59
- * <Button loading>Saving...</Button>
60
- *
61
- * // With icon
62
- * <Button icon={<Icon name="plus" />}>Add Item</Button>
63
- *
64
- * // As different element
65
- * <Button as="a" href="/link">Link Button</Button>
66
- * ```
67
- *
68
- * @template T - The HTML element type to render as
69
- * @param props - Button props including theme, size, loading state, etc.
70
- * @param ref - Forwarded ref to the button element
71
- * @returns A styled button component
72
- */
73
- export const Button = forwardRef(function Button({ className, icon, loading, theme, type = "button", size, rounded, ...props }, ref) {
74
- const disabled = loading || props.disabled;
75
- 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)}>
76
- {icon}
77
- {props.children}
78
- </Polymorph>);
79
- });
@@ -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,156 +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) ? newElement.props.children : null;
67
- }
68
- else {
69
- return child;
70
- }
71
- });
72
- return (<SlotClone {...slotProps} ref={forwardedRef}>
73
- {React.isValidElement(newElement) ? React.cloneElement(newElement, undefined, newChildren) : null}
74
- </SlotClone>);
75
- }
76
- return (<SlotClone {...slotProps} ref={forwardedRef}>
77
- {children}
78
- </SlotClone>);
79
- });
80
- Slot.displayName = `${ownerName}.Slot`;
81
- return Slot;
82
- }
83
- export const Slot = createSlot("Slot");
84
- function createSlotClone(ownerName) {
85
- const SlotClone = React.forwardRef((props, forwardedRef) => {
86
- let { children, ...slotProps } = props;
87
- if (isLazyComponent(children) && typeof use === "function") {
88
- children = use(children._payload);
89
- }
90
- if (React.isValidElement(children)) {
91
- const childrenRef = getElementRef(children);
92
- const props = mergeProps(slotProps, children.props);
93
- // do not pass ref to React.Fragment for React 19 compatibility
94
- if (children.type !== React.Fragment) {
95
- props.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
96
- }
97
- return React.cloneElement(children, props);
98
- }
99
- return React.Children.count(children) > 1 ? React.Children.only(null) : null;
100
- });
101
- SlotClone.displayName = `${ownerName}.SlotClone`;
102
- return SlotClone;
103
- }
104
- const SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
105
- export function createSlottable(ownerName) {
106
- const Slottable = ({ children }) => {
107
- return <>{children}</>;
108
- };
109
- Slottable.displayName = `${ownerName}.Slottable`;
110
- Slottable.__radixId = SLOTTABLE_IDENTIFIER;
111
- return Slottable;
112
- }
113
- const Slottable = createSlottable("Slottable");
114
- function isSlottable(child) {
115
- return (React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER);
116
- }
117
- function mergeProps(slotProps, childProps) {
118
- const overrideProps = { ...childProps };
119
- for (const propName in childProps) {
120
- const slotPropValue = slotProps[propName];
121
- const childPropValue = childProps[propName];
122
- const isHandler = /^on[A-Z]/.test(propName);
123
- if (isHandler) {
124
- if (slotPropValue && childPropValue) {
125
- overrideProps[propName] = (...args) => {
126
- const result = childPropValue(...args);
127
- slotPropValue(...args);
128
- return result;
129
- };
130
- }
131
- else if (slotPropValue) {
132
- overrideProps[propName] = slotPropValue;
133
- }
134
- }
135
- else if (propName === "style") {
136
- overrideProps[propName] = { ...slotPropValue, ...childPropValue };
137
- }
138
- else if (propName === "className") {
139
- overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
140
- }
141
- }
142
- return { ...slotProps, ...overrideProps };
143
- }
144
- function getElementRef(element) {
145
- let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
146
- let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
147
- if (mayWarn) {
148
- return element.ref;
149
- }
150
- getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
151
- mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
152
- if (mayWarn) {
153
- return element.props.ref;
154
- }
155
- return element.props.ref || element.ref;
156
- }
@@ -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
- tiny: "h-5 p-1 px-2 text-xs",
11
- small: "h-6 p-2 px-3 text-sm",
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 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 ease-linear duration-300 transition-all", {
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,22 +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={css(props.disabled ? "text-disabled" : "", props.row ? "w-fit text-base" : "w-full text-lg")}>{props.children}</span>
9
- </Fragment>
10
- </div>);
11
- export const PageTitle = (props) => (<div>
12
- <h2 className="typography text-3xl font-bold tracking-wide">{props.title}</h2>
13
- <p className="typography text-secondary">{props.children}</p>
14
- </div>);
15
- export const PageHeader = (props) => {
16
- return (<header className="gap-mega flex flex-row flex-wrap items-center justify-between">
17
- <div>
18
- <PageTitle title={props.title}>{props.description}</PageTitle>
19
- </div>
20
- <div className="gap-kilo flex flex-wrap items-center">{props.children}</div>
21
- </header>);
22
- };
@@ -1,58 +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
- <div className="grid grid-cols-[auto_1fr] gap-base">
42
- {onClose !== undefined && open ? (<button type="button" onClick={close} className="absolute right-3 top-3 text-foreground transition-colors duration-300 ease-in-out hover:text-danger">
43
- <XIcon size={20}/>
44
- </button>) : null}
45
- <div className={css("flex items-center gap-2", props.title ? "" : "w-fit")}>
46
- {!Icon && theme === "success" ? <CheckCircleIcon aria-hidden="true" size={20}/> : null}
47
- {!Icon && theme === "info" ? <InfoIcon aria-hidden="true" size={20}/> : null}
48
- {!Icon && theme === "danger" ? <TriangleAlertIcon aria-hidden="true" size={20}/> : null}
49
- {Icon}
50
- </div>
51
- {props.title ? <h4 className="tracking-3 col-start-2 text-balance text-lg font-semibold">{props.title}</h4> : null}
52
- <div className="col-start-2 w-full">{props.children}</div>
53
- </div>
54
- </Polymorph>
55
- </Collapse>
56
- </motion.div>) : null}
57
- </AnimatePresence>);
58
- });