@headless-adminapp/fluent 0.0.17-alpha.46 → 0.0.17-alpha.48
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/App/AppHeaderContianer.js +1 -1
- package/DataGrid/CustomizeColumns/CustomizeColumns.d.ts +2 -2
- package/form/controls/DateTimeControl.d.ts +1 -1
- package/form/controls/DateTimeControl.js +97 -16
- package/form/controls/DurationControl.d.ts +1 -1
- package/form/controls/IntegerControl.js +1 -2
- package/package.json +5 -4
- package/types/index.d.ts +1 -0
|
@@ -34,7 +34,7 @@ const AppHeaderContainer = ({ onNavToggle, }) => {
|
|
|
34
34
|
background: react_components_1.tokens.colorBrandBackground,
|
|
35
35
|
paddingInline: 8,
|
|
36
36
|
gap: 8,
|
|
37
|
-
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flex: 1, alignItems: 'center', gap: 8 }, children: [isMobile && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
37
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flex: 1, alignItems: 'center', gap: 8 }, children: [isMobile && ((0, jsx_runtime_1.jsx)("div", { role: "button", style: {
|
|
38
38
|
cursor: 'pointer',
|
|
39
39
|
}, onClick: onNavToggle, children: (0, jsx_runtime_1.jsx)(react_nav_preview_1.Hamburger, { style: { color: 'white' } }) })), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
40
40
|
display: 'flex',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
interface CustomizeColumnsProps {
|
|
2
|
-
opened: boolean;
|
|
3
|
-
onClose: () => void;
|
|
2
|
+
readonly opened: boolean;
|
|
3
|
+
readonly onClose: () => void;
|
|
4
4
|
}
|
|
5
5
|
export declare function CustomizeColumns({ onClose, opened }: CustomizeColumnsProps): import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export {};
|
|
@@ -3,4 +3,4 @@ export interface DateTimeControlProps extends ControlProps<string> {
|
|
|
3
3
|
maxDate?: Date;
|
|
4
4
|
minDate?: Date;
|
|
5
5
|
}
|
|
6
|
-
export declare function DateTimeControl({ value, onChange, id, name, onBlur, onFocus, placeholder, disabled, readOnly, }: DateTimeControlProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function DateTimeControl({ value, onChange, id, name, onBlur, onFocus, placeholder, disabled, readOnly, }: Readonly<DateTimeControlProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,23 +7,104 @@ exports.DateTimeControl = DateTimeControl;
|
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const react_components_1 = require("@fluentui/react-components");
|
|
9
9
|
const react_datepicker_compat_1 = require("@fluentui/react-datepicker-compat");
|
|
10
|
+
const react_timepicker_compat_1 = require("@fluentui/react-timepicker-compat");
|
|
11
|
+
const locale_1 = require("@headless-adminapp/app/locale");
|
|
10
12
|
const icons_1 = require("@headless-adminapp/icons");
|
|
11
13
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
14
|
+
const customParseFormat_1 = __importDefault(require("dayjs/plugin/customParseFormat"));
|
|
15
|
+
const timezone_1 = __importDefault(require("dayjs/plugin/timezone"));
|
|
16
|
+
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
17
|
+
const react_1 = require("react");
|
|
18
|
+
dayjs_1.default.extend(customParseFormat_1.default);
|
|
19
|
+
dayjs_1.default.extend(utc_1.default);
|
|
20
|
+
dayjs_1.default.extend(timezone_1.default);
|
|
12
21
|
function DateTimeControl({ value, onChange, id, name, onBlur, onFocus, placeholder, disabled, readOnly, }) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
const { dateFormats: { short: dateFormat }, timeFormats: { short: timeFormat }, timezone, } = (0, locale_1.useLocale)();
|
|
23
|
+
const [internalTimeValue, setInternalTimeValue] = (0, react_1.useState)(value ? (0, dayjs_1.default)(value).tz(timezone).format(timeFormat) : '');
|
|
24
|
+
const internalTimeValueRef = (0, react_1.useRef)(internalTimeValue);
|
|
25
|
+
internalTimeValueRef.current = internalTimeValue;
|
|
26
|
+
(0, react_1.useEffect)(() => {
|
|
27
|
+
const updatedValue = value
|
|
28
|
+
? (0, dayjs_1.default)(value).tz(timezone).format(timeFormat)
|
|
29
|
+
: '';
|
|
30
|
+
if (internalTimeValueRef.current !== updatedValue) {
|
|
31
|
+
setInternalTimeValue(updatedValue);
|
|
32
|
+
}
|
|
33
|
+
}, [value, timezone, timeFormat]);
|
|
34
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
35
|
+
display: 'flex',
|
|
36
|
+
alignItems: 'center',
|
|
37
|
+
gap: react_components_1.tokens.spacingHorizontalS,
|
|
38
|
+
}, children: [(0, jsx_runtime_1.jsx)(react_datepicker_compat_1.DatePicker, { id: id, name: name, onFocus: () => onFocus === null || onFocus === void 0 ? void 0 : onFocus(), onBlur: () => onBlur === null || onBlur === void 0 ? void 0 : onBlur(), placeholder: placeholder, appearance: "filled-darker", formatDate: (date) => date ? (0, dayjs_1.default)(date).tz(timezone).format(dateFormat) : '', disabled: disabled, readOnly: readOnly, value: value ? new Date(value) : null, onSelectDate: (date) => {
|
|
39
|
+
if (!date) {
|
|
40
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(null);
|
|
41
|
+
}
|
|
42
|
+
else if (!value) {
|
|
43
|
+
onChange === null || onChange === void 0 ? void 0 : onChange((0, dayjs_1.default)(date).tz(timezone, true).toISOString());
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
onChange === null || onChange === void 0 ? void 0 : onChange((0, dayjs_1.default)(date)
|
|
47
|
+
.tz(timezone, true)
|
|
48
|
+
.set('hour', (0, dayjs_1.default)(value).tz(timezone).hour())
|
|
49
|
+
.set('minute', (0, dayjs_1.default)(value).tz(timezone).minute())
|
|
50
|
+
.toISOString());
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
// allowTextInput={true}
|
|
54
|
+
contentAfter: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
55
|
+
display: 'flex',
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
justifyContent: 'center',
|
|
58
|
+
marginRight: -4,
|
|
59
|
+
color: react_components_1.tokens.colorNeutralForeground2,
|
|
60
|
+
}, children: (0, jsx_runtime_1.jsx)(icons_1.Icons.Calendar, { size: 20 }) }), style: { flex: 1 }, input: {
|
|
61
|
+
style: { minWidth: 0, width: '100%' },
|
|
62
|
+
} }), (0, jsx_runtime_1.jsx)(react_timepicker_compat_1.TimePicker, { appearance: "filled-darker", style: { flex: 1, minWidth: 0 }, input: {
|
|
63
|
+
style: { minWidth: 0 },
|
|
64
|
+
}, readOnly: readOnly || disabled || !value, selectedTime: value ? new Date(value) : null, freeform: true, value: internalTimeValue, onTimeChange: (_, data) => {
|
|
65
|
+
const dateValue = value
|
|
66
|
+
? (0, dayjs_1.default)(value).tz(timezone)
|
|
67
|
+
: (0, dayjs_1.default)().tz(timezone);
|
|
68
|
+
if (data.selectedTime) {
|
|
69
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(dateValue
|
|
70
|
+
.set('hour', data.selectedTime.getHours())
|
|
71
|
+
.set('minute', data.selectedTime.getMinutes())
|
|
72
|
+
.toISOString());
|
|
73
|
+
}
|
|
74
|
+
else if (data.selectedTimeText) {
|
|
75
|
+
let resolvedTime = resolveTimeValue(data.selectedTimeText, timeFormat);
|
|
76
|
+
if (!resolvedTime) {
|
|
77
|
+
setInternalTimeValue(value ? (0, dayjs_1.default)(value).format(timeFormat) : '');
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const newValue = dateValue
|
|
81
|
+
.set('hour', resolvedTime.getHours())
|
|
82
|
+
.set('minute', resolvedTime.getMinutes())
|
|
83
|
+
.toISOString();
|
|
84
|
+
if (newValue !== value) {
|
|
85
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
86
|
+
}
|
|
87
|
+
setInternalTimeValue(newValue ? (0, dayjs_1.default)(newValue).tz(timezone).format(timeFormat) : '');
|
|
88
|
+
}
|
|
89
|
+
}, onInput: (e) => {
|
|
90
|
+
setInternalTimeValue(e.currentTarget.value);
|
|
91
|
+
}, onBlur: () => {
|
|
92
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur();
|
|
93
|
+
}, expandIcon: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
94
|
+
display: 'flex',
|
|
95
|
+
alignItems: 'center',
|
|
96
|
+
justifyContent: 'center',
|
|
97
|
+
marginRight: -4,
|
|
98
|
+
color: react_components_1.tokens.colorNeutralForeground2,
|
|
99
|
+
}, children: (0, jsx_runtime_1.jsx)(icons_1.Icons.Clock, { size: 20 }) }) })] }));
|
|
100
|
+
}
|
|
101
|
+
function resolveTimeValue(value, timeFormat) {
|
|
102
|
+
if (!value) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const time = (0, dayjs_1.default)(value, timeFormat);
|
|
106
|
+
if (!time.isValid()) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
return time.toDate();
|
|
29
110
|
}
|
|
@@ -5,8 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
/* eslint-disable unused-imports/no-unused-vars */
|
|
6
6
|
const react_components_1 = require("@fluentui/react-components");
|
|
7
7
|
function IntegerControl({ value, onChange, id, name, onBlur, onFocus, error, disabled, placeholder, borderOnFocusOnly, readOnly, }) {
|
|
8
|
-
|
|
9
|
-
return ((0, jsx_runtime_1.jsx)(react_components_1.SpinButton, { appearance: "filled-darker", placeholder: placeholder, id: id, name: name, value: value, onChange: (e, data) => {
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.SpinButton, { appearance: "filled-darker", placeholder: placeholder, id: id, name: name, value: value !== null && value !== void 0 ? value : null, onChange: (e, data) => {
|
|
10
9
|
if (data.value !== undefined) {
|
|
11
10
|
onChange === null || onChange === void 0 ? void 0 : onChange(data.value);
|
|
12
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@headless-adminapp/fluent",
|
|
3
|
-
"version": "0.0.17-alpha.
|
|
3
|
+
"version": "0.0.17-alpha.48",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -29,8 +29,9 @@
|
|
|
29
29
|
"license": "ISC",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@fluentui/react-components": "9.54.4",
|
|
32
|
-
"@fluentui/react-datepicker-compat": "
|
|
33
|
-
"@fluentui/react-nav-preview": "
|
|
32
|
+
"@fluentui/react-datepicker-compat": "0.4.43",
|
|
33
|
+
"@fluentui/react-nav-preview": "0.5.1",
|
|
34
|
+
"@fluentui/react-timepicker-compat": "0.2.46",
|
|
34
35
|
"@hookform/resolvers": "^3.9.0",
|
|
35
36
|
"@tanstack/react-query": "5.51.1",
|
|
36
37
|
"@tanstack/react-table": "^8.20.1",
|
|
@@ -48,5 +49,5 @@
|
|
|
48
49
|
"uuid": "11.0.3",
|
|
49
50
|
"yup": "^1.4.0"
|
|
50
51
|
},
|
|
51
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "e8887232802a525648c316b2b8526b2571bc8b8c"
|
|
52
53
|
}
|