@g4rcez/components 3.0.0-0 → 3.0.0

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 (175) hide show
  1. package/dist/components/core/button.d.ts +2 -8
  2. package/dist/components/core/button.d.ts.map +1 -1
  3. package/dist/components/core/button.jsx +11 -18
  4. package/dist/components/core/polymorph.d.ts.map +1 -1
  5. package/dist/components/core/slot.d.ts +1 -1
  6. package/dist/components/core/slot.d.ts.map +1 -1
  7. package/dist/components/core/slot.jsx +28 -35
  8. package/dist/components/core/tag.d.ts +1 -1
  9. package/dist/components/core/tag.d.ts.map +1 -1
  10. package/dist/components/core/tag.jsx +3 -3
  11. package/dist/components/core/typography.d.ts.map +1 -1
  12. package/dist/components/core/typography.jsx +16 -20
  13. package/dist/components/display/alert.d.ts.map +1 -1
  14. package/dist/components/display/alert.jsx +19 -17
  15. package/dist/components/display/calendar.d.ts.map +1 -1
  16. package/dist/components/display/calendar.jsx +6 -8
  17. package/dist/components/display/card.d.ts.map +1 -1
  18. package/dist/components/display/card.jsx +6 -6
  19. package/dist/components/display/empty.jsx +1 -1
  20. package/dist/components/display/notifications.d.ts +2 -0
  21. package/dist/components/display/notifications.d.ts.map +1 -1
  22. package/dist/components/display/notifications.jsx +76 -48
  23. package/dist/components/display/progress.d.ts.map +1 -1
  24. package/dist/components/display/progress.jsx +7 -9
  25. package/dist/components/display/shortcut.jsx +1 -1
  26. package/dist/components/display/skeleton.d.ts.map +1 -1
  27. package/dist/components/display/skeleton.jsx +3 -5
  28. package/dist/components/display/step.d.ts.map +1 -1
  29. package/dist/components/display/step.jsx +27 -27
  30. package/dist/components/display/tabs.d.ts.map +1 -1
  31. package/dist/components/display/tabs.jsx +5 -7
  32. package/dist/components/display/timeline.jsx +1 -1
  33. package/dist/components/floating/command-palette.d.ts +1 -0
  34. package/dist/components/floating/command-palette.d.ts.map +1 -1
  35. package/dist/components/floating/command-palette.jsx +92 -70
  36. package/dist/components/floating/dropdown.d.ts.map +1 -1
  37. package/dist/components/floating/dropdown.jsx +15 -15
  38. package/dist/components/floating/menu.d.ts +2 -2
  39. package/dist/components/floating/menu.jsx +2 -2
  40. package/dist/components/floating/modal.d.ts +20 -53
  41. package/dist/components/floating/modal.d.ts.map +1 -1
  42. package/dist/components/floating/modal.jsx +109 -51
  43. package/dist/components/floating/tooltip.d.ts.map +1 -1
  44. package/dist/components/floating/tooltip.jsx +2 -8
  45. package/dist/components/floating/wizard.d.ts +1 -1
  46. package/dist/components/floating/wizard.d.ts.map +1 -1
  47. package/dist/components/floating/wizard.jsx +50 -53
  48. package/dist/components/form/autocomplete.d.ts.map +1 -1
  49. package/dist/components/form/autocomplete.jsx +42 -38
  50. package/dist/components/form/checkbox.jsx +3 -3
  51. package/dist/components/form/date-picker.d.ts.map +1 -1
  52. package/dist/components/form/date-picker.jsx +14 -14
  53. package/dist/components/form/file-upload.jsx +13 -13
  54. package/dist/components/form/free-text.d.ts.map +1 -1
  55. package/dist/components/form/free-text.jsx +3 -3
  56. package/dist/components/form/input-field.d.ts +3 -2
  57. package/dist/components/form/input-field.d.ts.map +1 -1
  58. package/dist/components/form/input-field.jsx +43 -41
  59. package/dist/components/form/multi-select.d.ts.map +1 -1
  60. package/dist/components/form/multi-select.jsx +56 -56
  61. package/dist/components/form/select.d.ts.map +1 -1
  62. package/dist/components/form/select.jsx +3 -3
  63. package/dist/components/form/slider.d.ts.map +1 -1
  64. package/dist/components/form/slider.jsx +10 -10
  65. package/dist/components/form/switch.jsx +2 -2
  66. package/dist/components/form/transfer-list.jsx +3 -3
  67. package/dist/components/index.d.ts +2 -0
  68. package/dist/components/index.d.ts.map +1 -1
  69. package/dist/components/index.js +2 -0
  70. package/dist/components/page-calendar/calendar-header.d.ts +16 -0
  71. package/dist/components/page-calendar/calendar-header.d.ts.map +1 -0
  72. package/dist/components/page-calendar/calendar-header.jsx +81 -0
  73. package/dist/components/page-calendar/day-view.d.ts +12 -0
  74. package/dist/components/page-calendar/day-view.d.ts.map +1 -0
  75. package/dist/components/page-calendar/day-view.jsx +87 -0
  76. package/dist/components/page-calendar/event-pill.d.ts +9 -0
  77. package/dist/components/page-calendar/event-pill.d.ts.map +1 -0
  78. package/dist/components/page-calendar/event-pill.jsx +25 -0
  79. package/dist/components/page-calendar/index.d.ts +4 -0
  80. package/dist/components/page-calendar/index.d.ts.map +1 -0
  81. package/dist/components/page-calendar/index.js +2 -0
  82. package/dist/components/page-calendar/month-view.d.ts +11 -0
  83. package/dist/components/page-calendar/month-view.d.ts.map +1 -0
  84. package/dist/components/page-calendar/month-view.jsx +47 -0
  85. package/dist/components/page-calendar/page-calendar.d.ts +18 -0
  86. package/dist/components/page-calendar/page-calendar.d.ts.map +1 -0
  87. package/dist/components/page-calendar/page-calendar.jsx +41 -0
  88. package/dist/components/page-calendar/page-calendar.types.d.ts +18 -0
  89. package/dist/components/page-calendar/page-calendar.types.d.ts.map +1 -0
  90. package/dist/components/page-calendar/page-calendar.types.js +1 -0
  91. package/dist/components/page-calendar/page-calendar.utils.d.ts +18 -0
  92. package/dist/components/page-calendar/page-calendar.utils.d.ts.map +1 -0
  93. package/dist/components/page-calendar/page-calendar.utils.js +71 -0
  94. package/dist/components/page-calendar/week-view.d.ts +11 -0
  95. package/dist/components/page-calendar/week-view.d.ts.map +1 -0
  96. package/dist/components/page-calendar/week-view.jsx +64 -0
  97. package/dist/components/table/filter.jsx +4 -4
  98. package/dist/components/table/index.d.ts.map +1 -1
  99. package/dist/components/table/index.jsx +10 -10
  100. package/dist/components/table/inner-table.d.ts.map +1 -1
  101. package/dist/components/table/inner-table.jsx +18 -18
  102. package/dist/components/table/metadata.d.ts.map +1 -1
  103. package/dist/components/table/metadata.jsx +29 -30
  104. package/dist/components/table/pagination.jsx +1 -1
  105. package/dist/components/table/row.d.ts.map +1 -1
  106. package/dist/components/table/row.jsx +17 -17
  107. package/dist/components/table/sort.jsx +1 -1
  108. package/dist/components/table/table-lib.d.ts.map +1 -1
  109. package/dist/components/table/table-lib.js +1 -2
  110. package/dist/components/table/thead.d.ts.map +1 -1
  111. package/dist/components/table/thead.jsx +6 -6
  112. package/dist/config/context.d.ts.map +1 -1
  113. package/dist/config/default-translations.d.ts +17 -0
  114. package/dist/config/default-translations.d.ts.map +1 -1
  115. package/dist/config/default-translations.jsx +18 -1
  116. package/dist/constants.d.ts.map +1 -1
  117. package/dist/hooks/use-components-provider.d.ts.map +1 -1
  118. package/dist/hooks/use-components-provider.jsx +4 -1
  119. package/dist/hooks/use-form.d.ts +11 -11
  120. package/dist/hooks/use-form.d.ts.map +1 -1
  121. package/dist/hooks/use-form.js +1 -0
  122. package/dist/hooks/use-input-id.d.ts.map +1 -1
  123. package/dist/hooks/use-is-coarse-device.js +1 -1
  124. package/dist/hooks/use-preferences.d.ts.map +1 -1
  125. package/dist/hooks/use-previous.d.ts.map +1 -1
  126. package/dist/hooks/use-previous.js +1 -0
  127. package/dist/hooks/use-reactive.d.ts.map +1 -1
  128. package/dist/hooks/use-reactive.js +1 -0
  129. package/dist/hooks/use-resize-observer.d.ts.map +1 -1
  130. package/dist/hooks/use-stable-ref.d.ts.map +1 -1
  131. package/dist/hooks/use-stable-ref.js +1 -0
  132. package/dist/hooks/use-swipe.d.ts.map +1 -1
  133. package/dist/hooks/use-swipe.js +1 -0
  134. package/dist/hooks/use-translations.d.ts +17 -0
  135. package/dist/hooks/use-translations.d.ts.map +1 -1
  136. package/dist/index.css +1 -0
  137. package/dist/index.d.ts.map +1 -1
  138. package/dist/index.js.map +1 -1
  139. package/dist/index.mjs +13689 -12344
  140. package/dist/index.mjs.map +1 -1
  141. package/dist/index.umd.js +24 -17
  142. package/dist/index.umd.js.map +1 -1
  143. package/dist/lib/dom.d.ts +1 -0
  144. package/dist/lib/dom.d.ts.map +1 -1
  145. package/dist/lib/dom.js +20 -2
  146. package/dist/lib/fns.d.ts.map +1 -1
  147. package/dist/lib/fns.js +2 -2
  148. package/dist/preset/plugin.tailwind.d.ts +9 -0
  149. package/dist/preset/plugin.tailwind.d.ts.map +1 -0
  150. package/dist/preset/plugin.tailwind.js +27 -0
  151. package/dist/preset/preset.tailwind.d.ts +8 -0
  152. package/dist/preset/preset.tailwind.d.ts.map +1 -0
  153. package/dist/preset/preset.tailwind.js +54 -0
  154. package/dist/preset/src/styles/common.d.ts +2 -14
  155. package/dist/preset/src/styles/common.d.ts.map +1 -1
  156. package/dist/preset/src/styles/common.js +1 -0
  157. package/dist/preset/src/styles/dark.d.ts.map +1 -1
  158. package/dist/preset/src/styles/dark.js +119 -114
  159. package/dist/preset/src/styles/light.d.ts.map +1 -1
  160. package/dist/preset/src/styles/light.js +111 -106
  161. package/dist/preset/src/styles/theme.types.d.ts +17 -8
  162. package/dist/preset/src/styles/theme.types.d.ts.map +1 -1
  163. package/dist/styles/common.d.ts +2 -14
  164. package/dist/styles/common.d.ts.map +1 -1
  165. package/dist/styles/common.js +1 -0
  166. package/dist/styles/dark.d.ts.map +1 -1
  167. package/dist/styles/dark.js +119 -114
  168. package/dist/styles/light.d.ts.map +1 -1
  169. package/dist/styles/light.js +111 -106
  170. package/dist/styles/theme.types.d.ts +17 -8
  171. package/dist/styles/theme.types.d.ts.map +1 -1
  172. package/package.json +299 -301
  173. package/dist/preset/tailwindcssv4.d.ts +0 -3
  174. package/dist/preset/tailwindcssv4.d.ts.map +0 -1
  175. package/dist/preset/tailwindcssv4.js +0 -75
@@ -7,31 +7,31 @@ import { useStableRef } from "../../hooks/use-stable-ref";
7
7
  import { useTranslations } from "../../hooks/use-translations";
8
8
  import { CombiKeys } from "../../lib/combi-keys";
9
9
  import { Dict } from "../../lib/dict";
10
- import { css, isReactFC } from "../../lib/dom";
10
+ import { css, isChildVisible, isReactFC } from "../../lib/dom";
11
11
  import { fzf } from "../../lib/fzf";
12
12
  import { Shortcut } from "../display/shortcut";
13
13
  import { SkeletonCell } from "../display/skeleton";
14
14
  import { Modal } from "./modal";
15
- const Group = (props) => (<span className="flex items-center h-full text-sm font-medium text-left text-secondary">
16
- {isReactFC(props.item.title) ? <props.item.title text={props.text}/> : props.item.title}
17
- </span>);
15
+ const Group = (props) => (<span className="flex h-full items-center text-left text-sm font-medium text-secondary">
16
+ {isReactFC(props.item.title) ? <props.item.title text={props.text}/> : props.item.title}
17
+ </span>);
18
18
  const Item = forwardRef((props, ref) => {
19
19
  const id = useId();
20
20
  const active = props.active;
21
21
  const item = props.item;
22
22
  if (item.type === "group")
23
- return (<div id={id} className="px-2 pt-2 pb-1 h-10">
24
- <Group text={props.text} item={item}/>
25
- </div>);
23
+ return (<div id={id} className="h-10 px-2 pb-1 pt-2">
24
+ <Group text={props.text} item={item}/>
25
+ </div>);
26
26
  if (item.type !== "shortcut")
27
27
  return <Fragment />;
28
28
  return (<button {...props} id={id} ref={ref} role="option" type="button" aria-selected={active} data-component="command-palette-item" className={css("flex h-10 items-center justify-between rounded-lg p-2 hover:bg-floating-hover", active ? "bg-floating-hover" : "")}>
29
- <span className="flex gap-2 items-center">
30
- {item.Icon ? item.Icon : null}
31
- <span>{isReactFC(item.title) ? <item.title text={props.text}/> : item.title}</span>
32
- </span>
33
- {item.shortcut ? <Shortcut value={item.shortcut}/> : null}
34
- </button>);
29
+ <span className="flex items-center gap-2">
30
+ {item.Icon ? item.Icon : null}
31
+ <span>{isReactFC(item.title) ? <item.title text={props.text}/> : item.title}</span>
32
+ </span>
33
+ {item.shortcut ? <Shortcut value={item.shortcut}/> : null}
34
+ </button>);
35
35
  });
36
36
  const getFuzzyData = (commands, value) => {
37
37
  if (value.length === 0)
@@ -53,57 +53,74 @@ const getFuzzyData = (commands, value) => {
53
53
  return Dict.unique(filter.concat(withEnabled), (x) => x.title);
54
54
  };
55
55
  const loadingSkeleton = [0, 0, 0, 0, 0];
56
+ const findFirstClickable = (items) => {
57
+ for (let index = 0; index < items.length; index++) {
58
+ const element = items[index];
59
+ if (element.type === "shortcut")
60
+ return element;
61
+ const recursive = findFirstClickable(element.items);
62
+ if (recursive)
63
+ return recursive;
64
+ }
65
+ return null;
66
+ };
56
67
  export const CommandPalette = (props) => {
57
- const bindKey = props.bind ?? "Mod + k";
68
+ const id = useId();
69
+ const scrollContainerRef = useRef(null);
70
+ const [text, setText] = useState("");
58
71
  const listRef = useRef([]);
59
72
  const translations = useTranslations();
60
- const [value, setValue] = useState("");
61
- const valueRef = useStableRef(value);
62
- const id = useId();
63
- const ref = useRef(null);
73
+ const valueRef = useStableRef(text);
64
74
  const [activeIndex, setActiveIndex] = useState(null);
75
+ const bindKey = props.bind ?? "Mod + k";
65
76
  const root = useFloating({
66
77
  open: props.open,
67
78
  strategy: "absolute",
68
79
  whileElementsMounted: autoUpdate,
69
80
  onOpenChange: props.onChangeVisibility,
70
81
  });
82
+ const commands = props.commands.flatMap((x) => (x.type === "group" ? [x, ...x.items] : [x]));
83
+ const fuzzy = getFuzzyData(commands, text);
84
+ const displayItems = text === ""
85
+ ? commands
86
+ : [
87
+ {
88
+ type: "group",
89
+ title: "Results",
90
+ items: [],
91
+ },
92
+ ...fuzzy.filter((x) => x.type !== "group"),
93
+ ];
71
94
  const listNav = useListNavigation(root.context, {
72
- cols: 0,
73
95
  listRef,
74
96
  loop: true,
75
97
  activeIndex,
76
98
  virtual: true,
77
- allowEscape: true,
78
- focusItemOnHover: false,
79
- focusItemOnOpen: "auto",
99
+ allowEscape: false,
100
+ focusItemOnOpen: true,
101
+ focusItemOnHover: true,
80
102
  openOnArrowKeyDown: true,
81
103
  scrollItemIntoView: false,
82
104
  selectedIndex: activeIndex,
105
+ disabledIndices: (n) => {
106
+ const item = displayItems[n];
107
+ if (item)
108
+ return item.type === "group";
109
+ return false;
110
+ },
83
111
  onNavigate: (n) => {
84
112
  if (Is.number(n)) {
85
- listRef.current[n]?.scrollIntoView({ block: "start", inline: "start" });
113
+ if (!isChildVisible(scrollContainerRef.current, listRef.current[n]))
114
+ listRef.current[n]?.scrollIntoView({ block: "start", inline: "start" });
86
115
  }
87
116
  setActiveIndex((prev) => {
88
117
  if (Is.number(n))
89
118
  return n;
90
119
  return props.open ? (prev ?? 0) : null;
91
120
  });
92
- }
121
+ },
93
122
  });
94
- const { getItemProps, getReferenceProps } = useInteractions([listNav]);
95
- const commands = props.commands.flatMap((x) => (x.type === "group" ? [x, ...x.items] : [x]));
96
- const fuzzy = getFuzzyData(commands, value);
97
- const displayItems = value === ""
98
- ? commands
99
- : [
100
- {
101
- type: "group",
102
- title: "Results",
103
- items: [],
104
- },
105
- ...fuzzy.filter((x) => x.type !== "group"),
106
- ];
123
+ const { getItemProps, getReferenceProps, getFloatingProps } = useInteractions([listNav]);
107
124
  useEffect(() => {
108
125
  const combi = new CombiKeys();
109
126
  combi.add(bindKey, () => props.onChangeVisibility?.(true));
@@ -113,6 +130,7 @@ export const CommandPalette = (props) => {
113
130
  if (cmd.type === "shortcut" && cmd.shortcut !== undefined)
114
131
  combi.add(cmd.shortcut, (event) => cmd.action({
115
132
  event,
133
+ setText,
116
134
  text: valueRef.current,
117
135
  setOpen: props.onChangeVisibility,
118
136
  }));
@@ -121,34 +139,38 @@ export const CommandPalette = (props) => {
121
139
  }, [bindKey, commands, props, valueRef]);
122
140
  const Icon = props.Icon ?? FilterIcon;
123
141
  return (<Fragment>
124
- <Modal ref={ref} animated={false} closable={false} open={props.open} overlayClickClose ariaTitle="Command palette" bodyClassName="px-0 py-0 pt-0" data-component="command-palette" onChange={props.onChangeVisibility} className="container relative py-0 md:max-w-(--breakpoint-sm) lg:max-w-(--breakpoint-md) overflow-clip">
125
- <header className="flex sticky top-0 items-center w-full h-12 border-b overflow-clip isolate z-floating border-floating-border bg-floating-background">
126
- <div className="flex justify-center items-center size-10">
127
- {props.Icon ? <Icon Default={FilterIcon} text={value} size={16}/> : <FilterIcon size={16}/>}
128
-
129
- </div>
130
- <input {...getReferenceProps({
142
+ <Modal {...getFloatingProps()} animated={false} closable={false} open={props.open} overlayClickClose ariaTitle="Command palette" bodyClassName="px-0 py-0 pt-0" data-component="command-palette" onChange={props.onChangeVisibility} className="container relative overflow-clip py-0 md:max-w-screen-sm lg:max-w-screen-md">
143
+ <header className="sticky top-0 isolate z-floating flex h-12 w-full items-center overflow-clip border-b border-floating-border bg-floating-background">
144
+ <div className="flex size-10 items-center justify-center">
145
+ {props.Icon ? <Icon Default={FilterIcon} text={text} size={16}/> : <FilterIcon size={16}/>}
146
+ </div>
147
+ <input {...getReferenceProps({
131
148
  ref: root.refs.setReference,
132
149
  onKeyDown: (e) => {
133
150
  const item = Is.number(activeIndex) ? displayItems[activeIndex] : null;
134
- if (item) {
135
- const key = e.key;
136
- if (key === "Enter") {
151
+ const key = e.key;
152
+ if (key === "Enter") {
153
+ if (item) {
137
154
  if (item.type === "shortcut")
138
- item.action({ event: e, text: value, setOpen: props.onChangeVisibility, });
155
+ item.action({ event: e, text: text, setOpen: props.onChangeVisibility, setText });
156
+ }
157
+ else {
158
+ const item = findFirstClickable(fuzzy);
159
+ if (item?.type === "shortcut")
160
+ item.action({ event: e, text: text, setOpen: props.onChangeVisibility, setText });
139
161
  }
140
162
  }
141
- }
142
- })} autoFocus value={value} data-combikeysbypass="true" placeholder="Search for..." onChange={(e) => setValue(e.target.value)} className="items-center py-2 px-2 pb-2 w-full h-12 text-lg text-left bg-transparent outline-hidden"/>
143
- </header>
144
- {props.loading ? (<ul role="listbox" data-component="command-palette-list" className="flex overflow-y-auto flex-col gap-1 px-2 my-2 w-full max-h-96 origin-[top_center]">
145
- <div className="px-2 pt-2 pb-1 h-10">{translations.commandPaletteLoading}</div>
146
- {loadingSkeleton.map((_, i) => (<li key={`${id}-${i}-skeleton-index`} className={css("flex h-10 items-center justify-between rounded-lg p-2 hover:bg-primary hover:text-primary-foreground")}>
147
- {SkeletonCell}
148
- </li>))}
149
- </ul>) : (<div className="flex flex-row flex-nowrap min-w-full" data-component="command-palette-container">
150
- <ul role="listbox" data-component="command-palette-list" className="flex overflow-y-auto flex-col gap-1 px-2 my-2 w-full max-h-96 h-fit origin-[top_center]">
151
- {displayItems.map((item, index) => (<Item {...getItemProps({
163
+ },
164
+ })} autoFocus value={text} data-combikeysbypass="true" placeholder="Search for..." onChange={(e) => setText(e.target.value)} className="h-12 w-full items-center bg-transparent px-2 py-2 pb-2 text-left text-lg outline-none"/>
165
+ </header>
166
+ {props.loading ? (<ul role="listbox" data-component="command-palette-list" className="my-2 flex max-h-96 w-full origin-[top_center] flex-col gap-1 overflow-y-auto px-2">
167
+ <div className="h-10 px-2 pb-1 pt-2">{translations.commandPaletteLoading}</div>
168
+ {loadingSkeleton.map((_, i) => (<li key={`${id}-${i}-skeleton-index`} className={css("flex h-10 items-center justify-between rounded-lg p-2 hover:bg-primary hover:text-primary-foreground")}>
169
+ {SkeletonCell}
170
+ </li>))}
171
+ </ul>) : (<div className="flex min-w-full flex-row flex-nowrap" data-component="command-palette-container">
172
+ <ul role="listbox" ref={scrollContainerRef} data-component="command-palette-list" className="my-2 flex h-fit max-h-96 w-full origin-[top_center] flex-col gap-1 overflow-y-auto px-2">
173
+ {displayItems.map((item, index) => (<Item {...getItemProps({
152
174
  onMouseEnter: () => setActiveIndex(index),
153
175
  ref(node) {
154
176
  listRef.current[index] = node;
@@ -157,16 +179,16 @@ export const CommandPalette = (props) => {
157
179
  e.preventDefault();
158
180
  props.onChangeVisibility(false);
159
181
  if (item.type === "shortcut")
160
- item.action({ event: e, text: value, setOpen: props.onChangeVisibility, });
182
+ item.action({ event: e, text: text, setOpen: props.onChangeVisibility, setText });
161
183
  },
162
- })} item={item} text={value} active={activeIndex === index} key={`${id}-${item.type}-${index}`}/>))}
163
- {displayItems.length === 1 ? (<div className={css("flex items-center justify-between rounded-lg p-2 text-secondary")}>
164
- {translations.commandPaletteEmpty ?? props.emptyMessage}
165
- </div>) : null}
166
- </ul>
167
- {props.Preview && Is.number(activeIndex) ? <props.Preview command={displayItems[activeIndex]} text={value}/> : null}
168
- </div>)}
169
- {props.footer ? <footer className="flex items-center p-2 h-8 rounded-b-lg bg-background">{props.footer}</footer> : null}
170
- </Modal>
171
- </Fragment>);
184
+ })} item={item} text={text} active={activeIndex === index} key={`${id}-${item.type}-${index}`}/>))}
185
+ {displayItems.length === 1 ? (<div className={css("flex items-center justify-between rounded-lg p-2 text-secondary")}>
186
+ {translations.commandPaletteEmpty ?? props.emptyMessage}
187
+ </div>) : null}
188
+ </ul>
189
+ {props.Preview && Is.number(activeIndex) ? <props.Preview command={displayItems[activeIndex]} text={text}/> : null}
190
+ </div>)}
191
+ {props.footer ? (<footer className="flex h-8 items-center rounded-b-lg border-t border-floating-border p-2">{props.footer}</footer>) : null}
192
+ </Modal>
193
+ </Fragment>);
172
194
  };
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/floating/dropdown.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,EAAY,iBAAiB,EAA+C,MAAM,OAAO,CAAC;AAExG,KAAK,aAAa,GAAG;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACxC,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,OAAO,EAAE,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,SAAS,CAAC;IAC9C,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC;CACvD,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,OAAO,iBAAiB,CAAC,aAAa,CAAC,sBAqE/D,CAAC"}
1
+ {"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/floating/dropdown.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,EAAY,iBAAiB,EAA+C,MAAM,OAAO,CAAC;AAExG,KAAK,aAAa,GAAG;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACxC,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,OAAO,EAAE,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,SAAS,CAAC;IAC9C,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC;CACzD,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,OAAO,iBAAiB,CAAC,aAAa,CAAC,sBAqE/D,CAAC"}
@@ -35,19 +35,19 @@ export const Dropdown = (props) => {
35
35
  const role = useRole(context, { role: "tooltip" });
36
36
  const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss, role]);
37
37
  return (<Fragment>
38
- <button ref={refs.setReference} {...getReferenceProps(props.buttonProps)} type="button">
39
- {props.trigger}
40
- </button>
41
- {open && (<FloatingPortal preserveTabOrder id={`${headingId}-portal`}>
42
- <FloatingFocusManager guards restoreFocus={true} returnFocus={true} visuallyHiddenDismiss context={context} modal={false}>
43
- <div className="relative p-4 rounded-lg border isolate z-floating min-w-96 border-floating-border bg-floating-background shadow-shadow-floating" ref={refs.setFloating} aria-labelledby={headingId} style={floatingStyles} {...getFloatingProps()}>
44
- <FloatingArrow ref={arrowRef} context={context} strokeWidth={0.1} className="fill-floating-background stroke-floating-border"/>
45
- <header className="mb-2">
46
- <h3 className="text-2xl font-medium tracking-wide leading-snug text-left">{props.title}</h3>
47
- </header>
48
- {props.children}
49
- </div>
50
- </FloatingFocusManager>
51
- </FloatingPortal>)}
52
- </Fragment>);
38
+ <button ref={refs.setReference} {...getReferenceProps(props.buttonProps)} type="button">
39
+ {props.trigger}
40
+ </button>
41
+ {open && (<FloatingPortal preserveTabOrder id={`${headingId}-portal`}>
42
+ <FloatingFocusManager guards restoreFocus={true} returnFocus={true} visuallyHiddenDismiss context={context} modal={false}>
43
+ <div className="relative isolate z-floating min-w-96 rounded-lg border border-floating-border bg-floating-background p-4 shadow-shadow-floating" ref={refs.setFloating} aria-labelledby={headingId} style={floatingStyles} {...getFloatingProps()}>
44
+ <FloatingArrow ref={arrowRef} context={context} strokeWidth={0.1} className="fill-floating-background stroke-floating-border"/>
45
+ <header className="mb-2">
46
+ <h3 className="text-left text-2xl font-medium leading-snug tracking-wide">{props.title}</h3>
47
+ </header>
48
+ {props.children}
49
+ </div>
50
+ </FloatingFocusManager>
51
+ </FloatingPortal>)}
52
+ </Fragment>);
53
53
  };
@@ -22,7 +22,7 @@ type MenuItemProps = {
22
22
  Right?: React.FC<LucideProps>;
23
23
  };
24
24
  export declare const MenuItem: React.ForwardRefExoticComponent<Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof MenuItemProps> & MenuItemProps & React.RefAttributes<HTMLButtonElement>>;
25
- export declare const Menu: React.ForwardRefExoticComponent<(Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "children" | "hover" | "open" | "restoreFocus" | "nested" | "asChild" | "isParent" | "floatingClassName" | "FloatingComponent"> & Partial<{
25
+ export declare const Menu: React.ForwardRefExoticComponent<(Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "children" | "hover" | "open" | "asChild" | "restoreFocus" | "nested" | "isParent" | "floatingClassName" | "FloatingComponent"> & Partial<{
26
26
  hover: boolean;
27
27
  open?: boolean;
28
28
  nested: boolean;
@@ -34,7 +34,7 @@ export declare const Menu: React.ForwardRefExoticComponent<(Omit<Omit<React.Deta
34
34
  FloatingComponent: React.ElementType;
35
35
  } & {
36
36
  label: string;
37
- }>, "ref"> | Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "children" | "hover" | "open" | "restoreFocus" | "nested" | "asChild" | "isParent" | "floatingClassName" | "FloatingComponent"> & Partial<{
37
+ }>, "ref"> | Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "children" | "hover" | "open" | "asChild" | "restoreFocus" | "nested" | "isParent" | "floatingClassName" | "FloatingComponent"> & Partial<{
38
38
  hover: boolean;
39
39
  open?: boolean;
40
40
  nested: boolean;
@@ -5,7 +5,7 @@ import { ChevronRightIcon } from "lucide-react";
5
5
  import React, { createContext, Fragment, useContext, useEffect, useRef, useState } from "react";
6
6
  import { FLOATING_DELAY, TYPEAHEAD_RESET_DELAY } from "../../constants";
7
7
  import { css, mergeRefs } from "../../lib/dom";
8
- const menuItemClassName = (highlight = "") => css("w-full min-w-36 outline-hidden p-2.5 items-center flex justify-between text-left", "hover:bg-primary focus:bg-primary aria-expanded:opacity-80", "focus:text-primary-foreground hover:text-primary-foreground", "first-of-type:rounded-t-lg last-of-type:rounded-b-lg", "disabled:opacity-40 disabled:cursor-not-allowed", highlight);
8
+ const menuItemClassName = (highlight = "") => css("w-full min-w-36 outline-none p-2.5 items-center flex justify-between text-left", "hover:bg-primary focus:bg-primary aria-expanded:opacity-80", "focus:text-primary-foreground hover:text-primary-foreground", "first-of-type:rounded-t-lg last-of-type:rounded-b-lg", "disabled:opacity-40 disabled:cursor-not-allowed", highlight);
9
9
  const MenuContext = createContext({
10
10
  isOpen: false,
11
11
  activeIndex: null,
@@ -111,7 +111,7 @@ const MenuComponent = React.forwardRef(({ children, FloatingComponent = "div", h
111
111
  <FloatingList elementsRef={elementsRef} labelsRef={labelsRef}>
112
112
  {isOpen && (<FloatingPortal>
113
113
  <FloatingFocusManager context={context} modal={false} initialFocus={isNested ? -1 : 0} returnFocus={isParent ? restoreFocus : !isNested}>
114
- <FloatingComponent {...getFloatingProps()} ref={refs.setFloating} style={{ ...props.style, ...floatingStyles }} className={css("isolate z-tooltip flex max-h-80 flex-col items-start overflow-y-auto rounded-lg border border-floating-border bg-floating-background text-left shadow-shadow-floating outline-hidden", floatingClassName)}>
114
+ <FloatingComponent {...getFloatingProps()} ref={refs.setFloating} style={{ ...props.style, ...floatingStyles }} className={css("isolate z-tooltip flex max-h-80 flex-col items-start overflow-y-auto rounded-lg border border-floating-border bg-floating-background text-left shadow-shadow-floating outline-none", floatingClassName)}>
115
115
  {children}
116
116
  </FloatingComponent>
117
117
  </FloatingFocusManager>
@@ -2,6 +2,8 @@ import { type ElementProps } from "@floating-ui/react";
2
2
  import { HTMLMotionProps } from "motion/react";
3
3
  import React from "react";
4
4
  import { Label, Override } from "../../types";
5
+ import { ButtonProps } from "../core/button";
6
+ export declare const useConfirm: () => (options: ConfirmOptions) => Promise<boolean>;
5
7
  export type ModalType = "dialog" | "drawer" | "sheet";
6
8
  export type DrawerPosition = "left" | "right";
7
9
  export type ModalProps = Override<HTMLMotionProps<"div">, ({
@@ -32,62 +34,27 @@ export type ModalProps = Override<HTMLMotionProps<"div">, ({
32
34
  interactions: ElementProps[];
33
35
  trigger: Label | React.FC<any>;
34
36
  }>>;
35
- type ModalRef = {
37
+ export type ModalRef = {
36
38
  context: any;
37
39
  floating: HTMLElement | null;
38
40
  };
39
- export declare const Modal: React.ForwardRefExoticComponent<(Omit<Omit<HTMLMotionProps<"div">, "footer" | "title" | "className" | "role" | "onChange" | "position" | "open" | "resizer" | "type" | "layoutId" | "trigger" | "closeOnFocusOut" | "asChild" | "animated" | "closable" | "forceType" | "bodyClassName" | "overlayClassName" | "overlayClickClose" | "interactions" | "ariaTitle"> & {
40
- title: Label;
41
- ariaTitle?: string;
42
- } & {
43
- open: boolean;
44
- onChange: (nextState: boolean) => void;
45
- } & Partial<{
46
- footer: Label;
47
- type: ModalType;
48
- animated: boolean;
49
- asChild: boolean;
50
- layoutId: string;
51
- resizer: boolean;
52
- className: string;
53
- closable: boolean;
54
- forceType: boolean;
55
- bodyClassName: string;
56
- overlayClassName: string;
57
- position: DrawerPosition;
58
- overlayClickClose: boolean;
59
- closeOnFocusOut: boolean;
60
- role: "dialog";
61
- interactions: ElementProps[];
62
- trigger: Label | React.FC<any>;
63
- }> & {
64
- children?: React.ReactNode | undefined;
65
- }, "ref"> | Omit<Omit<HTMLMotionProps<"div">, "footer" | "title" | "className" | "role" | "onChange" | "position" | "open" | "resizer" | "type" | "layoutId" | "trigger" | "closeOnFocusOut" | "asChild" | "animated" | "closable" | "forceType" | "bodyClassName" | "overlayClassName" | "overlayClickClose" | "interactions" | "ariaTitle"> & {
66
- ariaTitle: string;
41
+ type ModalComponent = React.FC<ModalProps> & {
42
+ confirm: <T>(options: ConfirmOptions) => Promise<T>;
43
+ };
44
+ export declare const Modal: ModalComponent;
45
+ type ButtonConfirmationAction = {
46
+ value?: any;
47
+ text?: Label;
48
+ theme?: ButtonProps["theme"];
49
+ };
50
+ export type ConfirmOptions = {
67
51
  title?: Label;
68
- } & {
69
- open: boolean;
70
- onChange: (nextState: boolean) => void;
71
- } & Partial<{
72
- footer: Label;
73
- type: ModalType;
74
- animated: boolean;
75
- asChild: boolean;
76
- layoutId: string;
77
- resizer: boolean;
78
- className: string;
79
- closable: boolean;
80
- forceType: boolean;
81
- bodyClassName: string;
82
- overlayClassName: string;
83
- position: DrawerPosition;
84
- overlayClickClose: boolean;
85
- closeOnFocusOut: boolean;
86
- role: "dialog";
87
- interactions: ElementProps[];
88
- trigger: Label | React.FC<any>;
89
- }> & {
90
- children?: React.ReactNode | undefined;
91
- }, "ref">) & React.RefAttributes<ModalRef>>;
52
+ description?: Label;
53
+ cancel?: ButtonConfirmationAction;
54
+ confirm?: ButtonConfirmationAction;
55
+ };
56
+ export declare const ModalConfirmProvider: ({ children }: {
57
+ children: React.ReactNode;
58
+ }) => React.JSX.Element;
92
59
  export {};
93
60
  //# sourceMappingURL=modal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../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O,EAAE,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;CAChC,CAAC,CACH,CAAC;AAgFF,KAAK,QAAQ,GAAG;IAAE,OAAO,EAAE,GAAG,CAAC;IAAC,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAA;CAAE,CAAC;AAI/D,eAAO,MAAM,KAAK;WA1GN,KAAK;gBAAc,MAAM;;UAC3B,OAAO;cACH,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI;;YAE9B,KAAK;UACP,SAAS;cACL,OAAO;aACR,OAAO;cACN,MAAM;aACP,OAAO;eACL,MAAM;cACP,OAAO;eACN,OAAO;mBACH,MAAM;sBACH,MAAM;cACd,cAAc;uBACL,OAAO;qBACT,OAAO;UAClB,QAAQ;kBACA,YAAY,EAAE;aACnB,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC;;;;eApBqB,MAAM;YAAU,KAAK;;UAClE,OAAO;cACH,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI;;YAE9B,KAAK;UACP,SAAS;cACL,OAAO;aACR,OAAO;cACN,MAAM;aACP,OAAO;eACL,MAAM;cACP,OAAO;eACN,OAAO;mBACH,MAAM;sBACH,MAAM;cACd,cAAc;uBACL,OAAO;qBACT,OAAO;UAClB,QAAQ;kBACA,YAAY,EAAE;aACnB,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC;;;2CA0UjC,CAAC"}
1
+ {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/components/floating/modal.tsx"],"names":[],"mappings":"AACA,OAAO,EASH,KAAK,YAAY,EACpB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAEH,eAAe,EAQlB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAWN,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,KAAK,EAAO,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAU,WAAW,EAAE,MAAM,gBAAgB,CAAC;A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