forstok-ui-lib 5.3.6 → 5.4.4
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/dist/index.d.ts +108 -5
- package/dist/index.js +1044 -163
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1036 -155
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -1
- package/src/assets/images/icons/edit-white.svg +5 -0
- package/src/assets/images/icons/loading-red.svg +27 -0
- package/src/assets/javascripts/function.ts +319 -10
- package/src/assets/javascripts/helper.ts +47 -0
- package/src/assets/stylesheets/shares.styles.ts +168 -0
- package/src/components/button/styles.ts +13 -0
- package/src/components/index.ts +2 -0
- package/src/components/masterTable/index.tsx +649 -0
- package/src/components/masterTable/partials/datas/confirm.tsx +92 -0
- package/src/components/masterTable/partials/datas/index.tsx +81 -0
- package/src/components/masterTable/partials/editors/date.bare.tsx +39 -0
- package/src/components/masterTable/partials/editors/date.tsx +123 -0
- package/src/components/masterTable/partials/editors/image.tsx +61 -0
- package/src/components/masterTable/partials/editors/input.bare.tsx +127 -0
- package/src/components/masterTable/partials/editors/input.tsx +140 -0
- package/src/components/masterTable/partials/editors/label.tsx +128 -0
- package/src/components/masterTable/partials/editors/select.bare.tsx +104 -0
- package/src/components/masterTable/partials/editors/select.tsx +142 -0
- package/src/components/masterTable/partials/editors/switch.tsx +56 -0
- package/src/components/masterTable/partials/editors/tag.tsx +49 -0
- package/src/components/masterTable/partials/editors/textarea.tsx +7 -0
- package/src/components/masterTable/styles.tsx +1012 -0
- package/src/components/masterTable/typed.ts +87 -0
- package/src/components/switch/index.tsx +52 -0
- package/src/components/switch/styles.ts +34 -0
- package/src/declarations.d.ts +3 -1
- package/src/typeds/shares.typed.ts +56 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "forstok-ui-lib",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.4",
|
|
4
4
|
"description": "Forstok UI Components Library",
|
|
5
5
|
"path": "dist",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -39,7 +39,9 @@
|
|
|
39
39
|
"@types/react": "^19.0.2",
|
|
40
40
|
"@types/react-datepicker": "^6.2.0",
|
|
41
41
|
"@types/react-dom": "^19.0.2",
|
|
42
|
+
"approvejs": "^3.1.2",
|
|
42
43
|
"html-to-text": "^9.0.5",
|
|
44
|
+
"moment": "^2.30.1",
|
|
43
45
|
"moment-range": "^4.0.2",
|
|
44
46
|
"npm-force-resolutions": "^0.0.10",
|
|
45
47
|
"react": "^19.0.0",
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<?xml version='1.0' encoding='utf-8'?>
|
|
2
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 129 129" xmlns:xlink="http://www.w3.org/1999/xlink" enable-background="new 0 0 129 129" style="fill: #fff;">
|
|
3
|
+
<path d="m119.2,114.3h-109.4c-2.3,0-4.1,1.9-4.1,4.1s1.9,4.1 4.1,4.1h109.5c2.3,0 4.1-1.9 4.1-4.1s-1.9-4.1-4.2-4.1z"/>
|
|
4
|
+
<path d="m5.7,78l-.1,19.5c0,1.1 0.4,2.2 1.2,3 0.8,0.8 1.8,1.2 2.9,1.2l19.4-.1c1.1,0 2.1-0.4 2.9-1.2l67-67c1.6-1.6 1.6-4.2 0-5.9l-19.2-19.4c-1.6-1.6-4.2-1.6-5.9-1.77636e-15l-13.4,13.5-53.6,53.5c-0.7,0.8-1.2,1.8-1.2,2.9zm71.2-61.1l13.5,13.5-7.6,7.6-13.5-13.5 7.6-7.6zm-62.9,62.9l49.4-49.4 13.5,13.5-49.4,49.3-13.6,.1 .1-13.5z"/>
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid" class="uil-default">
|
|
2
|
+
<rect x="0" y="0" width="100" height="100" fill="none" class="bk"></rect>
|
|
3
|
+
<rect x='46.5' y='40' width='7' height='20' rx='5' ry='5' fill='#FF585C' transform='rotate(0 50 50) translate(0 -30)'>
|
|
4
|
+
<animate attributeName='opacity' from='1' to='0' dur='1s' begin='0s' repeatCount='indefinite'/></rect>
|
|
5
|
+
<rect x='46.5' y='40' width='7' height='20' rx='5' ry='5' fill='#FF585C' transform='rotate(30 50 50) translate(0 -30)'>
|
|
6
|
+
<animate attributeName='opacity' from='1' to='0' dur='1s' begin='0.08333333333333333s' repeatCount='indefinite'/></rect>
|
|
7
|
+
<rect x='46.5' y='40' width='7' height='20' rx='5' ry='5' fill='#FF585C' transform='rotate(60 50 50) translate(0 -30)'>
|
|
8
|
+
<animate attributeName='opacity' from='1' to='0' dur='1s' begin='0.16666666666666666s' repeatCount='indefinite'/></rect>
|
|
9
|
+
<rect x='46.5' y='40' width='7' height='20' rx='5' ry='5' fill='#FF585C' transform='rotate(90 50 50) translate(0 -30)'>
|
|
10
|
+
<animate attributeName='opacity' from='1' to='0' dur='1s' begin='0.25s' repeatCount='indefinite'/></rect>
|
|
11
|
+
<rect x='46.5' y='40' width='7' height='20' rx='5' ry='5' fill='#FF585C' transform='rotate(120 50 50) translate(0 -30)'>
|
|
12
|
+
<animate attributeName='opacity' from='1' to='0' dur='1s' begin='0.3333333333333333s' repeatCount='indefinite'/></rect>
|
|
13
|
+
<rect x='46.5' y='40' width='7' height='20' rx='5' ry='5' fill='#FF585C' transform='rotate(150 50 50) translate(0 -30)'>
|
|
14
|
+
<animate attributeName='opacity' from='1' to='0' dur='1s' begin='0.4166666666666667s' repeatCount='indefinite'/></rect>
|
|
15
|
+
<rect x='46.5' y='40' width='7' height='20' rx='5' ry='5' fill='#FF585C' transform='rotate(180 50 50) translate(0 -30)'>
|
|
16
|
+
<animate attributeName='opacity' from='1' to='0' dur='1s' begin='0.5s' repeatCount='indefinite'/></rect>
|
|
17
|
+
<rect x='46.5' y='40' width='7' height='20' rx='5' ry='5' fill='#FF585C' transform='rotate(210 50 50) translate(0 -30)'>
|
|
18
|
+
<animate attributeName='opacity' from='1' to='0' dur='1s' begin='0.5833333333333334s' repeatCount='indefinite'/></rect>
|
|
19
|
+
<rect x='46.5' y='40' width='7' height='20' rx='5' ry='5' fill='#FF585C' transform='rotate(240 50 50) translate(0 -30)'>
|
|
20
|
+
<animate attributeName='opacity' from='1' to='0' dur='1s' begin='0.6666666666666666s' repeatCount='indefinite'/></rect>
|
|
21
|
+
<rect x='46.5' y='40' width='7' height='20' rx='5' ry='5' fill='#FF585C' transform='rotate(270 50 50) translate(0 -30)'>
|
|
22
|
+
<animate attributeName='opacity' from='1' to='0' dur='1s' begin='0.75s' repeatCount='indefinite'/></rect>
|
|
23
|
+
<rect x='46.5' y='40' width='7' height='20' rx='5' ry='5' fill='#FF585C' transform='rotate(300 50 50) translate(0 -30)'>
|
|
24
|
+
<animate attributeName='opacity' from='1' to='0' dur='1s' begin='0.8333333333333334s' repeatCount='indefinite'/></rect>
|
|
25
|
+
<rect x='46.5' y='40' width='7' height='20' rx='5' ry='5' fill='#FF585C' transform='rotate(330 50 50) translate(0 -30)'>
|
|
26
|
+
<animate attributeName='opacity' from='1' to='0' dur='1s' begin='0.9166666666666666s' repeatCount='indefinite'/></rect>
|
|
27
|
+
</svg>
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import approve from 'approvejs'
|
|
1
2
|
import { ReactNode } from 'react';
|
|
2
3
|
import { TMessage, TMessageQuestion } from '../../components/message/typed';
|
|
4
|
+
import { TObject } from '../../typeds/base.typed';
|
|
5
|
+
import { errorTitle } from './helper';
|
|
3
6
|
|
|
4
7
|
export const getStorage = (name: string, type: string = 'string', defaultVal?: any, loadName: string = 'load') => {
|
|
5
8
|
let result: any;
|
|
@@ -79,6 +82,10 @@ export const formatNumber = (n?: string | number, flag?: boolean) => {
|
|
|
79
82
|
return result;
|
|
80
83
|
}
|
|
81
84
|
|
|
85
|
+
export const IsNumeric = (val?: any) => {
|
|
86
|
+
return Number(parseFloat(val)) === val;
|
|
87
|
+
}
|
|
88
|
+
|
|
82
89
|
export const generateMessage = (type: string, value: string | ReactNode, callback?: () => void, timer?: number) => {
|
|
83
90
|
let result: TMessage = {
|
|
84
91
|
$type: type,
|
|
@@ -112,24 +119,326 @@ export const currencyNumber = (value: number) => {
|
|
|
112
119
|
}
|
|
113
120
|
|
|
114
121
|
export const evUpdateInputRc = (input?: HTMLInputElement, value?: string | number) => {
|
|
115
|
-
if (!input)
|
|
122
|
+
if (!input) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
116
125
|
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(
|
|
117
126
|
window.HTMLInputElement.prototype,
|
|
118
127
|
"value"
|
|
119
|
-
)?.set
|
|
120
|
-
nativeInputValueSetter && nativeInputValueSetter.call(input, (value === undefined ? '' : value))
|
|
121
|
-
const inputEvent = new Event('input', { bubbles: true})
|
|
122
|
-
input.dispatchEvent(inputEvent)
|
|
128
|
+
)?.set;
|
|
129
|
+
nativeInputValueSetter && nativeInputValueSetter.call(input, (value === undefined ? '' : value));
|
|
130
|
+
const inputEvent = new Event('input', { bubbles: true});
|
|
131
|
+
input.dispatchEvent(inputEvent);
|
|
123
132
|
}
|
|
124
133
|
|
|
125
134
|
export const getSizeContainer = (full?: boolean) => {
|
|
126
|
-
const height = window.innerHeight
|
|
127
|
-
const width = window.innerWidth
|
|
128
|
-
let result = { width: width, height: height }
|
|
135
|
+
const height = window.innerHeight;
|
|
136
|
+
const width = window.innerWidth;
|
|
137
|
+
let result = { width: width, height: height };
|
|
129
138
|
if (width >= 1366) {
|
|
130
|
-
result.width = width - 220 - 64
|
|
139
|
+
result.width = width - 220 - 64;
|
|
131
140
|
} else if (width >= 1280) {
|
|
132
|
-
result.width = width - 187 - 32
|
|
141
|
+
result.width = width - 187 - 32;
|
|
142
|
+
}
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export const generateValueTable = (input: string|number, key: string) => {
|
|
147
|
+
let result = input;
|
|
148
|
+
if (key && input !== '') {
|
|
149
|
+
const _key = key.toLowerCase();
|
|
150
|
+
const _input = (typeof input === 'string') ? parseInt(input) : input;
|
|
151
|
+
if (/price/.test(_key)) {
|
|
152
|
+
result = currencyNumber(_input);
|
|
153
|
+
} else if (/width/.test(_key) || /length/.test(_key) || /height/.test(_key)) {
|
|
154
|
+
result = input + ' cm';
|
|
155
|
+
} else if (/weight/.test(_key)) {
|
|
156
|
+
result = input + ' gr';
|
|
157
|
+
} else if(/discount/.test(_key)) {
|
|
158
|
+
result = input + ' %';
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return result;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export const generateValue = (type: string, value: any) => {
|
|
165
|
+
let result: any;
|
|
166
|
+
switch (type) {
|
|
167
|
+
case 'String':
|
|
168
|
+
result = value ? value.toString().trim() : '';
|
|
169
|
+
break
|
|
170
|
+
case 'Integer':
|
|
171
|
+
result = (value !== '' && value !== null) ? parseInt(value) : null;
|
|
172
|
+
break
|
|
173
|
+
case 'Currency':
|
|
174
|
+
result = (value !== '' && value !== null) ? parseInt(formatNumber(value, false)) : null;
|
|
175
|
+
break
|
|
176
|
+
case 'Boolean':
|
|
177
|
+
case 'Array':
|
|
178
|
+
result = value;
|
|
179
|
+
break
|
|
180
|
+
default:
|
|
181
|
+
result = value.toString().trim();
|
|
182
|
+
}
|
|
183
|
+
return result;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export const validateByApproveJs = (head: TObject, value: any, title?: string, valueMatch?: any) => {
|
|
187
|
+
let result: TObject = { approved: true };
|
|
188
|
+
let _title: string = title || errorTitle(head.name);
|
|
189
|
+
if (head.key.indexOf('options-option') !== -1) {
|
|
190
|
+
if (value === '') {
|
|
191
|
+
result = { approved: false, errors: [_title+' is required'] };
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (head?.validations) {
|
|
195
|
+
const typeData: string = head?.typeData || 'String';
|
|
196
|
+
let rules: TObject = { title: _title };
|
|
197
|
+
if (head.validations?.required) {
|
|
198
|
+
switch (typeData) {
|
|
199
|
+
case 'String':
|
|
200
|
+
rules.required = true;
|
|
201
|
+
break
|
|
202
|
+
case 'Integer':
|
|
203
|
+
case 'Currency':
|
|
204
|
+
const _value = (typeof value === 'undefined') ? '' : (isNaN(value) ? '' : value);
|
|
205
|
+
const requiredIntegerRule = {
|
|
206
|
+
expects: [
|
|
207
|
+
'value'
|
|
208
|
+
],
|
|
209
|
+
message: '{title} is required',
|
|
210
|
+
validate: (value: any, pars: TObject) => {
|
|
211
|
+
return pars.value !== '' && pars.value !== null
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
approve.addTest(requiredIntegerRule, 'requiredIntegerRule');
|
|
215
|
+
rules.requiredIntegerRule = {
|
|
216
|
+
value: _value
|
|
217
|
+
};
|
|
218
|
+
break
|
|
219
|
+
case 'Array':
|
|
220
|
+
const requiredArrayRule = {
|
|
221
|
+
expects: [
|
|
222
|
+
'value'
|
|
223
|
+
],
|
|
224
|
+
message: '{title} is required',
|
|
225
|
+
validate: (value: any, pars: TObject) => {
|
|
226
|
+
return pars.value?.length || (pars.value && Object.keys(pars.value).length) ? true : false
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
approve.addTest(requiredArrayRule, 'requiredArrayRule');
|
|
230
|
+
rules.requiredArrayRule = {
|
|
231
|
+
value: value
|
|
232
|
+
};
|
|
233
|
+
break
|
|
234
|
+
default:
|
|
235
|
+
rules.required = true;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if(('min' in head.validations && head.validations.min !== null) && ('max' in head.validations && head.validations.max !== null)) {
|
|
240
|
+
switch (typeData) {
|
|
241
|
+
case 'Integer':
|
|
242
|
+
case 'Currency':
|
|
243
|
+
const minMaxIntegerRule = {
|
|
244
|
+
expects: [
|
|
245
|
+
'value'
|
|
246
|
+
],
|
|
247
|
+
message: '{title} min '+head.validations.min+' and max '+head.validations.max,
|
|
248
|
+
validate: (value: any, pars: TObject) => {
|
|
249
|
+
return (pars.value >= head.validations.min && pars.value <= head.validations.max) || pars.value === '' || typeof pars.value === 'undefined'
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
approve.addTest(minMaxIntegerRule, 'minMaxIntegerRule');
|
|
253
|
+
rules.minMaxIntegerRule = {
|
|
254
|
+
value: value
|
|
255
|
+
};
|
|
256
|
+
break
|
|
257
|
+
case 'Array':
|
|
258
|
+
const minMaxArrayRule = {
|
|
259
|
+
expects: [
|
|
260
|
+
'value'
|
|
261
|
+
],
|
|
262
|
+
message: '{title} must be a minimum of '+head.validations.min+' and a maximum of '+head.validations.max,
|
|
263
|
+
validate: (value: any, pars: TObject) => {
|
|
264
|
+
return pars.value ? (pars.value.length >= head.validations.min && pars.value.length <= head.validations.max) : (head.validations.min === 0 ? true : false)
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
approve.addTest(minMaxArrayRule, 'minMaxArrayRule');
|
|
268
|
+
rules.minMaxArrayRule = {
|
|
269
|
+
value: value
|
|
270
|
+
};
|
|
271
|
+
break
|
|
272
|
+
default:
|
|
273
|
+
rules.min = head.validations.min;
|
|
274
|
+
rules.max = head.validations.max;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
else if('min' in head.validations && head.validations.min !== null) {
|
|
278
|
+
switch (typeData) {
|
|
279
|
+
case 'Integer':
|
|
280
|
+
case 'Currency':
|
|
281
|
+
const minIntegerRule = {
|
|
282
|
+
expects: [
|
|
283
|
+
'value'
|
|
284
|
+
],
|
|
285
|
+
message: '{title} min '+head.validations.min,
|
|
286
|
+
validate: (value: any, pars: TObject) => {
|
|
287
|
+
return pars.value >= head.validations.min || pars.value === '' || typeof pars.value === 'undefined'
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
approve.addTest(minIntegerRule, 'minIntegerRule');
|
|
291
|
+
rules.minIntegerRule = {
|
|
292
|
+
value: value
|
|
293
|
+
};
|
|
294
|
+
break
|
|
295
|
+
case 'Array':
|
|
296
|
+
const minArrayRule = {
|
|
297
|
+
expects: [
|
|
298
|
+
'value'
|
|
299
|
+
],
|
|
300
|
+
message: '{title} must be a minimum of '+head.validations.min,
|
|
301
|
+
validate: (value: any, pars: TObject) => {
|
|
302
|
+
return pars.value ? (pars.value.length >= head.validations.min) : (head.validations.min === 0 ? true : false)
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
approve.addTest(minArrayRule, 'minArrayRule');
|
|
306
|
+
rules.minArrayRule = {
|
|
307
|
+
value: value
|
|
308
|
+
};
|
|
309
|
+
break
|
|
310
|
+
default:
|
|
311
|
+
rules.min = head.validations.min;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
else if('max' in head.validations && head.validations.max !== null) {
|
|
315
|
+
switch (typeData) {
|
|
316
|
+
case 'Integer':
|
|
317
|
+
case 'Currency':
|
|
318
|
+
const maxIntegerRule = {
|
|
319
|
+
expects: [
|
|
320
|
+
'value'
|
|
321
|
+
],
|
|
322
|
+
message: '{title} max '+head.validations.max,
|
|
323
|
+
validate: (value: any, pars: TObject) => {
|
|
324
|
+
return pars.value <= head.validations.max || pars.value === '' || typeof pars.value === 'undefined'
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
approve.addTest(maxIntegerRule, 'maxIntegerRule');
|
|
328
|
+
rules.maxIntegerRule = {
|
|
329
|
+
value: value
|
|
330
|
+
};
|
|
331
|
+
break
|
|
332
|
+
case 'Array':
|
|
333
|
+
const maxArrayRule = {
|
|
334
|
+
expects: [
|
|
335
|
+
'value'
|
|
336
|
+
],
|
|
337
|
+
message: '{title} must be a maximum of '+head.validations.max,
|
|
338
|
+
validate: (value: any, pars: TObject) => {
|
|
339
|
+
return pars?.value?.length <= head.validations.max
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
approve.addTest(maxArrayRule, 'maxArrayRule');
|
|
343
|
+
rules.maxArrayRule = {
|
|
344
|
+
value: value
|
|
345
|
+
};
|
|
346
|
+
break
|
|
347
|
+
default:
|
|
348
|
+
rules.max = head.validations.max;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
if('lessEqual' in head.validations) {
|
|
353
|
+
const lessEqualRule = {
|
|
354
|
+
expects: [
|
|
355
|
+
'value',
|
|
356
|
+
'valueMatch',
|
|
357
|
+
],
|
|
358
|
+
message: '{title} is less than or equal {valueMatch}',
|
|
359
|
+
validate: (value: any, pars: TObject) => {
|
|
360
|
+
return (IsNumeric(value) && IsNumeric(pars?.valueMatch)) ? (value <= pars.valueMatch) : true
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
approve.addTest(lessEqualRule, 'lessEqualRule');
|
|
364
|
+
rules.lessEqualRule = {
|
|
365
|
+
value: value,
|
|
366
|
+
valueMatch: valueMatch
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
if('less' in head.validations) {
|
|
371
|
+
const lessRule = {
|
|
372
|
+
expects: [
|
|
373
|
+
'value',
|
|
374
|
+
'valueMatch',
|
|
375
|
+
],
|
|
376
|
+
message: '{title} is less than {valueMatch}',
|
|
377
|
+
validate: (value: any, pars: TObject) => {
|
|
378
|
+
return (IsNumeric(value) && IsNumeric(pars?.valueMatch)) ? (value < pars.valueMatch) : true
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
approve.addTest(lessRule, 'lessRule');
|
|
382
|
+
rules.lessRule = {
|
|
383
|
+
value: value,
|
|
384
|
+
valueMatch: valueMatch
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if(head.validations?.greaterEqual) {
|
|
389
|
+
const greaterEqualRule = {
|
|
390
|
+
expects: [
|
|
391
|
+
'value',
|
|
392
|
+
'valueMatch',
|
|
393
|
+
],
|
|
394
|
+
message: '{title} is greater than or equal {valueMatch}',
|
|
395
|
+
validate: (value: any, pars: TObject) => {
|
|
396
|
+
return (IsNumeric(value) && IsNumeric(pars?.valueMatch)) ? (value >= pars.valueMatch) : true
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
approve.addTest(greaterEqualRule, 'greaterEqualRule');
|
|
400
|
+
rules.greaterEqualRule = {
|
|
401
|
+
value: value,
|
|
402
|
+
valueMatch: valueMatch
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
if(head.validations?.greater) {
|
|
407
|
+
const greaterRule = {
|
|
408
|
+
expects: [
|
|
409
|
+
'value',
|
|
410
|
+
'valueMatch',
|
|
411
|
+
],
|
|
412
|
+
message: '{title} is greater than {valueMatch}',
|
|
413
|
+
validate: (value: any, pars: TObject) => {
|
|
414
|
+
return (IsNumeric(value) && IsNumeric(pars?.valueMatch)) ? (value > pars.valueMatch) : true
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
approve.addTest(greaterRule, 'greaterRule');
|
|
418
|
+
rules.greaterRule = {
|
|
419
|
+
value: value,
|
|
420
|
+
valueMatch: valueMatch
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
result = approve.value(value, rules);
|
|
133
425
|
}
|
|
134
426
|
return result
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
export const evGenerateValueMatch = (validation?: TObject, data?: any) => {
|
|
430
|
+
let result = undefined;
|
|
431
|
+
if (validation && Object.keys(validation).length) {
|
|
432
|
+
const keyArr = ['lessEqual', 'greaterEqual', 'less', 'greater'];
|
|
433
|
+
const key = keyArr.find((_key) => _key in validation);
|
|
434
|
+
if (data && key) {
|
|
435
|
+
const obj = validation[key];
|
|
436
|
+
if(obj && obj in data) result = data[obj];
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return result;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
export const unescapeHTML = (value?: string) => {
|
|
443
|
+
return value ? value.replace(/</g,'<').replace(/>/g,'>').replace(/&/g,'&') : value as string
|
|
135
444
|
}
|
|
@@ -8,4 +8,51 @@ export const dateRangeStatus = (value: string) => {
|
|
|
8
8
|
export const dateRangeDays = (value: string) => {
|
|
9
9
|
const dayObj: TObject = { 'today': 0, 'lastweek': 6, 'lastsecondweek': 13 ,'lastmonth': 29, 'lastquart': 89, 'custom': 0 }
|
|
10
10
|
return dayObj[value]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const pageMasterTable = (value: string) => {
|
|
14
|
+
switch (value) {
|
|
15
|
+
case 'create-master': case 'edit-master':
|
|
16
|
+
return 'master'
|
|
17
|
+
case 'create-listing': case 'edit-listing':
|
|
18
|
+
return 'listing'
|
|
19
|
+
case 'confirm-adjustment': case 'confirm-inbound': case 'confirm-outbound': case 'create-adjustment': case 'create-inbound': case 'create-outbound': case 'create-transfer': case 'create-price':
|
|
20
|
+
return 'stock'
|
|
21
|
+
case 'create-promotion':
|
|
22
|
+
return 'promotion'
|
|
23
|
+
case 'create-paymentreceive':
|
|
24
|
+
return 'payment'
|
|
25
|
+
case 'edit-picklist': case 'create-picklist':
|
|
26
|
+
return 'picklist'
|
|
27
|
+
default:
|
|
28
|
+
return ''
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const errorTitle = (name: string) => {
|
|
33
|
+
switch (name) {
|
|
34
|
+
case 'Quantity on Hand' :
|
|
35
|
+
return 'Quantity'
|
|
36
|
+
case 'Variant Option 1' :
|
|
37
|
+
return 'Variant Option'
|
|
38
|
+
case 'Variant Type 1' :
|
|
39
|
+
return 'Variant Type'
|
|
40
|
+
case 'Variant Option 2' :
|
|
41
|
+
return 'Variant Option'
|
|
42
|
+
case 'Variant Type 2' :
|
|
43
|
+
return 'Variant Type'
|
|
44
|
+
case 'variants-sku':
|
|
45
|
+
return 'Master SKU'
|
|
46
|
+
default:
|
|
47
|
+
return name
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const colorCommonQuantity = (value: number) => {
|
|
52
|
+
if(value <= 0) {
|
|
53
|
+
return 'red';
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return 'green';
|
|
57
|
+
}
|
|
11
58
|
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import styled, { css } from 'styled-components';
|
|
2
2
|
import { responseWidth, formLabel} from './bases.styles';
|
|
3
3
|
|
|
4
|
+
const initialStyles = css `
|
|
5
|
+
width: 32px;
|
|
6
|
+
height: 32px;
|
|
7
|
+
align-items: center;
|
|
8
|
+
display: grid;
|
|
9
|
+
background-color: #000;
|
|
10
|
+
`
|
|
11
|
+
|
|
4
12
|
const getTabsContentModFunc = ({ $mode }:{ $mode?: string }) => {
|
|
5
13
|
let style = ``
|
|
6
14
|
if ($mode === 'list') {
|
|
@@ -60,6 +68,46 @@ const getInputGroupModFunc = ({ $mode, $required }:{ $mode?: string, $required?:
|
|
|
60
68
|
}
|
|
61
69
|
return style
|
|
62
70
|
}
|
|
71
|
+
const getBulkActionWrapperModifiedStyled = ({ $isOpen }:{ $isOpen?: boolean }) => {
|
|
72
|
+
let style = ``
|
|
73
|
+
if ($isOpen) {
|
|
74
|
+
style += `
|
|
75
|
+
transition: bottom .2s;
|
|
76
|
+
bottom: 0;
|
|
77
|
+
@media (max-width: 767.9px) {
|
|
78
|
+
@keyframes droptoup {
|
|
79
|
+
50% {
|
|
80
|
+
bottom: -100px;
|
|
81
|
+
}
|
|
82
|
+
50% {
|
|
83
|
+
bottom: -50px;
|
|
84
|
+
}
|
|
85
|
+
100% {
|
|
86
|
+
bottom: 0px;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
&._refMasterTableBulkWrapper {
|
|
90
|
+
display: grid;
|
|
91
|
+
left: 0;
|
|
92
|
+
animation: droptoup .075s linear;
|
|
93
|
+
bottom: 0;
|
|
94
|
+
overflow-x: hidden;
|
|
95
|
+
& + ._refDropdownOverlay {
|
|
96
|
+
display: block;
|
|
97
|
+
width: 100%;
|
|
98
|
+
height: 100%;
|
|
99
|
+
position: fixed;
|
|
100
|
+
top: 0;
|
|
101
|
+
left: 0;
|
|
102
|
+
z-index: 100;
|
|
103
|
+
background-color: rgba(0, 0, 0, .1);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
`
|
|
108
|
+
}
|
|
109
|
+
return style
|
|
110
|
+
}
|
|
63
111
|
|
|
64
112
|
export const PanelContainer = styled.section`
|
|
65
113
|
position: relative;
|
|
@@ -324,4 +372,124 @@ export const BoxContainer = styled.aside`
|
|
|
324
372
|
@media only screen and (min-width: 768px) {
|
|
325
373
|
padding-bottom: 16px;
|
|
326
374
|
}
|
|
375
|
+
`
|
|
376
|
+
export const BulkActionWrapper = styled.aside<{ $isOpen?: boolean }>`
|
|
377
|
+
position: fixed;
|
|
378
|
+
z-index: 101;
|
|
379
|
+
bottom: -100%;
|
|
380
|
+
left: 0px;
|
|
381
|
+
width: 100%;
|
|
382
|
+
background-color: var(--ter-clr-bg);
|
|
383
|
+
display: inline-grid;
|
|
384
|
+
grid-auto-flow: column;
|
|
385
|
+
grid-template-columns: max-content auto;
|
|
386
|
+
justify-content: start;
|
|
387
|
+
grid-gap: 10px;
|
|
388
|
+
padding: 14px 1em 8px;
|
|
389
|
+
transition: bottom .2s ease-in-out;
|
|
390
|
+
overflow: auto;
|
|
391
|
+
white-space: nowrap;
|
|
392
|
+
i {
|
|
393
|
+
position: relative;
|
|
394
|
+
top: 5px;
|
|
395
|
+
}
|
|
396
|
+
span {
|
|
397
|
+
position: relative;
|
|
398
|
+
top: 7px;
|
|
399
|
+
}
|
|
400
|
+
button, a {
|
|
401
|
+
padding: 6px 16px;
|
|
402
|
+
font-size: 13px;
|
|
403
|
+
min-height: unset;
|
|
404
|
+
height: auto;
|
|
405
|
+
margin: 0;
|
|
406
|
+
}
|
|
407
|
+
@media (max-width: 767.9px) {
|
|
408
|
+
&._refMasterTableBulkWrapper {
|
|
409
|
+
position: fixed;
|
|
410
|
+
width: 100vw;
|
|
411
|
+
border: 1px solid #E3E3E3;
|
|
412
|
+
background: #FFFFFF;
|
|
413
|
+
z-index: 102;
|
|
414
|
+
box-shadow: 0px 4px 4px rgb(0 0 0 / 25%);
|
|
415
|
+
border-radius: 10px 10px 0px 0px;
|
|
416
|
+
display: none;
|
|
417
|
+
>i, >span, >button { display: none; }
|
|
418
|
+
>section {
|
|
419
|
+
padding: 1em;
|
|
420
|
+
>section >article {
|
|
421
|
+
display: inline-grid;
|
|
422
|
+
grid-auto-flow: row;
|
|
423
|
+
grid-gap: 12px;
|
|
424
|
+
width: 100%;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
& + ._refDropdownOverlay {
|
|
428
|
+
display:none;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
${getBulkActionWrapperModifiedStyled}
|
|
433
|
+
`
|
|
434
|
+
export const InitialContainer = styled.span`
|
|
435
|
+
${initialStyles}
|
|
436
|
+
align-items: center;
|
|
437
|
+
display: grid;
|
|
438
|
+
color: #fff;
|
|
439
|
+
text-align: center;
|
|
440
|
+
border-radius: var(--ter-rd);
|
|
441
|
+
`
|
|
442
|
+
export const MasterTableActionWrapper = styled.section<{ $mode?: string }>`
|
|
443
|
+
height: 35px;
|
|
444
|
+
border-bottom: 1px solid var(--tab-clr-ln);
|
|
445
|
+
background-color: var(--pri-clr-bg);
|
|
446
|
+
> div {
|
|
447
|
+
height: 35px !important;
|
|
448
|
+
> div {
|
|
449
|
+
display: inline-grid;
|
|
450
|
+
width: 100%;
|
|
451
|
+
grid-auto-flow: column;
|
|
452
|
+
grid-template-columns: min-content;
|
|
453
|
+
grid-gap: 5px;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
${({ $mode }:{ $mode?: string }) => {
|
|
457
|
+
if ($mode === 'picklist') {
|
|
458
|
+
return css`
|
|
459
|
+
background-color: var(--ter-clr-bg);
|
|
460
|
+
border-top: 1px solid var(--tab-clr-ln);
|
|
461
|
+
height: 50px;
|
|
462
|
+
> div {
|
|
463
|
+
height: 50px !important;
|
|
464
|
+
}
|
|
465
|
+
`
|
|
466
|
+
}
|
|
467
|
+
}}
|
|
468
|
+
`
|
|
469
|
+
export const FigureWraper = styled.figure<{ $size?: string, $mode?: string }>`
|
|
470
|
+
margin: 0;
|
|
471
|
+
position: relative;
|
|
472
|
+
overflow: hidden;
|
|
473
|
+
border: 1px solid var(--pri-clr-ln);
|
|
474
|
+
background-color: var(--pri-clr-bg);
|
|
475
|
+
border-radius: var(--ter-rd);
|
|
476
|
+
width: 30px;
|
|
477
|
+
height: 30px;
|
|
478
|
+
align-self: start;
|
|
479
|
+
> img {
|
|
480
|
+
object-fit: contain;
|
|
481
|
+
width: 100%;
|
|
482
|
+
height: 100%;
|
|
483
|
+
background-color: var(--pri-clr-bg);
|
|
484
|
+
}
|
|
485
|
+
${({ $size }:{ $size?: string }) => {
|
|
486
|
+
let style = ``;
|
|
487
|
+
if ($size) {
|
|
488
|
+
style += `
|
|
489
|
+
width:${$size};
|
|
490
|
+
height:${$size};
|
|
491
|
+
`
|
|
492
|
+
}
|
|
493
|
+
return style;
|
|
494
|
+
}}
|
|
327
495
|
`
|
|
@@ -202,6 +202,19 @@ const getButtonModifiedStyled = ({ $mode, $isIndicatorArrow, $isShown, $isLoadin
|
|
|
202
202
|
height: 16px;
|
|
203
203
|
}
|
|
204
204
|
`
|
|
205
|
+
} else if (iconLeft === 'add') {
|
|
206
|
+
style += `
|
|
207
|
+
&:before {
|
|
208
|
+
content: '+';
|
|
209
|
+
color: #118EC5;
|
|
210
|
+
position: absolute;
|
|
211
|
+
left: 12px;
|
|
212
|
+
top: 7px;
|
|
213
|
+
width: 14px;
|
|
214
|
+
height: 16px;
|
|
215
|
+
font-size: 16px;
|
|
216
|
+
}
|
|
217
|
+
`
|
|
205
218
|
}
|
|
206
219
|
}
|
|
207
220
|
if ($isIndicatorArrow) {
|
package/src/components/index.ts
CHANGED
|
@@ -23,6 +23,8 @@ export { default as TextAreaRefComponent } from './textarea/ref';
|
|
|
23
23
|
export { default as DateComponent } from './date';
|
|
24
24
|
export { default as DateTimeComponent } from './datetime';
|
|
25
25
|
export { default as RadioComponent } from './radio';
|
|
26
|
+
export { default as SwitchComponent } from './switch';
|
|
27
|
+
export { default as MasterTableComponent } from './masterTable';
|
|
26
28
|
|
|
27
29
|
export * from './dropdown/typed';
|
|
28
30
|
export * from './message/typed';
|