@humu-tech/ui 0.1.6 → 0.1.8
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.
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +75 -23
- package/dist/index.mjs +75 -23
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -196,6 +196,7 @@ type ComboboxProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onChange
|
|
|
196
196
|
loading?: boolean;
|
|
197
197
|
emptyMessage?: string;
|
|
198
198
|
allowClear?: boolean;
|
|
199
|
+
allowScrollSelection?: boolean;
|
|
199
200
|
};
|
|
200
201
|
|
|
201
202
|
declare const Combobox: react.ForwardRefExoticComponent<Omit<react.HTMLAttributes<HTMLDivElement>, "children" | "onChange"> & {
|
|
@@ -213,6 +214,7 @@ declare const Combobox: react.ForwardRefExoticComponent<Omit<react.HTMLAttribute
|
|
|
213
214
|
loading?: boolean;
|
|
214
215
|
emptyMessage?: string;
|
|
215
216
|
allowClear?: boolean;
|
|
217
|
+
allowScrollSelection?: boolean;
|
|
216
218
|
} & react.RefAttributes<HTMLButtonElement>>;
|
|
217
219
|
|
|
218
220
|
type ConfirmDialogVariant = 'danger' | 'warn' | 'info';
|
package/dist/index.d.ts
CHANGED
|
@@ -196,6 +196,7 @@ type ComboboxProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onChange
|
|
|
196
196
|
loading?: boolean;
|
|
197
197
|
emptyMessage?: string;
|
|
198
198
|
allowClear?: boolean;
|
|
199
|
+
allowScrollSelection?: boolean;
|
|
199
200
|
};
|
|
200
201
|
|
|
201
202
|
declare const Combobox: react.ForwardRefExoticComponent<Omit<react.HTMLAttributes<HTMLDivElement>, "children" | "onChange"> & {
|
|
@@ -213,6 +214,7 @@ declare const Combobox: react.ForwardRefExoticComponent<Omit<react.HTMLAttribute
|
|
|
213
214
|
loading?: boolean;
|
|
214
215
|
emptyMessage?: string;
|
|
215
216
|
allowClear?: boolean;
|
|
217
|
+
allowScrollSelection?: boolean;
|
|
216
218
|
} & react.RefAttributes<HTMLButtonElement>>;
|
|
217
219
|
|
|
218
220
|
type ConfirmDialogVariant = 'danger' | 'warn' | 'info';
|
package/dist/index.js
CHANGED
|
@@ -1304,6 +1304,17 @@ ColorPicker.displayName = "ColorPicker";
|
|
|
1304
1304
|
var import_react15 = require("react");
|
|
1305
1305
|
var import_react16 = require("@phosphor-icons/react");
|
|
1306
1306
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1307
|
+
function canScrollElementInWheelDirection(element, deltaY) {
|
|
1308
|
+
const hasVerticalScroll = element.scrollHeight > element.clientHeight;
|
|
1309
|
+
if (!hasVerticalScroll) return false;
|
|
1310
|
+
if (deltaY > 0) {
|
|
1311
|
+
return element.scrollTop + element.clientHeight < element.scrollHeight;
|
|
1312
|
+
}
|
|
1313
|
+
if (deltaY < 0) {
|
|
1314
|
+
return element.scrollTop > 0;
|
|
1315
|
+
}
|
|
1316
|
+
return false;
|
|
1317
|
+
}
|
|
1307
1318
|
var Combobox = (0, import_react15.forwardRef)(
|
|
1308
1319
|
({
|
|
1309
1320
|
items,
|
|
@@ -1320,6 +1331,7 @@ var Combobox = (0, import_react15.forwardRef)(
|
|
|
1320
1331
|
loading,
|
|
1321
1332
|
emptyMessage = "Nenhum resultado.",
|
|
1322
1333
|
allowClear = true,
|
|
1334
|
+
allowScrollSelection = false,
|
|
1323
1335
|
className,
|
|
1324
1336
|
...props
|
|
1325
1337
|
}, ref) => {
|
|
@@ -1346,6 +1358,18 @@ var Combobox = (0, import_react15.forwardRef)(
|
|
|
1346
1358
|
setOpen(false);
|
|
1347
1359
|
setQuery("");
|
|
1348
1360
|
};
|
|
1361
|
+
const handleTriggerWheel = (event) => {
|
|
1362
|
+
if (!allowScrollSelection || open) return;
|
|
1363
|
+
const enabledItems = items.filter((item) => !item.disabled);
|
|
1364
|
+
if (enabledItems.length === 0) return;
|
|
1365
|
+
const currentIndex = enabledItems.findIndex(
|
|
1366
|
+
(item) => item.value === currentValue
|
|
1367
|
+
);
|
|
1368
|
+
const direction = event.deltaY > 0 ? 1 : event.deltaY < 0 ? -1 : 0;
|
|
1369
|
+
if (direction === 0) return;
|
|
1370
|
+
const nextIndex = currentIndex === -1 ? direction > 0 ? 0 : enabledItems.length - 1 : (currentIndex + direction + enabledItems.length) % enabledItems.length;
|
|
1371
|
+
handleSelect(enabledItems[nextIndex].value);
|
|
1372
|
+
};
|
|
1349
1373
|
const handleKeyDown = (e) => {
|
|
1350
1374
|
if (e.key === "Escape") {
|
|
1351
1375
|
e.preventDefault();
|
|
@@ -1392,6 +1416,7 @@ var Combobox = (0, import_react15.forwardRef)(
|
|
|
1392
1416
|
"aria-invalid": !!error || void 0,
|
|
1393
1417
|
"aria-describedby": error ? errorId : helper ? helperId : void 0,
|
|
1394
1418
|
disabled,
|
|
1419
|
+
onWheel: handleTriggerWheel,
|
|
1395
1420
|
className: cn(
|
|
1396
1421
|
label ? "flex h-12 w-full items-center justify-between gap-2 rounded-v2-md border bg-v2-raised px-3 pt-2 text-v2-base text-v2-fg-default transition-colors focus:outline-none focus:ring-0 motion-reduce:transition-none" : "flex h-10 w-full items-center justify-between gap-2 rounded-v2-md border bg-v2-panel px-3 py-2 text-v2-base text-v2-fg-default focus:outline-none focus:ring-2 focus:ring-v2-action-primary/30",
|
|
1397
1422
|
error ? "border-v2-danger-500" : "border-v2-border-default focus:border-v2-action-primary",
|
|
@@ -1500,7 +1525,15 @@ var Combobox = (0, import_react15.forwardRef)(
|
|
|
1500
1525
|
{
|
|
1501
1526
|
id: listboxId,
|
|
1502
1527
|
role: "listbox",
|
|
1503
|
-
className: "max-h-[280px] overflow-y-auto py-1",
|
|
1528
|
+
className: "max-h-[280px] overflow-y-auto overscroll-contain py-1",
|
|
1529
|
+
onWheelCapture: (event) => {
|
|
1530
|
+
if (canScrollElementInWheelDirection(
|
|
1531
|
+
event.currentTarget,
|
|
1532
|
+
event.deltaY
|
|
1533
|
+
)) {
|
|
1534
|
+
event.stopPropagation();
|
|
1535
|
+
}
|
|
1536
|
+
},
|
|
1504
1537
|
children: loading ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("li", { className: "px-3 py-2 text-v2-sm text-v2-fg-muted", children: "Buscando\u2026" }) : filteredItems.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("li", { className: "px-3 py-2 text-v2-sm text-v2-fg-muted", children: emptyMessage }) : filteredItems.map((item) => {
|
|
1505
1538
|
const isSelected = item.value === currentValue;
|
|
1506
1539
|
const isHighlighted = item.value === highlightedValue;
|
|
@@ -2004,6 +2037,17 @@ var import_react24 = require("@phosphor-icons/react");
|
|
|
2004
2037
|
var import_style2 = require("react-day-picker/dist/style.css");
|
|
2005
2038
|
var import_DateRangeInput2 = require("./DateRangeInput-GFYTBAQ7.css");
|
|
2006
2039
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2040
|
+
function canScrollElementInWheelDirection2(element, deltaY) {
|
|
2041
|
+
const hasVerticalScroll = element.scrollHeight > element.clientHeight;
|
|
2042
|
+
if (!hasVerticalScroll) return false;
|
|
2043
|
+
if (deltaY > 0) {
|
|
2044
|
+
return element.scrollTop + element.clientHeight < element.scrollHeight;
|
|
2045
|
+
}
|
|
2046
|
+
if (deltaY < 0) {
|
|
2047
|
+
return element.scrollTop > 0;
|
|
2048
|
+
}
|
|
2049
|
+
return false;
|
|
2050
|
+
}
|
|
2007
2051
|
var ISO_FORMAT = "yyyy-MM-dd";
|
|
2008
2052
|
var DISPLAY_FORMAT = "dd/MM/yyyy";
|
|
2009
2053
|
function isoToDate(iso) {
|
|
@@ -2191,7 +2235,15 @@ var DateRangeInput = (0, import_react23.forwardRef)(
|
|
|
2191
2235
|
"div",
|
|
2192
2236
|
{
|
|
2193
2237
|
ref: yearListRef,
|
|
2194
|
-
className: "max-h-[280px] overflow-y-auto py-2",
|
|
2238
|
+
className: "max-h-[280px] overflow-y-auto overscroll-contain py-2",
|
|
2239
|
+
onWheelCapture: (event) => {
|
|
2240
|
+
if (canScrollElementInWheelDirection2(
|
|
2241
|
+
event.currentTarget,
|
|
2242
|
+
event.deltaY
|
|
2243
|
+
)) {
|
|
2244
|
+
event.stopPropagation();
|
|
2245
|
+
}
|
|
2246
|
+
},
|
|
2195
2247
|
children: years.map((y) => {
|
|
2196
2248
|
const isCurrent = y === month.getFullYear();
|
|
2197
2249
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
@@ -4936,27 +4988,26 @@ var Sidebar = (0, import_react65.forwardRef)(function Sidebar2({
|
|
|
4936
4988
|
children: [
|
|
4937
4989
|
headerSlot && !collapsed && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { children: headerSlot }),
|
|
4938
4990
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
4939
|
-
|
|
4991
|
+
Tooltip,
|
|
4940
4992
|
{
|
|
4941
|
-
|
|
4942
|
-
"
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
},
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
] })
|
|
4993
|
+
side: "right",
|
|
4994
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("span", { children: [
|
|
4995
|
+
collapsed ? "Expandir menu" : "Recolher menu",
|
|
4996
|
+
enableShortcut && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "ml-1 text-v2-fg-muted", children: getShortcutLabel("B") })
|
|
4997
|
+
] }),
|
|
4998
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
4999
|
+
"button",
|
|
5000
|
+
{
|
|
5001
|
+
type: "button",
|
|
5002
|
+
"aria-expanded": !collapsed,
|
|
5003
|
+
"aria-label": collapsed ? "Expandir menu" : "Recolher menu",
|
|
5004
|
+
onClick: toggleCollapse,
|
|
5005
|
+
className: cn(
|
|
5006
|
+
"inline-flex size-8 shrink-0 items-center justify-center rounded-v2-md text-current transition-colors hover:bg-v2-bg-subtle"
|
|
5007
|
+
),
|
|
5008
|
+
children: collapsed ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_react64.CaretDoubleRight, { size: 16 }) : /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_react64.CaretDoubleLeft, { size: 16 })
|
|
5009
|
+
}
|
|
5010
|
+
)
|
|
4960
5011
|
}
|
|
4961
5012
|
)
|
|
4962
5013
|
]
|
|
@@ -7504,7 +7555,8 @@ function renderField(field, value, onChange) {
|
|
|
7504
7555
|
placeholder: field.placeholder ?? "Selecione...",
|
|
7505
7556
|
value: isStringValue(value) ? value : void 0,
|
|
7506
7557
|
onValueChange: (v) => onChange(v || void 0),
|
|
7507
|
-
allowClear: true
|
|
7558
|
+
allowClear: true,
|
|
7559
|
+
allowScrollSelection: true
|
|
7508
7560
|
}
|
|
7509
7561
|
);
|
|
7510
7562
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1188,6 +1188,17 @@ ColorPicker.displayName = "ColorPicker";
|
|
|
1188
1188
|
import { forwardRef as forwardRef11, useEffect as useEffect3, useId as useId5, useRef, useState as useState4 } from "react";
|
|
1189
1189
|
import { Check as Check2, CaretDown, X, MagnifyingGlass } from "@phosphor-icons/react";
|
|
1190
1190
|
import { jsx as jsx16, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1191
|
+
function canScrollElementInWheelDirection(element, deltaY) {
|
|
1192
|
+
const hasVerticalScroll = element.scrollHeight > element.clientHeight;
|
|
1193
|
+
if (!hasVerticalScroll) return false;
|
|
1194
|
+
if (deltaY > 0) {
|
|
1195
|
+
return element.scrollTop + element.clientHeight < element.scrollHeight;
|
|
1196
|
+
}
|
|
1197
|
+
if (deltaY < 0) {
|
|
1198
|
+
return element.scrollTop > 0;
|
|
1199
|
+
}
|
|
1200
|
+
return false;
|
|
1201
|
+
}
|
|
1191
1202
|
var Combobox = forwardRef11(
|
|
1192
1203
|
({
|
|
1193
1204
|
items,
|
|
@@ -1204,6 +1215,7 @@ var Combobox = forwardRef11(
|
|
|
1204
1215
|
loading,
|
|
1205
1216
|
emptyMessage = "Nenhum resultado.",
|
|
1206
1217
|
allowClear = true,
|
|
1218
|
+
allowScrollSelection = false,
|
|
1207
1219
|
className,
|
|
1208
1220
|
...props
|
|
1209
1221
|
}, ref) => {
|
|
@@ -1230,6 +1242,18 @@ var Combobox = forwardRef11(
|
|
|
1230
1242
|
setOpen(false);
|
|
1231
1243
|
setQuery("");
|
|
1232
1244
|
};
|
|
1245
|
+
const handleTriggerWheel = (event) => {
|
|
1246
|
+
if (!allowScrollSelection || open) return;
|
|
1247
|
+
const enabledItems = items.filter((item) => !item.disabled);
|
|
1248
|
+
if (enabledItems.length === 0) return;
|
|
1249
|
+
const currentIndex = enabledItems.findIndex(
|
|
1250
|
+
(item) => item.value === currentValue
|
|
1251
|
+
);
|
|
1252
|
+
const direction = event.deltaY > 0 ? 1 : event.deltaY < 0 ? -1 : 0;
|
|
1253
|
+
if (direction === 0) return;
|
|
1254
|
+
const nextIndex = currentIndex === -1 ? direction > 0 ? 0 : enabledItems.length - 1 : (currentIndex + direction + enabledItems.length) % enabledItems.length;
|
|
1255
|
+
handleSelect(enabledItems[nextIndex].value);
|
|
1256
|
+
};
|
|
1233
1257
|
const handleKeyDown = (e) => {
|
|
1234
1258
|
if (e.key === "Escape") {
|
|
1235
1259
|
e.preventDefault();
|
|
@@ -1276,6 +1300,7 @@ var Combobox = forwardRef11(
|
|
|
1276
1300
|
"aria-invalid": !!error || void 0,
|
|
1277
1301
|
"aria-describedby": error ? errorId : helper ? helperId : void 0,
|
|
1278
1302
|
disabled,
|
|
1303
|
+
onWheel: handleTriggerWheel,
|
|
1279
1304
|
className: cn(
|
|
1280
1305
|
label ? "flex h-12 w-full items-center justify-between gap-2 rounded-v2-md border bg-v2-raised px-3 pt-2 text-v2-base text-v2-fg-default transition-colors focus:outline-none focus:ring-0 motion-reduce:transition-none" : "flex h-10 w-full items-center justify-between gap-2 rounded-v2-md border bg-v2-panel px-3 py-2 text-v2-base text-v2-fg-default focus:outline-none focus:ring-2 focus:ring-v2-action-primary/30",
|
|
1281
1306
|
error ? "border-v2-danger-500" : "border-v2-border-default focus:border-v2-action-primary",
|
|
@@ -1384,7 +1409,15 @@ var Combobox = forwardRef11(
|
|
|
1384
1409
|
{
|
|
1385
1410
|
id: listboxId,
|
|
1386
1411
|
role: "listbox",
|
|
1387
|
-
className: "max-h-[280px] overflow-y-auto py-1",
|
|
1412
|
+
className: "max-h-[280px] overflow-y-auto overscroll-contain py-1",
|
|
1413
|
+
onWheelCapture: (event) => {
|
|
1414
|
+
if (canScrollElementInWheelDirection(
|
|
1415
|
+
event.currentTarget,
|
|
1416
|
+
event.deltaY
|
|
1417
|
+
)) {
|
|
1418
|
+
event.stopPropagation();
|
|
1419
|
+
}
|
|
1420
|
+
},
|
|
1388
1421
|
children: loading ? /* @__PURE__ */ jsx16("li", { className: "px-3 py-2 text-v2-sm text-v2-fg-muted", children: "Buscando\u2026" }) : filteredItems.length === 0 ? /* @__PURE__ */ jsx16("li", { className: "px-3 py-2 text-v2-sm text-v2-fg-muted", children: emptyMessage }) : filteredItems.map((item) => {
|
|
1389
1422
|
const isSelected = item.value === currentValue;
|
|
1390
1423
|
const isHighlighted = item.value === highlightedValue;
|
|
@@ -1896,6 +1929,17 @@ import { CalendarBlank as CalendarBlank2, CaretDown as CaretDown3 } from "@phosp
|
|
|
1896
1929
|
import "react-day-picker/dist/style.css";
|
|
1897
1930
|
import "./DateRangeInput-GFYTBAQ7.css";
|
|
1898
1931
|
import { jsx as jsx20, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1932
|
+
function canScrollElementInWheelDirection2(element, deltaY) {
|
|
1933
|
+
const hasVerticalScroll = element.scrollHeight > element.clientHeight;
|
|
1934
|
+
if (!hasVerticalScroll) return false;
|
|
1935
|
+
if (deltaY > 0) {
|
|
1936
|
+
return element.scrollTop + element.clientHeight < element.scrollHeight;
|
|
1937
|
+
}
|
|
1938
|
+
if (deltaY < 0) {
|
|
1939
|
+
return element.scrollTop > 0;
|
|
1940
|
+
}
|
|
1941
|
+
return false;
|
|
1942
|
+
}
|
|
1899
1943
|
var ISO_FORMAT = "yyyy-MM-dd";
|
|
1900
1944
|
var DISPLAY_FORMAT = "dd/MM/yyyy";
|
|
1901
1945
|
function isoToDate(iso) {
|
|
@@ -2083,7 +2127,15 @@ var DateRangeInput = forwardRef14(
|
|
|
2083
2127
|
"div",
|
|
2084
2128
|
{
|
|
2085
2129
|
ref: yearListRef,
|
|
2086
|
-
className: "max-h-[280px] overflow-y-auto py-2",
|
|
2130
|
+
className: "max-h-[280px] overflow-y-auto overscroll-contain py-2",
|
|
2131
|
+
onWheelCapture: (event) => {
|
|
2132
|
+
if (canScrollElementInWheelDirection2(
|
|
2133
|
+
event.currentTarget,
|
|
2134
|
+
event.deltaY
|
|
2135
|
+
)) {
|
|
2136
|
+
event.stopPropagation();
|
|
2137
|
+
}
|
|
2138
|
+
},
|
|
2087
2139
|
children: years.map((y) => {
|
|
2088
2140
|
const isCurrent = y === month.getFullYear();
|
|
2089
2141
|
return /* @__PURE__ */ jsx20(
|
|
@@ -4876,27 +4928,26 @@ var Sidebar = forwardRef38(function Sidebar2({
|
|
|
4876
4928
|
children: [
|
|
4877
4929
|
headerSlot && !collapsed && /* @__PURE__ */ jsx50("div", { children: headerSlot }),
|
|
4878
4930
|
/* @__PURE__ */ jsx50(
|
|
4879
|
-
|
|
4931
|
+
Tooltip,
|
|
4880
4932
|
{
|
|
4881
|
-
|
|
4882
|
-
"
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
},
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
] })
|
|
4933
|
+
side: "right",
|
|
4934
|
+
content: /* @__PURE__ */ jsxs31("span", { children: [
|
|
4935
|
+
collapsed ? "Expandir menu" : "Recolher menu",
|
|
4936
|
+
enableShortcut && /* @__PURE__ */ jsx50("span", { className: "ml-1 text-v2-fg-muted", children: getShortcutLabel("B") })
|
|
4937
|
+
] }),
|
|
4938
|
+
children: /* @__PURE__ */ jsx50(
|
|
4939
|
+
"button",
|
|
4940
|
+
{
|
|
4941
|
+
type: "button",
|
|
4942
|
+
"aria-expanded": !collapsed,
|
|
4943
|
+
"aria-label": collapsed ? "Expandir menu" : "Recolher menu",
|
|
4944
|
+
onClick: toggleCollapse,
|
|
4945
|
+
className: cn(
|
|
4946
|
+
"inline-flex size-8 shrink-0 items-center justify-center rounded-v2-md text-current transition-colors hover:bg-v2-bg-subtle"
|
|
4947
|
+
),
|
|
4948
|
+
children: collapsed ? /* @__PURE__ */ jsx50(CaretDoubleRight, { size: 16 }) : /* @__PURE__ */ jsx50(CaretDoubleLeft, { size: 16 })
|
|
4949
|
+
}
|
|
4950
|
+
)
|
|
4900
4951
|
}
|
|
4901
4952
|
)
|
|
4902
4953
|
]
|
|
@@ -7446,7 +7497,8 @@ function renderField(field, value, onChange) {
|
|
|
7446
7497
|
placeholder: field.placeholder ?? "Selecione...",
|
|
7447
7498
|
value: isStringValue(value) ? value : void 0,
|
|
7448
7499
|
onValueChange: (v) => onChange(v || void 0),
|
|
7449
|
-
allowClear: true
|
|
7500
|
+
allowClear: true,
|
|
7501
|
+
allowScrollSelection: true
|
|
7450
7502
|
}
|
|
7451
7503
|
);
|
|
7452
7504
|
}
|