forstok-ui-lib 6.20.2 → 6.21.2

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 (29) hide show
  1. package/dist/index.d.ts +10 -49
  2. package/dist/index.js +571 -1167
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +569 -1165
  5. package/dist/index.mjs.map +1 -1
  6. package/package.json +1 -1
  7. package/src/assets/javascripts/function.ts +21 -0
  8. package/src/assets/javascripts/helper.ts +11 -2
  9. package/src/components/index.ts +0 -1
  10. package/src/components/link/index.tsx +4 -1
  11. package/src/components/link/styles.ts +152 -144
  12. package/src/components/link/typed.ts +10 -0
  13. package/src/typeds/shares.typed.ts +26 -26
  14. package/src/components/masterTable/index.tsx +0 -649
  15. package/src/components/masterTable/partials/datas/confirm.tsx +0 -92
  16. package/src/components/masterTable/partials/datas/index.tsx +0 -81
  17. package/src/components/masterTable/partials/editors/date.bare.tsx +0 -39
  18. package/src/components/masterTable/partials/editors/date.tsx +0 -123
  19. package/src/components/masterTable/partials/editors/image.tsx +0 -61
  20. package/src/components/masterTable/partials/editors/input.bare.tsx +0 -127
  21. package/src/components/masterTable/partials/editors/input.tsx +0 -140
  22. package/src/components/masterTable/partials/editors/label.tsx +0 -128
  23. package/src/components/masterTable/partials/editors/select.bare.tsx +0 -104
  24. package/src/components/masterTable/partials/editors/select.tsx +0 -142
  25. package/src/components/masterTable/partials/editors/switch.tsx +0 -56
  26. package/src/components/masterTable/partials/editors/tag.tsx +0 -49
  27. package/src/components/masterTable/partials/editors/textarea.tsx +0 -7
  28. package/src/components/masterTable/styles.tsx +0 -1011
  29. package/src/components/masterTable/typed.ts +0 -87
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forstok-ui-lib",
3
- "version": "6.20.2",
3
+ "version": "6.21.2",
4
4
  "description": "Forstok UI Components Library",
5
5
  "path": "dist",
6
6
  "main": "dist/index.js",
@@ -113,6 +113,27 @@ export const currencyNumber = (value?: number | null) => {
113
113
  return (value !== undefined && value !== null) ? value.toLocaleString('id-ID', { style: 'currency', currency: 'IDR', minimumFractionDigits: 0 }) : '-'
114
114
  }
115
115
 
116
+ export const generateSUM = (names: string[] | string, data: any, type?: string) => {
117
+ let result: number = 0
118
+ if (data && names) {
119
+ result = data.reduce((_sum: any, cur: any) => {
120
+ let _name
121
+ if (Array.isArray(names)) {
122
+ _name = cur
123
+ for (const name of names) {
124
+ if (name in _name) {
125
+ _name = _name[name]
126
+ }
127
+ }
128
+ } else {
129
+ _name = cur[names]
130
+ }
131
+ return _sum + (type === 'currency' ? parseInt(_name.replace(/,.*|[^0-9]/g, '')) : _name)
132
+ }, 0)
133
+ }
134
+ return result
135
+ }
136
+
116
137
  export const evUpdateInputRc = (input?: HTMLInputElement, value?: string | number) => {
117
138
  if (!input) {
118
139
  return false;
@@ -1,11 +1,11 @@
1
- import { TObject } from '../../typeds';
1
+ import { BodyContentMode, TObject } from '../../typeds';
2
2
 
3
3
  export const dateRangeStatus = (value: string) => {
4
4
  const statusObj: TObject = { 'today': 'Today', 'lastweek': 'Last 7 days', 'lastsecondweek': 'Last 14 days', 'lastmonth': 'Last 30 days', 'lastquart': 'Last 90 days', 'custom': 'Date' }
5
5
  return statusObj[value]
6
6
  }
7
7
 
8
- export const pageMasterTable = (value: string) => {
8
+ export const pageMasterTable = (value?: BodyContentMode) => {
9
9
  switch (value) {
10
10
  case 'create-master': case 'edit-master':
11
11
  return 'master'
@@ -154,6 +154,15 @@ export const typePage = (value?: string) => {
154
154
  }
155
155
  }
156
156
 
157
+ export const isCustomVariantChannel = (channelId: number) => {
158
+ let result = false
159
+ if (channelId !== undefined) {
160
+ const listCompareChannels = [9, 3, 12, 10030, 15, 13] //blibli, lazada, shopee, tiktok, tokopedia, zalora
161
+ result = listCompareChannels.includes(channelId)
162
+ }
163
+ return result
164
+ }
165
+
157
166
  export const historyType = (name?: string) => {
158
167
  if(!name) return ''
159
168
  switch(name) {
@@ -24,7 +24,6 @@ export { default as DateComponent } from './date';
24
24
  export { default as DateTimeComponent } from './datetime';
25
25
  export { default as RadioComponent } from './radio';
26
26
  export { default as SwitchComponent } from './switch';
27
- export { default as MasterTableComponent } from './masterTable';
28
27
  export { default as ListComponent } from './list';
29
28
 
30
29
  export * from './message/typed';
@@ -1,9 +1,12 @@
1
1
  import type { AnchorHTMLAttributes, ReactNode, MouseEvent, HTMLAttributes } from 'react';
2
+
2
3
  import { AnchorLinkContainer, ElLinkContainer } from './styles';
3
4
 
5
+ import { LinkMode } from './typed'
6
+
4
7
  type TLinkBase = {
5
8
  children: ReactNode
6
- mode?: string
9
+ mode?: LinkMode
7
10
  $activated?: boolean
8
11
  $elipsis?: boolean
9
12
  $shadow?: boolean
@@ -1,28 +1,10 @@
1
- import styled, { css } from 'styled-components';
2
- import { multiElipsis } from '../../assets/stylesheets/bases.styles';
1
+ import { Link } from 'react-router-dom'
2
+ import styled, { css } from 'styled-components'
3
3
 
4
- import IconXLS from '../../assets/images/icons/xls.svg'
4
+ import IconXls from '../../assets/images/icons/xls.svg'
5
+ import { multiElipsis } from '../../assets/stylesheets/bases.styles'
6
+ import { LinkMode } from './typed'
5
7
 
6
- const ClearStyles = css`
7
- color: var(--pri-clr-lnk);
8
- &,
9
- &:hover {
10
- text-decoration: none;
11
- }
12
- &:hover {
13
- color: var(--pri-clr-lnk__hvr);
14
- }
15
- `
16
- const ClearRStyles = css`
17
- color: var(--pri-clr-lnk);
18
- &,
19
- &:hover {
20
- text-decoration: none;
21
- }
22
- &:hover {
23
- color: var(--sec-clr-lnk__hvr);
24
- }
25
- `
26
8
  const ButtonStyles = css`
27
9
  position: relative;
28
10
  display: inline-grid;
@@ -38,132 +20,158 @@ const ButtonStyles = css`
38
20
  text-decoration: none;
39
21
  }
40
22
  `
41
- const getLinkModifiedStyled = ({ mode, $elipsis, $activated, $shadow, $iconRight, disabled }:{ mode?: string, $elipsis: boolean, $activated: boolean, $shadow: boolean, $iconRight?: string, disabled: boolean }) => {
42
- let style = ``;
43
- if (mode === 'clear') {
44
- style += ClearStyles
45
- } else if (mode === 'clearR') {
46
- style += ClearRStyles
47
- } else if (mode === 'blue') {
48
- style += `
49
- &, &:hover {
50
- color: var(--pri-clr-lnk__hvr);
51
- text-decoration: none;
52
- }
53
- `
54
- } else if (mode === 'trans') {
55
- style += ButtonStyles + `
56
- height: auto;
57
- padding: 0;
58
- opacity: 1;
59
- &,
60
- &:hover {
61
- color: var(--pri-clr-lnk__hvr);
62
- text-decoration: none;
63
- }
64
- &:hover {
65
- opacity: .9;
66
- }
67
- `
68
- } else if (mode === 'hover') {
69
- style += ButtonStyles + `
70
- height: auto;
71
- width: max-content;
72
- padding: 3px 6px;
73
- position: relative;
74
- left: -6px;
75
- color: initial;
76
- grid-gap: 4px;
77
- &:hover {
78
- border-radius: var(--ter-rd);
79
- box-shadow: 1px 1px var(--pri-clr-ln);
80
- background-color: var(--mt-clr-bg__fc);
81
- text-decoration: none;
82
- }
83
- `
84
- } else if (mode === 'whiteB') {
85
- style += ButtonStyles + `
86
- color: var(--ter-clr);
87
- background-color: var(--cl-clr-bg);
88
- border: 1px solid var(--sec-clr-ln);
89
- &,
90
- &:hover {
91
- background-color: var(--cl-clr-bg__hvr);
92
- }
93
- `
94
- } else if (mode === 'redB') {
95
- style += ButtonStyles + `
96
- color: var(--act-clr);
97
- background-color: var(--act-clr-bg);
98
- &:hover {
99
- background-color: var(--act-clr-bg__hvr);
100
- }
101
- `
102
- } else if (mode === 'greyB') {
103
- style += ButtonStyles + `
104
- color: var(--act-clr);
23
+ const modeStyles = {
24
+ clear: css`
25
+ color: var(--pri-clr-lnk);
26
+ &,
27
+ &:hover {
28
+ text-decoration: none;
29
+ }
30
+ &:hover {
31
+ color: var(--pri-clr-lnk__hvr);
32
+ }
33
+ `,
34
+ clearR: css`
35
+ color: var(--pri-clr-lnk);
36
+ &,
37
+ &:hover {
38
+ text-decoration: none;
39
+ }
40
+ &:hover {
41
+ color: var(--sec-clr-lnk__hvr);
42
+ }
43
+ `,
44
+ blue: css`
45
+ &,
46
+ &:hover {
47
+ color: var(--pri-clr-lnk__hvr);
48
+ text-decoration: none;
49
+ }
50
+ `,
51
+ trans: css`
52
+ ${ButtonStyles}
53
+ height: auto;
54
+ padding: 0;
55
+ opacity: 1;
56
+ &,
57
+ &:hover {
58
+ color: var(--pri-clr-lnk__hvr);
59
+ text-decoration: none;
60
+ }
61
+ &:hover {
62
+ opacity: .9;
63
+ }
64
+ `,
65
+ hover: css`
66
+ ${ButtonStyles}
67
+ height: auto;
68
+ width: max-content;
69
+ padding: 3px 6px;
70
+ position: relative;
71
+ left: -6px;
72
+ color: initial;
73
+ grid-gap: 4px;
74
+ &:hover {
75
+ border-radius: var(--ter-rd);
76
+ box-shadow: 1px 1px var(--pri-clr-ln);
105
77
  background-color: var(--mt-clr-bg__fc);
106
- &:hover {
107
- background-color: var(--cl-clr-bg__hvr);
108
- }
109
- `
110
- }
111
- if ($activated) {
112
- style += `
113
- color: var(--sta-clr);
114
- font-weight: 400;
115
- `
116
- if (mode === 'clear' || mode === 'clearR') {
117
- style += `
118
- color: var(--pri-clr-lnk__act);
119
- font-weight: 600;
120
- `
78
+ text-decoration: none;
121
79
  }
122
- }
123
- if ($elipsis) {
124
- style += `
125
- overflow: hidden;
126
- text-overflow: ellipsis;
127
- white-space: nowrap;
128
- display: block;
129
- max-width: 100%;
130
- width: auto;
131
- ${multiElipsis}
132
- `
133
- }
134
- if ($shadow) {
135
- style += `
136
- box-shadow: var(--act-shd-bx);
137
- `
138
- }
139
- if ($iconRight === 'xls') {
140
- style += `
141
- position: relative;
142
- padding-right: 21px;
143
- &:before {
144
- content: url(${IconXLS});
145
- position: absolute;
146
- right: 0px;
147
- top: -4px;
148
- width: 18px;
149
- height: 18px;
150
- }
151
- `
152
- }
153
- if(disabled) {
154
- style += `
155
- color: #A9A9A9;
156
- opacity: 0.7;
157
- pointer-events: none;
158
- `
159
- }
160
- return style;
161
- }
80
+ `,
81
+ whiteB: css`
82
+ ${ButtonStyles}
83
+ color: var(--ter-clr);
84
+ background-color: var(--cl-clr-bg);
85
+ border: 1px solid var(--sec-clr-ln);
86
+ &,
87
+ &:hover {
88
+ background-color: var(--cl-clr-bg__hvr);
89
+ }
90
+ `,
91
+ redB: css`
92
+ ${ButtonStyles}
93
+ color: var(--act-clr);
94
+ background-color: var(--act-clr-bg);
95
+ &:hover {
96
+ background-color: var(--act-clr-bg__hvr);
97
+ }
98
+ `,
99
+ greyB: css`
100
+ ${ButtonStyles}
101
+ color: var(--act-clr);
102
+ background-color: var(--mt-clr-bg__fc);
103
+ &:hover {
104
+ background-color: var(--cl-clr-bg__hvr);
105
+ }
106
+ `,
107
+ table: css`
108
+ display: block;
109
+ width: 100%;
110
+ text-wrap: wrap;
111
+ word-wrap: break-word;
112
+ font-size: 13px;
113
+ `
114
+ } as const
115
+ const getLinkModifiedStyled = ({ mode, $elipsis, $activated, $shadow, $iconRight, disabled }:{ mode?: LinkMode, $elipsis: boolean, $activated: boolean, $shadow: boolean, $iconRight?: string, disabled: boolean }) => css`
116
+ ${mode && modeStyles[mode]}
117
+
118
+ ${$activated && css`
119
+ color: var(--sta-clr);
120
+ font-weight: 400;
121
+ `}
122
+
123
+ ${(mode === 'clear' || mode === 'clearR') && css`
124
+ font-weight: ${$activated ? '600' : 'normal'};
125
+ color: ${$activated ? 'var(--pri-clr-lnk__act) !important' : 'inherit'};
126
+ `}
127
+
128
+ ${$elipsis && css`
129
+ overflow: hidden;
130
+ text-overflow: ellipsis;
131
+ white-space: nowrap;
132
+ display: block;
133
+ max-width: 100%;
134
+ width: auto;
135
+ ${multiElipsis}
136
+ `}
162
137
 
163
- export const AnchorLinkContainer = styled.a<{ mode?: string, $elipsis: boolean, $activated: boolean, $shadow: boolean, $iconRight?: string, disabled: boolean }>`
138
+ ${$shadow && css`
139
+ box-shadow: var(--act-shd-bx);
140
+ `}
141
+
142
+ ${$iconRight === 'xls' && css`
143
+ position: relative;
144
+ padding-right: 21px;
145
+ &:before {
146
+ content: url(${IconXls});
147
+ position: absolute;
148
+ right: 0px;
149
+ top: -4px;
150
+ width: 18px;
151
+ height: 18px;
152
+ }
153
+ `}
154
+
155
+ ${disabled && css`
156
+ color: #A9A9A9;
157
+ opacity: 0.7;
158
+ pointer-events: none;
159
+ `}
160
+ `
161
+ export const AnchorLinkContainer = styled.a<{ mode?: LinkMode, $elipsis: boolean, $activated: boolean, $shadow: boolean, $iconRight?: string, disabled: boolean }>`
164
162
  ${getLinkModifiedStyled}
165
163
  `
166
- export const ElLinkContainer = styled.span<{ mode?: string, $elipsis: boolean, $activated: boolean, $shadow: boolean, $iconRight?: string, disabled: boolean }>`
164
+
165
+ export const ElLinkContainer = styled.span<{ mode?: LinkMode, $elipsis: boolean, $activated: boolean, $shadow: boolean, $iconRight?: string, disabled: boolean }>`
167
166
  cursor:pointer;
168
167
  ${getLinkModifiedStyled}
168
+ `
169
+
170
+ export const LinkContainer = styled(Link)<{ mode?: LinkMode, $elipsis: boolean, $activated: boolean, $shadow: boolean, $iconRight?: string, disabled: boolean }>`
171
+ &._refHoverLink {
172
+ padding: 3px 0px 0px 6px;
173
+ position: relative;
174
+ top: -3px;
175
+ }
176
+ ${getLinkModifiedStyled}
169
177
  `
@@ -0,0 +1,10 @@
1
+ export type LinkMode =
2
+ | 'clear'
3
+ | 'clearR'
4
+ | 'blue'
5
+ | 'trans'
6
+ | 'hover'
7
+ | 'whiteB'
8
+ | 'redB'
9
+ | 'greyB'
10
+ | 'table'
@@ -1,6 +1,5 @@
1
1
  import { Dispatch, JSX } from 'react';
2
2
  import { TChangeEvent, TMouseEvent, TObject, TPage, TState, TUPage } from './base.typed';
3
- import { TCustomField, TAutoCopy } from '../components/masterTable/typed';
4
3
  import { TMessageFunction, TMessageQuestionFunction } from '../components/message/typed';
5
4
  import { TPopupFunction, TPopupOpenFunction } from '../components/popup/typed';
6
5
  import { TOption } from '../components/select/typed';
@@ -85,30 +84,7 @@ export type THeadProps = {
85
84
  placeholder?: string
86
85
  isHidden?: boolean
87
86
  showFormat?: string
88
- }
89
- export type TMasterProps = {
90
- data: any
91
- setData: any
92
- headerColumns: THeadProps[]
93
- evCreateMessage?: TMessageFunction
94
- evCreateMessageQuestion?: TMessageQuestionFunction
95
- type?: string
96
- isLessField?: boolean
97
- isForceUpdateField?: boolean
98
- setForceUpdateField?: TState<boolean>
99
- evOpenPopup?: TPopupOpenFunction
100
- autoCopy?: TAutoCopy
101
- setAutoCopy?: TState<TAutoCopy>
102
- isAutoCopyField?: boolean
103
- resultPopup?: TObject | null
104
- setResultPopup?: TState<TObject | null>
105
- evCheckAllValidation?: any
106
- dataCustomField?: TCustomField[]
107
- setDataCustomField?: TState<TCustomField[]>
108
- isRemovable?: boolean
109
- isForceUpdate?: boolean
110
- setForceUpdate?: TState<boolean>
111
- evPickAll?: TMouseEvent
87
+ containOfType?: string[] | null
112
88
  }
113
89
 
114
90
  export type TInData<TData = never> = {
@@ -320,4 +296,28 @@ export type modeTable =
320
296
  | 'price'
321
297
  | 'price'
322
298
  | 'price-full'
323
- | 'price-mid'
299
+ | 'price-mid'
300
+
301
+ export type BodyContentStyle =
302
+ | 'create-return'
303
+ | 'create-price'
304
+ | 'create-adjustment'
305
+ | 'create-outbound'
306
+ | 'confirm-inbound'
307
+ | 'confirm-outbound'
308
+ | 'confirm-adjustment'
309
+
310
+ export type BodyContentMode = BodyContentStyle
311
+ | 'create-promotion'
312
+ | 'create-inbound'
313
+ | 'create-transfer'
314
+ | 'create-picklist'
315
+ | 'edit-picklist'
316
+ | 'create-package'
317
+ | 'edit-master'
318
+ | 'putaway-inbound'
319
+ | 'create-paymentreceive'
320
+ | 'create-master'
321
+ | 'create-listing'
322
+ | 'create-adjustment'
323
+ | 'edit-listing'