@woobee/ui 0.2.2 → 0.2.3
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 +99 -0
- package/SKIPPED.md +0 -8
- package/dist/index.d.mts +75 -1
- package/dist/index.d.ts +75 -1
- package/dist/index.js +358 -93
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +271 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
2
|
+
import React18, { forwardRef, useRef, useEffect, createContext, useState, useImperativeHandle, useContext, useReducer, useCallback, useMemo } from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
4
|
import { CSSTransition } from 'react-transition-group';
|
|
5
5
|
|
|
@@ -466,7 +466,7 @@ function CSSTransitionComponent({
|
|
|
466
466
|
removeClasses(nodeRef.current, [...leaveToClasses, ...leaveClasses]);
|
|
467
467
|
onExited(nodeRef.current);
|
|
468
468
|
},
|
|
469
|
-
children:
|
|
469
|
+
children: React18.cloneElement(children, {
|
|
470
470
|
ref: (node) => {
|
|
471
471
|
nodeRef.current = node;
|
|
472
472
|
const childRef = children.ref;
|
|
@@ -1052,6 +1052,268 @@ function InlinePrompt({
|
|
|
1052
1052
|
)
|
|
1053
1053
|
] }) });
|
|
1054
1054
|
}
|
|
1055
|
+
function DefaultLink({ href, className, children }) {
|
|
1056
|
+
return /* @__PURE__ */ jsx("a", { href, className, children });
|
|
1057
|
+
}
|
|
1058
|
+
function Breadcrumb({
|
|
1059
|
+
links,
|
|
1060
|
+
onBack,
|
|
1061
|
+
linkComponent: LinkComponent = DefaultLink
|
|
1062
|
+
}) {
|
|
1063
|
+
function clickBack(e) {
|
|
1064
|
+
e.preventDefault();
|
|
1065
|
+
if (onBack) {
|
|
1066
|
+
onBack();
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "pb-5 px-4 sm:px-6 lg:px-8", children: [
|
|
1070
|
+
onBack && /* @__PURE__ */ jsx("nav", { className: "sm:hidden", children: /* @__PURE__ */ jsxs(
|
|
1071
|
+
"a",
|
|
1072
|
+
{
|
|
1073
|
+
onClick: clickBack,
|
|
1074
|
+
className: "flex items-center text-sm leading-5 font-medium text-gray-500 hover:text-gray-700 transition duration-150 ease-in-out cursor-pointer",
|
|
1075
|
+
children: [
|
|
1076
|
+
/* @__PURE__ */ jsx("svg", { className: "flex-shrink-0 -ml-1 mr-1 h-5 w-5 text-gray-400", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsx(
|
|
1077
|
+
"path",
|
|
1078
|
+
{
|
|
1079
|
+
fillRule: "evenodd",
|
|
1080
|
+
d: "M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",
|
|
1081
|
+
clipRule: "evenodd"
|
|
1082
|
+
}
|
|
1083
|
+
) }),
|
|
1084
|
+
"Back"
|
|
1085
|
+
]
|
|
1086
|
+
}
|
|
1087
|
+
) }),
|
|
1088
|
+
/* @__PURE__ */ jsx("nav", { className: "hidden sm:flex items-center text-sm leading-5 font-medium", children: links && links.length > 0 && links.map((link, index) => /* @__PURE__ */ jsxs("span", { className: "inline-flex", children: [
|
|
1089
|
+
/* @__PURE__ */ jsx(LinkComponent, { href: link.href, className: "text-gray-500 hover:text-gray-700 transition duration-150 ease-in-out", children: link.name }),
|
|
1090
|
+
index !== links.length - 1 && /* @__PURE__ */ jsx("svg", { className: "flex-shrink-0 mx-2 h-5 w-5 text-gray-400", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsx(
|
|
1091
|
+
"path",
|
|
1092
|
+
{
|
|
1093
|
+
fillRule: "evenodd",
|
|
1094
|
+
d: "M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",
|
|
1095
|
+
clipRule: "evenodd"
|
|
1096
|
+
}
|
|
1097
|
+
) })
|
|
1098
|
+
] }, `breadcrumb-link-${index}-${link.name}`)) })
|
|
1099
|
+
] }) });
|
|
1100
|
+
}
|
|
1101
|
+
function DefaultLink2({ href, className, children, onClick }) {
|
|
1102
|
+
return /* @__PURE__ */ jsx("a", { href, className, onClick, children });
|
|
1103
|
+
}
|
|
1104
|
+
function TabItemComponent({
|
|
1105
|
+
allowRedirect,
|
|
1106
|
+
item,
|
|
1107
|
+
label,
|
|
1108
|
+
isActive,
|
|
1109
|
+
onSelect,
|
|
1110
|
+
linkComponent: LinkComponent = DefaultLink2
|
|
1111
|
+
}) {
|
|
1112
|
+
function handleTabSelect() {
|
|
1113
|
+
onSelect(item);
|
|
1114
|
+
}
|
|
1115
|
+
if (!!allowRedirect && !!item.link) {
|
|
1116
|
+
return /* @__PURE__ */ jsx(
|
|
1117
|
+
LinkComponent,
|
|
1118
|
+
{
|
|
1119
|
+
href: item.link,
|
|
1120
|
+
className: classNames({
|
|
1121
|
+
"whitespace-no-wrap -mb-px cursor-pointer border-b-2 py-2 px-3 text-center text-sm font-medium leading-5 tracking-tight focus:outline-none sm:px-5 sm:text-base sm:tracking-normal": true,
|
|
1122
|
+
"border-primary-500 text-primary-500 focus:border-primary-500 focus:text-primary-500": isActive,
|
|
1123
|
+
"text-cool-gray-500 hover:text-cool-gray-700 focus:text-cool-gray-700 border-transparent hover:border-transparent focus:border-transparent": !isActive
|
|
1124
|
+
}),
|
|
1125
|
+
onClick: handleTabSelect,
|
|
1126
|
+
children: item[label]
|
|
1127
|
+
}
|
|
1128
|
+
);
|
|
1129
|
+
}
|
|
1130
|
+
return null;
|
|
1131
|
+
}
|
|
1132
|
+
function Tab({
|
|
1133
|
+
items,
|
|
1134
|
+
label,
|
|
1135
|
+
value,
|
|
1136
|
+
defaultValue,
|
|
1137
|
+
allowRedirect,
|
|
1138
|
+
onChange,
|
|
1139
|
+
rightContent,
|
|
1140
|
+
linkComponent
|
|
1141
|
+
}) {
|
|
1142
|
+
const [selected, setSelected] = useState(defaultValue);
|
|
1143
|
+
useEffect(() => {
|
|
1144
|
+
setSelected(value);
|
|
1145
|
+
}, [value]);
|
|
1146
|
+
function handleSelect(item) {
|
|
1147
|
+
if (typeof onChange === "function") {
|
|
1148
|
+
onChange(item);
|
|
1149
|
+
}
|
|
1150
|
+
setSelected(item && item.id || null);
|
|
1151
|
+
}
|
|
1152
|
+
return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex w-full items-stretch pb-1 sm:pb-2", children: [
|
|
1153
|
+
/* @__PURE__ */ jsx("nav", { className: "border-cool-gray-200 -mb-px flex w-full items-end border-b", children: items.map((item) => /* @__PURE__ */ jsx(
|
|
1154
|
+
TabItemComponent,
|
|
1155
|
+
{
|
|
1156
|
+
item,
|
|
1157
|
+
label,
|
|
1158
|
+
isActive: selected === item.id,
|
|
1159
|
+
allowRedirect,
|
|
1160
|
+
onSelect: handleSelect,
|
|
1161
|
+
linkComponent
|
|
1162
|
+
},
|
|
1163
|
+
item.id
|
|
1164
|
+
)) }),
|
|
1165
|
+
rightContent && /* @__PURE__ */ jsx("nav", { className: "border-cool-gray-200 -mb-px flex flex flex-shrink-0 items-center border-b px-4", children: rightContent })
|
|
1166
|
+
] });
|
|
1167
|
+
}
|
|
1168
|
+
function DefaultLink3({ href, children }) {
|
|
1169
|
+
return /* @__PURE__ */ jsx("a", { href, children });
|
|
1170
|
+
}
|
|
1171
|
+
function ButtonItem({
|
|
1172
|
+
className,
|
|
1173
|
+
active,
|
|
1174
|
+
direction,
|
|
1175
|
+
iconPosition,
|
|
1176
|
+
button,
|
|
1177
|
+
onChange,
|
|
1178
|
+
onChangeGroup,
|
|
1179
|
+
currentPath,
|
|
1180
|
+
navLinks,
|
|
1181
|
+
linkComponent: LinkComponent = DefaultLink3
|
|
1182
|
+
}) {
|
|
1183
|
+
let currentButton = { ...button };
|
|
1184
|
+
if (active && navLinks && currentPath) {
|
|
1185
|
+
const navItem = navLinks.find((navLink) => navLink.url === currentPath);
|
|
1186
|
+
if (navItem) {
|
|
1187
|
+
currentButton.label = navItem.label;
|
|
1188
|
+
currentButton.image = /* @__PURE__ */ jsx("div", { className: "w-5 h-5", children: navItem.icon });
|
|
1189
|
+
currentButton.icon = void 0;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
const buttonContent = /* @__PURE__ */ jsx(
|
|
1193
|
+
"div",
|
|
1194
|
+
{
|
|
1195
|
+
className: classNames({
|
|
1196
|
+
"p-3 rounded-xl mx-auto text-charcoal-700/70 dark:text-charcoal-50/50 flex justify-center cursor-pointer": true,
|
|
1197
|
+
"w-full": direction === "vertical",
|
|
1198
|
+
"w-full overflow-hidden": direction === "horizontal",
|
|
1199
|
+
"!text-charcoal-700 dark:!text-primary-500 bg-white/50 dark:bg-charcoal-800/90 dark:backdrop-filter dark:backdrop-blur-sm border border-white lg:border-transparent dark:border-charcoal-700 shadow-xs dark:shadow-none": active,
|
|
1200
|
+
...classNameObject(className)
|
|
1201
|
+
}),
|
|
1202
|
+
children: /* @__PURE__ */ jsxs(
|
|
1203
|
+
"div",
|
|
1204
|
+
{
|
|
1205
|
+
className: classNames({
|
|
1206
|
+
"flex items-center justify-center": true,
|
|
1207
|
+
"flex-col md:flex-row md:space-x-1.5": !!currentButton.image,
|
|
1208
|
+
"gap-2": !currentButton.image && !!currentButton.icon,
|
|
1209
|
+
"flex-row-reverse": !currentButton.image && iconPosition === "back",
|
|
1210
|
+
"flex-row": !currentButton.image && iconPosition !== "back"
|
|
1211
|
+
}),
|
|
1212
|
+
children: [
|
|
1213
|
+
currentButton.image && /* @__PURE__ */ jsxs("div", { className: "relative mb-0.5 md:mb-0", children: [
|
|
1214
|
+
typeof currentButton.image === "string" && /* @__PURE__ */ jsx(
|
|
1215
|
+
"img",
|
|
1216
|
+
{
|
|
1217
|
+
src: currentButton.image,
|
|
1218
|
+
alt: currentButton.label,
|
|
1219
|
+
className: "w-6 h-6 object-cover rounded-full pointer-events-none"
|
|
1220
|
+
}
|
|
1221
|
+
),
|
|
1222
|
+
typeof currentButton.image === "object" && currentButton.image
|
|
1223
|
+
] }),
|
|
1224
|
+
!currentButton.image && currentButton.icon && /* @__PURE__ */ jsx("span", { className: "text-sm", children: currentButton.icon }),
|
|
1225
|
+
/* @__PURE__ */ jsx(
|
|
1226
|
+
"div",
|
|
1227
|
+
{
|
|
1228
|
+
className: classNames({
|
|
1229
|
+
"text-xs font-thin tracking-tight": true,
|
|
1230
|
+
"!font-normal": active
|
|
1231
|
+
}),
|
|
1232
|
+
children: /* @__PURE__ */ jsx("div", { className: "line-clamp-1", children: currentButton.label })
|
|
1233
|
+
}
|
|
1234
|
+
)
|
|
1235
|
+
]
|
|
1236
|
+
}
|
|
1237
|
+
)
|
|
1238
|
+
}
|
|
1239
|
+
);
|
|
1240
|
+
if (currentButton.subgroups) {
|
|
1241
|
+
return /* @__PURE__ */ jsx(
|
|
1242
|
+
"div",
|
|
1243
|
+
{
|
|
1244
|
+
onClick: () => onChangeGroup(button),
|
|
1245
|
+
children: buttonContent
|
|
1246
|
+
}
|
|
1247
|
+
);
|
|
1248
|
+
}
|
|
1249
|
+
if (currentButton.url) {
|
|
1250
|
+
return /* @__PURE__ */ jsx(LinkComponent, { href: currentButton.url, children: buttonContent });
|
|
1251
|
+
}
|
|
1252
|
+
return /* @__PURE__ */ jsx(
|
|
1253
|
+
"div",
|
|
1254
|
+
{
|
|
1255
|
+
onClick: () => onChange && onChange(button.id),
|
|
1256
|
+
children: buttonContent
|
|
1257
|
+
}
|
|
1258
|
+
);
|
|
1259
|
+
}
|
|
1260
|
+
function ButtonGroup({
|
|
1261
|
+
buttons = [],
|
|
1262
|
+
direction = "horizontal",
|
|
1263
|
+
iconPosition = "front",
|
|
1264
|
+
activeId,
|
|
1265
|
+
onChange,
|
|
1266
|
+
className,
|
|
1267
|
+
itemClassName,
|
|
1268
|
+
currentPath,
|
|
1269
|
+
navLinks,
|
|
1270
|
+
linkComponent,
|
|
1271
|
+
subgroupModal
|
|
1272
|
+
}) {
|
|
1273
|
+
const [selectedGroup, setSelectedGroup] = useState(null);
|
|
1274
|
+
function handleCloseModal() {
|
|
1275
|
+
setSelectedGroup(null);
|
|
1276
|
+
}
|
|
1277
|
+
return /* @__PURE__ */ jsxs(
|
|
1278
|
+
"div",
|
|
1279
|
+
{
|
|
1280
|
+
className: classNames({
|
|
1281
|
+
"gap-2 scrollbar-hide": true,
|
|
1282
|
+
"w-full": direction === "vertical",
|
|
1283
|
+
"grid grid-cols-5 w-full items-center": direction === "horizontal",
|
|
1284
|
+
...classNameObject(className)
|
|
1285
|
+
}),
|
|
1286
|
+
children: [
|
|
1287
|
+
buttons.map((button) => {
|
|
1288
|
+
const isActive = activeId === button.id;
|
|
1289
|
+
return /* @__PURE__ */ jsx(
|
|
1290
|
+
ButtonItem,
|
|
1291
|
+
{
|
|
1292
|
+
className: itemClassName,
|
|
1293
|
+
button,
|
|
1294
|
+
direction,
|
|
1295
|
+
iconPosition,
|
|
1296
|
+
onChange,
|
|
1297
|
+
onChangeGroup: (group) => setSelectedGroup(group),
|
|
1298
|
+
active: isActive,
|
|
1299
|
+
currentPath,
|
|
1300
|
+
navLinks,
|
|
1301
|
+
linkComponent
|
|
1302
|
+
},
|
|
1303
|
+
button.id
|
|
1304
|
+
);
|
|
1305
|
+
}),
|
|
1306
|
+
subgroupModal && subgroupModal({
|
|
1307
|
+
open: !!selectedGroup,
|
|
1308
|
+
label: selectedGroup?.label,
|
|
1309
|
+
items: selectedGroup?.subgroups,
|
|
1310
|
+
onClose: handleCloseModal,
|
|
1311
|
+
onChange
|
|
1312
|
+
})
|
|
1313
|
+
]
|
|
1314
|
+
}
|
|
1315
|
+
);
|
|
1316
|
+
}
|
|
1055
1317
|
function H1({ className, children }) {
|
|
1056
1318
|
return /* @__PURE__ */ jsx(
|
|
1057
1319
|
"h1",
|
|
@@ -2516,9 +2778,9 @@ function Dragger({
|
|
|
2516
2778
|
}
|
|
2517
2779
|
dispatch({ dragging: false });
|
|
2518
2780
|
}
|
|
2519
|
-
const derivedItems = !!items &&
|
|
2781
|
+
const derivedItems = !!items && React18.cloneElement(children, {
|
|
2520
2782
|
children: items.map((grandChild, index) => {
|
|
2521
|
-
return
|
|
2783
|
+
return React18.cloneElement(grandChild, {
|
|
2522
2784
|
id: (records[index] || {}).id,
|
|
2523
2785
|
draggable: true,
|
|
2524
2786
|
className: classNames({
|
|
@@ -2535,9 +2797,9 @@ function Dragger({
|
|
|
2535
2797
|
});
|
|
2536
2798
|
})
|
|
2537
2799
|
});
|
|
2538
|
-
const derivedDisplayItems = !!displayItems &&
|
|
2800
|
+
const derivedDisplayItems = !!displayItems && React18.cloneElement(children, {
|
|
2539
2801
|
children: displayItems.map((grandChild, index) => {
|
|
2540
|
-
return
|
|
2802
|
+
return React18.cloneElement(grandChild, {
|
|
2541
2803
|
draggable: true,
|
|
2542
2804
|
className: classNames({
|
|
2543
2805
|
...classNameObject(grandChild.props.className),
|
|
@@ -3136,7 +3398,7 @@ function DataTableRow({ index, selected, label, description, additionalDescripti
|
|
|
3136
3398
|
"!text-left": dataItem.align === "left",
|
|
3137
3399
|
"align-middle": vertical === "middle"
|
|
3138
3400
|
}),
|
|
3139
|
-
children: typeof dataItem.data[index] === "string" ||
|
|
3401
|
+
children: typeof dataItem.data[index] === "string" || React18.isValidElement(dataItem.data[index]) ? dataItem.data[index] : numberFormatter(dataItem.data[index], dataItem.decimal != null ? dataItem.decimal : 1)
|
|
3140
3402
|
},
|
|
3141
3403
|
`${dataIndex}-${index}`
|
|
3142
3404
|
))
|
|
@@ -3273,7 +3535,7 @@ function DataTable({
|
|
|
3273
3535
|
backgroundColor: `${colors[dataIndex]}`,
|
|
3274
3536
|
color: bestTextColorForBg(colors[dataIndex])
|
|
3275
3537
|
} : void 0,
|
|
3276
|
-
children: typeof total[dataIndex] === "string" ||
|
|
3538
|
+
children: typeof total[dataIndex] === "string" || React18.isValidElement(total[dataIndex]) ? total[dataIndex] : showCurrency ? /* @__PURE__ */ jsx(CurrencyDisplay, { amount: total[dataIndex] }) : numberFormatter(total[dataIndex], 1)
|
|
3277
3539
|
},
|
|
3278
3540
|
`${dataIndex}-total`
|
|
3279
3541
|
))
|
|
@@ -3685,6 +3947,6 @@ function DataGrid({ headers, data, selectedId, footers, opts, onSelect }) {
|
|
|
3685
3947
|
);
|
|
3686
3948
|
}
|
|
3687
3949
|
|
|
3688
|
-
export { B, Button, CheckboxList, ConfirmationBox, Coverflow, DataGrid, Dragger, Drawer, ExcelTable, H1, H2, H3, H4, InlinePrompt, Input_default as Input, Label, Loading, Modal, ModalContext, ModalProvider, NoData, Popover, PopoverContext, PopoverProvider, Select_default as Select, SelectInput_default as SelectInput, SortIcon, Table, Tabs, Tag, TagGroup, TagInput, Tbody, Td, Textarea_default as Textarea, Th, Thead, ThemeContext, ThemeProvider, ThemeToggle, Toggle_default as Toggle, Tr, Transition, bestTextColorForBg, classNameObject, classNames, debounce, moveItem, numberFormatter, useDebounce, useModalContext, usePopoverContext, useResizeListener, useThemeContext };
|
|
3950
|
+
export { B, Breadcrumb, Button, ButtonGroup, CheckboxList, ConfirmationBox, Coverflow, DataGrid, Dragger, Drawer, ExcelTable, H1, H2, H3, H4, InlinePrompt, Input_default as Input, Label, Loading, Modal, ModalContext, ModalProvider, NoData, Popover, PopoverContext, PopoverProvider, Select_default as Select, SelectInput_default as SelectInput, SortIcon, Tab, Table, Tabs, Tag, TagGroup, TagInput, Tbody, Td, Textarea_default as Textarea, Th, Thead, ThemeContext, ThemeProvider, ThemeToggle, Toggle_default as Toggle, Tr, Transition, bestTextColorForBg, classNameObject, classNames, debounce, moveItem, numberFormatter, useDebounce, useModalContext, usePopoverContext, useResizeListener, useThemeContext };
|
|
3689
3951
|
//# sourceMappingURL=index.mjs.map
|
|
3690
3952
|
//# sourceMappingURL=index.mjs.map
|