namirasoft-account-react 1.4.418 → 1.4.421

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.
Files changed (74) hide show
  1. package/dist/IEntityInfo.d.ts +3 -1
  2. package/dist/NSACacheService.d.ts +3 -0
  3. package/dist/NSACacheService.js +13 -0
  4. package/dist/NSACacheService.js.map +1 -1
  5. package/dist/NSAFilterOperators.d.ts +28 -0
  6. package/dist/NSAFilterOperators.js +50 -0
  7. package/dist/NSAFilterOperators.js.map +1 -0
  8. package/dist/components/NSAQuickFilter/NSAFilterBoxBase.d.ts +14 -0
  9. package/dist/components/NSAQuickFilter/NSAFilterBoxBase.js +40 -0
  10. package/dist/components/NSAQuickFilter/NSAFilterBoxBase.js.map +1 -0
  11. package/dist/components/NSAQuickFilter/NSAFilterBoxBoolean.d.ts +12 -0
  12. package/dist/components/NSAQuickFilter/NSAFilterBoxBoolean.js +30 -0
  13. package/dist/components/NSAQuickFilter/NSAFilterBoxBoolean.js.map +1 -0
  14. package/dist/components/NSAQuickFilter/NSAFilterBoxDate.d.ts +12 -0
  15. package/dist/components/NSAQuickFilter/NSAFilterBoxDate.js +58 -0
  16. package/dist/components/NSAQuickFilter/NSAFilterBoxDate.js.map +1 -0
  17. package/dist/components/NSAQuickFilter/NSAFilterBoxDateTime.d.ts +12 -0
  18. package/dist/components/NSAQuickFilter/NSAFilterBoxDateTime.js +58 -0
  19. package/dist/components/NSAQuickFilter/NSAFilterBoxDateTime.js.map +1 -0
  20. package/dist/components/NSAQuickFilter/NSAFilterBoxEnum.d.ts +22 -0
  21. package/dist/components/NSAQuickFilter/NSAFilterBoxEnum.js +52 -0
  22. package/dist/components/NSAQuickFilter/NSAFilterBoxEnum.js.map +1 -0
  23. package/dist/components/NSAQuickFilter/NSAFilterBoxNumber.d.ts +22 -0
  24. package/dist/components/NSAQuickFilter/NSAFilterBoxNumber.js +67 -0
  25. package/dist/components/NSAQuickFilter/NSAFilterBoxNumber.js.map +1 -0
  26. package/dist/components/NSAQuickFilter/NSAFilterBoxString.d.ts +13 -0
  27. package/dist/components/NSAQuickFilter/NSAFilterBoxString.js +47 -0
  28. package/dist/components/NSAQuickFilter/NSAFilterBoxString.js.map +1 -0
  29. package/dist/components/NSAQuickFilter/NSAFilterBoxTime.d.ts +12 -0
  30. package/dist/components/NSAQuickFilter/NSAFilterBoxTime.js +58 -0
  31. package/dist/components/NSAQuickFilter/NSAFilterBoxTime.js.map +1 -0
  32. package/dist/components/NSAQuickFilter/NSAQuickFilterBar.d.ts +28 -0
  33. package/dist/components/NSAQuickFilter/NSAQuickFilterBar.js +74 -0
  34. package/dist/components/NSAQuickFilter/NSAQuickFilterBar.js.map +1 -0
  35. package/dist/components/NSAQuickFilter/NSAQuickFilterDialog.d.ts +43 -0
  36. package/dist/components/NSAQuickFilter/NSAQuickFilterDialog.js +114 -0
  37. package/dist/components/NSAQuickFilter/NSAQuickFilterDialog.js.map +1 -0
  38. package/dist/components/NSAReorderDialog.d.ts +30 -0
  39. package/dist/components/NSAReorderDialog.js +69 -0
  40. package/dist/components/NSAReorderDialog.js.map +1 -0
  41. package/dist/components/NSAReorderDialog.module.css +50 -0
  42. package/dist/components/NSASortDialog.d.ts +21 -0
  43. package/dist/components/NSASortDialog.js +61 -0
  44. package/dist/components/NSASortDialog.js.map +1 -0
  45. package/dist/components/NSATable.d.ts +95 -0
  46. package/dist/components/NSATable.js +335 -0
  47. package/dist/components/NSATable.js.map +1 -0
  48. package/dist/layouts/NSASectionList.d.ts +7 -37
  49. package/dist/layouts/NSASectionList.js +17 -247
  50. package/dist/layouts/NSASectionList.js.map +1 -1
  51. package/dist/layouts/NSASectionList.module.css +15 -18
  52. package/package.json +2 -2
  53. package/src/IEntityInfo.ts +3 -1
  54. package/src/NSACacheService.ts +20 -0
  55. package/src/NSAFilterOperators.ts +93 -0
  56. package/src/components/NSAQuickFilter/NSAFilterBoxBase.tsx +56 -0
  57. package/src/components/NSAQuickFilter/NSAFilterBoxBoolean.tsx +55 -0
  58. package/src/components/NSAQuickFilter/NSAFilterBoxDate.tsx +105 -0
  59. package/src/components/NSAQuickFilter/NSAFilterBoxDateTime.tsx +106 -0
  60. package/src/components/NSAQuickFilter/NSAFilterBoxEnum.module.css +45 -0
  61. package/src/components/NSAQuickFilter/NSAFilterBoxEnum.tsx +80 -0
  62. package/src/components/NSAQuickFilter/NSAFilterBoxNumber.tsx +137 -0
  63. package/src/components/NSAQuickFilter/NSAFilterBoxString.tsx +82 -0
  64. package/src/components/NSAQuickFilter/NSAFilterBoxTime.tsx +102 -0
  65. package/src/components/NSAQuickFilter/NSAQuickFilterBar.module.css +20 -0
  66. package/src/components/NSAQuickFilter/NSAQuickFilterBar.tsx +115 -0
  67. package/src/components/NSAQuickFilter/NSAQuickFilterDialog.module.css +75 -0
  68. package/src/components/NSAQuickFilter/NSAQuickFilterDialog.tsx +261 -0
  69. package/src/components/NSAReorderDialog.module.css +50 -0
  70. package/src/components/NSAReorderDialog.tsx +150 -0
  71. package/src/components/NSASortDialog.tsx +118 -0
  72. package/src/components/NSATable.tsx +490 -0
  73. package/src/layouts/NSASectionList.module.css +15 -18
  74. package/src/layouts/NSASectionList.tsx +43 -395
@@ -0,0 +1,150 @@
1
+ import { NSBox, NSButtonBlue, NSColumn, NSDialog, NSTitle, TableColumnInfo } from "namirasoft-site-react";
2
+ import { Component, DragEvent } from "react";
3
+ import Styles from "./NSAReorderDialog.module.css";
4
+
5
+ interface ColumnItem
6
+ {
7
+ key: string;
8
+ text: string;
9
+ checked: boolean;
10
+ }
11
+
12
+ interface NSAReorderDialogProps
13
+ {
14
+ visibleColumnKeys: string[];
15
+ getColumns: () => TableColumnInfo[];
16
+ onCancel: () => void;
17
+ onApply: (orderedKeys: string[]) => void;
18
+ }
19
+
20
+ interface NSAReorderDialogState
21
+ {
22
+ columns: ColumnItem[];
23
+ dragFromIndex: number | null;
24
+ dragOverIndex: number | null;
25
+ }
26
+
27
+ export class NSAReorderDialog extends Component<NSAReorderDialogProps, NSAReorderDialogState>
28
+ {
29
+ constructor(props: NSAReorderDialogProps)
30
+ {
31
+ super(props);
32
+ this.state = {
33
+ columns: this.buildColumnItems(props),
34
+ dragFromIndex: null,
35
+ dragOverIndex: null
36
+ };
37
+ }
38
+
39
+ private buildColumnItems(props: NSAReorderDialogProps): ColumnItem[]
40
+ {
41
+ const allColumns = props.getColumns();
42
+ const visibleKeys = props.visibleColumnKeys;
43
+
44
+ if (visibleKeys.length === 0)
45
+ return allColumns.map(c => ({ key: c.table.name + "." + c.name, text: c.text, checked: true }));
46
+
47
+ const visibleItems: ColumnItem[] = visibleKeys
48
+ .map(k => allColumns.find(c => c.table.name + "." + c.name === k))
49
+ .filter(Boolean)
50
+ .map(c => ({ key: c!.table.name + "." + c!.name, text: c!.text, checked: true }));
51
+
52
+ const hiddenItems: ColumnItem[] = allColumns
53
+ .filter(c => !visibleKeys.includes(c.table.name + "." + c.name))
54
+ .map(c => ({ key: c.table.name + "." + c.name, text: c.text, checked: false }));
55
+
56
+ return [...visibleItems, ...hiddenItems];
57
+ }
58
+
59
+ private onDragStart = (index: number) => this.setState({ dragFromIndex: index });
60
+
61
+ private onDragOver = (e: DragEvent, index: number) =>
62
+ {
63
+ e.preventDefault();
64
+ if (this.state.dragOverIndex !== index)
65
+ this.setState({ dragOverIndex: index });
66
+ };
67
+
68
+ private onDrop = (e: DragEvent, dropIndex: number) =>
69
+ {
70
+ e.preventDefault();
71
+ const { dragFromIndex, columns } = this.state;
72
+ if (dragFromIndex === null || dragFromIndex === dropIndex)
73
+ {
74
+ this.setState({ dragFromIndex: null, dragOverIndex: null });
75
+ return;
76
+ }
77
+ const next = [...columns];
78
+ const [moved] = next.splice(dragFromIndex, 1);
79
+ next.splice(dropIndex, 0, moved);
80
+ this.setState({ columns: next, dragFromIndex: null, dragOverIndex: null });
81
+ };
82
+
83
+ private onDragEnd = () => this.setState({ dragFromIndex: null, dragOverIndex: null });
84
+
85
+ private toggleChecked = (key: string) =>
86
+ this.setState(prev => ({
87
+ columns: prev.columns.map(c => c.key === key ? { ...c, checked: !c.checked } : c)
88
+ }));
89
+
90
+ private handleApply = () =>
91
+ {
92
+ const orderedKeys = this.state.columns.filter(c => c.checked).map(c => c.key);
93
+ this.props.onApply(orderedKeys);
94
+ };
95
+
96
+ override render()
97
+ {
98
+ const { onCancel } = this.props;
99
+ const { columns, dragFromIndex, dragOverIndex } = this.state;
100
+
101
+ return (
102
+ <NSDialog
103
+ center_dialog
104
+ closeButton={{ show: true }}
105
+ onClose={onCancel}
106
+ style={{ minWidth: NSBox.width.double }}
107
+ >
108
+ <NSColumn classList={["align-items-center"]}>
109
+ <NSTitle title="Columns" style={{ marginBottom: 0, fontSize: 24 }} />
110
+ <NSColumn classList={["gap-1"]}>
111
+ {
112
+ columns.map((col, index) =>
113
+ {
114
+ const isDragging = dragFromIndex === index;
115
+ const isDragOver = dragOverIndex === index && !isDragging;
116
+ let cls = Styles.column_item;
117
+ if (isDragging) cls += " " + Styles.column_item_dragging;
118
+ if (isDragOver) cls += " " + Styles.column_item_drag_over;
119
+ return (
120
+ <div
121
+ key={col.key}
122
+ draggable
123
+ onDragStart={() => this.onDragStart(index)}
124
+ onDragOver={e => this.onDragOver(e, index)}
125
+ onDrop={e => this.onDrop(e, index)}
126
+ onDragEnd={this.onDragEnd}
127
+ className={cls}
128
+ >
129
+ <span className={Styles.drag_handle}>⠿</span>
130
+ <input
131
+ type="checkbox"
132
+ checked={col.checked}
133
+ onChange={() => this.toggleChecked(col.key)}
134
+ className={Styles.checkbox}
135
+ />
136
+ <span className={Styles.column_label}>{col.text}</span>
137
+ </div>
138
+ );
139
+ })
140
+ }
141
+ </NSColumn>
142
+ <NSButtonBlue
143
+ title="Apply"
144
+ onClick={{ action: this.handleApply, showLoading: false }}
145
+ />
146
+ </NSColumn>
147
+ </NSDialog>
148
+ );
149
+ }
150
+ }
@@ -0,0 +1,118 @@
1
+ import { BaseMetaColumn, BaseMetaTable, SortItem } from "namirasoft-core";
2
+ import { NSBoxBaseCombo, NSBoxBoolean, NSBoxCombo, NSButtonBlue, NSColumn, NSDialog, NSTitle, TableColumnInfo } from "namirasoft-site-react";
3
+ import { Component, createRef } from "react";
4
+
5
+ interface NSASortDialogProps
6
+ {
7
+ sorts: SortItem[];
8
+ getColumns: () => TableColumnInfo[];
9
+ onCancel: () => void;
10
+ onApply: (sorts: SortItem[] | null) => void;
11
+ }
12
+
13
+ interface NSASortDialogState
14
+ {
15
+ sortEnabled: boolean;
16
+ }
17
+
18
+ export class NSASortDialog extends Component<NSASortDialogProps, NSASortDialogState>
19
+ {
20
+ private sortBoolRef = createRef<NSBoxBoolean>();
21
+ private sortColumnRef = createRef<NSBoxBaseCombo<TableColumnInfo>>();
22
+ private sortDirectionRef = createRef<NSBoxCombo>();
23
+
24
+ constructor(props: NSASortDialogProps)
25
+ {
26
+ super(props);
27
+ this.state = { sortEnabled: props.sorts.length > 0 };
28
+ }
29
+
30
+ private handleApply = () =>
31
+ {
32
+ if (!this.sortBoolRef.current?.getValueBool())
33
+ {
34
+ this.props.onApply(null);
35
+ return;
36
+ }
37
+ const column = this.sortColumnRef.current?.getDataOne();
38
+ const direction = this.sortDirectionRef.current?.getValueOne();
39
+ if (column)
40
+ {
41
+ const t = new BaseMetaTable(null, column.table.name, column.table.text);
42
+ const c = new BaseMetaColumn(t, column.name, column.text, "", true);
43
+ const sort = new SortItem(t, c, direction === "true");
44
+ this.props.onApply([sort]);
45
+ }
46
+ else
47
+ this.props.onApply(null);
48
+ };
49
+
50
+ override render()
51
+ {
52
+ const { sorts, getColumns, onCancel } = this.props;
53
+
54
+ return (
55
+ <NSDialog
56
+ center_dialog
57
+ closeButton={{ show: true }}
58
+ onClose={onCancel}
59
+ >
60
+ <NSTitle title="Sort" style={{ marginBottom: 0, fontSize: 24 }} />
61
+ <NSColumn classList={["align-items-center mt-3"]}>
62
+ <NSBoxBoolean
63
+ ref={this.sortBoolRef}
64
+ required
65
+ title="Sort"
66
+ hideHeader={true}
67
+ checked={sorts.length > 0}
68
+ onChanged={() => this.setState(prev => ({ sortEnabled: !prev.sortEnabled }))}
69
+ />
70
+ <NSBoxBaseCombo<TableColumnInfo>
71
+ ref={this.sortColumnRef}
72
+ title="Column"
73
+ required
74
+ defaultValue={sorts[0]?.column.name}
75
+ getItems={async () =>
76
+ {
77
+ const cs = getColumns();
78
+ return { count: cs.length, rows: cs }
79
+ }}
80
+ getTitle={c => c.text}
81
+ getValue={c => c.name}
82
+ getSort={() => null}
83
+ multiple={false}
84
+ disabled={this.state.sortEnabled}
85
+ menu={{
86
+ builtin: {
87
+ copy: { enabled: false, getValue: () => "" }
88
+ },
89
+ items: []
90
+ }}
91
+ />
92
+ <NSBoxCombo
93
+ ref={this.sortDirectionRef}
94
+ title="Direction"
95
+ required
96
+ defaultValue={sorts[0]?.ascending + ""}
97
+ getOptions={() => [
98
+ { value: "true", title: "Ascending" },
99
+ { value: "false", title: "Descending" }
100
+ ]}
101
+ multiple={false}
102
+ disabled={this.state.sortEnabled}
103
+ menu={{
104
+ builtin: {
105
+ copy: { enabled: false, getValue: () => "" }
106
+ },
107
+ items: []
108
+ }}
109
+ />
110
+ <NSButtonBlue
111
+ title="Apply"
112
+ onClick={{ action: this.handleApply, showLoading: false }}
113
+ />
114
+ </NSColumn>
115
+ </NSDialog>
116
+ );
117
+ }
118
+ }