forstok-ui-lib 5.2.30 → 5.2.37

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.
@@ -0,0 +1,401 @@
1
+ import styled, { css } from 'styled-components';
2
+ import { dropBase } from '../../assets';
3
+
4
+ const DateRangeWrapperStyles = css`
5
+ align-items: center;
6
+ display: flex;
7
+ flex: 1;
8
+ flex-wrap: wrap;
9
+ height: 100%;
10
+ `
11
+ const SelectionDateActiveStyles = css`
12
+ background-color: var(--act-clr-bg);
13
+ color: var(--sec-clr);
14
+ `
15
+ const getSelectionDateModifiedStyled = ({ $activated }:{ $activated?: boolean }) => {
16
+ if ($activated) {
17
+ return SelectionDateActiveStyles
18
+ }
19
+ }
20
+ const getDateRangeMenuContainerModifiedStyled = ({ $mode }:{ $mode: string} ) => {
21
+ let style = ``
22
+ if ($mode === 'filterorder') {
23
+ style += `
24
+ width: auto;
25
+ transform: translateX(-50%);
26
+ ${DateRangeSelection} {
27
+ text-align: center;
28
+ }
29
+ @media (min-width: 768px) {
30
+ width: auto;
31
+ left: 50% !important;
32
+ transform: translateX(-50%);
33
+ }
34
+ @media (min-width: 1024px) {
35
+ width: auto;
36
+ }
37
+ @media (min-width: 1280px) {
38
+ width: 660px;
39
+ ${DateRangeSelection} {
40
+ text-align: left;
41
+ }
42
+ }
43
+ `
44
+ } else if ($mode ==='filterdashboard') {
45
+ style += `
46
+ width: auto;
47
+ left: 50% !important;
48
+ transform: translateX(-50%);
49
+ ${DateRangeSelection} {
50
+ text-align: center;
51
+ }
52
+ @media (min-width: 768px) {
53
+ width: auto;
54
+ left: 50% !important;
55
+ transform: translateX(-50%);
56
+ }
57
+ @media (min-width: 1024px) {
58
+ width: auto;
59
+ }
60
+ @media (min-width: 1280px) {
61
+ width: 660px;
62
+ left: 0 !important;
63
+ transform: none;
64
+ ${DateRangeSelection} {
65
+ text-align: left;
66
+ }
67
+ }
68
+ `
69
+ } else if ($mode === 'filterordertofulfill') {
70
+ style += `
71
+ width: auto;
72
+ left: 50% !important;
73
+ transform: translateX(-50%);
74
+ ${DateRangeSelection} {
75
+ text-align: center;
76
+ }
77
+ @media (min-width: 768px) {
78
+ width: auto;
79
+ left: unset !important;
80
+ right: 0;
81
+ transform: none;
82
+ }
83
+ @media (min-width: 1024px) {
84
+ width: auto;
85
+ }
86
+ @media (min-width: 1280px) {
87
+ width: 660px;
88
+ ${DateRangeSelection} {
89
+ text-align: left;
90
+ }
91
+ }
92
+ `
93
+ } else if ($mode === 'popuppayment') {
94
+ style += `
95
+ width: auto;
96
+ border-radius: var(--ter-rd);
97
+ `
98
+ }
99
+ return style
100
+ }
101
+ const getDateRangeControlModifiedStyled = ({ $mode, $size }:{ $mode: string, $size?: string }) => {
102
+ let style = ``
103
+ if ($size === 'small') {
104
+ style += `height: 30px;`
105
+ } else {
106
+ style += `height: 36px;`
107
+ }
108
+ if ($mode === 'filterorder' || $mode === 'filterdashboard' || $mode === 'filterordertofulfill') {
109
+ style += `
110
+ height: auto;
111
+ border: none;
112
+ `
113
+ } else if ($mode === 'popuppayment') {
114
+ style += `
115
+ height: 30px;
116
+ border-radius: var(--ter-rd);
117
+ background-color: hsl(0,0%,100%);
118
+ & ${DateRangeLabel} {
119
+ color: var(--inp-clr);
120
+ padding-bottom: 0;
121
+ }
122
+ & ${DateRangeIndicatorsContainer} {
123
+ padding: 0 4px;
124
+ }
125
+ `
126
+ }
127
+ return style
128
+ }
129
+ const getDateRangeContainerModifiedStyled = ({ $mode }:{ $mode: string }) => {
130
+ let style = `
131
+ &.is-shown {
132
+ & ${DateRangeMenuContainer} {
133
+ display: block;
134
+ }
135
+ > div button { box-shadow: var(--act-shd-bx); }
136
+ }
137
+ `
138
+ if ($mode === 'filter') {
139
+ style += `
140
+ width: 100%;
141
+ & ${DateRangeMenuContainer} {
142
+ width: 100%;
143
+ margin-left: 16px;
144
+ @media (min-width: 768px) {
145
+ width: calc(40vw - 32px);
146
+ }
147
+ }
148
+ & ${DateRangeControl},
149
+ & ${DateRangeLabelContainer},
150
+ & ${DateRangeIndicatorsContainer} {
151
+ height: 14px;
152
+ }
153
+ & ${DateRangeLabelContainer} {
154
+ margin-left: 15px;
155
+ }
156
+ & ${DateRangeControl} {
157
+ border: 0;
158
+ }
159
+ & ${DateRangeLabel} {
160
+ padding-top: 3px;
161
+ }
162
+ & ${DateRangeIndicatorsContainer} {
163
+ margin-top: -5px;
164
+ }
165
+ & ${DateRangeIndicatorsArrowIconSvg} {
166
+ fill: #429ddf;
167
+ }
168
+ & .DateRangePicker__Month {
169
+ @media (min-width: 768px) {
170
+ width: calc((40vw - 182px) / 2);
171
+ margin: 0 10px;
172
+ }
173
+ @media (min-width: 1280px) {
174
+ width: calc((40vw - 234px) / 2);
175
+ margin: 0 20px;
176
+ }
177
+ }
178
+ ._refCheckboxContainer {
179
+ position: absolute;
180
+ top: 7px;
181
+ left: 0;
182
+ }
183
+ @media (min-width: 768px) {
184
+ width: 100%;
185
+ }
186
+ `
187
+ } else if ($mode === 'filterorder' || $mode === 'filterdashboard' || $mode === 'filterordertofulfill') {
188
+ style += `
189
+ width: auto !important;
190
+ `
191
+ } else if ($mode === 'popuppayment') {
192
+ style += `
193
+ width: 100% !important;
194
+ &.is-shown {
195
+ > div {
196
+ border: 1px solid var(--pri-clr-ln__fc) !important;
197
+ }
198
+ }
199
+ `
200
+ }
201
+ return style
202
+ }
203
+ const getDateRangeLabelModifiedStyled = ({ $size }: { $size?: string }) => {
204
+ if ($size === 'small') {
205
+ return `
206
+ font-size: 14px;
207
+ `
208
+ }
209
+ }
210
+ const getDatePickerContainerModifiedStyled = ({ $isError }:{ $isError?: boolean }) => {
211
+ if ($isError) {
212
+ return `
213
+ input {
214
+ border:1px solid var(--err-clr-ln) !important;
215
+ }
216
+ `
217
+ }
218
+ }
219
+
220
+ export const DateRangeMenuContainer = styled.section<{ $mode: string }>`
221
+ ${dropBase}
222
+ top:100%;
223
+ margin: 8px 0;
224
+ position:absolute;
225
+ z-index: 999;
226
+ width: 100%;
227
+ display: none;
228
+ @media (min-width: 768px) {
229
+ width: 45vw;
230
+ }
231
+ @media (min-width: 1024px) {
232
+ width: 39vw;
233
+ }
234
+ @media (min-width: 1280px) {
235
+ width: 660px;
236
+ }
237
+ ${getDateRangeMenuContainerModifiedStyled}
238
+ `
239
+ export const DateRangeControl = styled.div<{ $mode: string, $size?: string }>`
240
+ ${DateRangeWrapperStyles}
241
+ border: 1px solid var(--ck-clr-ln);
242
+ border-radius: var(--ter-rd);
243
+ cursor: pointer;
244
+ justify-content: space-between;
245
+ ${getDateRangeControlModifiedStyled}
246
+ `
247
+ export const DateRangeContainer = styled.section<{ $mode: string }>`
248
+ position: relative;
249
+ display: inline-grid;
250
+ width: 100%;
251
+ @media (min-width: 1024px) {
252
+ width: 220px;
253
+ }
254
+ @media (min-width: 1280px) {
255
+ width: 305px;
256
+ }
257
+ ${getDateRangeContainerModifiedStyled}
258
+ `
259
+ export const DateRangeLabelContainer = styled.div`
260
+ ${DateRangeWrapperStyles}
261
+ padding: 0 8px;
262
+ position: relative;
263
+ overflow: hidden;
264
+
265
+ `
266
+ export const DateRangeLabel = styled.div<{ $size?: string }>`
267
+ position: absolute;
268
+ top: 50%;
269
+ max-width: calc(100% - 8px);
270
+ color: initial;
271
+ margin: 0 2px;
272
+ overflow: hidden;
273
+ text-overflow: ellipsis;
274
+ white-space: nowrap;
275
+ transform: translateY(-50%);
276
+ padding-bottom: 2px;
277
+ font-weight: 400;
278
+ ${getDateRangeLabelModifiedStyled}
279
+ `
280
+ export const DateRangeIndicatorsContainer= styled.div`
281
+ color: #757575;
282
+ display: flex;
283
+ padding: 0 8px;
284
+ transition: color 150ms;
285
+ `
286
+ export const DateRangeIndicatorsArrowIconSvg= styled.svg`
287
+ display: inline-block;
288
+ fill: currentColor;
289
+ stroke: currentColor;
290
+ stroke-width: 0;
291
+ `
292
+ export const DateRangeMenu = styled.div`
293
+ display: grid;
294
+ grid-auto-flow: row;
295
+ justify-content: center;
296
+ @media (min-width: 1280px) {
297
+ grid-template-columns: 112px 1fr;
298
+ }
299
+ `
300
+ export const DateRangeSelection = styled.aside`
301
+ display: inline-grid;
302
+ grid-auto-flow: column;
303
+ border-bottom: 1px solid rgba(0, 0, 0, .1);
304
+ align-items: start;
305
+ font-size: 14px;
306
+ @media (min-width: 1280px) {
307
+ grid-auto-flow: row;
308
+ grid-template-rows: repeat(5, 35px [row-start]);
309
+ grid-row-gap: 1px;
310
+ border-right: 1px solid rgba(0, 0, 0, .1);
311
+ border-bottom: 0;
312
+ align-items: center;
313
+ }
314
+ `
315
+ export const SelectionDate = styled.div<{ $activated?: boolean }>`
316
+ cursor: pointer;
317
+ display: grid;
318
+ justify-self: stretch;
319
+ padding: 10px 8px;
320
+ border-right: 1px solid rgba(0, 0, 0, .1);
321
+ height: 100%;
322
+ align-items: center;
323
+ &:hover {
324
+ background-color: #ec5b62;
325
+ color: #fff;
326
+ }
327
+ @media (min-width: 1280px) {
328
+ height: auto;
329
+ border-right: 0;
330
+ }
331
+ ${getSelectionDateModifiedStyled}
332
+ `
333
+ export const DateRangeAside = styled.aside`
334
+ display: grid;
335
+ width: 100%;
336
+ grid-column-gap: 10px;
337
+ grid-row-gap: 0;
338
+ padding: 8px;
339
+ border-top: 1px solid rgba(0, 0, 0, .1);
340
+ justify-items: right;
341
+ grid-auto-flow: column;
342
+ grid-template-columns: 1fr max-content;
343
+ justify-content: right;
344
+ align-items: center;
345
+ > div {
346
+ display: grid;
347
+ grid-auto-flow: column;
348
+ grid-gap: 8px;
349
+ }
350
+ `
351
+ export const DateContainer = styled.div<{ $isError?: boolean }>`
352
+ position: relative;
353
+ .react-datepicker-wrapper {
354
+ width: 100%;
355
+ }
356
+ ${getDatePickerContainerModifiedStyled}
357
+ `
358
+ export const DateIndicatorContainer = styled.div`
359
+ position: absolute;
360
+ top: 5px;
361
+ right: 2px;
362
+ display: flex;
363
+ transition: color 150ms;
364
+ color: hsl(0, 0%, 80%);
365
+ padding: 0;
366
+ box-sizing: border-box;
367
+ min-height: 1px;
368
+ cursor: pointer;
369
+ &:hover {
370
+ color: hsl(0, 0%, 60%);
371
+ }
372
+ svg {
373
+ display: inline-block;
374
+ fill: currentColor;
375
+ line-height: 1;
376
+ stroke: currentColor;
377
+ stroke-width: 0;
378
+ }
379
+ `
380
+ export const DatePickerContainer = styled.div<{ $isError?: boolean }>`
381
+ .react-datepicker-wrapper {
382
+ width: 100%;
383
+ }
384
+ ${getDatePickerContainerModifiedStyled}
385
+ `
386
+ export const DateRangePortalContainer = styled.div`
387
+ display: inline-block;
388
+ position: fixed;
389
+ top: 0;
390
+ left: 0;
391
+ z-index: 999;
392
+ &.is-shown {
393
+ & ${DateRangeMenuContainer} {
394
+ display: block;
395
+ }
396
+ }
397
+ `
398
+ export const DateRangeIconContainer = styled.div`
399
+ display: flex;
400
+ padding: 0 0 0 12px;
401
+ `
@@ -0,0 +1 @@
1
+ export type TModerateDateFunction = (startDateObj: string, endDateObj: string, rangeDateObj: string, callback: () => void) => void;
@@ -22,6 +22,10 @@ import IconWarning from '../../assets/images/icons/warning.svg';
22
22
  import IconAlert from '../../assets/images/icons/alert.svg';
23
23
  import IconBarcode from '../../assets/images/icons/barcode.svg';
24
24
  import IconTrash from '../../assets/images/icons/trash.svg'
25
+ import IconArrowLeft from '../../assets/images/icons/arrow-left.svg'
26
+ import IconArrowLeftDouble from '../../assets/images/icons/arrow-left-double.svg'
27
+ import IconArrowRight from '../../assets/images/icons/arrow-right.svg'
28
+ import IconArrowRightDouble from '../../assets/images/icons/arrow-right-double.svg'
25
29
 
26
30
  const getIconContainerStyled = ({ $mode, $name, $width, onClick }:{ $mode?: string, $name: string, $width?: string | number, onClick?: (e: MouseEvent<HTMLElement>) => void }) => {
27
31
  let style = ``;
@@ -180,6 +184,34 @@ const getIconContainerStyled = ({ $mode, $name, $width, onClick }:{ $mode?: stri
180
184
  }
181
185
  `
182
186
  break;
187
+ case 'arrow-left':
188
+ style += `
189
+ &:before {
190
+ content: url(${IconArrowLeft});
191
+ }
192
+ `
193
+ break
194
+ case 'arrow-left-double':
195
+ style += `
196
+ &:before {
197
+ content: url(${IconArrowLeftDouble});
198
+ }
199
+ `
200
+ break
201
+ case 'arrow-right':
202
+ style += `
203
+ &:before {
204
+ content: url(${IconArrowRight});
205
+ }
206
+ `
207
+ break
208
+ case 'arrow-right-double':
209
+ style += `
210
+ &:before {
211
+ content: url(${IconArrowRightDouble});
212
+ }
213
+ `
214
+ break
183
215
  default:
184
216
  break;
185
217
  }
@@ -20,11 +20,13 @@ export { default as UploadComponent } from './upload';
20
20
  export { default as UploadDragDropComponent } from './upload/drag_drop';
21
21
  export { default as TextAreaComponent } from './textarea';
22
22
  export { default as TextAreaRefComponent } from './textarea/ref';
23
+ export { default as DateRangeComponent } from './date/daterange';
23
24
 
24
25
  export * from './dropdown/typed';
25
26
  export * from './message/typed';
26
27
  export * from './popup/typed';
27
28
  export * from './select/typed';
29
+ export * from './date/typed';
28
30
 
29
31
  export * from './form/styles';
30
32
 
package/src/index.ts CHANGED
@@ -2,4 +2,5 @@
2
2
 
3
3
  export * from './components';
4
4
  export * from './assets';
5
- export * from './typeds';
5
+ export * from './typeds';
6
+ export * from './maps';
@@ -0,0 +1,10 @@
1
+ import moment from 'moment';
2
+ import { dateRangeDays } from '../assets/javascripts/helper';
3
+
4
+ export const configDateRange = {
5
+ rangeDate: 'lastsecondweek',
6
+ startDate: moment().clone().subtract(13, 'days').format('YYYY-MM-DD') as string,
7
+ endDate: moment().clone().format('YYYY-MM-DD') as string,
8
+ placeholder: 'Last 14 days',
9
+ minDate: moment().clone().subtract(dateRangeDays('lastquart'), 'days').format('YYYY-MM-DD') as string
10
+ }
@@ -0,0 +1 @@
1
+ export * from './common';