@react-fabric/core 1.0.0-beta.54 → 1.0.0-beta.57

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 (50) hide show
  1. package/css/components/_button.css +8 -4
  2. package/css/components/_card.css +8 -4
  3. package/css/components/_tabPanel.css +65 -9
  4. package/css/core/_aside.css +4 -6
  5. package/css/reset/_reset.css +14 -0
  6. package/dist/cjs/components/avatar/Avatar.js +8 -4
  7. package/dist/cjs/components/button/Button.js +4 -2
  8. package/dist/cjs/components/card/Card.js +18 -12
  9. package/dist/cjs/components/chip/Chip.js +5 -3
  10. package/dist/cjs/components/dropdown/Dropdown.js +1 -0
  11. package/dist/cjs/components/icon/Icon.js +9 -5
  12. package/dist/cjs/components/menu/Menu.js +2 -0
  13. package/dist/cjs/components/tabpanel/Tab.js +1 -1
  14. package/dist/cjs/components/tabpanel/TabPanel.js +5 -2
  15. package/dist/cjs/overlays/flyout/Flyout.js +3 -1
  16. package/dist/cjs/overlays/modal/Modal.js +3 -3
  17. package/dist/cjs/types/icons.js +5 -1
  18. package/dist/esm/components/avatar/Avatar.js +8 -4
  19. package/dist/esm/components/button/Button.js +4 -2
  20. package/dist/esm/components/card/Card.js +18 -12
  21. package/dist/esm/components/chip/Chip.js +5 -3
  22. package/dist/esm/components/dropdown/Dropdown.js +1 -0
  23. package/dist/esm/components/icon/Icon.js +9 -5
  24. package/dist/esm/components/menu/Menu.js +2 -0
  25. package/dist/esm/components/tabpanel/Tab.js +1 -1
  26. package/dist/esm/components/tabpanel/TabPanel.js +5 -2
  27. package/dist/esm/overlays/flyout/Flyout.js +3 -1
  28. package/dist/esm/overlays/modal/Modal.js +3 -3
  29. package/dist/esm/types/icons.js +5 -1
  30. package/dist/types/components/avatar/Avatar.d.ts +5 -1
  31. package/dist/types/components/button/Button.d.ts +5 -1
  32. package/dist/types/components/card/Card.d.ts +5 -3
  33. package/dist/types/components/chip/Chip.d.ts +5 -1
  34. package/dist/types/components/tabpanel/TabPanel.d.ts +10 -2
  35. package/dist/types/overlays/flyout/Flyout.d.ts +5 -1
  36. package/dist/types/overlays/modal/Modal.d.ts +2 -2
  37. package/dist/types/types/icons.d.ts +5 -1
  38. package/package.json +2 -2
  39. package/src/components/avatar/Avatar.tsx +9 -1
  40. package/src/components/button/Button.tsx +14 -1
  41. package/src/components/card/Card.tsx +29 -15
  42. package/src/components/chip/Chip.tsx +8 -2
  43. package/src/components/dropdown/Dropdown.tsx +1 -0
  44. package/src/components/icon/Icon.tsx +5 -1
  45. package/src/components/menu/Menu.tsx +2 -0
  46. package/src/components/tabpanel/Tab.tsx +2 -2
  47. package/src/components/tabpanel/TabPanel.tsx +13 -1
  48. package/src/overlays/flyout/Flyout.tsx +6 -1
  49. package/src/overlays/modal/Modal.tsx +3 -3
  50. package/src/types/icons.ts +10 -1
@@ -24,10 +24,10 @@
24
24
  import classNames from "classnames";
25
25
  import {
26
26
  Children,
27
- type DragEvent,
28
- type MouseEventHandler,
29
27
  useCallback,
30
28
  useMemo,
29
+ type DragEvent,
30
+ type MouseEventHandler,
31
31
  } from "react";
32
32
  import { ErrorBoundary } from "../../core/boundary/ErrorBoundary";
33
33
  import { type ContentProps } from "../../core/content/Content";
@@ -37,6 +37,7 @@ import {
37
37
  type HeadFootProps,
38
38
  } from "../../core/headfoot/HeadFoot";
39
39
  import {
40
+ PolymorphicProps,
40
41
  type AriaProps,
41
42
  type ChildrenProp,
42
43
  type CssProp,
@@ -45,7 +46,7 @@ import {
45
46
  } from "../../types";
46
47
  import { nodeCheck } from "../../utils";
47
48
 
48
- export interface CardProps
49
+ interface BaseProps
49
50
  extends CssProp,
50
51
  AriaProps,
51
52
  TestProps,
@@ -93,6 +94,9 @@ export interface CardProps
93
94
  dragData?: KeyValue;
94
95
  }
95
96
 
97
+ export type CardProps<Tag extends React.ElementType = "div"> = BaseProps &
98
+ PolymorphicProps<Tag>;
99
+
96
100
  /**
97
101
  * A component that displays a card with a header, body, and footer. It can be used to display content in a structured format.
98
102
  * It supports various features such as click handling, drag-and-drop functionality, and customizable styles.
@@ -127,7 +131,7 @@ export interface CardProps
127
131
  *
128
132
  * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/core-components-card--docs} for more details.
129
133
  */
130
- export const Card = ({
134
+ export const Card = <Tag extends React.ElementType = "div">({
131
135
  children,
132
136
  className,
133
137
  bodyClassName,
@@ -140,8 +144,9 @@ export const Card = ({
140
144
  dragKey,
141
145
  dragData,
142
146
  ref,
147
+ as,
143
148
  ...aria
144
- }: CardProps) => {
149
+ }: CardProps<Tag>) => {
145
150
  const [header, body, footer] = useMemo(() => {
146
151
  return Children.toArray(children as AnyObject).reduce<AnyObject[]>(
147
152
  (ret, node) => {
@@ -164,6 +169,7 @@ export const Card = ({
164
169
  [onDragStart, dragKey, dragData],
165
170
  );
166
171
 
172
+ const E = as ?? "div";
167
173
  return (
168
174
  <div
169
175
  className={classNames(
@@ -171,7 +177,7 @@ export const Card = ({
171
177
  "rounded-capped relative grid",
172
178
  flex && "flex-1",
173
179
  selected && selectedRibbon && "selected",
174
- selected && "outline-2 outline-accent-500 outline-offset-2",
180
+ selected && "outline-1 outline-accent-500 outline-offset-2",
175
181
  )}
176
182
  >
177
183
  <ErrorBoundary>
@@ -179,22 +185,30 @@ export const Card = ({
179
185
  className={classNames(
180
186
  "fabric-card",
181
187
  className,
182
- "rounded-capped flex flex-col flex-nowrap overflow-hidden",
188
+ "rounded-capped relative flex flex-col flex-nowrap overflow-hidden",
189
+ "href" in aria && "clickable",
190
+ "to" in aria && "clickable",
183
191
  onClick && "clickable",
184
192
  )}
185
193
  draggable={draggable}
186
194
  onDragStart={!draggable ? undefined : handleDragStart}
187
195
  ref={ref}
188
- {...aria}
189
196
  >
190
197
  {header}
191
- <div
192
- role="none"
193
- className={classNames("fabric-cardBody", bodyClassName, "flex-1")}
194
- onClick={onClick}
195
- >
196
- {body}
197
- </div>
198
+ <E role="none" onClick={onClick} {...aria} className="contents">
199
+ {body && (
200
+ <object
201
+ type="none"
202
+ className={classNames(
203
+ "fabric-cardBody",
204
+ bodyClassName,
205
+ "flex-1",
206
+ )}
207
+ >
208
+ {body}
209
+ </object>
210
+ )}
211
+ </E>
198
212
  {footer}
199
213
  </div>
200
214
  </ErrorBoundary>
@@ -66,6 +66,10 @@ export interface ChipProps
66
66
  * disabled state
67
67
  */
68
68
  disabled?: boolean;
69
+ /**
70
+ * prevent click default, useful when component is within a `a` link
71
+ */
72
+ preventDefault?: boolean;
69
73
  /**
70
74
  * prevent click propagation
71
75
  */
@@ -128,6 +132,7 @@ export const Chip = <Tag extends React.ElementType = "div">({
128
132
  onIconClick,
129
133
  onRemove,
130
134
  rounded,
135
+ preventDefault,
131
136
  stopPropagation,
132
137
  as,
133
138
  ...aria
@@ -153,10 +158,11 @@ export const Chip = <Tag extends React.ElementType = "div">({
153
158
 
154
159
  const clickHandler = useCallback(
155
160
  (e: React.MouseEvent) => {
156
- if (stopPropagation) e.stopPropagation();
161
+ preventDefault && e.preventDefault();
162
+ stopPropagation && e.stopPropagation();
157
163
  onClick?.(e);
158
164
  },
159
- [onClick, stopPropagation],
165
+ [onClick, preventDefault, stopPropagation],
160
166
  );
161
167
 
162
168
  const removeHandler = useCallback(
@@ -221,6 +221,7 @@ const DropdownElement = ({
221
221
  onClick: (e) => {
222
222
  anchor.props.onClick?.(e);
223
223
  e.stopPropagation();
224
+ e.preventDefault();
224
225
  },
225
226
  }),
226
227
  "data-inner-clickable": "true",
@@ -193,7 +193,11 @@ export const Icon = ({
193
193
  !!onClick && disabled && "opacity-30 pointer-events-none",
194
194
  className,
195
195
  )}
196
- onClick={onClick}
196
+ onClick={(e) => {
197
+ onClick && e.stopPropagation();
198
+ onClick && e.preventDefault();
199
+ onClick?.(e);
200
+ }}
197
201
  data-flip={rtlFlip}
198
202
  style={styles}
199
203
  data-clickable={!!onClick}
@@ -313,6 +313,7 @@ export const Menu = (props: MenuProps) => {
313
313
  return (
314
314
  <MenuComponent
315
315
  {...(props as AnyObject)}
316
+ className=""
316
317
  menuClassName={props.className}
317
318
  />
318
319
  );
@@ -323,6 +324,7 @@ export const Menu = (props: MenuProps) => {
323
324
  <FloatingTree>
324
325
  <MenuComponent
325
326
  {...(props as AnyObject)}
327
+ className=""
326
328
  menuClassName={props.className}
327
329
  />
328
330
  </FloatingTree>
@@ -174,8 +174,8 @@ export const Tab = <Tag extends React.ElementType = "button">({
174
174
  active && activeClassName,
175
175
  disabled && "text-tint-500 pointer-events-none",
176
176
  tabFlex ? "flex-1" : "flex-initial max-w-36",
177
- minimal ? "min-w-6" : "min-w-18",
178
- "flex items-center justify-center px-1 rounded overflow-hidden cursor-pointer",
177
+ minimal ? "min-w-6 rounded" : "rounded-capped",
178
+ "flex items-center justify-center overflow-hidden cursor-pointer",
179
179
  )}
180
180
  onClick={() => !active && onClick?.(id)}
181
181
  ref={ref as AnyObject}
@@ -47,11 +47,15 @@ export interface TabPanelProps extends ChildrenProp<typeof Tab> {
47
47
  /**
48
48
  * tab variations
49
49
  */
50
- variant?: "soft" | "solid" | "outline";
50
+ variant?: "soft" | "solid" | "outline" | "pills";
51
51
  /**
52
52
  * tab button flex to fill tabs
53
53
  */
54
54
  tabFlex?: boolean;
55
+ /**
56
+ * rotate tab sideways for start/end orientation
57
+ */
58
+ tabRotate?: boolean;
55
59
  /**
56
60
  * tab button gap
57
61
  */
@@ -64,6 +68,10 @@ export interface TabPanelProps extends ChildrenProp<typeof Tab> {
64
68
  * tab list className
65
69
  */
66
70
  headerClassName?: string;
71
+ /**
72
+ * active tab className
73
+ */
74
+ activeClassName?: string;
67
75
  /**
68
76
  * append element
69
77
  */
@@ -122,11 +130,13 @@ export const TabPanel = ({
122
130
  headerClassName,
123
131
  orientation = "top",
124
132
  activeTab,
133
+ activeClassName,
125
134
  justify,
126
135
  variant,
127
136
  tabFlex,
128
137
  append,
129
138
  prepend,
139
+ tabRotate,
130
140
  gap,
131
141
  onBeforeChange,
132
142
  onChange,
@@ -177,6 +187,7 @@ export const TabPanel = ({
177
187
  className={classNames(
178
188
  "fabric-tabHeader",
179
189
  headerClassName,
190
+ tabRotate && "tab-rotate",
180
191
  justify && `justify-${justify}`,
181
192
  ["start", "end"].includes(orientation) && "flex-col",
182
193
  "flex flex-nowrap overflow-hidden items-center",
@@ -196,6 +207,7 @@ export const TabPanel = ({
196
207
  {tabs.map((node: AnyObject) =>
197
208
  cloneElement(node, {
198
209
  tabFlex: node.props.tabFlex ?? tabFlex,
210
+ activeClassName: node.props.activeClassName ?? activeClassName,
199
211
  onClick: handleClick,
200
212
  active: node.props.id === active,
201
213
  }),
@@ -94,6 +94,10 @@ export interface FlyoutProps
94
94
  * minimum width
95
95
  */
96
96
  minWidth?: string | number;
97
+ /**
98
+ * portal root element
99
+ */
100
+ root?: HTMLElement;
97
101
  /**
98
102
  * hide backdrop mask
99
103
  */
@@ -129,6 +133,7 @@ export const Flyout = ({
129
133
  size,
130
134
  width,
131
135
  minWidth,
136
+ root,
132
137
  hideMask,
133
138
  align = "start",
134
139
  ...aria
@@ -193,7 +198,7 @@ export const Flyout = ({
193
198
  );
194
199
 
195
200
  return (
196
- <FloatingPortal>
201
+ <FloatingPortal root={root}>
197
202
  {!hideMask && (
198
203
  <FloatingOverlay
199
204
  lockScroll
@@ -105,7 +105,7 @@ export interface ModalProps
105
105
  /**
106
106
  * hide mask background
107
107
  */
108
- noMask?: boolean;
108
+ hideMask?: boolean;
109
109
  /**
110
110
  * close handler
111
111
  */
@@ -131,7 +131,7 @@ export const Modal = ({
131
131
  loading,
132
132
  root,
133
133
  size,
134
- noMask,
134
+ hideMask,
135
135
  width,
136
136
  height,
137
137
  minHeight,
@@ -193,7 +193,7 @@ export const Modal = ({
193
193
  }}
194
194
  className={classNames(
195
195
  "grid place-items-center p-16",
196
- !noMask && "bg-tint-100/20 backdrop-blur-sm",
196
+ !hideMask && "bg-tint-100/20 backdrop-blur-sm",
197
197
  )}
198
198
  >
199
199
  <FloatingFocusManager context={context}>
@@ -417,7 +417,7 @@ export namespace CoreIcons {
417
417
  export const mediaPlay = "M8,5.14V19.14L19,12.14L8,5.14Z";
418
418
  export const mediaPause = "M14,19H18V5H14M6,19H10V5H6V19Z";
419
419
  export const mediaContrast =
420
- "M12 2A10 10 0 0 0 2 12A10 10 0 0 0 12 22A10 10 0 0 0 22 12A10 10 0 0 0 12 2M12 4A8 8 0 0 1 20 12A8 8 0 0 1 12 20V4Z";
420
+ "M12,20C9.79,20 7.79,19.1 6.34,17.66L17.66,6.34C19.1,7.79 20,9.79 20,12A8,8 0 0,1 12,20M6,8H8V6H9.5V8H11.5V9.5H9.5V11.5H8V9.5H6M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,16H17V14.5H12V16Z";
421
421
  export const mediaEqs =
422
422
  "M7 3H5V9H7V3M19 3H17V13H19V3M3 13H5V21H7V13H9V11H3V13M15 7H13V3H11V7H9V9H15V7M11 21H13V11H11V21M15 15V17H17V21H19V17H21V15H15Z";
423
423
  export const mediaCaptionOff =
@@ -437,4 +437,13 @@ export namespace CoreIcons {
437
437
  "M9,22A1,1 0 0,1 8,21V18H4A2,2 0 0,1 2,16V4C2,2.89 2.9,2 4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H13.9L10.2,21.71C10,21.9 9.75,22 9.5,22V22H9M10,16V19.08L13.08,16H20V4H4V16H10M6,7H18V9H6V7M6,11H15V13H6V11Z";
438
438
  export const mediaCommentAdd =
439
439
  "M9,22A1,1 0 0,1 8,21V18H4A2,2 0 0,1 2,16V4C2,2.89 2.9,2 4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H13.9L10.2,21.71C10,21.9 9.75,22 9.5,22V22H9M10,16V19.08L13.08,16H20V4H4V16H10M11,6H13V9H16V11H13V14H11V11H8V9H11V6Z";
440
+
441
+ export const mediaLightness =
442
+ "M12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6A6,6 0 0,1 18,12A6,6 0 0,1 12,18M20,15.31L23.31,12L20,8.69V4H15.31L12,0.69L8.69,4H4V8.69L0.69,12L4,15.31V20H8.69L12,23.31L15.31,20H20V15.31Z";
443
+ export const mediaColor =
444
+ "M19,11.5C19,11.5 17,13.67 17,15A2,2 0 0,0 19,17A2,2 0 0,0 21,15C21,13.67 19,11.5 19,11.5M5.21,10L10,5.21L14.79,10M16.56,8.94L7.62,0L6.21,1.41L8.59,3.79L3.44,8.94C2.85,9.5 2.85,10.47 3.44,11.06L8.94,16.56C9.23,16.85 9.62,17 10,17C10.38,17 10.77,16.85 11.06,16.56L16.56,11.06C17.15,10.47 17.15,9.5 16.56,8.94Z";
445
+ export const mediaInvert =
446
+ "M12,19.58V19.58C10.4,19.58 8.89,18.96 7.76,17.83C6.62,16.69 6,15.19 6,13.58C6,12 6.62,10.47 7.76,9.34L12,5.1M17.66,7.93L12,2.27V2.27L6.34,7.93C3.22,11.05 3.22,16.12 6.34,19.24C7.9,20.8 9.95,21.58 12,21.58C14.05,21.58 16.1,20.8 17.66,19.24C20.78,16.12 20.78,11.05 17.66,7.93Z";
447
+ export const mediaSaturate =
448
+ "M12 2A10 10 0 0 0 2 12A10 10 0 0 0 12 22A10 10 0 0 0 22 12A10 10 0 0 0 12 2M12 4A8 8 0 0 1 20 12A8 8 0 0 1 12 20V4Z";
440
449
  }