@woobee/ui 0.2.2 → 0.2.4
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 +363 -99
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +276 -15
- 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;
|
|
@@ -633,16 +633,15 @@ function Modal({
|
|
|
633
633
|
}
|
|
634
634
|
if (!mounted) return null;
|
|
635
635
|
return createPortal(
|
|
636
|
-
/* @__PURE__ */ jsx(Transition, { show: open, onExited, children: /* @__PURE__ */ jsx("div", { className: "fixed inset-x-0 text-sm bottom-0 z-[1300] px-0 bg-opacity-30
|
|
636
|
+
/* @__PURE__ */ jsx(Transition, { show: open, onExited, children: /* @__PURE__ */ jsx("div", { className: "fixed inset-x-0 text-sm bottom-0 z-[1300] px-0 bg-opacity-30 md:px-6 md:inset-0 md:flex md:items-center md:justify-center", children: /* @__PURE__ */ jsxs(
|
|
637
637
|
"div",
|
|
638
638
|
{
|
|
639
639
|
className: classNames({
|
|
640
640
|
"max-h-[100dvh] overflow-y-auto sm:w-full": true,
|
|
641
|
-
"
|
|
642
|
-
"
|
|
643
|
-
"
|
|
644
|
-
"
|
|
645
|
-
"h-[100dvh] lg:h-auto lg:max-w-3xl": size === "full"
|
|
641
|
+
"md:max-w-2xl": !size || size === "medium",
|
|
642
|
+
"md:max-w-md": size === "small",
|
|
643
|
+
"md:max-w-4xl": size === "large",
|
|
644
|
+
"h-[100dvh] md:h-auto md:max-w-3xl": size === "full"
|
|
646
645
|
}),
|
|
647
646
|
children: [
|
|
648
647
|
/* @__PURE__ */ jsx(
|
|
@@ -1052,6 +1051,268 @@ function InlinePrompt({
|
|
|
1052
1051
|
)
|
|
1053
1052
|
] }) });
|
|
1054
1053
|
}
|
|
1054
|
+
function DefaultLink({ href, className, children }) {
|
|
1055
|
+
return /* @__PURE__ */ jsx("a", { href, className, children });
|
|
1056
|
+
}
|
|
1057
|
+
function Breadcrumb({
|
|
1058
|
+
links,
|
|
1059
|
+
onBack,
|
|
1060
|
+
linkComponent: LinkComponent = DefaultLink
|
|
1061
|
+
}) {
|
|
1062
|
+
function clickBack(e) {
|
|
1063
|
+
e.preventDefault();
|
|
1064
|
+
if (onBack) {
|
|
1065
|
+
onBack();
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "pb-5 px-4 sm:px-6 lg:px-8", children: [
|
|
1069
|
+
onBack && /* @__PURE__ */ jsx("nav", { className: "sm:hidden", children: /* @__PURE__ */ jsxs(
|
|
1070
|
+
"a",
|
|
1071
|
+
{
|
|
1072
|
+
onClick: clickBack,
|
|
1073
|
+
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",
|
|
1074
|
+
children: [
|
|
1075
|
+
/* @__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(
|
|
1076
|
+
"path",
|
|
1077
|
+
{
|
|
1078
|
+
fillRule: "evenodd",
|
|
1079
|
+
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",
|
|
1080
|
+
clipRule: "evenodd"
|
|
1081
|
+
}
|
|
1082
|
+
) }),
|
|
1083
|
+
"Back"
|
|
1084
|
+
]
|
|
1085
|
+
}
|
|
1086
|
+
) }),
|
|
1087
|
+
/* @__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: [
|
|
1088
|
+
/* @__PURE__ */ jsx(LinkComponent, { href: link.href, className: "text-gray-500 hover:text-gray-700 transition duration-150 ease-in-out", children: link.name }),
|
|
1089
|
+
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(
|
|
1090
|
+
"path",
|
|
1091
|
+
{
|
|
1092
|
+
fillRule: "evenodd",
|
|
1093
|
+
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",
|
|
1094
|
+
clipRule: "evenodd"
|
|
1095
|
+
}
|
|
1096
|
+
) })
|
|
1097
|
+
] }, `breadcrumb-link-${index}-${link.name}`)) })
|
|
1098
|
+
] }) });
|
|
1099
|
+
}
|
|
1100
|
+
function DefaultLink2({ href, className, children, onClick }) {
|
|
1101
|
+
return /* @__PURE__ */ jsx("a", { href, className, onClick, children });
|
|
1102
|
+
}
|
|
1103
|
+
function TabItemComponent({
|
|
1104
|
+
allowRedirect,
|
|
1105
|
+
item,
|
|
1106
|
+
label,
|
|
1107
|
+
isActive,
|
|
1108
|
+
onSelect,
|
|
1109
|
+
linkComponent: LinkComponent = DefaultLink2
|
|
1110
|
+
}) {
|
|
1111
|
+
function handleTabSelect() {
|
|
1112
|
+
onSelect(item);
|
|
1113
|
+
}
|
|
1114
|
+
if (!!allowRedirect && !!item.link) {
|
|
1115
|
+
return /* @__PURE__ */ jsx(
|
|
1116
|
+
LinkComponent,
|
|
1117
|
+
{
|
|
1118
|
+
href: item.link,
|
|
1119
|
+
className: classNames({
|
|
1120
|
+
"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,
|
|
1121
|
+
"border-primary-500 text-primary-500 focus:border-primary-500 focus:text-primary-500": isActive,
|
|
1122
|
+
"text-cool-gray-500 hover:text-cool-gray-700 focus:text-cool-gray-700 border-transparent hover:border-transparent focus:border-transparent": !isActive
|
|
1123
|
+
}),
|
|
1124
|
+
onClick: handleTabSelect,
|
|
1125
|
+
children: item[label]
|
|
1126
|
+
}
|
|
1127
|
+
);
|
|
1128
|
+
}
|
|
1129
|
+
return null;
|
|
1130
|
+
}
|
|
1131
|
+
function Tab({
|
|
1132
|
+
items,
|
|
1133
|
+
label,
|
|
1134
|
+
value,
|
|
1135
|
+
defaultValue,
|
|
1136
|
+
allowRedirect,
|
|
1137
|
+
onChange,
|
|
1138
|
+
rightContent,
|
|
1139
|
+
linkComponent
|
|
1140
|
+
}) {
|
|
1141
|
+
const [selected, setSelected] = useState(defaultValue);
|
|
1142
|
+
useEffect(() => {
|
|
1143
|
+
setSelected(value);
|
|
1144
|
+
}, [value]);
|
|
1145
|
+
function handleSelect(item) {
|
|
1146
|
+
if (typeof onChange === "function") {
|
|
1147
|
+
onChange(item);
|
|
1148
|
+
}
|
|
1149
|
+
setSelected(item && item.id || null);
|
|
1150
|
+
}
|
|
1151
|
+
return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex w-full items-stretch pb-1 sm:pb-2", children: [
|
|
1152
|
+
/* @__PURE__ */ jsx("nav", { className: "border-cool-gray-200 -mb-px flex w-full items-end border-b", children: items.map((item) => /* @__PURE__ */ jsx(
|
|
1153
|
+
TabItemComponent,
|
|
1154
|
+
{
|
|
1155
|
+
item,
|
|
1156
|
+
label,
|
|
1157
|
+
isActive: selected === item.id,
|
|
1158
|
+
allowRedirect,
|
|
1159
|
+
onSelect: handleSelect,
|
|
1160
|
+
linkComponent
|
|
1161
|
+
},
|
|
1162
|
+
item.id
|
|
1163
|
+
)) }),
|
|
1164
|
+
rightContent && /* @__PURE__ */ jsx("nav", { className: "border-cool-gray-200 -mb-px flex flex flex-shrink-0 items-center border-b px-4", children: rightContent })
|
|
1165
|
+
] });
|
|
1166
|
+
}
|
|
1167
|
+
function DefaultLink3({ href, children }) {
|
|
1168
|
+
return /* @__PURE__ */ jsx("a", { href, children });
|
|
1169
|
+
}
|
|
1170
|
+
function ButtonItem({
|
|
1171
|
+
className,
|
|
1172
|
+
active,
|
|
1173
|
+
direction,
|
|
1174
|
+
iconPosition,
|
|
1175
|
+
button,
|
|
1176
|
+
onChange,
|
|
1177
|
+
onChangeGroup,
|
|
1178
|
+
currentPath,
|
|
1179
|
+
navLinks,
|
|
1180
|
+
linkComponent: LinkComponent = DefaultLink3
|
|
1181
|
+
}) {
|
|
1182
|
+
let currentButton = { ...button };
|
|
1183
|
+
if (active && navLinks && currentPath) {
|
|
1184
|
+
const navItem = navLinks.find((navLink) => navLink.url === currentPath);
|
|
1185
|
+
if (navItem) {
|
|
1186
|
+
currentButton.label = navItem.label;
|
|
1187
|
+
currentButton.image = /* @__PURE__ */ jsx("div", { className: "w-5 h-5", children: navItem.icon });
|
|
1188
|
+
currentButton.icon = void 0;
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
const buttonContent = /* @__PURE__ */ jsx(
|
|
1192
|
+
"div",
|
|
1193
|
+
{
|
|
1194
|
+
className: classNames({
|
|
1195
|
+
"p-3 rounded-xl mx-auto text-charcoal-700/70 dark:text-charcoal-50/50 flex justify-center cursor-pointer": true,
|
|
1196
|
+
"w-full": direction === "vertical",
|
|
1197
|
+
"w-full overflow-hidden": direction === "horizontal",
|
|
1198
|
+
"!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,
|
|
1199
|
+
...classNameObject(className)
|
|
1200
|
+
}),
|
|
1201
|
+
children: /* @__PURE__ */ jsxs(
|
|
1202
|
+
"div",
|
|
1203
|
+
{
|
|
1204
|
+
className: classNames({
|
|
1205
|
+
"flex items-center justify-center": true,
|
|
1206
|
+
"flex-col md:flex-row md:space-x-1.5": !!currentButton.image,
|
|
1207
|
+
"gap-2": !currentButton.image && !!currentButton.icon,
|
|
1208
|
+
"flex-row-reverse": !currentButton.image && iconPosition === "back",
|
|
1209
|
+
"flex-row": !currentButton.image && iconPosition !== "back"
|
|
1210
|
+
}),
|
|
1211
|
+
children: [
|
|
1212
|
+
currentButton.image && /* @__PURE__ */ jsxs("div", { className: "relative mb-0.5 md:mb-0", children: [
|
|
1213
|
+
typeof currentButton.image === "string" && /* @__PURE__ */ jsx(
|
|
1214
|
+
"img",
|
|
1215
|
+
{
|
|
1216
|
+
src: currentButton.image,
|
|
1217
|
+
alt: currentButton.label,
|
|
1218
|
+
className: "w-6 h-6 object-cover rounded-full pointer-events-none"
|
|
1219
|
+
}
|
|
1220
|
+
),
|
|
1221
|
+
typeof currentButton.image === "object" && currentButton.image
|
|
1222
|
+
] }),
|
|
1223
|
+
!currentButton.image && currentButton.icon && /* @__PURE__ */ jsx("span", { className: "text-sm", children: currentButton.icon }),
|
|
1224
|
+
/* @__PURE__ */ jsx(
|
|
1225
|
+
"div",
|
|
1226
|
+
{
|
|
1227
|
+
className: classNames({
|
|
1228
|
+
"text-xs font-thin tracking-tight": true,
|
|
1229
|
+
"!font-normal": active
|
|
1230
|
+
}),
|
|
1231
|
+
children: /* @__PURE__ */ jsx("div", { className: "line-clamp-1", children: currentButton.label })
|
|
1232
|
+
}
|
|
1233
|
+
)
|
|
1234
|
+
]
|
|
1235
|
+
}
|
|
1236
|
+
)
|
|
1237
|
+
}
|
|
1238
|
+
);
|
|
1239
|
+
if (currentButton.subgroups) {
|
|
1240
|
+
return /* @__PURE__ */ jsx(
|
|
1241
|
+
"div",
|
|
1242
|
+
{
|
|
1243
|
+
onClick: () => onChangeGroup(button),
|
|
1244
|
+
children: buttonContent
|
|
1245
|
+
}
|
|
1246
|
+
);
|
|
1247
|
+
}
|
|
1248
|
+
if (currentButton.url) {
|
|
1249
|
+
return /* @__PURE__ */ jsx(LinkComponent, { href: currentButton.url, children: buttonContent });
|
|
1250
|
+
}
|
|
1251
|
+
return /* @__PURE__ */ jsx(
|
|
1252
|
+
"div",
|
|
1253
|
+
{
|
|
1254
|
+
onClick: () => onChange && onChange(button.id),
|
|
1255
|
+
children: buttonContent
|
|
1256
|
+
}
|
|
1257
|
+
);
|
|
1258
|
+
}
|
|
1259
|
+
function ButtonGroup({
|
|
1260
|
+
buttons = [],
|
|
1261
|
+
direction = "horizontal",
|
|
1262
|
+
iconPosition = "front",
|
|
1263
|
+
activeId,
|
|
1264
|
+
onChange,
|
|
1265
|
+
className,
|
|
1266
|
+
itemClassName,
|
|
1267
|
+
currentPath,
|
|
1268
|
+
navLinks,
|
|
1269
|
+
linkComponent,
|
|
1270
|
+
subgroupModal
|
|
1271
|
+
}) {
|
|
1272
|
+
const [selectedGroup, setSelectedGroup] = useState(null);
|
|
1273
|
+
function handleCloseModal() {
|
|
1274
|
+
setSelectedGroup(null);
|
|
1275
|
+
}
|
|
1276
|
+
return /* @__PURE__ */ jsxs(
|
|
1277
|
+
"div",
|
|
1278
|
+
{
|
|
1279
|
+
className: classNames({
|
|
1280
|
+
"gap-2 scrollbar-hide": true,
|
|
1281
|
+
"w-full": direction === "vertical",
|
|
1282
|
+
"grid grid-cols-5 w-full items-center": direction === "horizontal",
|
|
1283
|
+
...classNameObject(className)
|
|
1284
|
+
}),
|
|
1285
|
+
children: [
|
|
1286
|
+
buttons.map((button) => {
|
|
1287
|
+
const isActive = activeId === button.id;
|
|
1288
|
+
return /* @__PURE__ */ jsx(
|
|
1289
|
+
ButtonItem,
|
|
1290
|
+
{
|
|
1291
|
+
className: itemClassName,
|
|
1292
|
+
button,
|
|
1293
|
+
direction,
|
|
1294
|
+
iconPosition,
|
|
1295
|
+
onChange,
|
|
1296
|
+
onChangeGroup: (group) => setSelectedGroup(group),
|
|
1297
|
+
active: isActive,
|
|
1298
|
+
currentPath,
|
|
1299
|
+
navLinks,
|
|
1300
|
+
linkComponent
|
|
1301
|
+
},
|
|
1302
|
+
button.id
|
|
1303
|
+
);
|
|
1304
|
+
}),
|
|
1305
|
+
subgroupModal && subgroupModal({
|
|
1306
|
+
open: !!selectedGroup,
|
|
1307
|
+
label: selectedGroup?.label,
|
|
1308
|
+
items: selectedGroup?.subgroups,
|
|
1309
|
+
onClose: handleCloseModal,
|
|
1310
|
+
onChange
|
|
1311
|
+
})
|
|
1312
|
+
]
|
|
1313
|
+
}
|
|
1314
|
+
);
|
|
1315
|
+
}
|
|
1055
1316
|
function H1({ className, children }) {
|
|
1056
1317
|
return /* @__PURE__ */ jsx(
|
|
1057
1318
|
"h1",
|
|
@@ -2516,9 +2777,9 @@ function Dragger({
|
|
|
2516
2777
|
}
|
|
2517
2778
|
dispatch({ dragging: false });
|
|
2518
2779
|
}
|
|
2519
|
-
const derivedItems = !!items &&
|
|
2780
|
+
const derivedItems = !!items && React18.cloneElement(children, {
|
|
2520
2781
|
children: items.map((grandChild, index) => {
|
|
2521
|
-
return
|
|
2782
|
+
return React18.cloneElement(grandChild, {
|
|
2522
2783
|
id: (records[index] || {}).id,
|
|
2523
2784
|
draggable: true,
|
|
2524
2785
|
className: classNames({
|
|
@@ -2535,9 +2796,9 @@ function Dragger({
|
|
|
2535
2796
|
});
|
|
2536
2797
|
})
|
|
2537
2798
|
});
|
|
2538
|
-
const derivedDisplayItems = !!displayItems &&
|
|
2799
|
+
const derivedDisplayItems = !!displayItems && React18.cloneElement(children, {
|
|
2539
2800
|
children: displayItems.map((grandChild, index) => {
|
|
2540
|
-
return
|
|
2801
|
+
return React18.cloneElement(grandChild, {
|
|
2541
2802
|
draggable: true,
|
|
2542
2803
|
className: classNames({
|
|
2543
2804
|
...classNameObject(grandChild.props.className),
|
|
@@ -3136,7 +3397,7 @@ function DataTableRow({ index, selected, label, description, additionalDescripti
|
|
|
3136
3397
|
"!text-left": dataItem.align === "left",
|
|
3137
3398
|
"align-middle": vertical === "middle"
|
|
3138
3399
|
}),
|
|
3139
|
-
children: typeof dataItem.data[index] === "string" ||
|
|
3400
|
+
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
3401
|
},
|
|
3141
3402
|
`${dataIndex}-${index}`
|
|
3142
3403
|
))
|
|
@@ -3273,7 +3534,7 @@ function DataTable({
|
|
|
3273
3534
|
backgroundColor: `${colors[dataIndex]}`,
|
|
3274
3535
|
color: bestTextColorForBg(colors[dataIndex])
|
|
3275
3536
|
} : void 0,
|
|
3276
|
-
children: typeof total[dataIndex] === "string" ||
|
|
3537
|
+
children: typeof total[dataIndex] === "string" || React18.isValidElement(total[dataIndex]) ? total[dataIndex] : showCurrency ? /* @__PURE__ */ jsx(CurrencyDisplay, { amount: total[dataIndex] }) : numberFormatter(total[dataIndex], 1)
|
|
3277
3538
|
},
|
|
3278
3539
|
`${dataIndex}-total`
|
|
3279
3540
|
))
|
|
@@ -3685,6 +3946,6 @@ function DataGrid({ headers, data, selectedId, footers, opts, onSelect }) {
|
|
|
3685
3946
|
);
|
|
3686
3947
|
}
|
|
3687
3948
|
|
|
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 };
|
|
3949
|
+
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
3950
|
//# sourceMappingURL=index.mjs.map
|
|
3690
3951
|
//# sourceMappingURL=index.mjs.map
|