@scripso-homepad/ui 0.4.10 → 0.4.12
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.cjs +122 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +124 -45
- package/dist/index.js.map +1 -1
- package/dist/web/index.cjs +48 -37
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.d.cts +2 -1
- package/dist/web/index.d.ts +2 -1
- package/dist/web/index.js +48 -37
- package/dist/web/index.js.map +1 -1
- package/package.json +3 -2
- package/src/components/Calendar.tsx +10 -2
- package/src/components/DatePicker.tsx +3 -3
- package/src/components/Select.tsx +133 -38
- package/src/theme/select.ts +1 -1
- package/src/utils/calendarDays.ts +15 -6
- package/src/web/components/Badge.tsx +1 -1
- package/src/web/components/ConfirmModal.tsx +2 -2
- package/src/web/components/Drawer.stories.tsx +7 -7
- package/src/web/components/Drawer.tsx +2 -2
- package/src/web/components/HistoryTimeline.tsx +2 -2
- package/src/web/components/Modal.stories.tsx +1 -1
- package/src/web/components/Modal.tsx +32 -14
- package/src/web/components/Pagination.tsx +2 -2
- package/src/web/components/TableActionButton.tsx +1 -1
- package/src/web/components/TableActionsMenu.tsx +1 -1
- package/src/web/components/TableIconText.tsx +1 -1
- package/src/web/components/Toaster.stories.tsx +7 -7
- package/src/web/components/table/constants.ts +2 -2
- package/src/web/layout/AppHeader.tsx +1 -1
- package/src/web/layout/BuildingSelect.tsx +2 -2
- package/src/web/layout/DashboardLayout.stories.tsx +1 -1
- package/src/web/layout/SidebarNavItem.tsx +1 -1
- package/src/web/layout/SidebarUserCard.tsx +3 -3
- package/src/web/styles/typography.css +99 -0
package/dist/index.cjs
CHANGED
|
@@ -871,7 +871,7 @@ var selectLabelTypography = {
|
|
|
871
871
|
fontFamily: fonts.sans,
|
|
872
872
|
fontSize: fontSize.sm,
|
|
873
873
|
fontWeight: fontWeight.medium,
|
|
874
|
-
lineHeight:
|
|
874
|
+
lineHeight: 16,
|
|
875
875
|
letterSpacing: 0,
|
|
876
876
|
color: colors.slateBlue
|
|
877
877
|
};
|
|
@@ -1191,6 +1191,86 @@ function renderSelectIcon(icon, color) {
|
|
|
1191
1191
|
}
|
|
1192
1192
|
return icon;
|
|
1193
1193
|
}
|
|
1194
|
+
function resolveWebTextNode(ref) {
|
|
1195
|
+
if (reactNative.Platform.OS !== "web") {
|
|
1196
|
+
return null;
|
|
1197
|
+
}
|
|
1198
|
+
const node = ref.current;
|
|
1199
|
+
return node instanceof HTMLElement ? node : null;
|
|
1200
|
+
}
|
|
1201
|
+
function syncTruncatedNativeTitle(ref, label) {
|
|
1202
|
+
const element = resolveWebTextNode(ref);
|
|
1203
|
+
if (!element) {
|
|
1204
|
+
return;
|
|
1205
|
+
}
|
|
1206
|
+
if (element.scrollWidth > element.clientWidth) {
|
|
1207
|
+
element.setAttribute("title", label);
|
|
1208
|
+
return;
|
|
1209
|
+
}
|
|
1210
|
+
element.removeAttribute("title");
|
|
1211
|
+
}
|
|
1212
|
+
function clearNativeTitle(ref) {
|
|
1213
|
+
resolveWebTextNode(ref)?.removeAttribute("title");
|
|
1214
|
+
}
|
|
1215
|
+
function SelectOptionItem({
|
|
1216
|
+
option,
|
|
1217
|
+
compact,
|
|
1218
|
+
optionHeight,
|
|
1219
|
+
isSelected,
|
|
1220
|
+
isHighlighted,
|
|
1221
|
+
isLast,
|
|
1222
|
+
selectableIndex,
|
|
1223
|
+
onHighlight,
|
|
1224
|
+
onSelect
|
|
1225
|
+
}) {
|
|
1226
|
+
const labelRef = react.useRef(null);
|
|
1227
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1228
|
+
reactNative.Pressable,
|
|
1229
|
+
{
|
|
1230
|
+
accessibilityRole: "button",
|
|
1231
|
+
accessibilityState: { disabled: option.disabled, selected: isSelected },
|
|
1232
|
+
disabled: option.disabled,
|
|
1233
|
+
onPress: () => {
|
|
1234
|
+
if (!option.disabled) {
|
|
1235
|
+
onSelect(option.value);
|
|
1236
|
+
}
|
|
1237
|
+
},
|
|
1238
|
+
onHoverIn: () => {
|
|
1239
|
+
if (!option.disabled && selectableIndex >= 0) {
|
|
1240
|
+
onHighlight(selectableIndex);
|
|
1241
|
+
}
|
|
1242
|
+
syncTruncatedNativeTitle(labelRef, option.label);
|
|
1243
|
+
},
|
|
1244
|
+
onHoverOut: () => {
|
|
1245
|
+
clearNativeTitle(labelRef);
|
|
1246
|
+
},
|
|
1247
|
+
style: [
|
|
1248
|
+
selectDropdownMetrics.option,
|
|
1249
|
+
compact && styles4.optionCompact,
|
|
1250
|
+
{ height: optionHeight, minHeight: optionHeight, maxHeight: optionHeight },
|
|
1251
|
+
isSelected && selectDropdownMetrics.optionSelected,
|
|
1252
|
+
compact && isSelected && styles4.optionSelectedCompact,
|
|
1253
|
+
isHighlighted && !isSelected && !option.disabled ? selectDropdownMetrics.optionHighlighted : null,
|
|
1254
|
+
!isLast && styles4.optionSpacing,
|
|
1255
|
+
option.disabled && styles4.optionDisabled
|
|
1256
|
+
],
|
|
1257
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1258
|
+
reactNative.Text,
|
|
1259
|
+
{
|
|
1260
|
+
ref: labelRef,
|
|
1261
|
+
style: [
|
|
1262
|
+
selectDropdownMetrics.optionLabel,
|
|
1263
|
+
styles4.optionLabel,
|
|
1264
|
+
isSelected && selectDropdownMetrics.optionLabelSelected,
|
|
1265
|
+
option.disabled && styles4.optionLabelDisabled
|
|
1266
|
+
],
|
|
1267
|
+
numberOfLines: 1,
|
|
1268
|
+
children: option.label
|
|
1269
|
+
}
|
|
1270
|
+
)
|
|
1271
|
+
}
|
|
1272
|
+
);
|
|
1273
|
+
}
|
|
1194
1274
|
var useIsomorphicLayoutEffect = typeof window === "undefined" ? react.useEffect : react.useLayoutEffect;
|
|
1195
1275
|
function normalizeSelectedValues(multiple, value) {
|
|
1196
1276
|
if (multiple) {
|
|
@@ -1323,6 +1403,11 @@ function Select({
|
|
|
1323
1403
|
onValueChange?.(nextValues);
|
|
1324
1404
|
return;
|
|
1325
1405
|
}
|
|
1406
|
+
if (selectedValues.includes(nextValue)) {
|
|
1407
|
+
onValueChange?.("");
|
|
1408
|
+
closeMenu();
|
|
1409
|
+
return;
|
|
1410
|
+
}
|
|
1326
1411
|
onValueChange?.(nextValue);
|
|
1327
1412
|
closeMenu();
|
|
1328
1413
|
}
|
|
@@ -1332,43 +1417,17 @@ function Select({
|
|
|
1332
1417
|
const isHighlighted = selectableIndex === highlightedIndex;
|
|
1333
1418
|
const isLast = index === options.length - 1;
|
|
1334
1419
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1335
|
-
|
|
1420
|
+
SelectOptionItem,
|
|
1336
1421
|
{
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
if (!option.disabled && selectableIndex >= 0) {
|
|
1347
|
-
setHighlightedIndex(selectableIndex);
|
|
1348
|
-
}
|
|
1349
|
-
},
|
|
1350
|
-
style: [
|
|
1351
|
-
selectDropdownMetrics.option,
|
|
1352
|
-
compact && styles4.optionCompact,
|
|
1353
|
-
{ height: optionHeight, minHeight: optionHeight, maxHeight: optionHeight },
|
|
1354
|
-
isSelected && selectDropdownMetrics.optionSelected,
|
|
1355
|
-
compact && isSelected && styles4.optionSelectedCompact,
|
|
1356
|
-
isHighlighted && !isSelected && !option.disabled ? selectDropdownMetrics.optionHighlighted : null,
|
|
1357
|
-
!isLast && styles4.optionSpacing,
|
|
1358
|
-
option.disabled && styles4.optionDisabled
|
|
1359
|
-
],
|
|
1360
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1361
|
-
reactNative.Text,
|
|
1362
|
-
{
|
|
1363
|
-
style: [
|
|
1364
|
-
selectDropdownMetrics.optionLabel,
|
|
1365
|
-
isSelected && selectDropdownMetrics.optionLabelSelected,
|
|
1366
|
-
option.disabled && styles4.optionLabelDisabled
|
|
1367
|
-
],
|
|
1368
|
-
numberOfLines: 1,
|
|
1369
|
-
children: option.label
|
|
1370
|
-
}
|
|
1371
|
-
)
|
|
1422
|
+
option,
|
|
1423
|
+
compact,
|
|
1424
|
+
optionHeight,
|
|
1425
|
+
isSelected,
|
|
1426
|
+
isHighlighted,
|
|
1427
|
+
isLast,
|
|
1428
|
+
selectableIndex,
|
|
1429
|
+
onHighlight: setHighlightedIndex,
|
|
1430
|
+
onSelect: handleSelect
|
|
1372
1431
|
},
|
|
1373
1432
|
option.value
|
|
1374
1433
|
);
|
|
@@ -1503,6 +1562,14 @@ var styles4 = reactNative.StyleSheet.create({
|
|
|
1503
1562
|
optionDisabled: {
|
|
1504
1563
|
opacity: 0.5
|
|
1505
1564
|
},
|
|
1565
|
+
optionLabel: {
|
|
1566
|
+
minWidth: 0,
|
|
1567
|
+
...reactNative.Platform.OS === "web" ? {
|
|
1568
|
+
overflow: "hidden",
|
|
1569
|
+
textOverflow: "ellipsis",
|
|
1570
|
+
whiteSpace: "nowrap"
|
|
1571
|
+
} : null
|
|
1572
|
+
},
|
|
1506
1573
|
optionLabelDisabled: {
|
|
1507
1574
|
color: colors.stormGray300
|
|
1508
1575
|
},
|
|
@@ -2331,17 +2398,24 @@ function isInDateRange(date, start, end) {
|
|
|
2331
2398
|
}
|
|
2332
2399
|
function selectRangeDate(clicked, current) {
|
|
2333
2400
|
const clickedDate = stripTime(clicked);
|
|
2334
|
-
if (!current?.start
|
|
2401
|
+
if (!current?.start) {
|
|
2335
2402
|
return { start: clickedDate };
|
|
2336
2403
|
}
|
|
2337
2404
|
const start = stripTime(current.start);
|
|
2338
|
-
|
|
2405
|
+
const end = current.end ? stripTime(current.end) : void 0;
|
|
2406
|
+
if (!end) {
|
|
2407
|
+
if (isSameDay(clickedDate, start)) {
|
|
2408
|
+
return void 0;
|
|
2409
|
+
}
|
|
2410
|
+
if (isBeforeDay(clickedDate, start)) {
|
|
2411
|
+
return { start: clickedDate };
|
|
2412
|
+
}
|
|
2339
2413
|
return { start, end: clickedDate };
|
|
2340
2414
|
}
|
|
2341
|
-
if (
|
|
2342
|
-
return
|
|
2415
|
+
if (isSameDay(clickedDate, end)) {
|
|
2416
|
+
return void 0;
|
|
2343
2417
|
}
|
|
2344
|
-
return { start
|
|
2418
|
+
return { start: clickedDate };
|
|
2345
2419
|
}
|
|
2346
2420
|
function isSameDay(left, right) {
|
|
2347
2421
|
return left.getFullYear() === right.getFullYear() && left.getMonth() === right.getMonth() && left.getDate() === right.getDate();
|
|
@@ -2833,6 +2907,11 @@ function Calendar(props) {
|
|
|
2833
2907
|
rangeProps.onChange?.(selectRangeDate(date, rangeProps.value));
|
|
2834
2908
|
return;
|
|
2835
2909
|
}
|
|
2910
|
+
const currentValue = singleProps?.value;
|
|
2911
|
+
if (currentValue && isSameDay(date, currentValue)) {
|
|
2912
|
+
singleProps?.onChange?.(void 0);
|
|
2913
|
+
return;
|
|
2914
|
+
}
|
|
2836
2915
|
singleProps?.onChange?.(date);
|
|
2837
2916
|
}
|
|
2838
2917
|
const headerIsPressable = pickerView === "days" || pickerView === "months";
|
|
@@ -3081,7 +3160,7 @@ function DatePicker(props) {
|
|
|
3081
3160
|
return;
|
|
3082
3161
|
}
|
|
3083
3162
|
props.onChange?.(range);
|
|
3084
|
-
if (closeOnRangeComplete && range
|
|
3163
|
+
if (closeOnRangeComplete && range?.end) {
|
|
3085
3164
|
closePicker();
|
|
3086
3165
|
}
|
|
3087
3166
|
}
|