datastake-daf 0.6.756 → 0.6.758

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.
@@ -14139,12 +14139,357 @@ function buildBreadcrumbs({
14139
14139
  }];
14140
14140
  }
14141
14141
 
14142
+ const buildBreadCrumbs = ({
14143
+ config,
14144
+ items,
14145
+ t,
14146
+ breadCrumbsLabels,
14147
+ id,
14148
+ getRedirectLink,
14149
+ createOnClick,
14150
+ goTo,
14151
+ view,
14152
+ skipInteractions = false
14153
+ }) => {
14154
+ const pathConfig = config.path || [];
14155
+ pathConfig.forEach(pathItem => {
14156
+ if (typeof pathItem === 'string') {
14157
+ items.push({
14158
+ label: t(breadCrumbsLabels[pathItem]),
14159
+ onClick: () => {}
14160
+ });
14161
+ } else if (typeof pathItem === 'object') {
14162
+ const {
14163
+ key,
14164
+ link,
14165
+ useRedirect
14166
+ } = pathItem;
14167
+ if (key === 'id' && id) {
14168
+ const resolvedLink = typeof link === 'function' ? link(id) : link;
14169
+ const finalLink = useRedirect ? getRedirectLink(resolvedLink) : resolvedLink;
14170
+ items.push({
14171
+ label: id,
14172
+ onClick: skipInteractions ? () => {} : finalLink ? createOnClick(() => goTo(finalLink)) : () => {}
14173
+ });
14174
+ } else {
14175
+ const resolvedLink = typeof link === 'function' ? link(view, id) : link;
14176
+ const finalLink = resolvedLink && useRedirect ? getRedirectLink(resolvedLink) : resolvedLink;
14177
+ items.push({
14178
+ label: t(breadCrumbsLabels[key]),
14179
+ onClick: skipInteractions ? () => {} : finalLink ? createOnClick(() => goTo(finalLink)) : () => {}
14180
+ });
14181
+ }
14182
+ }
14183
+ });
14184
+ if (config.includeId && id && id !== 'user') {
14185
+ items.push({
14186
+ label: id,
14187
+ onClick: () => {}
14188
+ });
14189
+ }
14190
+ if (config.suffix) {
14191
+ config.suffix.forEach(suffixItem => {
14192
+ items.push({
14193
+ label: t(breadCrumbsLabels[suffixItem]),
14194
+ onClick: () => {}
14195
+ });
14196
+ });
14197
+ }
14198
+ };
14199
+ const renderBreadCrumbs = ({
14200
+ t = () => {},
14201
+ goTo = () => {},
14202
+ view,
14203
+ isAnalysis = false,
14204
+ isEdit = false,
14205
+ isView = false,
14206
+ isDataStore = false,
14207
+ id,
14208
+ addedItems = [],
14209
+ changeNotificationState,
14210
+ breadCrumbConfig = {},
14211
+ breadCrumbsLabels = {},
14212
+ getRedirectLink = () => {},
14213
+ condition,
14214
+ conditionFallback = 'show-non-interactive' // 'show-non-interactive' | 'hide' | 'show-simplified'
14215
+ }) => {
14216
+ const items = [];
14217
+ const createOnClick = callback => {
14218
+ if (!callback) return () => {};
14219
+ return () => {
14220
+ if (changeNotificationState) {
14221
+ changeNotificationState({
14222
+ onYes: callback
14223
+ });
14224
+ } else {
14225
+ callback();
14226
+ }
14227
+ };
14228
+ };
14229
+ const evaluateCondition = (cond, context) => {
14230
+ if (cond === undefined) return true; // No condition = always pass
14231
+ if (typeof cond === 'function') return cond(context); // Function condition
14232
+ return Boolean(cond); // Boolean condition
14233
+ };
14234
+ const config = breadCrumbConfig[view];
14235
+ console.log({
14236
+ config,
14237
+ breadCrumbConfig,
14238
+ breadCrumbsLabels,
14239
+ condition
14240
+ });
14241
+ if (config) {
14242
+ const conditionContext = {
14243
+ isDataStore,
14244
+ isAnalysis,
14245
+ isEdit,
14246
+ isView,
14247
+ id,
14248
+ view,
14249
+ t,
14250
+ goTo,
14251
+ getRedirectLink,
14252
+ changeNotificationState,
14253
+ addedItems
14254
+ };
14255
+ const externalConditionPassed = evaluateCondition(condition, conditionContext);
14256
+ const configConditionPassed = evaluateCondition(config.condition, conditionContext);
14257
+ if (!configConditionPassed) {
14258
+ if (config.fallback) {
14259
+ buildBreadCrumbs({
14260
+ config: config.fallback,
14261
+ items,
14262
+ t,
14263
+ breadCrumbsLabels,
14264
+ id,
14265
+ getRedirectLink,
14266
+ createOnClick,
14267
+ goTo,
14268
+ view
14269
+ });
14270
+ }
14271
+ } else if (!externalConditionPassed) {
14272
+ if (config.fallback) {
14273
+ // Use config fallback when prop condition fails
14274
+ buildBreadCrumbs({
14275
+ config: config.fallback,
14276
+ items,
14277
+ t,
14278
+ breadCrumbsLabels,
14279
+ id,
14280
+ getRedirectLink,
14281
+ createOnClick,
14282
+ goTo,
14283
+ view
14284
+ });
14285
+ } else {
14286
+ switch (conditionFallback) {
14287
+ case 'hide':
14288
+ break;
14289
+ case 'show-simplified':
14290
+ {
14291
+ const simplifiedConfig = {
14292
+ ...config,
14293
+ path: config.path.slice(0, 2),
14294
+ includeId: false,
14295
+ suffix: undefined
14296
+ };
14297
+ buildBreadCrumbs({
14298
+ config: simplifiedConfig,
14299
+ items,
14300
+ t,
14301
+ breadCrumbsLabels,
14302
+ id,
14303
+ getRedirectLink,
14304
+ createOnClick,
14305
+ goTo,
14306
+ view
14307
+ });
14308
+ break;
14309
+ }
14310
+ case 'show-non-interactive':
14311
+ default:
14312
+ buildBreadCrumbs({
14313
+ config,
14314
+ items,
14315
+ t,
14316
+ breadCrumbsLabels,
14317
+ id,
14318
+ getRedirectLink,
14319
+ createOnClick,
14320
+ goTo,
14321
+ view,
14322
+ skipInteractions: true
14323
+ });
14324
+ break;
14325
+ }
14326
+ }
14327
+ } else {
14328
+ buildBreadCrumbs({
14329
+ config,
14330
+ items,
14331
+ t,
14332
+ breadCrumbsLabels,
14333
+ id,
14334
+ getRedirectLink,
14335
+ createOnClick,
14336
+ goTo,
14337
+ view
14338
+ });
14339
+ }
14340
+ }
14341
+ if (isView) {
14342
+ items.push({
14343
+ label: t(breadCrumbsLabels.details)
14344
+ });
14345
+ } else if (isEdit) {
14346
+ items.push({
14347
+ label: t(breadCrumbsLabels.edit)
14348
+ });
14349
+ } else if (isAnalysis) {
14350
+ items.push({
14351
+ label: t(breadCrumbsLabels.summary)
14352
+ });
14353
+ }
14354
+ items.push(...addedItems);
14355
+ return items.filter(v => !!v.label);
14356
+ };
14357
+
14358
+ // Breadcrumbs Config Helper
14359
+
14360
+ // 1.Simple static path
14361
+ // 'country-overview': {
14362
+ // path: ['analysis', 'country-overview'],
14363
+ // }
14364
+ // Result: Analysis > Country Overview
14365
+ // Neither is clickable
14366
+
14367
+ // 2.Clickable Parents with Links
14368
+ // 'mines': {
14369
+ // path: [
14370
+ // 'modules', // Not clickable
14371
+ // { key: 'mines', link: '/app/mines' } // Clickable, navigates to /app/mines
14372
+ // ],
14373
+ // }
14374
+ // Result: Modules > Mines (clickable)
14375
+
14376
+ // 3.Include ID at the end
14377
+ // 'partners': {
14378
+ // path: ['modules', { key: 'partners', link: '/app/partners', useRedirect: true }],
14379
+ // includeId: true, // ← ID will be added at the end
14380
+ // }
14381
+ // With id='ABC123':
14382
+ // Result: Modules > Partners (clickable) > ABC123 (not clickable)
14383
+
14384
+ // 4.Dynamic Id in the middle
14385
+ // 'mine-evaluation': {
14386
+ // path: [
14387
+ // 'modules',
14388
+ // { key: 'mines', link: '/app/mines' },
14389
+ // { key: 'id', link: (id) => `/app/mines/${id}` }, // ← ID here
14390
+ // 'evaluation',
14391
+ // ],
14392
+ // }
14393
+ // With id='MINE-456':
14394
+ // Result: Modules > Mines > MINE-456 (clickable to /app/mines/MINE-456) > Evaluation
14395
+
14396
+ // 5. Dynamic Links using functions
14397
+ // 'producers': {
14398
+ // path: [
14399
+ // 'modules',
14400
+ // {
14401
+ // key: 'producers',
14402
+ // link: (view) => `/app/${view}`, // ← Uses 'view' parameter
14403
+ // useRedirect: true
14404
+ // }
14405
+ // ],
14406
+ // includeId: true,
14407
+ // }
14408
+ // With view='producers':
14409
+ // Result: Modules > Producers (navigates to /app/producers)
14410
+
14411
+ // 6.use Redirect link
14412
+ // 'settings': {
14413
+ // path: [
14414
+ // {
14415
+ // key: 'settings',
14416
+ // link: '/app/view/settings',
14417
+ // useRedirect: true // ← Wraps with getRedirectLink()
14418
+ // }
14419
+ // ],
14420
+ // }
14421
+ // Navigation will use getRedirectLink('/app/view/settings')
14422
+
14423
+ // 7.Conditional Rendering
14424
+ // 'entities': {
14425
+ // condition: (opts) => opts.isDataStore, // ← Only shows if isDataStore=true
14426
+ // path: [
14427
+ // 'data',
14428
+ // { key: 'data-store', link: '/app/data-store', useRedirect: true },
14429
+ // { key: 'entities', link: '/app/data-store/entities', useRedirect: true },
14430
+ // ],
14431
+ // }
14432
+ // With isDataStore=false: No breadcrumbs shown
14433
+ // With isDataStore=true: Data > Store > Entities
14434
+
14435
+ // 8.Conditional Fallback
14436
+ // 'locations': {
14437
+ // condition: (opts) => opts.isDataStore,
14438
+ // path: [
14439
+ // 'data',
14440
+ // { key: 'data-store', link: '/app/data-store', useRedirect: true },
14441
+ // { key: 'locations', link: '/app/data-store/locations', useRedirect: true },
14442
+ // ],
14443
+ // fallback: { // ← Alternative when condition is false
14444
+ // path: [
14445
+ // 'modules',
14446
+ // 'linkedSubjects',
14447
+ // { key: 'locations', link: '/app/locations', useRedirect: true },
14448
+ // ],
14449
+ // includeId: true,
14450
+ // },
14451
+ // }
14452
+ // isDataStore=true: Data > Store > Locations
14453
+ // isDataStore=false: Modules > Associated Information > Locations > {id}
14454
+
14455
+ // 9. Suffix items
14456
+ // 'mine-monitoring': {
14457
+ // path: [
14458
+ // 'modules',
14459
+ // { key: 'mines', link: '/app/mines' }
14460
+ // ],
14461
+ // includeId: true,
14462
+ // suffix: ['visits'], // ← Added at the end
14463
+ // }
14464
+ // With id='MINE-789':
14465
+ // Result: Modules > Mines > MINE-789 > Visits
14466
+
14467
+ // 10. Complex multi level path
14468
+ // 'monitoringReport': {
14469
+ // path: [
14470
+ // 'modules', // Static label
14471
+ // { key: 'mines', link: '/app/mines' }, // Clickable parent
14472
+ // { key: 'id', link: (id) => `/app/mines/${id}` }, // Dynamic ID with link
14473
+ // 'monitoringReport', // Static label at end
14474
+ // ],
14475
+ // }
14476
+ // With id='MINE-999':
14477
+ // Result: Modules > Mines (→/app/mines) > MINE-999 (→/app/mines/MINE-999) > Executive Monitoring Report
14478
+
14479
+ // 11. Access multiple options in condition
14480
+ // 'custom-view': {
14481
+ // condition: (opts) => opts.isDataStore && opts.isEdit && opts.id,
14482
+ // path: ['data', 'custom'],
14483
+ // }
14484
+ // Available in opts: { isDataStore, isAnalysis, isEdit, isView, id, view }
14485
+
14142
14486
  exports.ErrorFormat = ErrorFormat;
14143
14487
  exports.MessageTypes = MessageTypes;
14144
14488
  exports.StorageManager = StorageManager;
14145
14489
  exports.assignParamsToUrl = assignParamsToUrl;
14146
14490
  exports.btn = button;
14147
14491
  exports.buildActionWidgetsConfig = buildActionWidgetsConfig;
14492
+ exports.buildBreadCrumbsHelper = buildBreadCrumbs;
14148
14493
  exports.buildBreadcrumbs = buildBreadcrumbs;
14149
14494
  exports.buildKeyIndicatorsConfig = buildKeyIndicatorsConfig;
14150
14495
  exports.buildQueryString = buildQueryString;
@@ -14209,6 +14554,7 @@ exports.modules = modules;
14209
14554
  exports.nowToIso = nowToIso;
14210
14555
  exports.processConfig = processConfig;
14211
14556
  exports.propHasValue = propHasValue;
14557
+ exports.renderBreadCrumbs = renderBreadCrumbs;
14212
14558
  exports.renderDateFormatted = renderDateFormatted;
14213
14559
  exports.renderNumber = renderNumber;
14214
14560
  exports.renderPercentage = renderPercentage;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.756",
3
+ "version": "0.6.758",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
package/rollup.config.js CHANGED
@@ -103,6 +103,26 @@ export default [
103
103
  requireReturnsDefault: "auto",
104
104
  }),
105
105
  ],
106
+ },
107
+ {
108
+ input: "src/constants.js",
109
+ output: [
110
+ {
111
+ file: "dist/constants/index.js",
112
+ format: "cjs",
113
+ },
114
+ ],
115
+ external,
116
+ plugins: [
117
+ nodePolyfills(),
118
+ resolve({ browser: true }),
119
+ babel({ exclude: "node_modules/**", babelrc: true }),
120
+ peerDep(),
121
+ commonjs({
122
+ include: /node_modules/,
123
+ requireReturnsDefault: "auto",
124
+ }),
125
+ ],
106
126
  },
107
127
  {
108
128
  input: "src/services.js",