nntc-ui 0.0.83 → 0.0.84
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/index.css +4 -3
- package/index.d.ts +3 -2
- package/index.js +56 -14
- package/package.json +1 -1
package/index.css
CHANGED
|
@@ -733,11 +733,12 @@
|
|
|
733
733
|
}
|
|
734
734
|
.dateTime_popoverTarget {
|
|
735
735
|
position: absolute;
|
|
736
|
-
|
|
736
|
+
top: 0;
|
|
737
737
|
left: 0;
|
|
738
|
-
z-index:
|
|
738
|
+
z-index: 0;
|
|
739
739
|
width: 100%;
|
|
740
|
-
height:
|
|
740
|
+
height: 100%;
|
|
741
|
+
pointer-events: none;
|
|
741
742
|
}
|
|
742
743
|
.dateTime_popoverContent {
|
|
743
744
|
max-width: none;
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { ButtonHTMLAttributes, ReactNode, DetailedHTMLProps, InputHTMLAttributes, PropsWithChildren,
|
|
2
|
+
import { ButtonHTMLAttributes, ReactNode, DetailedHTMLProps, InputHTMLAttributes, PropsWithChildren, JSX, MutableRefObject, ReactElement, CSSProperties, HTMLProps, ElementType } from 'react';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { Placement } from '@floating-ui/react';
|
|
5
5
|
|
|
@@ -96,6 +96,7 @@ interface Props$k {
|
|
|
96
96
|
variant?: Variant$6;
|
|
97
97
|
isPeriod?: boolean;
|
|
98
98
|
valueType?: ValueType;
|
|
99
|
+
defaultOpen?: boolean;
|
|
99
100
|
componentSize?: Size$9;
|
|
100
101
|
fullWidth?: boolean;
|
|
101
102
|
label?: string;
|
|
@@ -347,7 +348,7 @@ interface Props$8 {
|
|
|
347
348
|
additionalColumnsViews?: (id: string, value: string | number | undefined, payload: {
|
|
348
349
|
[key: string]: string;
|
|
349
350
|
} | undefined) => {
|
|
350
|
-
edit: ((onChange: (
|
|
351
|
+
edit: ((onChange: (changeValue?: string, withBlur?: boolean) => void, onBlur: () => void) => JSX.Element | null) | null;
|
|
351
352
|
view: JSX.Element | null;
|
|
352
353
|
};
|
|
353
354
|
onChangeCell?: (rowIndex: number, columnId: string, value: string | number | undefined, original?: TableRow) => void;
|
package/index.js
CHANGED
|
@@ -1540,6 +1540,7 @@ var DateTime = forwardRef5(
|
|
|
1540
1540
|
variant = "filled",
|
|
1541
1541
|
isPeriod = false,
|
|
1542
1542
|
valueType = "date",
|
|
1543
|
+
defaultOpen = false,
|
|
1543
1544
|
componentSize = "medium",
|
|
1544
1545
|
fullWidth: fullWidth4,
|
|
1545
1546
|
label: label9,
|
|
@@ -1551,12 +1552,15 @@ var DateTime = forwardRef5(
|
|
|
1551
1552
|
dayjs: dayjsFromProps,
|
|
1552
1553
|
classes,
|
|
1553
1554
|
id,
|
|
1555
|
+
onFocus,
|
|
1556
|
+
onBlur,
|
|
1554
1557
|
...inputProps
|
|
1555
1558
|
}, ref) => {
|
|
1556
1559
|
const dayjs3 = dayjsFromProps ?? defaultDayjs2;
|
|
1557
1560
|
const [stateValues, setStateValues] = useState5(
|
|
1558
1561
|
values !== void 0 ? values : defaultValues
|
|
1559
1562
|
);
|
|
1563
|
+
const [isPopoverOpen, setIsPopoverOpen] = useState5(defaultOpen);
|
|
1560
1564
|
const stateValuesRef = useRef4(stateValues);
|
|
1561
1565
|
useEffect5(() => {
|
|
1562
1566
|
if (values !== void 0) {
|
|
@@ -1573,16 +1577,48 @@ var DateTime = forwardRef5(
|
|
|
1573
1577
|
}, [stateValues]);
|
|
1574
1578
|
const effectiveValueType = isPeriod && valueType === "dateTime" ? "date" : valueType;
|
|
1575
1579
|
const inputRef = useRef4(null);
|
|
1576
|
-
const popoverTargetRef = useRef4(null);
|
|
1577
1580
|
const reactId = useId2();
|
|
1578
1581
|
const inputId = id ?? reactId;
|
|
1579
|
-
const
|
|
1580
|
-
(
|
|
1581
|
-
|
|
1582
|
-
|
|
1582
|
+
const inputFocusHandler = useCallback5(
|
|
1583
|
+
(event) => {
|
|
1584
|
+
setIsPopoverOpen(true);
|
|
1585
|
+
onFocus?.(event);
|
|
1583
1586
|
},
|
|
1584
|
-
[
|
|
1587
|
+
[onFocus]
|
|
1585
1588
|
);
|
|
1589
|
+
const inputBlurHandler = useCallback5(
|
|
1590
|
+
(event) => {
|
|
1591
|
+
if (isPopoverOpen) {
|
|
1592
|
+
return;
|
|
1593
|
+
}
|
|
1594
|
+
onBlur?.(event);
|
|
1595
|
+
},
|
|
1596
|
+
[isPopoverOpen, onBlur]
|
|
1597
|
+
);
|
|
1598
|
+
const popoverOpenChangeHandler = useCallback5(
|
|
1599
|
+
(open) => {
|
|
1600
|
+
setIsPopoverOpen(open);
|
|
1601
|
+
if (!open) {
|
|
1602
|
+
const currentValues = stateValuesRef.current;
|
|
1603
|
+
if (currentValues !== void 0) {
|
|
1604
|
+
onValueChange?.(currentValues);
|
|
1605
|
+
}
|
|
1606
|
+
const inputElement = inputRef.current;
|
|
1607
|
+
if (!inputElement) {
|
|
1608
|
+
return;
|
|
1609
|
+
}
|
|
1610
|
+
if (document.activeElement === inputElement) {
|
|
1611
|
+
inputElement.blur();
|
|
1612
|
+
return;
|
|
1613
|
+
}
|
|
1614
|
+
onBlur?.({ target: inputElement, currentTarget: inputElement });
|
|
1615
|
+
}
|
|
1616
|
+
},
|
|
1617
|
+
[onBlur, onValueChange]
|
|
1618
|
+
);
|
|
1619
|
+
const iconClickHandler = useCallback5(() => {
|
|
1620
|
+
inputRef.current?.focus();
|
|
1621
|
+
}, []);
|
|
1586
1622
|
const changeDates = useCallback5(
|
|
1587
1623
|
(newStartDate, newEndDate) => {
|
|
1588
1624
|
const newValues = isPeriod ? [newStartDate, newEndDate] : [newStartDate];
|
|
@@ -1594,9 +1630,8 @@ var DateTime = forwardRef5(
|
|
|
1594
1630
|
}
|
|
1595
1631
|
stateValuesRef.current = newValues;
|
|
1596
1632
|
setStateValues(newValues);
|
|
1597
|
-
onValueChange?.(newValues);
|
|
1598
1633
|
},
|
|
1599
|
-
[isPeriod
|
|
1634
|
+
[isPeriod]
|
|
1600
1635
|
);
|
|
1601
1636
|
return /* @__PURE__ */ jsxs7(
|
|
1602
1637
|
"div",
|
|
@@ -1634,14 +1669,17 @@ var DateTime = forwardRef5(
|
|
|
1634
1669
|
)}` : "",
|
|
1635
1670
|
onChange: () => {
|
|
1636
1671
|
},
|
|
1637
|
-
|
|
1672
|
+
onFocus: inputFocusHandler,
|
|
1673
|
+
onBlur: inputBlurHandler
|
|
1638
1674
|
}
|
|
1639
1675
|
),
|
|
1640
|
-
/* @__PURE__ */ jsx15("span", { onClick:
|
|
1676
|
+
/* @__PURE__ */ jsx15("span", { onClick: iconClickHandler, className: classnames7(icon2, classes?.icon), children: /* @__PURE__ */ jsx15(DateRangeIcon, {}) }),
|
|
1641
1677
|
/* @__PURE__ */ jsx15(
|
|
1642
1678
|
Popover,
|
|
1643
1679
|
{
|
|
1644
1680
|
placement: "bottom-start",
|
|
1681
|
+
open: isPopoverOpen,
|
|
1682
|
+
onOpenChange: popoverOpenChangeHandler,
|
|
1645
1683
|
classes: { ...classes?.popover, content: popoverContent2 },
|
|
1646
1684
|
containerOffset: 4,
|
|
1647
1685
|
description: /* @__PURE__ */ jsx15(
|
|
@@ -1658,7 +1696,7 @@ var DateTime = forwardRef5(
|
|
|
1658
1696
|
onClear
|
|
1659
1697
|
}
|
|
1660
1698
|
),
|
|
1661
|
-
children: /* @__PURE__ */ jsx15("div", {
|
|
1699
|
+
children: /* @__PURE__ */ jsx15("div", { className: classnames7(popoverTarget2) })
|
|
1662
1700
|
}
|
|
1663
1701
|
)
|
|
1664
1702
|
] })
|
|
@@ -3266,15 +3304,19 @@ var DefaultColumn = {
|
|
|
3266
3304
|
tableMeta?.updateData(index, id, value, original);
|
|
3267
3305
|
setIsEdit(false);
|
|
3268
3306
|
};
|
|
3269
|
-
const onChange = (
|
|
3270
|
-
setValue(
|
|
3307
|
+
const onChange = (changeValue, withBlur) => {
|
|
3308
|
+
setValue(changeValue);
|
|
3309
|
+
if (withBlur) {
|
|
3310
|
+
tableMeta?.updateData(index, id, changeValue, original);
|
|
3311
|
+
setIsEdit(false);
|
|
3312
|
+
}
|
|
3271
3313
|
};
|
|
3272
3314
|
return /* @__PURE__ */ jsx31(
|
|
3273
3315
|
Tooltip,
|
|
3274
3316
|
{
|
|
3275
3317
|
label: original[id]?.tooltip ?? "",
|
|
3276
3318
|
alertType: original[id]?.fill === "error" ? "error" : original[id]?.fill === "success" ? "success" : "default",
|
|
3277
|
-
children: additionalViewResult?.edit !== null && additionalViewResult?.edit !== void 0 ? additionalViewResult.edit(onChange, onBlur) : /* @__PURE__ */ jsx31(Fragment6, { children: /* @__PURE__ */ jsx31("input", { onChange, onBlur, value: value ?? "", autoFocus: true }) })
|
|
3319
|
+
children: additionalViewResult?.edit !== null && additionalViewResult?.edit !== void 0 ? additionalViewResult.edit(onChange, onBlur) : /* @__PURE__ */ jsx31(Fragment6, { children: /* @__PURE__ */ jsx31("input", { onChange: (e) => onChange(e.target.value), onBlur, value: value ?? "", autoFocus: true }) })
|
|
3278
3320
|
}
|
|
3279
3321
|
);
|
|
3280
3322
|
}
|