@headless-adminapp/fluent 0.0.17-alpha.22 → 0.0.17-alpha.25
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.
|
@@ -38,7 +38,7 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
38
38
|
const [, setSorting] = (0, hooks_1.useGridSorting)();
|
|
39
39
|
const schema = (0, hooks_1.useDataGridSchema)();
|
|
40
40
|
const { schemaStore } = (0, hooks_3.useMetadata)();
|
|
41
|
-
const [, setSelectedIds] = (0, hooks_1.useGridSelection)();
|
|
41
|
+
const [selectedIds, setSelectedIds] = (0, hooks_1.useGridSelection)();
|
|
42
42
|
const setSelectedIdsRef = (0, react_1.useRef)(setSelectedIds);
|
|
43
43
|
setSelectedIdsRef.current = setSelectedIds;
|
|
44
44
|
const isSubgrid = (0, mutable_1.useContextSelector)(datagrid_1.GridContext, (state) => state.isSubGrid);
|
|
@@ -73,9 +73,22 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
73
73
|
const router = (0, hooks_5.useRouter)();
|
|
74
74
|
const recordSetSetter = (0, hooks_4.useRecordSetSetter)();
|
|
75
75
|
const openRecord = (0, useOpenRecord_1.useOpenRecord)();
|
|
76
|
-
const { currency, dateFormats } = (0, locale_1.useLocale)();
|
|
76
|
+
const { currency, dateFormats, timezone } = (0, locale_1.useLocale)();
|
|
77
77
|
const dataRef = (0, react_1.useRef)(data);
|
|
78
78
|
dataRef.current = data;
|
|
79
|
+
const headingSelectionState = (0, react_1.useMemo)(() => {
|
|
80
|
+
var _a;
|
|
81
|
+
if ((data === null || data === void 0 ? void 0 : data.records.length) === 0) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
if (selectedIds.length === 0) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
if (selectedIds.length === ((_a = dataRef.current) === null || _a === void 0 ? void 0 : _a.records.length)) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
return 'mixed';
|
|
91
|
+
}, [data === null || data === void 0 ? void 0 : data.records.length, selectedIds]);
|
|
79
92
|
return (0, react_1.useMemo)(() => {
|
|
80
93
|
return [
|
|
81
94
|
...(disableSelection
|
|
@@ -83,7 +96,7 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
83
96
|
: [
|
|
84
97
|
columnHelper.accessor((info) => info[schema.idAttribute], {
|
|
85
98
|
id: '$selectColumn',
|
|
86
|
-
header: () => ((0, jsx_runtime_1.jsx)(react_components_1.TableSelectionCell, { checked:
|
|
99
|
+
header: () => ((0, jsx_runtime_1.jsx)(react_components_1.TableSelectionCell, { checked: headingSelectionState, as: 'th', style: {
|
|
87
100
|
position: 'sticky',
|
|
88
101
|
display: 'flex',
|
|
89
102
|
left: 0,
|
|
@@ -93,6 +106,14 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
93
106
|
width: 32,
|
|
94
107
|
maxWidth: 32,
|
|
95
108
|
minWidth: 32,
|
|
109
|
+
}, onClick: () => {
|
|
110
|
+
setSelectedIdsRef.current((ids) => {
|
|
111
|
+
var _a, _b, _c;
|
|
112
|
+
if (ids.length === ((_a = dataRef.current) === null || _a === void 0 ? void 0 : _a.records.length)) {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
return ((_c = (_b = dataRef.current) === null || _b === void 0 ? void 0 : _b.records.map((record) => record[schema.idAttribute])) !== null && _c !== void 0 ? _c : []);
|
|
116
|
+
});
|
|
96
117
|
} })),
|
|
97
118
|
cell: (info) => ((0, jsx_runtime_1.jsx)(react_components_1.TableSelectionCell, { className: (0, react_components_1.mergeClasses)(styles.selectionCell), checked: info.row.getIsSelected(), onClick: (event) => {
|
|
98
119
|
event.preventDefault();
|
|
@@ -148,6 +169,7 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
148
169
|
const formattedValue = (_c = (0, utils_1.getAttributeFormattedValue)(attribute, value, {
|
|
149
170
|
currency: currency.currency,
|
|
150
171
|
dateFormat: dateFormats.short,
|
|
172
|
+
timezone,
|
|
151
173
|
})) !== null && _c !== void 0 ? _c : '';
|
|
152
174
|
if (schema.primaryAttribute === column.name) {
|
|
153
175
|
const path = routeResolver({
|
|
@@ -235,5 +257,7 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
235
257
|
recordSetSetter,
|
|
236
258
|
router,
|
|
237
259
|
mutableContextCommandState,
|
|
260
|
+
headingSelectionState,
|
|
261
|
+
timezone,
|
|
238
262
|
]);
|
|
239
263
|
}
|
|
@@ -74,7 +74,7 @@ function PromptDialog(props) {
|
|
|
74
74
|
: '';
|
|
75
75
|
return ((0, jsx_runtime_1.jsx)(SectionControl_1.SectionControlWrapper, { label: attribute.label, labelPosition: "left", required: attribute.required, isError: isError, errorMessage: errorMessage, children: (0, jsx_runtime_1.jsx)(StandardControl_1.StandardControl, { attribute: attribute, name: attributeName, value: field.value, onChange: field.onChange, onBlur: field.onBlur, errorMessage: errorMessage, isError: isError }) }));
|
|
76
76
|
} }, attributeName));
|
|
77
|
-
}) })] }), (0, jsx_runtime_1.jsxs)(react_components_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "secondary", onClick: () => {
|
|
77
|
+
}) })] }), (0, jsx_runtime_1.jsxs)(react_components_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "secondary", type: "button", onClick: () => {
|
|
78
78
|
var _a;
|
|
79
79
|
(_a = props.onCancel) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
80
80
|
}, children: (_a = props.cancelText) !== null && _a !== void 0 ? _a : 'Cancel' }), (0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "primary", disabled: form.formState.submitCount > 0 && !form.formState.isValid, onClick: () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -49,22 +49,20 @@ const AttachmentsControl = ({ onChange, id, onBlur, onFocus, disabled, readOnly,
|
|
|
49
49
|
flexWrap: 'wrap',
|
|
50
50
|
columnGap: react_components_1.tokens.spacingHorizontalXS,
|
|
51
51
|
gap: react_components_1.tokens.spacingHorizontalXS,
|
|
52
|
-
}, children: [value === null || value === void 0 ? void 0 : value.map((file, index) => ((0, jsx_runtime_1.jsx)(react_components_1.Tag, { as: "span", appearance: "brand", size: "small", shape: "rounded",
|
|
53
|
-
|
|
54
|
-
dismissible: true, dismissIcon: (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', cursor: 'pointer' }, onClick: () => {
|
|
55
|
-
if (readOnly)
|
|
52
|
+
}, children: [value === null || value === void 0 ? void 0 : value.map((file, index) => ((0, jsx_runtime_1.jsx)(react_components_1.Tag, { as: "span", appearance: "brand", size: "small", shape: "rounded", dismissible: !disabled && !readOnly, dismissIcon: (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', cursor: 'pointer' }, onClick: () => {
|
|
53
|
+
if (disabled || readOnly)
|
|
56
54
|
return;
|
|
57
55
|
onChange === null || onChange === void 0 ? void 0 : onChange(value === null || value === void 0 ? void 0 : value.filter((_, i) => i !== index));
|
|
58
56
|
}, children: (0, jsx_runtime_1.jsx)(icons_1.Icons.Close, { size: 16 }) }), children: (0, jsx_runtime_1.jsx)(react_components_1.Link, { href: file.url, target: "_blank", onClick: (event) => {
|
|
59
57
|
event.preventDefault();
|
|
60
58
|
event.stopPropagation();
|
|
61
59
|
window.open(file.url, '_blank');
|
|
62
|
-
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { overflow: 'hidden', textOverflow: 'ellipsis' }, children: file.name }) }) }, index))), (0, jsx_runtime_1.jsx)(react_components_1.Button, { size: "small", icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.Add, { size: 16 }), appearance: "outline", onClick: () => {
|
|
60
|
+
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { overflow: 'hidden', textOverflow: 'ellipsis' }, children: file.name }) }) }, index))), !readOnly && !disabled && ((0, jsx_runtime_1.jsx)(react_components_1.Button, { size: "small", icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.Add, { size: 16 }), appearance: "outline", onClick: () => {
|
|
63
61
|
var _a;
|
|
64
62
|
if (readOnly)
|
|
65
63
|
return;
|
|
66
64
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
67
|
-
}, children: "Add" })] }) }), (0, jsx_runtime_1.jsx)(react_components_1.TagPickerList, {})] }), (0, jsx_runtime_1.jsx)("input", { ref: inputRef, type: "file", multiple: true, style: { display: 'none' }, onChange: (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
+
}, children: "Add" }))] }) }), (0, jsx_runtime_1.jsx)(react_components_1.TagPickerList, {})] }), (0, jsx_runtime_1.jsx)("input", { ref: inputRef, type: "file", multiple: true, style: { display: 'none' }, onChange: (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
68
66
|
const files = event.target.files;
|
|
69
67
|
if (files === null || files === void 0 ? void 0 : files.length) {
|
|
70
68
|
const fileObjects = yield Promise.all(Array.from(files).map((file) => fileToObject(file)));
|
|
@@ -8,14 +8,18 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
8
8
|
const react_datepicker_compat_1 = require("@fluentui/react-datepicker-compat");
|
|
9
9
|
const locale_1 = require("@headless-adminapp/app/locale");
|
|
10
10
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
11
|
+
const timezone_1 = __importDefault(require("dayjs/plugin/timezone"));
|
|
12
|
+
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
11
13
|
const AppStringContext_1 = require("../../App/AppStringContext");
|
|
14
|
+
dayjs_1.default.extend(utc_1.default);
|
|
15
|
+
dayjs_1.default.extend(timezone_1.default);
|
|
12
16
|
function DateControl({ value, onChange, id, name, onBlur, onFocus, placeholder, disabled, readOnly, }) {
|
|
13
|
-
const { dateFormats } = (0, locale_1.useLocale)();
|
|
17
|
+
const { dateFormats, timezone } = (0, locale_1.useLocale)();
|
|
14
18
|
const { datePickerStrings } = (0, AppStringContext_1.useAppStrings)();
|
|
15
19
|
return ((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",
|
|
16
20
|
// size="sm"
|
|
17
21
|
// error={error}
|
|
18
22
|
// maxDate={maxDate}
|
|
19
23
|
// minDate={minDate}
|
|
20
|
-
disabled: disabled, readOnly: readOnly, formatDate: (date) =>
|
|
24
|
+
disabled: disabled, readOnly: readOnly, formatDate: (date) => date ? (0, dayjs_1.default)(date).tz(timezone).format(dateFormats.short) : '', value: value ? new Date(value) : null, onSelectDate: (date) => onChange === null || onChange === void 0 ? void 0 : onChange(date ? (0, dayjs_1.default)(date).tz(timezone).startOf('day').toISOString() : null), strings: datePickerStrings }));
|
|
21
25
|
}
|
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.25",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"react-hook-form": "7.52.2",
|
|
45
45
|
"yup": "^1.4.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "0a42b982d6113067cd2f9739ec646d138c1a5274"
|
|
48
48
|
}
|