hazo_ui 2.0.0 → 2.1.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.
- package/README.md +223 -0
- package/dist/index.cjs +305 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.js +295 -50
- package/dist/index.js.map +1 -1
- package/package.json +11 -9
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { cva } from 'class-variance-authority';
|
|
|
6
6
|
import { clsx } from 'clsx';
|
|
7
7
|
import { twMerge } from 'tailwind-merge';
|
|
8
8
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
9
|
-
import { X, ChevronDown, ChevronUp, Check, Filter, Plus, ChevronsUpDown, ArrowUpDown, Trash2, GripVertical, Calendar as Calendar$1, ChevronRight, ChevronLeft } from 'lucide-react';
|
|
9
|
+
import { X, ChevronDown, ChevronUp, Check, Circle, Filter, Plus, ChevronsUpDown, ArrowUpDown, Trash2, GripVertical, Calendar as Calendar$1, ChevronRight, ChevronLeft } from 'lucide-react';
|
|
10
10
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
11
11
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
12
12
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
@@ -16,6 +16,17 @@ import * as SwitchPrimitives from '@radix-ui/react-switch';
|
|
|
16
16
|
import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCenter } from '@dnd-kit/core';
|
|
17
17
|
import { sortableKeyboardCoordinates, SortableContext, verticalListSortingStrategy, arrayMove, useSortable } from '@dnd-kit/sortable';
|
|
18
18
|
import { CSS } from '@dnd-kit/utilities';
|
|
19
|
+
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
20
|
+
import * as FaIcons from 'react-icons/fa';
|
|
21
|
+
import * as MdIcons from 'react-icons/md';
|
|
22
|
+
import * as HiIcons from 'react-icons/hi';
|
|
23
|
+
import * as BiIcons from 'react-icons/bi';
|
|
24
|
+
import * as AiIcons from 'react-icons/ai';
|
|
25
|
+
import * as BsIcons from 'react-icons/bs';
|
|
26
|
+
import * as FiIcons from 'react-icons/fi';
|
|
27
|
+
import * as IoIcons from 'react-icons/io5';
|
|
28
|
+
import * as RiIcons from 'react-icons/ri';
|
|
29
|
+
import * as TbIcons from 'react-icons/tb';
|
|
19
30
|
|
|
20
31
|
var ExampleComponent = ({ children, className = "" }) => {
|
|
21
32
|
return /* @__PURE__ */ jsx("div", { className: `cls_example_component ${className}`, children });
|
|
@@ -760,30 +771,27 @@ function MultiFilterDialog({
|
|
|
760
771
|
) }),
|
|
761
772
|
/* @__PURE__ */ jsx(PopoverContent, { className: "cls_combobox_popover w-full p-0", children: /* @__PURE__ */ jsxs(Command, { children: [
|
|
762
773
|
/* @__PURE__ */ jsx(CommandInput, { placeholder: "Search fields...", className: "cls_command_input" }),
|
|
763
|
-
/* @__PURE__ */
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
field.value
|
|
785
|
-
)) })
|
|
786
|
-
] })
|
|
774
|
+
/* @__PURE__ */ jsx(CommandList, { children: availableFieldsToAdd.length === 0 ? /* @__PURE__ */ jsx(CommandEmpty, { children: "No fields found." }) : /* @__PURE__ */ jsx(CommandGroup, { children: availableFieldsToAdd.map((field) => /* @__PURE__ */ jsxs(
|
|
775
|
+
CommandItem,
|
|
776
|
+
{
|
|
777
|
+
value: field.label,
|
|
778
|
+
onSelect: () => handleAddField(field.value),
|
|
779
|
+
className: "cls_command_item",
|
|
780
|
+
children: [
|
|
781
|
+
/* @__PURE__ */ jsx(
|
|
782
|
+
Check,
|
|
783
|
+
{
|
|
784
|
+
className: cn(
|
|
785
|
+
"cls_check_icon mr-2 h-4 w-4",
|
|
786
|
+
"opacity-0"
|
|
787
|
+
)
|
|
788
|
+
}
|
|
789
|
+
),
|
|
790
|
+
field.label
|
|
791
|
+
]
|
|
792
|
+
},
|
|
793
|
+
field.value
|
|
794
|
+
)) }) })
|
|
787
795
|
] }) })
|
|
788
796
|
] }) }),
|
|
789
797
|
filterFields.length > 0 ? /* @__PURE__ */ jsx("div", { className: "cls_filter_fields_list space-y-2", children: filterFields.map((filterConfig) => {
|
|
@@ -1065,30 +1073,27 @@ function MultiSortDialog({
|
|
|
1065
1073
|
) }),
|
|
1066
1074
|
/* @__PURE__ */ jsx(PopoverContent, { className: "cls_combobox_popover w-full p-0", children: /* @__PURE__ */ jsxs(Command, { children: [
|
|
1067
1075
|
/* @__PURE__ */ jsx(CommandInput, { placeholder: "Search fields...", className: "cls_command_input" }),
|
|
1068
|
-
/* @__PURE__ */
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
field.value
|
|
1090
|
-
)) })
|
|
1091
|
-
] })
|
|
1076
|
+
/* @__PURE__ */ jsx(CommandList, { children: availableFieldsToAdd.length === 0 ? /* @__PURE__ */ jsx(CommandEmpty, { children: "No fields found." }) : /* @__PURE__ */ jsx(CommandGroup, { children: availableFieldsToAdd.map((field) => /* @__PURE__ */ jsxs(
|
|
1077
|
+
CommandItem,
|
|
1078
|
+
{
|
|
1079
|
+
value: field.label,
|
|
1080
|
+
onSelect: () => handleAddField(field.value),
|
|
1081
|
+
className: "cls_command_item",
|
|
1082
|
+
children: [
|
|
1083
|
+
/* @__PURE__ */ jsx(
|
|
1084
|
+
Check,
|
|
1085
|
+
{
|
|
1086
|
+
className: cn(
|
|
1087
|
+
"cls_check_icon mr-2 h-4 w-4",
|
|
1088
|
+
"opacity-0"
|
|
1089
|
+
)
|
|
1090
|
+
}
|
|
1091
|
+
),
|
|
1092
|
+
field.label
|
|
1093
|
+
]
|
|
1094
|
+
},
|
|
1095
|
+
field.value
|
|
1096
|
+
)) }) })
|
|
1092
1097
|
] }) })
|
|
1093
1098
|
] }) }),
|
|
1094
1099
|
sortFields.length > 0 ? /* @__PURE__ */ jsx("div", { className: "cls_sort_fields_list space-y-2", children: /* @__PURE__ */ jsx(
|
|
@@ -1151,7 +1156,247 @@ function MultiSortDialog({
|
|
|
1151
1156
|
] })
|
|
1152
1157
|
] });
|
|
1153
1158
|
}
|
|
1159
|
+
var RadioGroup = React6.forwardRef(({ className, ...props }, ref) => {
|
|
1160
|
+
return /* @__PURE__ */ jsx(
|
|
1161
|
+
RadioGroupPrimitive.Root,
|
|
1162
|
+
{
|
|
1163
|
+
className: cn("grid gap-2", className),
|
|
1164
|
+
...props,
|
|
1165
|
+
ref
|
|
1166
|
+
}
|
|
1167
|
+
);
|
|
1168
|
+
});
|
|
1169
|
+
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
|
|
1170
|
+
var RadioGroupItem = React6.forwardRef(({ className, ...props }, ref) => {
|
|
1171
|
+
return /* @__PURE__ */ jsx(
|
|
1172
|
+
RadioGroupPrimitive.Item,
|
|
1173
|
+
{
|
|
1174
|
+
ref,
|
|
1175
|
+
className: cn(
|
|
1176
|
+
"aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
1177
|
+
className
|
|
1178
|
+
),
|
|
1179
|
+
...props,
|
|
1180
|
+
children: /* @__PURE__ */ jsx(RadioGroupPrimitive.Indicator, { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(Circle, { className: "h-2.5 w-2.5 fill-current text-current" }) })
|
|
1181
|
+
}
|
|
1182
|
+
);
|
|
1183
|
+
});
|
|
1184
|
+
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
|
|
1185
|
+
var iconSetMap = {
|
|
1186
|
+
fa: FaIcons,
|
|
1187
|
+
md: MdIcons,
|
|
1188
|
+
hi: HiIcons,
|
|
1189
|
+
bi: BiIcons,
|
|
1190
|
+
ai: AiIcons,
|
|
1191
|
+
bs: BsIcons,
|
|
1192
|
+
fi: FiIcons,
|
|
1193
|
+
io: IoIcons,
|
|
1194
|
+
io5: IoIcons,
|
|
1195
|
+
ri: RiIcons,
|
|
1196
|
+
tb: TbIcons
|
|
1197
|
+
};
|
|
1198
|
+
function getIconLibrary(iconSet) {
|
|
1199
|
+
if (!iconSet) return null;
|
|
1200
|
+
const normalizedSet = iconSet.toLowerCase();
|
|
1201
|
+
return iconSetMap[normalizedSet] || null;
|
|
1202
|
+
}
|
|
1203
|
+
function getIconComponent(iconSet, iconName) {
|
|
1204
|
+
if (!iconSet || !iconName) return null;
|
|
1205
|
+
const iconLibrary = getIconLibrary(iconSet);
|
|
1206
|
+
if (!iconLibrary) return null;
|
|
1207
|
+
const IconComponent = iconLibrary[iconName];
|
|
1208
|
+
return IconComponent || null;
|
|
1209
|
+
}
|
|
1210
|
+
function MultiStateRadio({
|
|
1211
|
+
layout = "horizontal",
|
|
1212
|
+
style = "radio",
|
|
1213
|
+
display_label = true,
|
|
1214
|
+
icon_set,
|
|
1215
|
+
data,
|
|
1216
|
+
selection = "single",
|
|
1217
|
+
value,
|
|
1218
|
+
onChange,
|
|
1219
|
+
className
|
|
1220
|
+
}) {
|
|
1221
|
+
const handleSingleSelection = (selectedValue) => {
|
|
1222
|
+
onChange(selectedValue);
|
|
1223
|
+
};
|
|
1224
|
+
const handleMultiSelection = (selectedValue) => {
|
|
1225
|
+
const currentValues = Array.isArray(value) ? value : [];
|
|
1226
|
+
const isSelected2 = currentValues.includes(selectedValue);
|
|
1227
|
+
if (isSelected2) {
|
|
1228
|
+
onChange(currentValues.filter((v) => v !== selectedValue));
|
|
1229
|
+
} else {
|
|
1230
|
+
onChange([...currentValues, selectedValue]);
|
|
1231
|
+
}
|
|
1232
|
+
};
|
|
1233
|
+
const isSelected = (itemValue) => {
|
|
1234
|
+
if (selection === "single") {
|
|
1235
|
+
return value === itemValue;
|
|
1236
|
+
} else {
|
|
1237
|
+
const currentValues = Array.isArray(value) ? value : [];
|
|
1238
|
+
return currentValues.includes(itemValue);
|
|
1239
|
+
}
|
|
1240
|
+
};
|
|
1241
|
+
const renderRadioOption = (item) => {
|
|
1242
|
+
const selected = isSelected(item.value);
|
|
1243
|
+
if (selection === "single") {
|
|
1244
|
+
const optionContent = /* @__PURE__ */ jsxs(
|
|
1245
|
+
"div",
|
|
1246
|
+
{
|
|
1247
|
+
className: cn(
|
|
1248
|
+
"cls_radio_option flex items-center gap-2",
|
|
1249
|
+
layout === "horizontal" ? "flex-row" : "flex-col",
|
|
1250
|
+
"p-2 rounded-md hover:bg-accent transition-colors",
|
|
1251
|
+
selected && "bg-accent"
|
|
1252
|
+
),
|
|
1253
|
+
children: [
|
|
1254
|
+
/* @__PURE__ */ jsx(
|
|
1255
|
+
RadioGroupItem,
|
|
1256
|
+
{
|
|
1257
|
+
value: item.value,
|
|
1258
|
+
id: `radio-${item.value}`,
|
|
1259
|
+
className: "cls_radio_item shrink-0"
|
|
1260
|
+
}
|
|
1261
|
+
),
|
|
1262
|
+
display_label && /* @__PURE__ */ jsx(
|
|
1263
|
+
"label",
|
|
1264
|
+
{
|
|
1265
|
+
htmlFor: `radio-${item.value}`,
|
|
1266
|
+
className: "cls_radio_label text-sm font-medium cursor-pointer flex-1",
|
|
1267
|
+
children: item.label
|
|
1268
|
+
}
|
|
1269
|
+
)
|
|
1270
|
+
]
|
|
1271
|
+
}
|
|
1272
|
+
);
|
|
1273
|
+
return /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 1e3, children: [
|
|
1274
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: optionContent }),
|
|
1275
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { className: "cls_tooltip_text", children: item.label }) })
|
|
1276
|
+
] }, item.value);
|
|
1277
|
+
} else {
|
|
1278
|
+
const optionContent = /* @__PURE__ */ jsxs(
|
|
1279
|
+
"div",
|
|
1280
|
+
{
|
|
1281
|
+
className: cn(
|
|
1282
|
+
"cls_radio_option flex items-center gap-2 cursor-pointer",
|
|
1283
|
+
layout === "horizontal" ? "flex-row" : "flex-col",
|
|
1284
|
+
"p-2 rounded-md hover:bg-accent transition-colors",
|
|
1285
|
+
selected && "bg-accent"
|
|
1286
|
+
),
|
|
1287
|
+
onClick: () => handleMultiSelection(item.value),
|
|
1288
|
+
role: "button",
|
|
1289
|
+
tabIndex: 0,
|
|
1290
|
+
onKeyDown: (e) => {
|
|
1291
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1292
|
+
e.preventDefault();
|
|
1293
|
+
handleMultiSelection(item.value);
|
|
1294
|
+
}
|
|
1295
|
+
},
|
|
1296
|
+
children: [
|
|
1297
|
+
/* @__PURE__ */ jsx(
|
|
1298
|
+
"div",
|
|
1299
|
+
{
|
|
1300
|
+
className: cn(
|
|
1301
|
+
"cls_checkbox_indicator h-4 w-4 rounded-sm border-2 border-primary flex items-center justify-center transition-colors shrink-0",
|
|
1302
|
+
selected ? "bg-primary" : "bg-background"
|
|
1303
|
+
),
|
|
1304
|
+
children: selected && /* @__PURE__ */ jsx(
|
|
1305
|
+
"svg",
|
|
1306
|
+
{
|
|
1307
|
+
className: "cls_checkmark h-3 w-3 text-primary-foreground",
|
|
1308
|
+
fill: "none",
|
|
1309
|
+
viewBox: "0 0 24 24",
|
|
1310
|
+
stroke: "currentColor",
|
|
1311
|
+
strokeWidth: 3,
|
|
1312
|
+
children: /* @__PURE__ */ jsx(
|
|
1313
|
+
"path",
|
|
1314
|
+
{
|
|
1315
|
+
strokeLinecap: "round",
|
|
1316
|
+
strokeLinejoin: "round",
|
|
1317
|
+
d: "M5 13l4 4L19 7"
|
|
1318
|
+
}
|
|
1319
|
+
)
|
|
1320
|
+
}
|
|
1321
|
+
)
|
|
1322
|
+
}
|
|
1323
|
+
),
|
|
1324
|
+
display_label && /* @__PURE__ */ jsx("span", { className: "cls_checkbox_label text-sm font-medium flex-1", children: item.label })
|
|
1325
|
+
]
|
|
1326
|
+
}
|
|
1327
|
+
);
|
|
1328
|
+
return /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 1e3, children: [
|
|
1329
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: optionContent }),
|
|
1330
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { className: "cls_tooltip_text", children: item.label }) })
|
|
1331
|
+
] }, item.value);
|
|
1332
|
+
}
|
|
1333
|
+
};
|
|
1334
|
+
const renderIconOption = (item) => {
|
|
1335
|
+
const selected = isSelected(item.value);
|
|
1336
|
+
const SelectedIcon = icon_set && item.icon_selected ? getIconComponent(icon_set, item.icon_selected) : null;
|
|
1337
|
+
const UnselectedIcon = icon_set && item.icon_unselected ? getIconComponent(icon_set, item.icon_unselected) : null;
|
|
1338
|
+
const IconComponent = selected && SelectedIcon ? SelectedIcon : UnselectedIcon || SelectedIcon;
|
|
1339
|
+
const buttonContent = /* @__PURE__ */ jsxs(
|
|
1340
|
+
Button,
|
|
1341
|
+
{
|
|
1342
|
+
variant: selected ? "default" : "ghost",
|
|
1343
|
+
size: "default",
|
|
1344
|
+
className: cn(
|
|
1345
|
+
"cls_icon_option border-0",
|
|
1346
|
+
layout === "horizontal" ? "flex-row" : "flex-col",
|
|
1347
|
+
"gap-2 h-auto py-2 px-3 sm:py-3 sm:px-4",
|
|
1348
|
+
selected && "bg-primary text-primary-foreground",
|
|
1349
|
+
!selected && "hover:bg-accent"
|
|
1350
|
+
),
|
|
1351
|
+
onClick: () => {
|
|
1352
|
+
if (selection === "single") {
|
|
1353
|
+
handleSingleSelection(item.value);
|
|
1354
|
+
} else {
|
|
1355
|
+
handleMultiSelection(item.value);
|
|
1356
|
+
}
|
|
1357
|
+
},
|
|
1358
|
+
"aria-label": item.label,
|
|
1359
|
+
"aria-pressed": selected,
|
|
1360
|
+
children: [
|
|
1361
|
+
IconComponent && /* @__PURE__ */ jsx(IconComponent, { className: "cls_icon h-4 w-4 sm:h-5 sm:w-5" }),
|
|
1362
|
+
display_label && /* @__PURE__ */ jsx("span", { className: "cls_icon_label text-sm font-medium", children: item.label })
|
|
1363
|
+
]
|
|
1364
|
+
}
|
|
1365
|
+
);
|
|
1366
|
+
return /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 1e3, children: [
|
|
1367
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: buttonContent }),
|
|
1368
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { className: "cls_tooltip_text", children: item.label }) })
|
|
1369
|
+
] }, item.value);
|
|
1370
|
+
};
|
|
1371
|
+
const containerClasses = cn(
|
|
1372
|
+
"cls_multi_state_radio border border-input rounded-md p-2 sm:p-3",
|
|
1373
|
+
layout === "horizontal" ? "flex flex-row flex-wrap gap-2 sm:gap-3" : "flex flex-col gap-2 sm:gap-3",
|
|
1374
|
+
className
|
|
1375
|
+
);
|
|
1376
|
+
const radioGroupClasses = cn(
|
|
1377
|
+
containerClasses,
|
|
1378
|
+
"!flex !flex-row !flex-wrap"
|
|
1379
|
+
// Override RadioGroup's default grid
|
|
1380
|
+
);
|
|
1381
|
+
if (style === "icons") {
|
|
1382
|
+
return /* @__PURE__ */ jsx(TooltipProvider, { delayDuration: 1e3, children: /* @__PURE__ */ jsx("div", { className: containerClasses, role: selection === "single" ? "radiogroup" : "group", children: data.map((item) => renderIconOption(item)) }) });
|
|
1383
|
+
} else {
|
|
1384
|
+
if (selection === "single") {
|
|
1385
|
+
return /* @__PURE__ */ jsx(TooltipProvider, { delayDuration: 1e3, children: /* @__PURE__ */ jsx(
|
|
1386
|
+
RadioGroup,
|
|
1387
|
+
{
|
|
1388
|
+
value: typeof value === "string" ? value : "",
|
|
1389
|
+
onValueChange: handleSingleSelection,
|
|
1390
|
+
className: layout === "horizontal" ? cn(radioGroupClasses, "!flex-row") : cn(radioGroupClasses, "!flex-col"),
|
|
1391
|
+
children: data.map((item) => renderRadioOption(item))
|
|
1392
|
+
}
|
|
1393
|
+
) });
|
|
1394
|
+
} else {
|
|
1395
|
+
return /* @__PURE__ */ jsx(TooltipProvider, { delayDuration: 1e3, children: /* @__PURE__ */ jsx("div", { className: containerClasses, role: "group", children: data.map((item) => renderRadioOption(item)) }) });
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1154
1399
|
|
|
1155
|
-
export { ExampleComponent, MultiFilterDialog, MultiSortDialog };
|
|
1400
|
+
export { ExampleComponent, MultiFilterDialog, MultiSortDialog, MultiStateRadio };
|
|
1156
1401
|
//# sourceMappingURL=index.js.map
|
|
1157
1402
|
//# sourceMappingURL=index.js.map
|