@react-fabric/core 1.0.0-beta.3 → 1.0.0-beta.30

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 (207) hide show
  1. package/css/index.js +14 -14
  2. package/css/reset/_reset.css +1 -1
  3. package/dist/cjs/components/actionLabel/ActionLabel.js +1 -0
  4. package/dist/cjs/components/animations/Animations.js +14 -7
  5. package/dist/cjs/components/avatar/Avatar.js +8 -10
  6. package/dist/cjs/components/avatar/AvatarGroup.js +1 -0
  7. package/dist/cjs/components/badge/Badge.js +5 -4
  8. package/dist/cjs/components/breadcrumbs/Breadcrumbs.js +5 -2
  9. package/dist/cjs/components/button/Button.js +5 -4
  10. package/dist/cjs/components/button/Button.module.css +1 -1
  11. package/dist/cjs/components/button/ButtonGroup.js +3 -1
  12. package/dist/cjs/components/button/ConfirmButton.js +7 -2
  13. package/dist/cjs/components/button/ToggleButtonGroup.js +2 -1
  14. package/dist/cjs/components/callout/Callout.js +7 -2
  15. package/dist/cjs/components/card/Card.js +5 -3
  16. package/dist/cjs/components/card/CardCover.js +1 -1
  17. package/dist/cjs/components/chip/Chip.js +9 -4
  18. package/dist/cjs/components/chip/Chip.module.css +1 -1
  19. package/dist/cjs/components/collapsable/Collapsable.js +3 -2
  20. package/dist/cjs/components/divider/Divider.js +4 -3
  21. package/dist/cjs/components/divider/Divider.module.css +1 -0
  22. package/dist/cjs/components/dropdown/Dropdown.js +4 -2
  23. package/dist/cjs/components/dropdown/DropdownTool.js +4 -3
  24. package/dist/cjs/components/icon/Icon.js +14 -12
  25. package/dist/cjs/components/icon/Icon.module.css +1 -1
  26. package/dist/cjs/components/menu/ContextMenu.js +30 -10
  27. package/dist/cjs/components/menu/Menu.js +39 -20
  28. package/dist/cjs/components/menu/MenuItem.js +29 -14
  29. package/dist/cjs/components/navigator/Navigator.js +16 -9
  30. package/dist/cjs/components/panel/Panel.js +3 -1
  31. package/dist/cjs/components/progress/ProgressBar.js +2 -1
  32. package/dist/cjs/components/progress/ProgressCircle.js +2 -1
  33. package/dist/cjs/components/tabpanel/Tab.js +55 -36
  34. package/dist/cjs/components/tabpanel/TabPanel.js +19 -14
  35. package/dist/cjs/components/tabpanel/TabPanel.module.css +1 -1
  36. package/dist/cjs/core/aside/Aside.js +6 -2
  37. package/dist/cjs/core/content/Content.js +8 -5
  38. package/dist/cjs/core/headfoot/HeadFoot.js +3 -2
  39. package/dist/cjs/core/headfoot/HeadFoot.module.css +1 -1
  40. package/dist/cjs/core/page/Page.js +1 -0
  41. package/dist/cjs/core/responsive/Responsive.js +1 -1
  42. package/dist/cjs/core/section/Section.module.css +1 -1
  43. package/dist/cjs/hooks/useNavigator.js +6 -4
  44. package/dist/cjs/index.js +7 -2
  45. package/dist/cjs/overlays/alert/Alert.js +42 -17
  46. package/dist/cjs/overlays/alert/Alert.module.css +1 -1
  47. package/dist/cjs/overlays/flyout/Flyout.js +40 -42
  48. package/dist/cjs/overlays/message/Message.js +1 -1
  49. package/dist/cjs/overlays/modal/Modal.js +4 -5
  50. package/dist/cjs/overlays/toast/Toast.js +1 -1
  51. package/dist/cjs/overlays/tooltip/Tooltip.js +3 -3
  52. package/dist/cjs/overlays/tooltip/Tooltip.module.css +1 -1
  53. package/dist/cjs/types/icons.js +3 -0
  54. package/dist/cjs/typography/Abbr.js +1 -1
  55. package/dist/cjs/typography/{Link.js → Anchor.js} +4 -3
  56. package/dist/cjs/typography/Mark.js +1 -1
  57. package/dist/cjs/typography/Text.js +2 -2
  58. package/dist/cjs/typography/Title.js +3 -2
  59. package/dist/cjs/typography/Typography.module.css +1 -1
  60. package/dist/cjs/utils/cloneElement.js +44 -0
  61. package/dist/esm/components/actionLabel/ActionLabel.js +1 -0
  62. package/dist/esm/components/animations/Animations.js +14 -7
  63. package/dist/esm/components/avatar/Avatar.js +9 -11
  64. package/dist/esm/components/avatar/AvatarGroup.js +1 -0
  65. package/dist/esm/components/badge/Badge.js +5 -4
  66. package/dist/esm/components/breadcrumbs/Breadcrumbs.js +5 -2
  67. package/dist/esm/components/button/Button.js +5 -4
  68. package/dist/esm/components/button/Button.module.css +1 -1
  69. package/dist/esm/components/button/ButtonGroup.js +4 -2
  70. package/dist/esm/components/button/ConfirmButton.js +7 -2
  71. package/dist/esm/components/button/ToggleButtonGroup.js +3 -2
  72. package/dist/esm/components/callout/Callout.js +7 -2
  73. package/dist/esm/components/card/Card.js +5 -3
  74. package/dist/esm/components/card/CardCover.js +1 -1
  75. package/dist/esm/components/chip/Chip.js +9 -4
  76. package/dist/esm/components/chip/Chip.module.css +1 -1
  77. package/dist/esm/components/collapsable/Collapsable.js +3 -2
  78. package/dist/esm/components/divider/Divider.js +4 -3
  79. package/dist/esm/components/divider/Divider.module.css +1 -0
  80. package/dist/esm/components/dropdown/Dropdown.js +4 -2
  81. package/dist/esm/components/dropdown/DropdownTool.js +4 -3
  82. package/dist/esm/components/icon/Icon.js +14 -12
  83. package/dist/esm/components/icon/Icon.module.css +1 -1
  84. package/dist/esm/components/menu/ContextMenu.js +32 -12
  85. package/dist/esm/components/menu/Menu.js +41 -22
  86. package/dist/esm/components/menu/MenuItem.js +23 -8
  87. package/dist/esm/components/navigator/Navigator.js +16 -9
  88. package/dist/esm/components/panel/Panel.js +3 -1
  89. package/dist/esm/components/progress/ProgressBar.js +2 -1
  90. package/dist/esm/components/progress/ProgressCircle.js +2 -1
  91. package/dist/esm/components/tabpanel/Tab.js +56 -37
  92. package/dist/esm/components/tabpanel/TabPanel.js +19 -14
  93. package/dist/esm/components/tabpanel/TabPanel.module.css +1 -1
  94. package/dist/esm/core/aside/Aside.js +6 -2
  95. package/dist/esm/core/content/Content.js +8 -5
  96. package/dist/esm/core/headfoot/HeadFoot.js +3 -2
  97. package/dist/esm/core/headfoot/HeadFoot.module.css +1 -1
  98. package/dist/esm/core/page/Page.js +1 -0
  99. package/dist/esm/core/responsive/Responsive.js +1 -1
  100. package/dist/esm/core/section/Section.module.css +1 -1
  101. package/dist/esm/hooks/useNavigator.js +7 -5
  102. package/dist/esm/index.js +4 -1
  103. package/dist/esm/overlays/alert/Alert.js +31 -6
  104. package/dist/esm/overlays/alert/Alert.module.css +1 -1
  105. package/dist/esm/overlays/flyout/Flyout.js +41 -43
  106. package/dist/esm/overlays/message/Message.js +1 -1
  107. package/dist/esm/overlays/modal/Modal.js +5 -6
  108. package/dist/esm/overlays/toast/Toast.js +1 -1
  109. package/dist/esm/overlays/tooltip/Tooltip.js +3 -3
  110. package/dist/esm/overlays/tooltip/Tooltip.module.css +1 -1
  111. package/dist/esm/types/icons.js +3 -0
  112. package/dist/esm/typography/Abbr.js +1 -1
  113. package/dist/esm/typography/{Link.js → Anchor.js} +4 -3
  114. package/dist/esm/typography/Mark.js +1 -1
  115. package/dist/esm/typography/Text.js +2 -2
  116. package/dist/esm/typography/Title.js +3 -2
  117. package/dist/esm/typography/Typography.module.css +1 -1
  118. package/dist/esm/utils/cloneElement.js +44 -0
  119. package/dist/types/components/actionLabel/ActionLabel.d.ts +2 -2
  120. package/dist/types/components/animations/Animations.d.ts +1 -1
  121. package/dist/types/components/badge/Badge.d.ts +5 -1
  122. package/dist/types/components/breadcrumbs/Breadcrumbs.d.ts +2 -2
  123. package/dist/types/components/button/Button.d.ts +5 -3
  124. package/dist/types/components/button/ConfirmButton.d.ts +6 -1
  125. package/dist/types/components/card/Card.d.ts +3 -3
  126. package/dist/types/components/chip/Chip.d.ts +1 -1
  127. package/dist/types/components/collapsable/Collapsable.d.ts +5 -1
  128. package/dist/types/components/dropdown/DropdownTool.d.ts +2 -1
  129. package/dist/types/components/media/Media.d.ts +2 -2
  130. package/dist/types/components/menu/ContextMenu.d.ts +2 -1
  131. package/dist/types/components/menu/MenuItem.d.ts +1 -1
  132. package/dist/types/components/navigator/Navigator.d.ts +3 -3
  133. package/dist/types/components/tabpanel/Tab.d.ts +4 -4
  134. package/dist/types/components/tabpanel/TabPanel.d.ts +10 -1
  135. package/dist/types/core/aside/Aside.d.ts +7 -3
  136. package/dist/types/core/content/Content.d.ts +3 -2
  137. package/dist/types/core/responsive/Responsive.d.ts +1 -1
  138. package/dist/types/core/theme/ThemeProvider.d.ts +1 -1
  139. package/dist/types/hooks/useOverlayService.d.ts +3 -3
  140. package/dist/types/index.d.ts +3 -0
  141. package/dist/types/overlays/alert/Alert.d.ts +9 -1
  142. package/dist/types/overlays/flyout/Flyout.d.ts +3 -2
  143. package/dist/types/overlays/modal/Modal.d.ts +4 -3
  144. package/dist/types/types/icons.d.ts +3 -0
  145. package/dist/types/types/index.d.ts +8 -1
  146. package/dist/types/typography/{Link.d.ts → Anchor.d.ts} +2 -2
  147. package/dist/types/typography/index.d.ts +1 -1
  148. package/dist/types/utils/cloneElement.d.ts +2 -0
  149. package/dist/types/utils/index.d.ts +1 -0
  150. package/package.json +5 -5
  151. package/src/components/actionLabel/ActionLabel.tsx +13 -3
  152. package/src/components/animations/Animations.tsx +9 -3
  153. package/src/components/avatar/Avatar.tsx +69 -81
  154. package/src/components/avatar/AvatarGroup.tsx +1 -0
  155. package/src/components/badge/Badge.tsx +9 -4
  156. package/src/components/breadcrumbs/Breadcrumbs.tsx +9 -4
  157. package/src/components/button/Button.module.css +8 -1
  158. package/src/components/button/Button.tsx +12 -9
  159. package/src/components/button/ButtonGroup.tsx +3 -2
  160. package/src/components/button/ConfirmButton.tsx +15 -5
  161. package/src/components/button/ToggleButtonGroup.tsx +3 -2
  162. package/src/components/callout/Callout.tsx +12 -3
  163. package/src/components/card/Card.tsx +4 -0
  164. package/src/components/chip/Chip.module.css +4 -1
  165. package/src/components/chip/Chip.tsx +9 -4
  166. package/src/components/collapsable/Collapsable.tsx +6 -0
  167. package/src/components/divider/Divider.module.css +32 -0
  168. package/src/components/divider/Divider.tsx +3 -2
  169. package/src/components/dropdown/Dropdown.tsx +3 -2
  170. package/src/components/dropdown/DropdownTool.tsx +4 -2
  171. package/src/components/icon/Icon.module.css +0 -1
  172. package/src/components/icon/Icon.tsx +48 -58
  173. package/src/components/media/Media.tsx +2 -2
  174. package/src/components/menu/ContextMenu.tsx +36 -11
  175. package/src/components/menu/Menu.tsx +51 -30
  176. package/src/components/menu/MenuItem.tsx +14 -3
  177. package/src/components/navigator/Navigator.tsx +17 -4
  178. package/src/components/panel/Panel.tsx +3 -1
  179. package/src/components/tabpanel/Tab.tsx +74 -59
  180. package/src/components/tabpanel/TabPanel.module.css +19 -30
  181. package/src/components/tabpanel/TabPanel.tsx +33 -10
  182. package/src/core/aside/Aside.tsx +17 -3
  183. package/src/core/content/Content.tsx +16 -10
  184. package/src/core/headfoot/HeadFoot.module.css +2 -0
  185. package/src/core/headfoot/HeadFoot.tsx +1 -1
  186. package/src/core/page/Page.tsx +1 -0
  187. package/src/core/responsive/Responsive.tsx +3 -2
  188. package/src/core/section/Section.module.css +1 -1
  189. package/src/core/theme/ThemeProvider.tsx +1 -1
  190. package/src/hooks/useNavigator.tsx +10 -5
  191. package/src/hooks/useOverlayService.tsx +12 -4
  192. package/src/index.ts +4 -0
  193. package/src/overlays/alert/Alert.module.css +1 -1
  194. package/src/overlays/alert/Alert.tsx +30 -4
  195. package/src/overlays/flyout/Flyout.tsx +63 -62
  196. package/src/overlays/modal/Modal.tsx +13 -8
  197. package/src/overlays/tooltip/Tooltip.module.css +7 -7
  198. package/src/overlays/tooltip/Tooltip.tsx +4 -4
  199. package/src/types/icons.ts +6 -0
  200. package/src/types/index.ts +10 -9
  201. package/src/typography/{Link.tsx → Anchor.tsx} +3 -3
  202. package/src/typography/Text.tsx +1 -1
  203. package/src/typography/Title.tsx +0 -1
  204. package/src/typography/Typography.module.css +4 -2
  205. package/src/typography/index.ts +1 -1
  206. package/src/utils/cloneElement.ts +44 -0
  207. package/src/utils/index.ts +1 -0
package/src/index.ts CHANGED
@@ -40,9 +40,13 @@ export * from "./hooks/useStorage";
40
40
 
41
41
  export { HotKey } from "./hotkeys/HotKey";
42
42
  export { HotKeyLabel } from "./hotkeys/HotKeyLabel";
43
+ export { HotKeyWrapper } from "./hotkeys/HotKeyWrapper";
43
44
 
45
+ export { type ModalProps } from "./types";
44
46
  export { CoreIcons } from "./types/icons";
45
47
 
48
+ export { cloneChildren } from "./utils";
49
+
46
50
  export {
47
51
  ApplicationProvider,
48
52
  useApplicationContext,
@@ -25,7 +25,7 @@
25
25
  .alert {
26
26
  z-index: var(--z-overlay);
27
27
 
28
- grid-template: "icon title" auto "icon message" auto "input input" auto "actions actions" auto / auto 1fr;
28
+ grid-template: "icon title" auto "message message" auto "input input" auto "actions actions" auto / auto 1fr;
29
29
  gap: 0.5rem 1rem;
30
30
 
31
31
  margin-top: -100%;
@@ -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: () => {
@@ -179,8 +190,23 @@ export const Alert = ({
179
190
  {iconType}
180
191
  </div>
181
192
 
182
- <Title className="font-medium area-[title]">{title}</Title>
183
- <p className="area-[message] py-4">{message}</p>
193
+ <Title className="font-medium area-[title] self-center">
194
+ {title}
195
+ </Title>
196
+ <div className="area-[message] py-4">{message}</div>
197
+ {type === "prompt" && (
198
+ <input
199
+ value={value}
200
+ placeholder={placeholder}
201
+ className={classNames(
202
+ `area-[input] appearance-none outline-0 ring-${color}-500 border rounded border-${color}-200 w-full px-2 py-1`,
203
+ )}
204
+ ref={(e) => e != null && setTimeout(() => e.focus(), 100)}
205
+ onBlur={(e) => e.target.focus()}
206
+ onChange={(e) => setValue(e.target.value)}
207
+ onKeyDown={(e) => e.key === "Enter" && handleClose(value)}
208
+ />
209
+ )}
184
210
  <div className="flex gap-1 justify-center flex-nowrap pt-2 area-[actions]">
185
211
  <div
186
212
  className="contents"
@@ -204,7 +230,7 @@ export const Alert = ({
204
230
  size="sm"
205
231
  variant="solid"
206
232
  color={color}
207
- onClick={() => handleClose(true)}
233
+ onClick={() => handleClose(type === "prompt" ? value : true)}
208
234
  >
209
235
  {okLabel ?? t("action.ok", "OK")}
210
236
  </Button>
@@ -30,11 +30,14 @@ import {
30
30
  useInteractions,
31
31
  useRole,
32
32
  } from "@floating-ui/react";
33
+ import { isString } from "@react-fabric/utilities";
33
34
  import classNames from "classnames";
34
35
  import {
35
36
  Fragment,
37
+ isValidElement,
36
38
  useCallback,
37
39
  useEffect,
40
+ type ElementType,
38
41
  type PropsWithChildren,
39
42
  } from "react";
40
43
  import { Loading } from "../../components/animations/Animations";
@@ -55,8 +58,9 @@ import classes from "./Flyout.module.css";
55
58
  export interface FlyoutProps
56
59
  extends AriaProps,
57
60
  TestProps,
58
- IconProps,
61
+ Omit<IconProps, "icon">,
59
62
  ChildrenProp {
63
+ icon?: string | ElementType<IconProps>;
60
64
  /**
61
65
  * flyout alignment
62
66
  */
@@ -140,6 +144,7 @@ export const Flyout = ({
140
144
  });
141
145
  const dismiss = useDismiss(context, {
142
146
  outsidePressEvent: "mousedown",
147
+ outsidePress: !hideMask,
143
148
  escapeKey: true,
144
149
  });
145
150
  const role = useRole(context);
@@ -173,9 +178,6 @@ export const Flyout = ({
173
178
  useEffect(() => {
174
179
  setTimeout(() => {
175
180
  refs.floating.current && (refs.floating.current.dataset.show = "true");
176
- refs.floating.current
177
- ?.querySelector<HTMLElement>('[role="dialog"]')
178
- ?.focus();
179
181
  }, 50);
180
182
  }, []);
181
183
 
@@ -214,68 +216,67 @@ export const Flyout = ({
214
216
  <FloatingPortal>
215
217
  <Wrapper>
216
218
  <FloatingFocusManager context={context}>
217
- <Wrapper>
218
- <div
219
- data-align={align}
220
- className={classNames(
221
- classes.flyout,
222
- "fixed inset-y-0 overflow-hidden flex flex-col flex-nowrap pointer-events-auto shadow-xl",
223
- align === "start" ? "start-0" : "end-0",
224
- size === "sm" && "w-[20rem]",
225
- size === "md" && "w-[40rem]",
226
- size === "lg" && "w-[60vw]",
227
- size === "xl" && "w-[80vw]",
228
- )}
229
- style={{
230
- width,
231
- minWidth,
232
- }}
233
- onMouseUpCapture={tryClosing}
234
- ref={refs.setFloating}
235
- {...getFloatingProps()}
236
- {...aria}
237
- {...aria}
238
- >
239
- <HotKeyWrapper>
240
- <Header
241
- flex
242
- className={classNames(classes.flyoutHeader, headerClassName)}
243
- >
244
- {icon && (
245
- <Icon
246
- icon={icon}
247
- bg={iconBg}
248
- color={iconColor}
249
- className={classNames(iconClassName, "p-1")}
250
- rtlFlip={rtlFlip}
251
- />
252
- )}
253
- <label className="flex-1 truncate py-2 px-1">{title}</label>
254
- {actions}
219
+ <div
220
+ data-align={align}
221
+ className={classNames(
222
+ classes.flyout,
223
+ "fixed inset-y-0 overflow-hidden flex flex-col flex-nowrap pointer-events-auto shadow-xl",
224
+ align === "start" ? "start-0" : "end-0",
225
+ size === "sm" && "w-[20rem]",
226
+ size === "md" && "w-[40rem]",
227
+ size === "lg" && "w-[60vw]",
228
+ size === "xl" && "w-[80vw]",
229
+ )}
230
+ style={{
231
+ width,
232
+ minWidth,
233
+ }}
234
+ onMouseUpCapture={tryClosing}
235
+ ref={refs.setFloating}
236
+ {...getFloatingProps()}
237
+ {...aria}
238
+ {...aria}
239
+ >
240
+ <HotKeyWrapper>
241
+ <Header
242
+ flex
243
+ className={classNames(classes.flyoutHeader, headerClassName)}
244
+ >
245
+ {isString(icon) && (
255
246
  <Icon
256
- data-ref="panelClose"
257
- className={classNames(
258
- classes.panelAction,
259
- "cursor-pointer p-1 text-xl self-stretch",
260
- )}
261
- icon={CoreIcons.close}
262
- onClick={() => handleClose(false)}
247
+ icon={icon}
248
+ bg={iconBg}
249
+ color={iconColor}
250
+ className={classNames(iconClassName, "p-1")}
251
+ rtlFlip={rtlFlip}
263
252
  />
264
- </Header>
265
- {loading && <Loading />}
266
- <div
267
- role="dialog"
253
+ )}
254
+ {isValidElement(icon) && icon}
255
+ <label className="flex-1 truncate py-2 px-1">{title}</label>
256
+ {actions}
257
+ <Icon
258
+ data-ref="panelClose"
268
259
  className={classNames(
269
- classes.flyoutBody,
270
- "flex-1 grid overflow-hidden",
260
+ classes.panelAction,
261
+ "cursor-pointer p-1 text-xl self-stretch",
271
262
  )}
272
- {...({ tabIndex: 0 } as AnyObject)}
273
- >
274
- {children}
275
- </div>
276
- </HotKeyWrapper>
277
- </div>
278
- </Wrapper>
263
+ icon={CoreIcons.close}
264
+ onClick={() => handleClose(false)}
265
+ />
266
+ </Header>
267
+ {loading && <Loading />}
268
+ <div
269
+ role="dialog"
270
+ className={classNames(
271
+ classes.flyoutBody,
272
+ "flex-1 grid overflow-hidden",
273
+ )}
274
+ {...({ tabIndex: 0 } as AnyObject)}
275
+ >
276
+ {children}
277
+ </div>
278
+ </HotKeyWrapper>
279
+ </div>
279
280
  </FloatingFocusManager>
280
281
  </Wrapper>
281
282
  </FloatingPortal>
@@ -30,8 +30,14 @@ import {
30
30
  useInteractions,
31
31
  useRole,
32
32
  } from "@floating-ui/react";
33
+ import { isString } from "@react-fabric/utilities";
33
34
  import classNames from "classnames";
34
- import { useCallback, useEffect } from "react";
35
+ import {
36
+ type ElementType,
37
+ isValidElement,
38
+ useCallback,
39
+ useEffect,
40
+ } from "react";
35
41
  import { Loading } from "../../components/animations/Animations";
36
42
  import { Icon } from "../../components/icon/Icon";
37
43
  import { Header } from "../../core/headfoot/HeadFoot";
@@ -50,8 +56,9 @@ import classes from "./Modal.module.css";
50
56
  export interface ModalProps
51
57
  extends AriaProps,
52
58
  TestProps,
53
- IconProps,
59
+ Omit<IconProps, "icon">,
54
60
  ChildrenProp {
61
+ icon?: string | ElementType<IconProps>;
55
62
  /**
56
63
  * header className
57
64
  */
@@ -95,7 +102,7 @@ export interface ModalProps
95
102
  /**
96
103
  * close handler
97
104
  */
98
- onClose: (...args: AnyObject) => void;
105
+ onClose?: (...args: AnyObject) => void;
99
106
  /**
100
107
  * before close handler, return false to prevent close
101
108
  */
@@ -163,9 +170,6 @@ export const Modal = ({
163
170
  useEffect(() => {
164
171
  setTimeout(() => {
165
172
  refs.floating.current && (refs.floating.current.dataset.show = "true");
166
- refs.floating.current
167
- ?.querySelector<HTMLElement>("[role='dialog']")
168
- ?.focus();
169
173
  }, 50);
170
174
  }, []);
171
175
 
@@ -174,7 +178,7 @@ export const Modal = ({
174
178
  <FloatingOverlay
175
179
  lockScroll
176
180
  style={{ zIndex: "var(--z-overlay-mask)" }}
177
- className="bg-base/50 backdrop-blur-sm grid place-items-center"
181
+ className="bg-base/20 backdrop-blur-sm grid place-items-center"
178
182
  >
179
183
  <FloatingFocusManager context={context}>
180
184
  <dialog
@@ -203,7 +207,7 @@ export const Modal = ({
203
207
  flex
204
208
  className={classNames(classes.modalHeader, headerClassName)}
205
209
  >
206
- {icon && (
210
+ {isString(icon) && (
207
211
  <Icon
208
212
  icon={icon}
209
213
  bg={iconBg}
@@ -212,6 +216,7 @@ export const Modal = ({
212
216
  rtlFlip={rtlFlip}
213
217
  />
214
218
  )}
219
+ {isValidElement(icon) && icon}
215
220
  <label className="flex-1 truncate py-2 px-1">{title}</label>
216
221
  {actions}
217
222
  <Icon
@@ -24,30 +24,30 @@
24
24
  @layer comp {
25
25
  .tooltip {
26
26
  z-index: var(--z-tooltip);
27
- color: theme(backgroundColor.invert);
27
+ color: theme(backgroundColor.dimmed);
28
28
 
29
29
  &[data-color="primary"] {
30
- color: theme(colors.primary.600);
30
+ color: theme(colors.primary.200);
31
31
  }
32
32
 
33
33
  &[data-color="accent"] {
34
- color: theme(colors.accent.600);
34
+ color: theme(colors.accent.200);
35
35
  }
36
36
 
37
37
  &[data-color="info"] {
38
- color: theme(colors.info.600);
38
+ color: theme(colors.info.200);
39
39
  }
40
40
 
41
41
  &[data-color="danger"] {
42
- color: theme(colors.danger.600);
42
+ color: theme(colors.danger.200);
43
43
  }
44
44
 
45
45
  &[data-color="success"] {
46
- color: theme(colors.success.600);
46
+ color: theme(colors.success.200);
47
47
  }
48
48
 
49
49
  &[data-color="warning"] {
50
- color: theme(colors.warning.600);
50
+ color: theme(colors.warning.200);
51
51
  }
52
52
  }
53
53
  }
@@ -153,7 +153,7 @@ export const Tooltip = ({
153
153
  return (
154
154
  <span
155
155
  role="none"
156
- className="ms-2 cursor-pointer text-invert flex-content opacity-75 hover:opacity-90 active:opacity-60"
156
+ className="ms-2 cursor-pointer text-dimmed flex-content opacity-75 hover:opacity-90 active:opacity-60"
157
157
  onClick={handler}
158
158
  >
159
159
  <Icon icon={CoreIcons.copy} />
@@ -176,7 +176,7 @@ export const Tooltip = ({
176
176
  data-color={color}
177
177
  className={classNames(
178
178
  classes.tooltip,
179
- "select-none text-sm not-italic flex py-1 px-2 rounded shadow-md bg-current",
179
+ "select-none text-sm not-italic flex py-1 px-2 !max-w-64 rounded shadow-md bg-current",
180
180
  )}
181
181
  ref={refs.setFloating}
182
182
  style={floatingStyles}
@@ -184,8 +184,8 @@ export const Tooltip = ({
184
184
  >
185
185
  <span
186
186
  className={classNames(
187
- "font-medium text-invert flex-1",
188
- isString(content) && "whitespace-pre-wrap",
187
+ "font-medium text-dimmed flex-1 break-all",
188
+ isString(content) && "whitespace-pre-wrap mixed-lang",
189
189
  )}
190
190
  >
191
191
  {content}
@@ -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 =
@@ -244,6 +249,7 @@ export module CoreIcons {
244
249
  "M5.541 2.159c-0.153-0.1-0.34-0.159-0.541-0.159-0.552 0-1 0.448-1 1v18c-0.001 0.182 0.050 0.372 0.159 0.541 0.299 0.465 0.917 0.599 1.382 0.3l14-9c0.114-0.072 0.219-0.174 0.3-0.3 0.299-0.465 0.164-1.083-0.3-1.382zM6 4.832l11.151 7.168-11.151 7.168z";
245
250
  export const pause =
246
251
  "M6 3c-0.552 0-1 0.448-1 1v16c0 0.552 0.448 1 1 1h4c0.552 0 1-0.448 1-1v-16c0-0.552-0.448-1-1-1zM7 5h2v14h-2zM14 3c-0.552 0-1 0.448-1 1v16c0 0.552 0.448 1 1 1h4c0.552 0 1-0.448 1-1v-16c0-0.552-0.448-1-1-1zM15 5h2v14h-2z";
252
+ export const stop = "M18,18H6V6H18V18Z";
247
253
  export const volumeOn =
248
254
  "M10 7.081v9.839l-3.375-2.7c-0.17-0.137-0.388-0.22-0.625-0.22h-3v-4h3c0.218 0.001 0.439-0.071 0.625-0.219zM10.375 4.219l-4.726 3.781h-3.649c-0.552 0-1 0.448-1 1v6c0 0.552 0.448 1 1 1h3.649l4.726 3.781c0.431 0.345 1.061 0.275 1.406-0.156 0.148-0.185 0.22-0.407 0.219-0.625v-14c0-0.552-0.448-1-1-1-0.237 0-0.455 0.083-0.625 0.219zM18.363 5.637c1.757 1.758 2.635 4.059 2.635 6.364 0 2.304-0.878 4.605-2.635 6.362-0.39 0.391-0.39 1.024 0 1.414s1.024 0.39 1.414 0c2.147-2.147 3.22-4.963 3.221-7.776s-1.074-5.63-3.221-7.778c-0.39-0.391-1.024-0.391-1.414 0s-0.391 1.024 0 1.414zM14.833 9.167c0.781 0.781 1.171 1.803 1.171 2.828s-0.39 2.047-1.171 2.828c-0.39 0.391-0.39 1.024 0 1.414s1.024 0.39 1.414 0c1.171-1.171 1.757-2.708 1.757-4.242s-0.586-3.071-1.757-4.242c-0.39-0.391-1.024-0.391-1.414 0s-0.391 1.024 0 1.414z";
249
255
  export const volumeOff =
@@ -25,6 +25,10 @@
25
25
  import { type Placement } from "@floating-ui/react";
26
26
  import { type JSXElementConstructor, type Ref } from "react";
27
27
 
28
+ export type ModalProps<P = unknown> = P & {
29
+ onClose: (...args: AnyObject) => void;
30
+ };
31
+
28
32
  export type SizeType = "xs" | "sm" | "md" | "lg" | "xl";
29
33
 
30
34
  export type SizeTypeWithZero = "xs" | "sm" | "md" | "lg" | "xl" | 0;
@@ -122,15 +126,7 @@ export interface TestProps {
122
126
  "data-test-value"?: AnyObject;
123
127
  }
124
128
 
125
- export type Elements<T> =
126
- | React.ReactElement<T>
127
- | React.ReactPortal
128
- | React.ReactNode
129
- | string
130
- | number
131
- | boolean
132
- | null
133
- | undefined;
129
+ export type Elements<T> = React.ReactElement<T> | React.ReactNode;
134
130
 
135
131
  export type AriaProps = React.AriaAttributes;
136
132
 
@@ -239,3 +235,8 @@ export interface SizeObject {
239
235
  width: number;
240
236
  height: number;
241
237
  }
238
+
239
+ export interface ScrollObject extends PositionObject, SizeObject {
240
+ scrollWidth?: number;
241
+ scrollHeight: number;
242
+ }
@@ -36,7 +36,7 @@ import {
36
36
  import { getBgClass, getColor, getColorClass } from "../utils";
37
37
  import { TextSizeMap } from "./types";
38
38
 
39
- export interface LinkProps extends ChildrenProp, CssProp, RefProp, AriaProps {
39
+ export interface AnchorProps extends ChildrenProp, CssProp, RefProp, AriaProps {
40
40
  /**
41
41
  * link background (CSS color / tailwind color)
42
42
  */
@@ -60,7 +60,7 @@ export interface LinkProps extends ChildrenProp, CssProp, RefProp, AriaProps {
60
60
  /**
61
61
  * Typography link component
62
62
  */
63
- export const Link = <Tag extends React.ElementType = "a">({
63
+ export const Anchor = <Tag extends React.ElementType = "a">({
64
64
  ref,
65
65
  as,
66
66
  children,
@@ -70,7 +70,7 @@ export const Link = <Tag extends React.ElementType = "a">({
70
70
  family,
71
71
  size,
72
72
  ...aria
73
- }: LinkProps & PolymorphicProps<Tag>) => {
73
+ }: AnchorProps & PolymorphicProps<Tag>) => {
74
74
  /** ***************** style map *******************/
75
75
  const styles = useMemoDebugger(
76
76
  () => {
@@ -165,7 +165,7 @@ export const Text = ({
165
165
  <div
166
166
  className={classNames(
167
167
  classes.text,
168
- "text-reset mixed-lang px-[2px] whitespace-pre-wrap",
168
+ "mixed-lang px-[2px] whitespace-pre-wrap",
169
169
  family && `font-${family}`,
170
170
  bg && getBgClass(bg),
171
171
  color && getColorClass(color),
@@ -110,7 +110,6 @@ export const Title = ({
110
110
  <E
111
111
  className={classNames(
112
112
  classes.title,
113
- "px-[2px] py-1 truncate whitespace-pre-wrap",
114
113
  className,
115
114
  family && `font-${family}`,
116
115
  !as && "text-lg",
@@ -23,11 +23,13 @@
23
23
 
24
24
  @layer comp {
25
25
  .title {
26
+ padding: 4px 2px;
26
27
  line-height: 1.125;
28
+ white-space: prewrap;
27
29
  }
28
30
 
29
31
  .moreLink {
30
- margin: -0.25rem 0 1rem;
32
+ margin: -0.25rem 0 0.25rem;
31
33
  text-align: end;
32
34
 
33
35
  & > span {
@@ -57,7 +59,7 @@
57
59
  }
58
60
 
59
61
  .mark {
60
- --mark-color: var(--accent);
62
+ --mark-color: var(--primary);
61
63
 
62
64
  background-color: color-mix(
63
65
  in lab,
@@ -22,8 +22,8 @@
22
22
  */
23
23
 
24
24
  export { Abbr } from "./Abbr";
25
+ export { Anchor } from "./Anchor";
25
26
  export { Copy } from "./Copy";
26
- export { Link } from "./Link";
27
27
  export { Mark } from "./Mark";
28
28
  export { Text } from "./Text";
29
29
  export { Title } from "./Title";
@@ -0,0 +1,44 @@
1
+ /*
2
+ * React Fabric
3
+ * @version: 1.0.0
4
+ *
5
+ *
6
+ * The MIT License (MIT)
7
+ * Copyright (c) 2024 Adarsh Pastakia
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
10
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
11
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
12
+ * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
13
+ * subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all copies or substantial
16
+ * portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19
+ * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+ import { type ReactNode, Children, isValidElement } from "react";
25
+ import { Fragment } from "react/jsx-runtime";
26
+
27
+ export const cloneChildren = (
28
+ children: ReactNode,
29
+ callback: (child: ReactNode, index: number) => ReactNode,
30
+ ): ReactNode => {
31
+ return Children.map(children, (c: ReactNode) => {
32
+ if (isValidElement(c)) {
33
+ if (c.type === Fragment) {
34
+ // just compare to `Fragment`
35
+ return cloneChildren(c.props?.children, callback);
36
+ }
37
+ return c;
38
+ }
39
+ return c;
40
+ })
41
+ ?.flat()
42
+ .filter(Boolean)
43
+ .map(callback);
44
+ };
@@ -24,5 +24,6 @@
24
24
  /* istanbul ignore file */
25
25
 
26
26
  export * from "./calculateDimensions";
27
+ export * from "./cloneElement";
27
28
  export * from "./getColor";
28
29
  export * from "./nodeCheck";