aio-entitykit 1.0.0 → 2.0.1

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 (5) hide show
  1. package/d1.css +177 -45
  2. package/index.css +81 -0
  3. package/package.json +1 -1
  4. package/index.d.ts +0 -91
  5. package/index.js +0 -240
package/d1.css CHANGED
@@ -9,12 +9,12 @@
9
9
  --d1-gray-grad: linear-gradient(0deg, #343434, #727272);
10
10
  --d1-cream: #ffe29d;
11
11
  --d1-active: #ffe29d;
12
+ --d1-active-grad: linear-gradient(180deg, #f7e5b3, #9a7e2f);
12
13
  --d1-cream-grad: linear-gradient(180deg, rgb(226 188 80), rgb(67 60 37));
13
- --d1-active-grad: linear-gradient(0deg, #0c2e5e, #034eb9);
14
14
  --d1-green: #04ff69;
15
- --d1-green-grad: linear-gradient(0deg, #005d10, #04ff69);
16
- --d1-orange: #ffc800;
17
- --d1-orange-grad: linear-gradient(0deg, #8f4300, #ffc800);
15
+ --d1-green-grad: linear-gradient(0deg, #007414, #1dd11f);
16
+ --d1-orange: #ff8900;
17
+ --d1-orange-grad: linear-gradient(0deg, #7a3900, #ff8900);
18
18
  --d1-white: #dfdfdf;
19
19
  --d1-white-grad: linear-gradient(0deg, #888, #fff);
20
20
  --d1-text-in-dark: #ddd;
@@ -34,13 +34,25 @@
34
34
  --d1-text-medium: #acacac;
35
35
  --d1-text-light: #e7e7e7;
36
36
  --d1-text-dark: #383838;
37
- --d1-bg-dark-1: rgba(0, 0, 0, 0.1);
38
- --d1-bg-dark-2: rgba(0, 0, 0, 0.2);
39
- --d1-bg-dark-3: rgba(0, 0, 0, 0.3);
40
- --d1-bg-dark-4: rgba(0, 0, 0, 0.4);
41
- --d1-bg-dark-5: rgba(0, 0, 0, 0.5);
42
- --d1-bg-dark-6: rgba(0, 0, 0, 0.6);
43
- --active-grd: linear-gradient(0deg, #3e5701, #a2df0d);
37
+ --d1-bg-dark-05: rgba(0, 0, 0, 0.05);
38
+ --d1-bg-dark-10: rgba(0, 0, 0, 0.10);
39
+ --d1-bg-dark-15: rgba(0, 0, 0, 0.15);
40
+ --d1-bg-dark-20: rgba(0, 0, 0, 0.20);
41
+ --d1-bg-dark-25: rgba(0, 0, 0, 0.25);
42
+ --d1-bg-dark-30: rgba(0, 0, 0, 0.30);
43
+ --d1-bg-dark-35: rgba(0, 0, 0, 0.35);
44
+ --d1-bg-dark-40: rgba(0, 0, 0, 0.40);
45
+ --d1-bg-dark-45: rgba(0, 0, 0, 0.45);
46
+ --d1-bg-dark-50: rgba(0, 0, 0, 0.50);
47
+ --d1-bg-dark-55: rgba(0, 0, 0, 0.55);
48
+ --d1-bg-dark-60: rgba(0, 0, 0, 0.60);
49
+ --d1-bg-dark-65: rgba(0, 0, 0, 0.65);
50
+ --d1-bg-dark-70: rgba(0, 0, 0, 0.70);
51
+ --d1-bg-dark-75: rgba(0, 0, 0, 0.75);
52
+ --d1-bg-dark-80: rgba(0, 0, 0, 0.80);
53
+ --d1-bg-dark-85: rgba(0, 0, 0, 0.85);
54
+ --d1-bg-dark-90: rgba(0, 0, 0, 0.90);
55
+ --d1-bg-dark-95: rgba(0, 0, 0, 0.95);
44
56
  --d1-border-radius: 6px;
45
57
  }
46
58
 
@@ -49,35 +61,75 @@
49
61
  color: var(--d1-text-in-dark);
50
62
  }
51
63
 
52
- .d1 .d1-bg-dark-1 {
64
+ .d1 .d1-bg-dark- {
53
65
  background: var(--d1-bg-dark-1)
54
66
  }
55
67
 
56
- .d1 .d1-bg-dark-2 {
57
- background: var(--d1-bg-dark-2)
68
+ .d1 .d1-bg-dark-05 {
69
+ background: var(--d1-bg-dark-05)
58
70
  }
59
71
 
60
- .d1 .d1-bg-dark-3 {
61
- background: var(--d1-bg-dark-3)
72
+ .d1 .d1-bg-dark-10 {
73
+ background: var(--d1-bg-dark-10)
62
74
  }
63
-
64
- .d1 .d1-bg-dark-4 {
65
- background: var(--d1-bg-dark-4)
75
+ .d1 .d1-bg-dark-15 {
76
+ background: var(--d1-bg-dark-15)
66
77
  }
67
-
68
- .d1 .d1-bg-dark-5 {
69
- background: var(--d1-bg-dark-5)
78
+ .d1 .d1-bg-dark-20 {
79
+ background: var(--d1-bg-dark-20)
70
80
  }
71
-
72
- .d1 .d1-bg-dark-6 {
73
- background: var(--d1-bg-dark-6)
81
+ .d1 .d1-bg-dark-25 {
82
+ background: var(--d1-bg-dark-25)
83
+ }
84
+ .d1 .d1-bg-dark-30 {
85
+ background: var(--d1-bg-dark-30)
86
+ }
87
+ .d1 .d1-bg-dark-35 {
88
+ background: var(--d1-bg-dark-35)
89
+ }
90
+ .d1 .d1-bg-dark-40 {
91
+ background: var(--d1-bg-dark-40)
92
+ }
93
+ .d1 .d1-bg-dark-45 {
94
+ background: var(--d1-bg-dark-45)
95
+ }
96
+ .d1 .d1-bg-dark-50 {
97
+ background: var(--d1-bg-dark-50)
98
+ }
99
+ .d1 .d1-bg-dark-55 {
100
+ background: var(--d1-bg-dark-55)
101
+ }
102
+ .d1 .d1-bg-dark-60 {
103
+ background: var(--d1-bg-dark-60)
104
+ }
105
+ .d1 .d1-bg-dark-65 {
106
+ background: var(--d1-bg-dark-65)
107
+ }
108
+ .d1 .d1-bg-dark-70 {
109
+ background: var(--d1-bg-dark-70)
110
+ }
111
+ .d1 .d1-bg-dark-75 {
112
+ background: var(--d1-bg-dark-75)
113
+ }
114
+ .d1 .d1-bg-dark-80 {
115
+ background: var(--d1-bg-dark-80)
116
+ }
117
+ .d1 .d1-bg-dark-85 {
118
+ background: var(--d1-bg-dark-85)
119
+ }
120
+ .d1 .d1-bg-dark-90 {
121
+ background: var(--d1-bg-dark-90)
74
122
  }
123
+ .d1 .d1-bg-dark-95 {
124
+ background: var(--d1-bg-dark-95)
125
+ }
126
+
75
127
  .d1 .d1-border-medium {
76
- border: 1px solid var(--d1-border-medium)
128
+ border: 1px solid var(--d1-border-medium) !important;
77
129
  }
78
130
 
79
131
  .d1 .d1-border-light {
80
- border: 1px solid var(--d1-border-light)
132
+ border: 1px solid var(--d1-border-light) !important;
81
133
  }
82
134
 
83
135
  .d1 .d1-border-dark {
@@ -139,10 +191,7 @@
139
191
  }
140
192
 
141
193
  .d1 .ai-form .aio-input {
142
- border: none !important;
143
194
  color: var(--d1-text-in-dark) !important;
144
- background: var(--d1-black) !important;
145
- box-shadow: var(--shadow-dep) !important;
146
195
  border-radius: var(--d1-border-radius) !important;
147
196
  }
148
197
 
@@ -184,7 +233,9 @@
184
233
  box-shadow: var(--shadow-dep);
185
234
  margin: 4px 0;
186
235
  }
187
-
236
+ .d1 .ai-form-panel{
237
+ border:1px solid var(--d1-border-medium);
238
+ }
188
239
 
189
240
  .d1 .aio-input-switch-groove {
190
241
  background: var(--d1-black) !important;
@@ -201,8 +252,8 @@
201
252
 
202
253
  }
203
254
 
204
- .d1 .aio-input-switch-nutton.active {
205
- background: var(--active-grd);
255
+ .d1 .aio-input-switch-button.active {
256
+ background: var(--active-grad);
206
257
  }
207
258
 
208
259
  .d1 .aio-input-range {
@@ -225,7 +276,7 @@
225
276
  }
226
277
 
227
278
  .d1 .ai-range-point {
228
- background: var(--active-grd);
279
+ background: var(--d1-active-grad);
229
280
  box-shadow: var(--thumb-shadow);
230
281
  color: var(--d1-text-in-dark);
231
282
  }
@@ -338,7 +389,7 @@
338
389
 
339
390
  .d1 .d1-bg-green-grad {
340
391
  background: var(--d1-green-grad) !important;
341
- box-shadow: inset 0px 1px 0px 0px #a5ffb6;
392
+ box-shadow: inset 0px 1px 0px 0px #00e82c;
342
393
  color: #000 !important;
343
394
  }
344
395
 
@@ -413,20 +464,14 @@
413
464
  }
414
465
 
415
466
  .d1 .ai-indent-line {
416
- stroke: var(--d1-border-medium);
467
+ stroke: var(--d1-border-light);
417
468
  }
418
469
 
419
- .d1 .ai-toggle-icon:not(.ai-leaf-icon) {
420
- background: var(--d1-gray-grad);
421
- border-radius: 24px;
422
- width: 2em;
423
- height: 2em;
424
- box-shadow: var(--d1-shadow-1);
425
- }
470
+
426
471
 
427
472
  .d1 .aio-input-date-theme-active {
428
473
  background: var(--d1-active);
429
- color: #fff;
474
+ color: #666;
430
475
  }
431
476
 
432
477
  .d1 .aio-input-date-cell.today {
@@ -602,6 +647,17 @@
602
647
  color: #fff;
603
648
  border: none !important;
604
649
  }
650
+ .d1 .d1-panel{
651
+ display: flex;
652
+ flex-direction: column;
653
+ gap:1em;
654
+ border: 1px solid var(--d1-border-medium);
655
+ padding:0.4em;
656
+ padding-top:1.2em;
657
+ border-radius:0.4em;
658
+ width:100%;
659
+ position: relative;
660
+ }
605
661
 
606
662
  .d1 .d1-panel-label {
607
663
  font-weight: bold;
@@ -645,7 +701,6 @@
645
701
 
646
702
  .d1 .aio-input-tag {
647
703
  background: var(--d1-gray);
648
- color: #fff;
649
704
  border: none !important;
650
705
  }
651
706
 
@@ -779,4 +834,81 @@
779
834
  .ai-form-wizard-step-button:disabled,.ai-form-wizard-submit-button:disabled{
780
835
  cursor:pointer;
781
836
  opacity:0.5;
837
+ }
838
+ .d1 .entity-card{
839
+ background: var(--d1-active);
840
+ padding:0.5em;
841
+ display:flex;
842
+ flex-direction: column;
843
+ gap:0.5em;
844
+ border-radius:0.8em;
845
+ color:#333;
846
+ }
847
+ .d1 .entity-card-header{
848
+ display: flex;
849
+ align-items: center;
850
+ }
851
+ .d1 .entity-card-toggle-icon{
852
+ display: flex;
853
+ align-items: center;
854
+ justify-content: center;
855
+ width:24px;
856
+ height:30px;
857
+ }
858
+ .d1 .entity-card-title{
859
+ cursor: pointer;
860
+ flex:1;
861
+ font-weight:bold;
862
+ }
863
+ .d1 .entity-row{
864
+ display: flex;
865
+ flex-direction: column;
866
+ padding: 0.2em;
867
+ justify-content: center;
868
+ gap:0.4em;
869
+ }
870
+ .d1 .entity-row-header{
871
+ display: flex;
872
+ align-items: center;
873
+ }
874
+ .d1 .entity-table-deselect-all{
875
+ height:30px;
876
+ width: 30px;
877
+ display:flex;
878
+ align-items: center;
879
+ justify-content: center;
880
+ }
881
+ .d1 .entity-table-selected-options{
882
+ display: flex;
883
+ align-items: center;
884
+ justify-content: center;
885
+ }
886
+ .d1 .entity-table-today{
887
+ font-size:0.7em;
888
+ width:100%;
889
+ display: flex;
890
+ justify-content: center;
891
+ }
892
+ .d1 .entity-table .aio-table{
893
+ flex:1;
894
+ overflow: hidden;
895
+ }
896
+ .d1 .entity-table-toolbar{
897
+ display: flex;
898
+ align-items: center;
899
+ gap:3em;
900
+ font-size:0.8em;
901
+ }
902
+ .d1 .date-box{
903
+ display:flex;
904
+ align-items: center;
905
+ justify-content: center;
906
+ border-radius:1em;
907
+ cursor:pointer;
908
+ font-size:0.8em;
909
+ width:48px;
910
+ height:48px;
911
+ text-align: center;
912
+ border:1px solid var(--d1-border-medium);
913
+ padding:0;
782
914
  }
package/index.css ADDED
@@ -0,0 +1,81 @@
1
+ .date-filter{
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 0.5em;
5
+ padding: 0 0.5em;
6
+ padding-bottom:0.5em;
7
+ }
8
+ .date-filter-toolbar{
9
+ display:flex;
10
+ flex-direction: row;
11
+ align-items: center;
12
+ }
13
+ .date-filter-toolbar-buttons{
14
+ display:flex;
15
+ flex-direction: row;
16
+ gap: 0.5em;
17
+ }
18
+ .date-filter-input{
19
+ display:flex;
20
+ align-items: center;
21
+ justify-content: center;
22
+ border-radius: 0.4em;
23
+ cursor:pointer;
24
+ font-size: 1em;
25
+ width: 48px;
26
+ height: 48px;
27
+ text-align: center;
28
+ border:none;
29
+ }
30
+ .date-filter-result{
31
+ border:none;
32
+ border-radius: 0.4em;
33
+ padding:0 1em;
34
+ height:2.4em;
35
+ font-size:1em;
36
+ font-weight: bold;
37
+ background:linear-gradient(180deg, #f7e5b3, #9a7e2f);
38
+ }
39
+ .time-range{
40
+ display:flex;
41
+ flex-direction: row;
42
+ align-items: center;
43
+ border-radius: 0;
44
+ padding: 0;
45
+ border: 1px solid #444;
46
+ }
47
+ .time-range-splitter{
48
+ width: 1px;
49
+ background-color: #444;
50
+ height: 100%;
51
+ }
52
+ .time-range-input{
53
+ border:none;
54
+ font-size: 1em;
55
+ border-radius: 0;
56
+ background: none;
57
+ }
58
+ .card-row{
59
+ display: flex;
60
+ padding: 0.5em 0.75em;
61
+ margin: 0.25em 0;
62
+ border-radius: 0.4em;
63
+ align-items: center;
64
+ background:rgba(0,0,0,0.2);
65
+ }
66
+ .entity-row-title{
67
+ flex:1;
68
+ font-size:0.8em;
69
+ font-weight:bold;
70
+ }
71
+ .entity-table-selected{
72
+ padding:0 1em;
73
+ height:2.4em;
74
+ display:flex;
75
+ align-items: center;
76
+ color:orange;
77
+ }
78
+ .entity-card-title{
79
+ display:flex;
80
+ align-items: center;
81
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aio-entitykit",
3
- "version": "1.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "kit",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/index.d.ts DELETED
@@ -1,91 +0,0 @@
1
- import { type FC, type ReactNode } from "react";
2
- import { type I_table } from 'aio-table';
3
- import type { AIOCordova } from 'aio-cordova';
4
- import type { useEntity } from 'aio-entity';
5
- type I_option = {
6
- text: string;
7
- title?: string;
8
- show?: boolean;
9
- body?: () => ReactNode;
10
- onClick?: () => void;
11
- };
12
- type I_EntityTable<T> = {
13
- root?: boolean;
14
- popup?: any;
15
- cordova?: AIOCordova;
16
- io?: boolean;
17
- sideOptions?: {
18
- text: string;
19
- value: any;
20
- onClick?: () => void;
21
- before?: ReactNode;
22
- }[];
23
- header?: () => ReactNode;
24
- footer?: () => ReactNode;
25
- entity: ReturnType<typeof useEntity<T, any>>;
26
- table: Partial<I_table<T>>;
27
- attrs?: any;
28
- moveTo?: (moveFrom: T, moveTo: T) => boolean;
29
- getCardContent: (row: T, parent: T | false, type: 'root' | 'leaf' | 'node') => ReactNode;
30
- getCardOptions?: (row: T, parent: T | false) => I_option[];
31
- getRootOptions?: () => I_option[];
32
- getCardTitle: (row: T) => string;
33
- archive?: boolean;
34
- size?: number;
35
- };
36
- export declare const EntityTable: <T>(props: I_EntityTable<T>) => import("react/jsx-runtime").JSX.Element;
37
- export declare const Card: <T>({ row }: {
38
- row: T;
39
- index: number;
40
- }) => import("react/jsx-runtime").JSX.Element;
41
- type I_DateFilter = {
42
- result?: any;
43
- fromDate?: number;
44
- toDate?: number;
45
- onChange: (p: {
46
- fromDate?: number;
47
- toDate?: number;
48
- }) => void;
49
- };
50
- export declare const DateFilter: FC<I_DateFilter>;
51
- export declare const TimeRange: FC<{
52
- fromDate?: number;
53
- toDate?: number;
54
- onChange: (p: {
55
- fromDate?: number;
56
- toDate?: number;
57
- }) => void;
58
- }>;
59
- export declare const TimeInput: FC<{
60
- value?: number;
61
- onChange: (date: number) => void;
62
- disabled?: boolean;
63
- }>;
64
- export declare const CardRow: FC<{
65
- label: string;
66
- value: ReactNode;
67
- color?: string;
68
- onClick?: () => void;
69
- }>;
70
- export type I_CardRow = [label: string, value: ReactNode, config?: {
71
- isPrice?: boolean;
72
- onClick?: () => void;
73
- }];
74
- export declare const CardRows: FC<{
75
- rows: I_CardRow[];
76
- placeholder?: string;
77
- }>;
78
- export declare const CardBox: FC<{
79
- label: string;
80
- value: ReactNode;
81
- color?: string;
82
- onClick?: () => void;
83
- type: number;
84
- isPrice?: boolean;
85
- }>;
86
- export declare const Panel: FC<{
87
- label?: ReactNode;
88
- content: ReactNode;
89
- }>;
90
- export declare const dateStringToDateNumber: (dateNumber: number) => any;
91
- export {};
package/index.js DELETED
@@ -1,240 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { AIDate, AISelect, AITime, AITree } from 'aio-input';
3
- import { createContext, useContext, useState } from "react";
4
- import AIOTable from 'aio-table';
5
- import { AddToAttrs, GetSvg, SplitNumber, useSide } from 'aio-utils';
6
- import AIODate from 'aio-date';
7
- import Icon from '@mdi/react';
8
- import { mdiDownload, mdiListBox, mdiUpload } from "@mdi/js";
9
- const Context = createContext({});
10
- const Provider = ({ children, value }) => {
11
- return _jsx(Context.Provider, { value: value, children: children });
12
- };
13
- const useProvider = () => useContext(Context);
14
- export const EntityTable = (props) => {
15
- const DATE = new AIODate();
16
- const { table, moveTo, entity, popup, archive } = props;
17
- const [showArchive, setShowArchive] = useState(false);
18
- const { getId, filteredData, data } = entity;
19
- const [rowForMove, setRowForMove] = useState(undefined);
20
- const canMoveTo = (row) => {
21
- return !!moveTo && !!rowForMove && getId(rowForMove) !== getId(row);
22
- };
23
- const getOptionDetails = (options) => {
24
- return options.map((o) => {
25
- return {
26
- text: o.text, show: o.show,
27
- onClick: () => {
28
- if (o.body) {
29
- popup.addModal({ header: { title: o.title || o.text }, body: o.body() });
30
- }
31
- if (o.onClick) {
32
- o.onClick();
33
- }
34
- }
35
- };
36
- });
37
- };
38
- const getRootOptions = () => {
39
- const options = props.getRootOptions ? props.getRootOptions() : [];
40
- const res = [];
41
- if (props.archive) {
42
- res.push({
43
- text: showArchive ? 'مخفی سازی آرشیو' : 'نمایش آرشیو', onClick: () => {
44
- setShowArchive(!showArchive);
45
- }
46
- });
47
- }
48
- return [...options, ...res];
49
- };
50
- const getOptions = (row, parent) => {
51
- const options = props.getCardOptions ? props.getCardOptions(row, parent) : [];
52
- const res = getOptionDetails(options);
53
- return [
54
- ...res,
55
- {
56
- show: canMoveTo(row), text: 'انتقال به اینجا', onClick: () => {
57
- if (rowForMove && moveTo) {
58
- entity.moveTo(getId(rowForMove), getId(row));
59
- setRowForMove(undefined);
60
- }
61
- }
62
- },
63
- { show: !!archive && !row.archive, text: 'انتقال به آرشیو', onClick: () => { if (!!archive) {
64
- entity.edit(Object.assign(Object.assign({}, row), { archive: true }));
65
- } } },
66
- { show: !!archive && !!row.archive, text: 'خروج از آرشیو', onClick: () => { if (!!archive) {
67
- entity.edit(Object.assign(Object.assign({}, row), { archive: false }));
68
- } } },
69
- { show: !!moveTo, text: 'ذخیره برای انتقال', onClick: () => { if (moveTo) {
70
- setRowForMove(row);
71
- } } },
72
- { text: 'حذف', onClick: () => entity.remove(getId(row)) }
73
- ];
74
- };
75
- const side = useSide({
76
- options: props.sideOptions || [],
77
- option: {
78
- before: (o) => _jsx(Icon, { path: { reports: mdiListBox, export: mdiDownload, import: mdiUpload }[o.value], size: 1 })
79
- },
80
- onChange: (o) => {
81
- side.close();
82
- }
83
- });
84
- const rows = entity.hasFilter ? filteredData.rows : data;
85
- const attrs = AddToAttrs(props.attrs, { className: 'entity-table' });
86
- return (_jsx(Provider, { value: { getRootOptions, rootProps: props, getOptions, entity, getOptionDetails, showArchive, setShowArchive }, children: _jsxs("div", Object.assign({}, attrs, { children: [_jsx("div", { className: "text-xs w-full flex flex-row justify-center", style: { background: 'rgba(0,0,0,0.2)' }, children: DATE.getDateByPattern(DATE.getToday(true), 'امروز {weekDay} {day} {monthString} {year}') }), _jsxs("div", { className: "flex flex-row", children: [!!props.sideOptions && !!props.sideOptions.length &&
87
- _jsx("div", { className: "border-0 ml-2 px-2 py-2 rounded-full", onClick: () => side.open(), children: _jsx(Icon, { path: mdiListBox, size: 1 }) }), !!props.header && props.header()] }), _jsx(AIOTable, Object.assign({}, table, { value: rows, className: 'flex-1 overflow-hidden', headerAttrs: { style: { display: 'none' } }, rowTemplate: ({ row, rowIndex }) => _jsx(Card, { row: row, index: rowIndex }), toolbar: () => _jsx(TableToolbar, {}) })), _jsx("div", { className: "mb-2" }), !!props.footer && props.footer(), side.render()] })) }));
88
- };
89
- const TableToolbar = () => {
90
- const { rootProps, getOptionDetails, getRootOptions } = useProvider();
91
- const { table } = rootProps;
92
- let node = null;
93
- if (typeof table.toolbar === 'function') {
94
- node = table.toolbar() || null;
95
- }
96
- else if (table.toolbar) {
97
- node = table.toolbar || null;
98
- }
99
- const options = getRootOptions();
100
- const res = getOptionDetails(options);
101
- return (_jsxs("div", { className: "flex flex-row items-center gap-4 text-sm", children: [!!res.length &&
102
- _jsx(AISelect, { rtl: true, options: res, text: new GetSvg().getIcon('mdiPlusThick', .8), caret: false, justify: true, className: 'd1-bg-cream flex flex-row items-center justify-center', style: { background: 'none', border: 'none', height: 30, width: 30, padding: 0, } }), node] }));
103
- };
104
- export const Card = ({ row }) => {
105
- const { rootProps, getOptions, entity, showArchive } = useProvider();
106
- const { size = 72 } = rootProps;
107
- const { getCardContent, getCardTitle } = rootProps;
108
- const [open, setOpen] = useState(false);
109
- const childs = entity.getChilds(row);
110
- return (_jsxs("div", { className: "d1-bg-cream p-2 flex flex-col gap-1 rounded-lg", children: [_jsxs("div", { className: "flex flex-row items-center", children: [_jsx("div", { className: "flex flex-row items-center justify-center w-[30px] h-[30px]", onClick: () => setOpen(!open), children: new GetSvg().getIcon(open ? 'mdiChevronDown' : 'mdiChevronLeft', .8) }), _jsx("div", { className: "text-[1em] cursor-pointer flex-1", children: getCardTitle(row) }), !!getOptions && _jsx(CardOptions, { row: row, parent: false, isRoot: true })] }), getCardContent(row, false, 'root'), !!childs && !!open &&
111
- _jsx(AITree, { rtl: true, size: size, indent: 24, value: childs, option: {
112
- childs: (o) => entity.getChilds(o),
113
- text: (row, { parentOptions }) => {
114
- const childs = entity.getChilds(row);
115
- const parentOption = parentOptions.length ? parentOptions[parentOptions.length - 1] : undefined;
116
- const parent = parentOption ? parentOption.optionOrg : false;
117
- if (childs) {
118
- return (_jsxs("div", { className: "flex flex-col gap-1", children: [_jsxs("div", { className: "flex flex-row gap-1 flex-1 font-bold items-center", children: [_jsx("div", { className: "flex-1", children: getCardTitle(row) }), !!getOptions && _jsx(CardOptions, { row: row, parent: parent })] }), getCardContent(row, parent, 'node')] }));
119
- }
120
- return (_jsxs("div", { className: "flex flex-col", children: [_jsxs("div", { className: "flex flex-row font-bold items-center", children: [_jsx("div", { className: "flex-1 flex flex-row items-center h-fit", children: getCardTitle(row) }), !!getOptions && _jsx(CardOptions, { row: row, parent: parent })] }), getCardContent(row, parent, 'leaf')] }));
121
- },
122
- value: (o) => entity.getId(o),
123
- show: (o) => showArchive ? true : !o.archive,
124
- className: () => {
125
- return `${'d1-bg-dark-gray'} !rounded-md`;
126
- },
127
- style: () => ({ fontSize: '0.7em', borderBottom: '2px dashed #333' })
128
- } })] }));
129
- };
130
- const CardOptions = ({ row, parent, isRoot }) => {
131
- const { getOptions } = useProvider();
132
- return (_jsx(AISelect, { text: new GetSvg().getIcon('mdiDotsHorizontal', .8), caret: false, options: getOptions(row, parent, !!isRoot), justify: true, className: `${!isRoot ? 'd1-bg-cream' : 'd1-bg-gray'}`, style: { background: 'none', border: 'none', height: 30, width: 42 } }));
133
- };
134
- export const DateFilter = ({ result, fromDate, toDate, onChange }) => {
135
- const DATE = new AIODate();
136
- const changeDateByDay = (date) => {
137
- const [year, month, day] = date;
138
- const fromDate = DATE.getTime([year, month, day, 0, 0]);
139
- const toDate = DATE.getTime([year, month, day, 23, 59]);
140
- onChange({ fromDate, toDate });
141
- };
142
- const buttonCls = `d1-bg-cream border-none rounded-lg px-4 h-10 text-sm font-bold`;
143
- return (_jsxs("div", { className: "flex flex-col gap-2 p-2", children: [_jsxs("div", { className: "flex flex-row items-center", children: [result !== undefined && _jsx("button", { className: buttonCls, children: result }), _jsx("div", { className: "flex-1" }), _jsxs("div", { className: "flex flex-row gap-2", children: [_jsx(AIDate, { className: 'flex items-center justify-center rounded-lg! cursor-pointer text-sm w-[48px] h-[48px] text-center border-none!', style: { background: 'none' }, caret: false, justify: true, jalali: true, calendarClose: true, text: _jsx(CalendarIcon, {}), dateUnit: 'day', dateType: 'dateArray', onChange: (v) => { changeDateByDay(v); }, popover: { position: 'center' } }), _jsx(DateBox, { unit: 'day', className: 'd1-bg-blue-grad', onChange: onChange }), _jsx(DateBox, { unit: 'month', className: 'd1-bg-green-grad', onChange: onChange }), _jsx(DateBox, { unit: 'year', className: 'd1-bg-red-grad', onChange: onChange })] })] }), _jsx(TimeRange, { fromDate: fromDate, toDate: toDate, onChange: ({ fromDate, toDate }) => { onChange({ fromDate, toDate }); } })] }));
144
- };
145
- const DateBox = ({ unit, onChange }) => {
146
- const DATE = new AIODate();
147
- const dic = { day: 'امروز', week: 'هفته جاری', month: 'انتخاب ماه', year: 'سال جاری' };
148
- const changeDateByUnit = (unit) => {
149
- let [fromArray, toArray] = DATE.getCurrentRange(unit, true);
150
- const fromDate = DATE.getTime(fromArray);
151
- const toDate = DATE.getTime(toArray);
152
- onChange({ fromDate, toDate });
153
- };
154
- const changeDateByMonth = (month) => {
155
- const [year] = DATE.getToday(true);
156
- const dateArray = [year, month];
157
- const monthDaysLength = DATE.getMonthDaysLength(dateArray);
158
- const fromArray = [dateArray[0], dateArray[1], 1, 0, 0];
159
- const toArray = [dateArray[0], dateArray[1], monthDaysLength, 23, 59];
160
- const fromDate = DATE.getTime(fromArray);
161
- const toDate = DATE.getTime(toArray);
162
- onChange({ fromDate, toDate });
163
- };
164
- if (unit === 'month') {
165
- return (_jsx(AISelect, { className: `flex items-center justify-center !rounded-lg cursor-pointer !text-xs w-[48px] !h-[48px] text-center d1-border-light !p-0`, style: { color: '#ddd', background: 'none' }, caret: false, text: dic[unit], optionsWrap: false, popover: { modalAttrs: { style: { width: '100vw' } } }, options: [
166
- { text: 'ماه جاری', onClick: () => changeDateByUnit('month') },
167
- ...DATE.getMonths(true).map((o, i) => ({ text: o, onClick: () => changeDateByMonth(i + 1) }))
168
- ] }));
169
- }
170
- return (_jsx("div", { className: `flex items-center justify-center rounded-lg cursor-pointer text-xs w-[48px] h-[48px] text-center d1-border-light`, style: { color: '#ddd' }, onClick: () => {
171
- if (unit === 'day') {
172
- changeDateByUnit('day');
173
- }
174
- if (unit === 'year') {
175
- changeDateByUnit('year');
176
- }
177
- }, children: dic[unit] }));
178
- };
179
- const CalendarIcon = () => {
180
- return (_jsx("svg", { viewBox: "0 0 24 24", role: "presentation", style: { width: '1.5rem', height: '1.5rem' }, children: _jsx("path", { d: "M19,19H5V8H19M16,1V3H8V1H6V3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3H18V1M17,12H12V17H17V12Z", style: { fill: 'currentcolor' } }) }));
181
- };
182
- export const TimeRange = ({ fromDate, toDate, onChange }) => {
183
- const getText = (time, field) => {
184
- if (!time) {
185
- return field === 'fromDate' ? 'از تاریخ' : 'تا تاریخ';
186
- }
187
- const DATE = new AIODate();
188
- const { weekDay, monthString, yearStr, dayStr } = DATE.getDetails(time, true);
189
- return `${weekDay} ${dayStr} ${monthString} ${yearStr}`;
190
- };
191
- const renderTime = (time, field) => {
192
- const text = getText(time, field);
193
- return (_jsx(AITime, { dateType: "dateNumber", className: '!border-none !text-sm !rounded-0 !bg-none', style: { background: 'none' }, value: time, text: text, jalali: true, caret: false, onChange: (v) => onChange({ fromDate, toDate, [field]: v }), deSelect: true }));
194
- };
195
- return (_jsxs("div", { className: "flex flex-row items-center d1-border-medium", children: [_jsx("div", { className: "flex-1", children: renderTime(fromDate, 'fromDate') }), _jsx("div", { className: "w-[1px] d1-bg-border-medium h-full" }), _jsx("div", { className: "flex-1", children: renderTime(toDate, 'toDate') })] }));
196
- };
197
- export const TimeInput = ({ value, onChange, disabled }) => {
198
- const DATE = new AIODate();
199
- const str = (_jsx("div", { className: "text-md flex flex-row items-center gap-2 justify-center", children: !!value && _jsx(_Fragment, { children: DATE.getDateByPattern(value, '{weekDay} {day} {monthString} {year}', true) }) }));
200
- return (_jsxs("div", { className: "flex flex-col gap-4 w-full px-4", children: [_jsx(AITime, { jalali: true, disabled: disabled, dateType: 'dateNumber', className: 'd1-in-shadow', value: value || DATE.getTime(DATE.getToday(true)), onChange: onChange, justify: true, timeUnit: { year: true, month: true, day: true } }), str] }));
201
- };
202
- export const CardRow = ({ label, value, color, onClick }) => {
203
- return (_jsxs("div", { className: `flex flex-row d1-bg-dark-2 px-3 py-2 my-0.5 rounded-md items-center`, onClick: () => { if (onClick) {
204
- onClick();
205
- } }, children: [_jsx("div", { className: "text-sm", children: label }), _jsx("div", { className: "flex-1" }), _jsx("div", { className: "font-bold text-sm flex flex-row items-center justify-center", style: { color }, children: value })] }));
206
- };
207
- export const CardRows = ({ rows, placeholder = 'موردی وجود ندارد' }) => {
208
- return (_jsxs("div", { className: "flex flex-col gap-2", children: [!rows.length && _jsx("div", { className: "text-xs w-full flex flex-row items-center justify-center", children: placeholder }), rows.map((r, i) => {
209
- const { onClick, isPrice } = r[2] || {};
210
- let value = r[1];
211
- if (isPrice && (typeof r[1] === 'number' || typeof r[1] === 'string')) {
212
- value = SplitNumber(r[1]);
213
- }
214
- return _jsx(CardRow, { label: r[0], value: value, onClick: onClick }, i);
215
- })] }));
216
- };
217
- export const CardBox = ({ type, label, value, color, onClick, isPrice }) => {
218
- let cls = `flex flex-col flex-1 items-center rounded-lg py-2`;
219
- if (type === 0) {
220
- cls += ' d1-bg-cream';
221
- }
222
- const style = {};
223
- if (type === 1) {
224
- style.boxShadow = 'inset 2px 2px 5px 0px rgb(110 85 27 / 40%)';
225
- }
226
- else if (type === 2) {
227
- style.background = 'rgba(0,0,0,0.2)';
228
- style.color = '#fff';
229
- }
230
- return (_jsxs("div", { className: cls, style: style, onClick: () => { if (onClick) {
231
- onClick();
232
- } }, children: [_jsx("div", { className: "text-xs", children: label }), _jsx("div", { className: "flex-1" }), _jsx("div", { className: "font-bold text-sm", style: { color }, children: isPrice ? SplitNumber(value) : value })] }));
233
- };
234
- export const Panel = ({ label, content }) => {
235
- const panelCls = 'flex flex-col gap-4 d1-border-medium p-4 rounded-lg relative';
236
- return (_jsxs("div", { className: panelCls, children: [!!label && _jsx("div", { className: "d1-panel-label d1-panel-label-online-rtl", children: label }), content] }));
237
- };
238
- export const dateStringToDateNumber = (dateNumber) => {
239
- return new AIODate().getDateByPattern(dateNumber, '{year}/{month}/{day}', true);
240
- };