@operato/scene-chartjs 7.0.0-rc.0 → 7.0.0-rc.3

Sign up to get free protection for your applications and to get access to all the features.
package/schema.graphql CHANGED
@@ -29,7 +29,7 @@ type AppBinding {
29
29
  email: EmailAddress!
30
30
  id: ID!
31
31
  locale: String
32
- name: String
32
+ name: String!
33
33
  owner: Boolean
34
34
  reference: String
35
35
  refreshToken: String
@@ -133,7 +133,7 @@ type ApprovalLine {
133
133
  createdAt: DateTimeISO
134
134
  creator: User
135
135
  description: String
136
- domain: Domain!
136
+ domain: Domain
137
137
  id: ID!
138
138
  model: [ApprovalLineItem!]
139
139
  name: String
@@ -283,10 +283,11 @@ type AuthProvider {
283
283
  clientSecret: String
284
284
  createdAt: DateTimeISO
285
285
  creator: User
286
- domain: Domain!
286
+ domain: Domain
287
287
  id: ID!
288
288
  params: Object
289
289
  privateKey: String
290
+ state: String
290
291
  tenantId: String
291
292
  type: String
292
293
  updatedAt: DateTimeISO
@@ -304,7 +305,6 @@ type AuthProviderParameterSpec {
304
305
  name: String!
305
306
  placeholder: String
306
307
  property: Object
307
- styles: Object
308
308
  type: String!
309
309
  }
310
310
 
@@ -411,7 +411,7 @@ type BoardTemplate {
411
411
  createdAt: DateTimeISO
412
412
  creator: User
413
413
  description: String
414
- domain: Domain!
414
+ domain: Domain
415
415
  id: ID!
416
416
  mine: Boolean!
417
417
  model: String
@@ -462,7 +462,7 @@ type CommonCode {
462
462
  creator: User
463
463
  description: String
464
464
  details: [CommonCodeDetail!]!
465
- domain: Domain!
465
+ domain: Domain
466
466
  id: ID!
467
467
  name: String!
468
468
  updatedAt: DateTimeISO
@@ -475,9 +475,8 @@ type CommonCodeDetail {
475
475
  createdAt: DateTimeISO
476
476
  creator: User
477
477
  description: String
478
- domain: Domain!
478
+ domain: Domain
479
479
  id: ID!
480
- labels: Object
481
480
  name: String!
482
481
  rank: Float
483
482
  updatedAt: DateTimeISO
@@ -494,7 +493,6 @@ input CommonCodeDetailPatch {
494
493
  cuFlag: String
495
494
  description: String
496
495
  id: ID
497
- labels: Object
498
496
  name: String
499
497
  rank: Float
500
498
  }
@@ -518,7 +516,6 @@ type Connection {
518
516
  creator: User
519
517
  description: String
520
518
  domain: Domain
521
- edge: Appliance
522
519
  endpoint: String
523
520
  id: ID!
524
521
  name: String!
@@ -538,7 +535,6 @@ input ConnectionPatch {
538
535
  active: Boolean
539
536
  cuFlag: String
540
537
  description: String
541
- edge: ObjectRef
542
538
  endpoint: String
543
539
  id: ID
544
540
  name: String
@@ -548,8 +544,7 @@ input ConnectionPatch {
548
544
 
549
545
  type ConnectionState {
550
546
  description: String
551
- domain: Domain!
552
- edge: Appliance
547
+ domain: Domain
553
548
  id: String
554
549
  name: String
555
550
  state: String
@@ -578,7 +573,7 @@ type Contact {
578
573
  creator: User
579
574
  deletedAt: DateTimeISO
580
575
  department: String
581
- domain: Domain!
576
+ domain: Domain
582
577
  email: EmailAddress
583
578
  id: ID!
584
579
  items: [ContactItem!]
@@ -649,7 +644,7 @@ type Department {
649
644
  creator: User
650
645
  deletedAt: DateTimeISO
651
646
  description: String
652
- domain: Domain!
647
+ domain: Domain
653
648
  extension: String
654
649
  id: ID!
655
650
  manager: Employee
@@ -756,7 +751,7 @@ type Employee {
756
751
  creator: User
757
752
  deletedAt: DateTimeISO
758
753
  department: Department
759
- domain: Domain!
754
+ domain: Domain
760
755
  email: EmailAddress
761
756
  extension: String
762
757
  hiredOn: String
@@ -822,7 +817,7 @@ type Entity {
822
817
  dataProp: String
823
818
  delStrategy: String
824
819
  description: String
825
- domain: Domain!
820
+ domain: Domain
826
821
  extEntity: Boolean
827
822
  fixedColumns: Float
828
823
  id: ID!
@@ -847,7 +842,7 @@ type EntityColumn {
847
842
  creator: User
848
843
  defVal: String
849
844
  description: String
850
- domain: Domain!
845
+ domain: Domain
851
846
  entity: Entity!
852
847
  formEditor: String
853
848
  formFormat: String
@@ -1020,7 +1015,7 @@ type Font {
1020
1015
  active: Boolean!
1021
1016
  createdAt: DateTimeISO
1022
1017
  creator: User
1023
- domain: Domain!
1018
+ domain: Domain
1024
1019
  files: [Attachment!]
1025
1020
  id: ID!
1026
1021
  name: String!
@@ -1143,14 +1138,14 @@ type LoginHistoryList {
1143
1138
  type Menu {
1144
1139
  buttons: [MenuButton!]!
1145
1140
  category: String
1146
- children(permittedOnly: Boolean! = false): [Menu!]!
1141
+ children: [Menu!]!
1147
1142
  columns: [MenuColumn!]!
1148
1143
  createdAt: DateTimeISO
1149
1144
  creator: User
1150
1145
  description: String
1151
1146
  detailFormId: String
1152
1147
  detailLayout: String
1153
- domain: Domain!
1148
+ domain: Domain
1154
1149
  fixedColumns: Float
1155
1150
  gridSaveUrl: String
1156
1151
  hiddenFlag: Boolean
@@ -1162,7 +1157,6 @@ type Menu {
1162
1157
  name: String
1163
1158
  pagination: Boolean
1164
1159
  parent: Menu
1165
- privilege: PrivilegeObject
1166
1160
  rank: Float
1167
1161
  resourceId: String
1168
1162
  resourceName: String
@@ -1184,7 +1178,7 @@ type MenuButton {
1184
1178
  auth: String
1185
1179
  createdAt: DateTimeISO
1186
1180
  creator: User
1187
- domain: Domain!
1181
+ domain: Domain
1188
1182
  icon: String
1189
1183
  id: ID!
1190
1184
  logic: String
@@ -1219,7 +1213,7 @@ type MenuColumn {
1219
1213
  creator: User
1220
1214
  defVal: String
1221
1215
  description: String
1222
- domain: Domain!
1216
+ domain: Domain
1223
1217
  extField: Boolean
1224
1218
  formEditor: String
1225
1219
  formFormat: String
@@ -1308,7 +1302,7 @@ type MenuDetail {
1308
1302
  creator: User
1309
1303
  customView: String
1310
1304
  dataProp: String
1311
- domain: Domain!
1305
+ domain: Domain
1312
1306
  entityId: String
1313
1307
  id: ID!
1314
1308
  masterField: String
@@ -1325,7 +1319,7 @@ type MenuDetail {
1325
1319
  type MenuDetailButton {
1326
1320
  createdAt: DateTimeISO
1327
1321
  creator: User
1328
- domain: Domain!
1322
+ domain: Domain
1329
1323
  icon: String
1330
1324
  id: ID!
1331
1325
  logic: String
@@ -1359,7 +1353,7 @@ type MenuDetailColumn {
1359
1353
  creator: User
1360
1354
  defVal: String
1361
1355
  description: String
1362
- domain: Domain!
1356
+ domain: Domain
1363
1357
  extField: Boolean
1364
1358
  formEditor: String
1365
1359
  formFormat: String
@@ -1484,7 +1478,6 @@ input MenuPatch {
1484
1478
  name: String
1485
1479
  pagination: Boolean
1486
1480
  parent: ObjectRef
1487
- privilege: PrivilegeInput
1488
1481
  rank: Int
1489
1482
  resourceId: String
1490
1483
  resourceName: String
@@ -1506,9 +1499,6 @@ type Mutation {
1506
1499
  attachContact(contactId: String!, id: String!): Employee!
1507
1500
  cancelInvitation(email: EmailAddress!, reference: String!, type: String!): Boolean!
1508
1501
 
1509
- """To clear translations cache"""
1510
- clearTranslationsCache: Boolean!
1511
-
1512
1502
  """To clone a Board from existing Board"""
1513
1503
  cloneBoard(id: String!, patch: BoardPatch!, targetGroupId: String, targetSubdomain: String!): Board!
1514
1504
 
@@ -1995,7 +1985,7 @@ type Mutation {
1995
1985
  """
1996
1986
  To run new scenario instance and will return the result after the scenario stop.
1997
1987
  """
1998
- runScenario(instanceName: String, scenarioName: String!, variables: Object): ScenarioInstanceRunResult!
1988
+ runScenario(instanceName: String, scenarioName: String!, variables: Object): ScenarioInstance!
1999
1989
  sendInvitation(email: EmailAddress!, reference: String!, type: String!): Invitation!
2000
1990
  singleUpload(file: Upload!): Attachment!
2001
1991
 
@@ -2313,14 +2303,12 @@ input NewCommonCode {
2313
2303
  input NewCommonCodeDetail {
2314
2304
  commonCode: ObjectRef!
2315
2305
  description: String
2316
- labels: Object
2317
2306
  name: String!
2318
2307
  rank: Float!
2319
2308
  }
2320
2309
 
2321
2310
  input NewConnection {
2322
2311
  description: String
2323
- edge: ObjectRef
2324
2312
  endpoint: String
2325
2313
  name: String!
2326
2314
  params: String
@@ -2462,7 +2450,6 @@ input NewMenu {
2462
2450
  name: String!
2463
2451
  pagination: Boolean
2464
2452
  parent: ObjectRef
2465
- privilege: PrivilegeInput
2466
2453
  rank: Int
2467
2454
  resourceId: String
2468
2455
  resourceName: String
@@ -2679,7 +2666,6 @@ input NewScenario {
2679
2666
  privilege: PrivilegeInput
2680
2667
  schedule: String
2681
2668
  timezone: String
2682
- ttl: Float
2683
2669
  type: String
2684
2670
  }
2685
2671
 
@@ -2738,7 +2724,7 @@ type Notification {
2738
2724
  body: String
2739
2725
  createdAt: DateTimeISO
2740
2726
  creator: User
2741
- domain: Domain!
2727
+ domain: Domain
2742
2728
  id: ID!
2743
2729
  image: String
2744
2730
  owner: User
@@ -2772,7 +2758,7 @@ type NotificationRule {
2772
2758
  creator: User
2773
2759
  deletedAt: DateTimeISO
2774
2760
  description: String
2775
- domain: Domain!
2761
+ domain: Domain
2776
2762
  id: ID!
2777
2763
  name: String
2778
2764
 
@@ -2829,7 +2815,7 @@ type Oauth2Client {
2829
2815
  createdAt: DateTimeISO
2830
2816
  creator: User
2831
2817
  description: String
2832
- domain: Domain!
2818
+ domain: Domain
2833
2819
  expires: DateTimeISO
2834
2820
  grantType: String
2835
2821
  icon: String
@@ -2962,12 +2948,12 @@ input Pagination {
2962
2948
  }
2963
2949
 
2964
2950
  type Partner {
2965
- approvedAt: DateTimeISO
2951
+ approvedAt: DateTimeISO!
2966
2952
  approver: User
2967
2953
  domain: Domain!
2968
2954
  id: ID!
2969
2955
  partnerDomain: Domain!
2970
- requestedAt: DateTimeISO
2956
+ requestedAt: DateTimeISO!
2971
2957
  requester: User
2972
2958
  }
2973
2959
 
@@ -2982,7 +2968,7 @@ type PartnerSetting {
2982
2968
  createdAt: DateTimeISO
2983
2969
  creator: User
2984
2970
  description: String
2985
- domain: Domain!
2971
+ domain: Domain
2986
2972
  id: ID!
2987
2973
  name: String
2988
2974
  partnerDomain: Domain
@@ -3011,7 +2997,7 @@ input PartnerSettingPatch {
3011
2997
  type PayloadLog {
3012
2998
  createdAt: DateTimeISO
3013
2999
  creator: User
3014
- domain: Domain!
3000
+ domain: Domain
3015
3001
  endpoint: String!
3016
3002
  id: ID!
3017
3003
  name: String!
@@ -3177,7 +3163,6 @@ type PropertySpec {
3177
3163
  name: String!
3178
3164
  placeholder: String
3179
3165
  property: Object
3180
- styles: Object
3181
3166
  type: String!
3182
3167
  }
3183
3168
 
@@ -3324,9 +3309,6 @@ type Query {
3324
3309
  """To fetch domains with given privilege for user"""
3325
3310
  domainsWithPrivilege(category: String!, privilege: String!): [Domain!]!
3326
3311
 
3327
- """To fetch multiple appliance"""
3328
- edges(filters: [Filter!], inherited: InheritedValueType, pagination: Pagination, sortings: [Sorting!]): ApplianceList!
3329
-
3330
3312
  """To fetch a Employee"""
3331
3313
  employee(id: String!): Employee
3332
3314
 
@@ -3433,9 +3415,6 @@ type Query {
3433
3415
  myFavorites: [Favorite!]!
3434
3416
  myLoginHistories(limit: Float!): [LoginHistory!]!
3435
3417
 
3436
- """To fetch my own Menus"""
3437
- myMenus(filters: [Filter!], inherited: InheritedValueType, pagination: Pagination, sortings: [Sorting!]): MenuList!
3438
-
3439
3418
  """To fetch my notifications"""
3440
3419
  myNotifications(filters: [Filter!], inherited: InheritedValueType, pagination: Pagination, sortings: [Sorting!]): NotificationList!
3441
3420
 
@@ -3590,7 +3569,7 @@ type Role {
3590
3569
  description: String
3591
3570
  domain: Domain!
3592
3571
  id: ID!
3593
- name: String
3572
+ name: String!
3594
3573
  privileges: [Privilege!]
3595
3574
  updatedAt: DateTimeISO
3596
3575
  updater: User
@@ -3626,7 +3605,7 @@ type Scenario {
3626
3605
  createdAt: DateTimeISO
3627
3606
  creator: User
3628
3607
  description: String
3629
- domain: Domain!
3608
+ domain: Domain
3630
3609
  id: ID!
3631
3610
  instances: [ScenarioInstance!]
3632
3611
  name: String!
@@ -3640,7 +3619,6 @@ type Scenario {
3640
3619
  state: String
3641
3620
  steps: [Step!]
3642
3621
  timezone: String
3643
- ttl: Float
3644
3622
  type: String
3645
3623
  updatedAt: DateTimeISO
3646
3624
  updater: User
@@ -3673,17 +3651,6 @@ type ScenarioInstanceProgress {
3673
3651
  steps: Int!
3674
3652
  }
3675
3653
 
3676
- type ScenarioInstanceRunResult {
3677
- data: Object
3678
- instanceName: String
3679
- message: String
3680
- result: Object
3681
- scenarioName: String
3682
- state: String
3683
- timestamp: DateTimeISO
3684
- variables: Object
3685
- }
3686
-
3687
3654
  type ScenarioInstanceState {
3688
3655
  data: Object
3689
3656
  domain: Domain
@@ -3720,7 +3687,6 @@ input ScenarioPatch {
3720
3687
  schedule: String
3721
3688
  steps: [StepPatch!]
3722
3689
  timezone: String
3723
- ttl: Float
3724
3690
  type: String
3725
3691
  }
3726
3692
 
@@ -3735,7 +3701,7 @@ type Setting {
3735
3701
  createdAt: DateTimeISO
3736
3702
  creator: User
3737
3703
  description: String
3738
- domain: Domain!
3704
+ domain: Domain
3739
3705
  id: ID!
3740
3706
  name: String!
3741
3707
  updatedAt: DateTimeISO
@@ -3772,7 +3738,7 @@ type StateRegister {
3772
3738
  createdAt: DateTimeISO
3773
3739
  creator: User
3774
3740
  description: String
3775
- domain: Domain!
3741
+ domain: Domain
3776
3742
  id: ID!
3777
3743
  name: String
3778
3744
  refBy: String
@@ -3872,7 +3838,6 @@ type TaskTypeList {
3872
3838
  type Terminology {
3873
3839
  category: String!
3874
3840
  createdAt: DateTimeISO
3875
- creator: User
3876
3841
  description: String
3877
3842
  display: String!
3878
3843
  domain: Domain!
@@ -3880,7 +3845,6 @@ type Terminology {
3880
3845
  locale: String!
3881
3846
  name: String!
3882
3847
  updatedAt: DateTimeISO
3883
- updater: User
3884
3848
  }
3885
3849
 
3886
3850
  type TerminologyList {
@@ -3889,12 +3853,12 @@ type TerminologyList {
3889
3853
  }
3890
3854
 
3891
3855
  input TerminologyPatch {
3892
- category: String
3856
+ category: String!
3893
3857
  cuFlag: String
3894
3858
  description: String
3895
- display: String
3859
+ display: String!
3896
3860
  id: ID
3897
- locale: String
3861
+ locale: String!
3898
3862
  name: String
3899
3863
  }
3900
3864
 
@@ -3905,7 +3869,7 @@ type Theme {
3905
3869
  creator: User
3906
3870
  deletedAt: DateTimeISO
3907
3871
  description: String
3908
- domain: Domain!
3872
+ domain: Domain
3909
3873
  id: ID!
3910
3874
  name: String
3911
3875
  type: String
@@ -3945,7 +3909,7 @@ type User {
3945
3909
  email: EmailAddress!
3946
3910
  id: ID!
3947
3911
  locale: String
3948
- name: String
3912
+ name: String!
3949
3913
  owner: Boolean
3950
3914
  reference: String
3951
3915
  roles: [Role!]!
@@ -3986,7 +3950,7 @@ type UserRole {
3986
3950
  type UsersAuthProviders {
3987
3951
  authProvider: AuthProvider
3988
3952
  createdAt: DateTimeISO
3989
- domain: Domain!
3953
+ domain: Domain
3990
3954
  id: ID!
3991
3955
  ssoId: String
3992
3956
  updatedAt: DateTimeISO
@@ -1,4 +1,5 @@
1
1
  import { TinyColor } from '@ctrl/tinycolor'
2
+ import { format as formatText } from './text-formatter'
2
3
 
3
4
  export function convertConfigure(chart: SceneChart.ChartConfig) {
4
5
  if (!chart) return
@@ -389,9 +390,12 @@ function _setTooltipCallback(tooltips: SceneChart.ChartTooltipOptions) {
389
390
  value = toNumValue.toLocaleString()
390
391
  }
391
392
 
393
+ var format = data.datasets?.[tooltipItem.datasetIndex || 0].valueFormat || ''
392
394
  var prefix = data.datasets?.[tooltipItem.datasetIndex || 0].valuePrefix || ''
393
395
  var suffix = data.datasets?.[tooltipItem.datasetIndex || 0].valueSuffix || ''
394
396
 
395
- return `${label}: ${prefix + value + suffix}`
397
+ var stringValue = format ? formatText(format, Number(label)) : Number(label).toLocaleString()
398
+
399
+ return `${label}: ${prefix + stringValue + suffix}`
396
400
  }
397
401
  }
@@ -57,6 +57,17 @@ export default class PropertyEditorChartJSAbstract extends LitElement {
57
57
 
58
58
  displayValueTemplate() {
59
59
  return html`
60
+ <label for="value-format"> <ox-i18n msgid="label.value-format">Value Format</ox-i18n> </label>
61
+ <input type="text" value-key="series.valueFormat" .value=${this.series.valueFormat || ''} list="format-list" />
62
+ <datalist id="format-list">
63
+ <option value="#,###."></option>
64
+ <option value="#,###.#"></option>
65
+ <option value="#,###.0"></option>
66
+ <option value="#,##0.#"></option>
67
+ <option value="#,##0.0"></option>
68
+ <option value="#,##0.0%"></option>
69
+ </datalist>
70
+
60
71
  <label> <ox-i18n msgid="label.value-prefix">Value Prefix</ox-i18n> </label>
61
72
  <input type="text" value-key="series.valuePrefix" .value=${this.series.valuePrefix || ''} />
62
73
 
@@ -24,6 +24,14 @@ export default class PropertyEditorChartJSPie extends PropertyEditorChartJSAbstr
24
24
  this.currentSeriesIndex = 0
25
25
  }
26
26
 
27
+ get valueFormat() {
28
+ return this.series.valueFormat
29
+ }
30
+
31
+ set valueFormat(valueFormat) {
32
+ this.series.valueFormat = valueFormat
33
+ }
34
+
27
35
  get valuePrefix() {
28
36
  return this.series.valuePrefix
29
37
  }
package/src/ox-chart.ts CHANGED
@@ -7,6 +7,7 @@ import { customElement, property, query } from 'lit/decorators.js'
7
7
  import { Chart } from 'chart.js'
8
8
  import DataBinderPlugin from './plugins/chartjs-plugin-data-binder'
9
9
  import { convertConfigure } from './config-converter'
10
+ import { format as formatText } from './text-formatter'
10
11
 
11
12
  Chart.plugins.register(DataBinderPlugin)
12
13
 
@@ -135,13 +136,15 @@ export class OxChart extends LitElement {
135
136
  },
136
137
  clamp: true,
137
138
  formatter: function (value, context) {
139
+ //@ts-ignore
140
+ var format = context.dataset.valueFormat || ''
138
141
  //@ts-ignore
139
142
  var prefix = context.dataset.valuePrefix || ''
140
143
  //@ts-ignore
141
144
  var suffix = context.dataset.valueSuffix || ''
142
145
  if (value == undefined) return value
143
146
 
144
- var stringValue = Number(value).toLocaleString()
147
+ var stringValue = format ? formatText(format, Number(value)) : Number(value).toLocaleString()
145
148
  return prefix + stringValue + suffix
146
149
  }
147
150
  }
@@ -27,6 +27,7 @@ declare namespace SceneChart {
27
27
  interface ChartDataSets extends Chart.ChartDataSets {
28
28
  color: string
29
29
  dataKey: string
30
+ valueFormat: string
30
31
  valuePrefix: string
31
32
  valueSuffix: string
32
33
  displayValue: string
@@ -0,0 +1,106 @@
1
+ export function format(mask: string, value: number): string {
2
+ if (!mask || isNaN(+value)) {
3
+ return value.toString() // return as it is.
4
+ }
5
+
6
+ let isNegative: boolean,
7
+ result: string | RegExpMatchArray | null,
8
+ decimal: string,
9
+ group: string,
10
+ posLeadZero: number,
11
+ posTrailZero: number,
12
+ posSeparator: number,
13
+ part: string[],
14
+ szSep: string[],
15
+ integer: string,
16
+ // find prefix/suffix
17
+ len = mask.length,
18
+ start = mask.search(/[0-9\-\+#]/),
19
+ prefix = start > 0 ? mask.substring(0, start) : '',
20
+ // reverse string: not an ideal method if there are surrogate pairs
21
+ str = mask.split('').reverse().join(''),
22
+ end = str.search(/[0-9\-\+#]/),
23
+ offset = len - end,
24
+ substr = mask.substring(offset, offset + 1),
25
+ indx = offset + (substr === '.' || substr === ',' ? 1 : 0),
26
+ suffix = end > 0 ? mask.substring(indx, len) : '',
27
+ splittedMask: string[],
28
+ splittedValue: string[],
29
+ stringValue: string
30
+
31
+ // mask with prefix & suffix removed
32
+ mask = mask.substring(start, indx)
33
+
34
+ // convert any string to number according to formation sign.
35
+ value = mask.charAt(0) === '-' ? -value : +value
36
+ isNegative = value < 0 ? ((value = -value), true) : false // process only abs(), and turn on flag.
37
+
38
+ // search for separator for grp & decimal, anything not digit, not +/- sign, not #.
39
+ result = mask.match(/[^\d\-\+#]/g)
40
+ decimal = '.' // ( result && result[ result.length - 1 ] ) || '.'; // ','는 소수점이 되지 않게 함
41
+ group = (result && result[1] && result[0]) || ',' // treat the left most symbol as group separator
42
+
43
+ // split the decimal for the format string if any.
44
+ splittedMask = mask.split(decimal)
45
+ // Fix the decimal first, toFixed will auto fill trailing zero.
46
+ value = parseFloat(value.toFixed((splittedMask[1] && splittedMask[1].length) || 0))
47
+ stringValue = +value + '' // convert number to string to trim off *all* trailing decimal zero(es)
48
+
49
+ // fill back any trailing zero according to format
50
+ posTrailZero = (splittedMask[1] && splittedMask[1].lastIndexOf('0')) || 0 // look for last zero in format
51
+ part = stringValue.split('.')
52
+ // integer will get !part[1]
53
+ if (!part[1] || (part[1] && part[1].length <= posTrailZero)) {
54
+ stringValue = (+value).toFixed(posTrailZero + 1)
55
+ }
56
+ szSep = splittedMask[0].split(group) // look for separator
57
+ splittedMask[0] = szSep.join('') // join back without separator for counting the pos of any leading 0.
58
+
59
+ posLeadZero = (splittedMask[0] && splittedMask[0].indexOf('0')) || 0
60
+ if (posLeadZero > -1) {
61
+ while (part[0].length < splittedMask[0].length - posLeadZero) {
62
+ part[0] = '0' + part[0]
63
+ }
64
+ } else if (+part[0] === 0) {
65
+ part[0] = ''
66
+ }
67
+
68
+ splittedValue = stringValue.split('.')
69
+ splittedValue[0] = part[0]
70
+
71
+ // process the first group separator from decimal (.) only, the rest ignore.
72
+ // get the length of the last slice of split result.
73
+ posSeparator = (szSep[1] && szSep[szSep.length - 1].length) || 0
74
+ if (posSeparator) {
75
+ integer = splittedValue[0]
76
+ str = ''
77
+ offset = integer.length % posSeparator
78
+ len = integer.length
79
+ for (indx = 0; indx < len; indx++) {
80
+ str += integer.charAt(indx) // ie6 only support charAt for sz.
81
+ // -posSeparator so that won't trail separator on full length
82
+ /* jshint -W018 */
83
+ if (!((indx - offset + 1) % posSeparator) && indx < len - posSeparator) {
84
+ str += group
85
+ }
86
+ }
87
+ splittedValue[0] = str
88
+ }
89
+ splittedValue[1] = splittedMask[1] && splittedValue[1] ? decimal + splittedValue[1] : ''
90
+
91
+ // remove negative sign if result is zero
92
+ result = splittedValue.join('')
93
+ if (result === '0' || result === '') {
94
+ // remove negative sign if result is zero
95
+ isNegative = false
96
+ }
97
+
98
+ // 앞에 +가 붙는다면 양수일 경우에도 +를 표기해줌
99
+ let fixedPlusSign: string
100
+
101
+ if (splittedMask[0].substring(0, 1) === '+') fixedPlusSign = isNegative ? '-' : '+'
102
+ else fixedPlusSign = isNegative ? '-' : ''
103
+
104
+ // put back any negation, combine integer and fraction, and add back prefix & suffix
105
+ return prefix + (fixedPlusSign + result) + suffix
106
+ }