forstok-ui-lib 6.4.3 → 6.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forstok-ui-lib",
3
- "version": "6.4.3",
3
+ "version": "6.5.1",
4
4
  "description": "Forstok UI Components Library",
5
5
  "path": "dist",
6
6
  "main": "dist/index.js",
@@ -108,14 +108,8 @@ export const generateMessageQuestion = (type: string, title: string, subtitle: s
108
108
  return result;
109
109
  }
110
110
 
111
- export const currencyNumber = (value: number) => {
112
- if (value === null) {
113
- return value;
114
- } else if (typeof value == 'number') {
115
- return value.toLocaleString('id-ID', {style: 'currency', currency: 'IDR', minimumFractionDigits: 0});
116
- } else {
117
- return value;
118
- }
111
+ export const currencyNumber = (value?: number | null) => {
112
+ return (value !== undefined && value !== null) ? value.toLocaleString('id-ID', { style: 'currency', currency: 'IDR', minimumFractionDigits: 0 }) : '-'
119
113
  }
120
114
 
121
115
  export const evUpdateInputRc = (input?: HTMLInputElement, value?: string | number) => {
@@ -679,4 +673,9 @@ export const evSetTotal = (totalCount: number, totalEl: HTMLSpanElement, callbac
679
673
  if (callback && typeof(callback) == "function") {
680
674
  callback()
681
675
  }
676
+ }
677
+
678
+ export const humanise = (value?: string) => {
679
+ const underscoreMatch = /_/g, underscoreMatch2 = /-/g
680
+ return value ? value.replace(underscoreMatch, " ").replace(underscoreMatch2, " ") : ''
682
681
  }
@@ -3996,4 +3996,46 @@ export const BulkSelectContainer = styled.div`
3996
3996
  @media only screen and (min-width: 1024px) {
3997
3997
  grid-gap: 32px;
3998
3998
  }
3999
+ `
4000
+
4001
+ export const DotIcon = styled.span<{ $color?: string, $mode?: 'activities' }>`
4002
+ display: inline-block;
4003
+ vertical-align: middle;
4004
+ margin-right: 8px;
4005
+ margin-top: -4px;
4006
+ width: 4px;
4007
+ height: 4px;
4008
+ border-radius: 2px;
4009
+
4010
+ ${({ $color }) => $color && css`
4011
+ background-color: ${$color}
4012
+ `}
4013
+
4014
+ ${({ $mode }) => $mode === 'activities' && css`
4015
+ margin-top: -6px;
4016
+ margin-left: -2.5px;
4017
+ width: 8px;
4018
+ height: 8px;
4019
+ border-radius: 4px;
4020
+ `}
4021
+ `
4022
+
4023
+ export const ItemQtyLabel = styled.span`
4024
+ text-align: right;
4025
+ display: grid;
4026
+ `
4027
+
4028
+ export const APILabel = styled.label`
4029
+ color: var(--act-clr);
4030
+ font-size: 10px;
4031
+ text-transform: uppercase;
4032
+ letter-spacing: .5px;
4033
+ padding: 3px 5px;
4034
+ background-color: #21BA45;
4035
+ display: block;
4036
+ position: absolute;
4037
+ right: 10px;
4038
+ top: 12px;
4039
+ z-index: 1;
4040
+ border-radius: var(--ter-rd);
3999
4041
  `
@@ -0,0 +1,62 @@
1
+ import Image from '.'
2
+
3
+ import { InitialContainer, APILabel } from '../../assets/stylesheets/shares.styles'
4
+
5
+ import { ImageMode } from './type'
6
+
7
+ const ImageChannelComponent = ({ data, label, size, isImageOnly, $mode }:{ data?: any, label?: string, size?: string, isImageOnly?: boolean, $mode?: ImageMode }) => {
8
+ const fontSize = size ? ((parseInt(size) / 2) > 10 ? (parseInt(size) / 2) : 10) : 10
9
+ const defSize = size || '20px'
10
+
11
+ if (!data) {
12
+ return (
13
+ <>{!isImageOnly && <span>{label || '-'}</span>}</>
14
+ )
15
+ }
16
+
17
+ const defName = label || data?.name || data?.storeName || data?.store_name || data?.accountName || data?.channelName || data?.channel_name || 'No Store'
18
+ const defSrc = data?.icon || data?.imageUrl || data?.channelImage || data?.channel_image || ''
19
+ const defColor = data?.color || data?.channelColor || data?.channel_color || '#ooo'
20
+ const defInitial = data?.channelInitials || data?.channelInitial || data?.channel_initials || data?.initials || ''
21
+ const isAPI = data?.availableAPI
22
+
23
+ return (
24
+ <>
25
+ <div>
26
+ {defSrc ? (
27
+ <Image
28
+ $mode={$mode}
29
+ width='auto'
30
+ height={defSize}
31
+ src={defSrc || '/'}
32
+ alt={data.channelName || data.channel_name || ''}
33
+ />
34
+ ) : (
35
+ defInitial? (
36
+ <InitialContainer style={{
37
+ width: defSize,
38
+ height: defSize,
39
+ backgroundColor: defColor,
40
+ fontSize: fontSize+'px'}}
41
+ >{defInitial}</InitialContainer>
42
+ ) : (
43
+ <Image
44
+ $mode={$mode}
45
+ width='auto'
46
+ height={defSize}
47
+ src={'/'}
48
+ />
49
+ )
50
+ )}
51
+ </div>
52
+ {!isImageOnly && (
53
+ <span className='multi-elipsis' title={defName}>
54
+ {defName}
55
+ {isAPI && <APILabel className='_refLabel'>API</APILabel>}
56
+ </span>
57
+ )}
58
+ </>
59
+ )
60
+ }
61
+
62
+ export default ImageChannelComponent
@@ -0,0 +1,3 @@
1
+ export type ImageMode =
2
+ | 'store'
3
+ | 'product'
@@ -12,6 +12,7 @@ export { default as MessageComponent } from './message';
12
12
  export { default as MessageQuestionComponent } from './message/question';
13
13
  export { default as PopupComponent } from './popup';
14
14
  export { default as ImageComponent } from './image';
15
+ export { default as ImageChannelComponent } from './image/channel';
15
16
  export { default as SelectComponent } from './select';
16
17
  export { default as MenuList } from './select/menulist';
17
18
  export { default as ErrorComponent } from './error';