@react-fabric/core 1.0.0-beta.1 → 1.0.0-beta.4

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 (56) hide show
  1. package/css/index.js +2 -2
  2. package/dist/cjs/components/animations/Animations.js +1 -1
  3. package/dist/cjs/components/badge/Badge.js +6 -4
  4. package/dist/cjs/components/button/Button.js +4 -3
  5. package/dist/cjs/components/button/Button.module.css +1 -1
  6. package/dist/cjs/components/callout/Callout.js +3 -2
  7. package/dist/cjs/components/collapsable/Collapsable.js +3 -2
  8. package/dist/cjs/components/menu/MenuItem.js +1 -1
  9. package/dist/cjs/core/aside/Aside.js +4 -2
  10. package/dist/cjs/core/section/Section.js +5 -2
  11. package/dist/cjs/index.js +1 -0
  12. package/dist/cjs/overlays/alert/Alert.js +38 -16
  13. package/dist/cjs/types/icons.js +2 -0
  14. package/dist/cjs/typography/Abbr.js +2 -0
  15. package/dist/esm/components/animations/Animations.js +1 -1
  16. package/dist/esm/components/badge/Badge.js +7 -5
  17. package/dist/esm/components/button/Button.js +4 -3
  18. package/dist/esm/components/button/Button.module.css +1 -1
  19. package/dist/esm/components/callout/Callout.js +3 -2
  20. package/dist/esm/components/collapsable/Collapsable.js +3 -2
  21. package/dist/esm/components/menu/MenuItem.js +1 -1
  22. package/dist/esm/core/aside/Aside.js +4 -2
  23. package/dist/esm/core/section/Section.js +5 -2
  24. package/dist/esm/index.js +1 -0
  25. package/dist/esm/overlays/alert/Alert.js +27 -5
  26. package/dist/esm/types/icons.js +2 -0
  27. package/dist/esm/typography/Abbr.js +2 -0
  28. package/dist/types/components/button/Button.d.ts +2 -1
  29. package/dist/types/components/callout/Callout.d.ts +3 -3
  30. package/dist/types/components/collapsable/Collapsable.d.ts +5 -1
  31. package/dist/types/components/menu/types.d.ts +2 -2
  32. package/dist/types/components/tabpanel/Tab.d.ts +4 -0
  33. package/dist/types/core/aside/Aside.d.ts +9 -5
  34. package/dist/types/core/section/Section.d.ts +2 -2
  35. package/dist/types/overlays/alert/Alert.d.ts +9 -1
  36. package/dist/types/types/icons.d.ts +2 -0
  37. package/dist/types/types/index.d.ts +2 -2
  38. package/dist/types/typography/Abbr.d.ts +3 -3
  39. package/dist/types/typography/Link.d.ts +2 -1
  40. package/package.json +3 -3
  41. package/src/components/animations/Animations.tsx +1 -1
  42. package/src/components/badge/Badge.tsx +24 -20
  43. package/src/components/button/Button.module.css +1 -1
  44. package/src/components/button/Button.tsx +5 -2
  45. package/src/components/callout/Callout.tsx +8 -1
  46. package/src/components/collapsable/Collapsable.tsx +6 -1
  47. package/src/components/menu/Menu.tsx +1 -1
  48. package/src/components/menu/types.ts +2 -2
  49. package/src/components/tabpanel/Tab.tsx +4 -0
  50. package/src/core/aside/Aside.tsx +23 -4
  51. package/src/core/section/Section.tsx +8 -2
  52. package/src/overlays/alert/Alert.tsx +25 -2
  53. package/src/types/icons.ts +5 -0
  54. package/src/types/index.ts +5 -2
  55. package/src/typography/Abbr.tsx +4 -3
  56. package/src/typography/Link.tsx +3 -0
@@ -31,7 +31,7 @@ import {
31
31
  useRole,
32
32
  } from "@floating-ui/react";
33
33
  import classNames from "classnames";
34
- import { useCallback, useLayoutEffect, useMemo } from "react";
34
+ import { useCallback, useLayoutEffect, useMemo, useState } from "react";
35
35
  import { useTranslation } from "react-i18next";
36
36
  import { AnimationIndicator } from "../../components/animations/Animations";
37
37
  import { Button } from "../../components/button/Button";
@@ -71,6 +71,14 @@ export interface AlertProps extends Omit<IconProps, "iconBg" | "iconColor"> {
71
71
  * cancel label
72
72
  */
73
73
  cancelLabel?: string;
74
+ /**
75
+ * placeholder for prompt
76
+ */
77
+ placeholder?: string;
78
+ /**
79
+ * default value for prompt
80
+ */
81
+ defaultValue?: string;
74
82
  }
75
83
 
76
84
  export const Alert = ({
@@ -85,8 +93,11 @@ export const Alert = ({
85
93
  type,
86
94
  okLabel,
87
95
  cancelLabel,
96
+ placeholder,
97
+ defaultValue,
88
98
  }: AlertProps) => {
89
99
  const { t } = useTranslation("core");
100
+ const [value, setValue] = useState(defaultValue);
90
101
  const { refs, context } = useFloating({
91
102
  open: true,
92
103
  onOpenChange: () => {
@@ -181,7 +192,19 @@ export const Alert = ({
181
192
 
182
193
  <Title className="font-medium area-[title]">{title}</Title>
183
194
  <p className="area-[message] py-4">{message}</p>
184
- <div className="area-[message]">{message}</div>
195
+ {type === "prompt" && (
196
+ <input
197
+ value={value}
198
+ placeholder={placeholder}
199
+ className={classNames(
200
+ "border rounded focus:border-primary-500",
201
+ )}
202
+ ref={(e) => e != null && setTimeout(() => e.focus(), 100)}
203
+ onBlur={(e) => e.target.focus()}
204
+ onChange={(e) => setValue(e.target.value)}
205
+ onKeyDown={(e) => e.key === "Enter" && handleClose(value)}
206
+ />
207
+ )}
185
208
  <div className="flex gap-1 justify-center flex-nowrap pt-2 area-[actions]">
186
209
  <div
187
210
  className="contents"
@@ -90,6 +90,11 @@ export module CoreIcons {
90
90
  export const collapse =
91
91
  "M5 2c-0.828 0-1.58 0.337-2.121 0.879s-0.879 1.293-0.879 2.121v14c0 0.828 0.337 1.58 0.879 2.121s1.293 0.879 2.121 0.879h14c0.828 0 1.58-0.337 2.121-0.879s0.879-1.293 0.879-2.121v-14c0-0.828-0.337-1.58-0.879-2.121s-1.293-0.879-2.121-0.879zM5 4h14c0.276 0 0.525 0.111 0.707 0.293s0.293 0.431 0.293 0.707v14c0 0.276-0.111 0.525-0.293 0.707s-0.431 0.293-0.707 0.293h-14c-0.276 0-0.525-0.111-0.707-0.293s-0.293-0.431-0.293-0.707v-14c0-0.276 0.111-0.525 0.293-0.707s0.431-0.293 0.707-0.293zM8 13h8c0.552 0 1-0.448 1-1s-0.448-1-1-1h-8c-0.552 0-1 0.448-1 1s0.448 1 1 1z";
92
92
 
93
+ export const expandActive =
94
+ "M17,13H13V17H11V13H7V11H11V7H13V11H17M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3Z";
95
+ export const collapseActive =
96
+ "M17,13H7V11H17M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3Z";
97
+
93
98
  export const expandAll =
94
99
  "M5.293 16.707l6 6c0.391 0.391 1.024 0.391 1.414 0l6-6c0.391-0.391 0.391-1.024 0-1.414s-1.024-0.391-1.414 0l-5.293 5.293-5.293-5.293c-0.391-0.391-1.024-0.391-1.414 0s-0.391 1.024 0 1.414zM18.707 7.293l-6-6c-0.391-0.391-1.024-0.391-1.414 0l-6 6c-0.391 0.391-0.391 1.024 0 1.414s1.024 0.391 1.414 0l5.293-5.293 5.293 5.293c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414z";
95
100
  export const colapseAll =
@@ -145,7 +145,10 @@ export interface RefProp<T = HTMLElement> {
145
145
  /* *********** */
146
146
 
147
147
  // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
148
- export type CallbackReturn<T = unknown> = void | T | Promise<T | void>;
148
+ export type CallbackReturn<T = unknown> =
149
+ | undefined
150
+ | T
151
+ | Promise<T | undefined>;
149
152
 
150
153
  export type ReactTag = keyof JSX.IntrinsicElements | JSXElementConstructor<any>;
151
154
 
@@ -155,7 +158,7 @@ export type PropsOf<AsTag extends ReactTag> = AsTag extends React.ElementType
155
158
 
156
159
  export type PolymorphicProps<AsTag extends ReactTag> = Omit<
157
160
  PropsOf<AsTag>,
158
- "children" | "as" | "className"
161
+ "children" | "as" | "className" | "onClick"
159
162
  > & {
160
163
  /**
161
164
  * The component used for the root node.
@@ -26,7 +26,7 @@ import classNames from "classnames";
26
26
  import { Fragment, useCallback, useMemo } from "react";
27
27
  import { useMemoDebugger } from "../hooks/useEffectDebugger";
28
28
  import { Tooltip, getTooltipProps } from "../overlays/tooltip/Tooltip";
29
- import { type ChildProp, type ColorType } from "../types";
29
+ import { type ChildProp, type ColorType, type CssProp } from "../types";
30
30
  import { getColor, getColorClass } from "../utils";
31
31
  import classes from "./Typography.module.css";
32
32
 
@@ -64,7 +64,7 @@ const AbbrText = ({ color, children, tooltip, content }: AbbrTextProps) => {
64
64
  );
65
65
  };
66
66
 
67
- export interface AbbrProps extends ChildProp<string> {
67
+ export interface AbbrProps extends ChildProp<string>, CssProp {
68
68
  /**
69
69
  * content to copy using the tooltip copy action
70
70
  */
@@ -87,6 +87,7 @@ export interface AbbrProps extends ChildProp<string> {
87
87
  export const Abbr = ({
88
88
  children,
89
89
  abbr,
90
+ className,
90
91
  renderer,
91
92
  copyContent = "text",
92
93
  }: AbbrProps) => {
@@ -148,5 +149,5 @@ export const Abbr = ({
148
149
  );
149
150
 
150
151
  /** ***************** component *******************/
151
- return <span>{inner}</span>;
152
+ return <span className={className}>{inner}</span>;
152
153
  };
@@ -22,6 +22,7 @@
22
22
  */
23
23
 
24
24
  import classNames from "classnames";
25
+ import { type MouseEventHandler } from "react";
25
26
  import { useMemoDebugger } from "../hooks/useEffectDebugger";
26
27
  import {
27
28
  type AriaProps,
@@ -52,6 +53,8 @@ export interface LinkProps extends ChildrenProp, CssProp, RefProp, AriaProps {
52
53
  * font family
53
54
  */
54
55
  family?: "sans" | "serif" | "mono";
56
+
57
+ onClick?: MouseEventHandler;
55
58
  }
56
59
 
57
60
  /**