@headless-adminapp/fluent 0.0.17-alpha.22 → 0.0.17-alpha.24

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);
@@ -76,6 +76,19 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
76
76
  const { currency, dateFormats } = (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: 'mixed', as: 'th', style: {
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();
@@ -235,5 +256,6 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
235
256
  recordSetSetter,
236
257
  router,
237
258
  mutableContextCommandState,
259
+ headingSelectionState,
238
260
  ]);
239
261
  }
@@ -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* () {
@@ -27,7 +27,7 @@ const Item = ({ item, toasterId, }) => {
27
27
  return;
28
28
  }
29
29
  opened.current = true;
30
- dispatchToast((0, jsx_runtime_1.jsxs)(react_components_1.Toast, { children: [(0, jsx_runtime_1.jsx)(react_components_1.ToastTitle, { children: item.title }), (0, jsx_runtime_1.jsx)(react_components_1.ToastBody, { children: item.text }), !!((_a = item.actions) === null || _a === void 0 ? void 0 : _a.length) && ((0, jsx_runtime_1.jsx)(react_components_1.ToastFooter, { children: item.actions.map((action, index) => ((0, jsx_runtime_1.jsx)(react_components_1.Link, { onClick: action.onClick, children: action.text }, index))) }))] }), {
30
+ dispatchToast((0, jsx_runtime_1.jsxs)(react_components_1.Toast, { children: [!!item.title && (0, jsx_runtime_1.jsx)(react_components_1.ToastTitle, { children: item.title }), (0, jsx_runtime_1.jsx)(react_components_1.ToastBody, { children: item.text }), !!((_a = item.actions) === null || _a === void 0 ? void 0 : _a.length) && ((0, jsx_runtime_1.jsx)(react_components_1.ToastFooter, { children: item.actions.map((action, index) => ((0, jsx_runtime_1.jsx)(react_components_1.Link, { onClick: action.onClick, children: action.text }, index))) }))] }), {
31
31
  timeout: 2000,
32
32
  intent: item.type,
33
33
  pauseOnHover: true,
@@ -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
- // value={option}
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)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@headless-adminapp/fluent",
3
- "version": "0.0.17-alpha.22",
3
+ "version": "0.0.17-alpha.24",
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": "a6d5c09c93ce38a63c40db11e217000bb2276c99"
47
+ "gitHead": "3280eb0e29b7a026f0251771f564b33c123c9bec"
48
48
  }