@cratis/scene.blueprint.default 4.36.0 → 4.38.0

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 (105) hide show
  1. package/ComponentName.ts +9 -0
  2. package/defaultBlueprintComponents.ts +4 -1
  3. package/dist/cjs/ComponentName.js +3 -0
  4. package/dist/cjs/ComponentName.js.map +1 -1
  5. package/dist/cjs/defaultBlueprint.js +1 -0
  6. package/dist/cjs/defaultBlueprint.js.map +1 -1
  7. package/dist/cjs/defaultBlueprintComponentMetadata.js +1 -0
  8. package/dist/cjs/defaultBlueprintComponentMetadata.js.map +1 -1
  9. package/dist/cjs/defaultBlueprintComponents.js +7 -1
  10. package/dist/cjs/defaultBlueprintComponents.js.map +1 -1
  11. package/dist/cjs/foundation/ApprovalChainStepper.js +130 -0
  12. package/dist/cjs/foundation/ApprovalChainStepper.js.map +1 -0
  13. package/dist/cjs/foundation/OrgTree.js +188 -0
  14. package/dist/cjs/foundation/OrgTree.js.map +1 -0
  15. package/dist/cjs/foundation/PermissionMatrix.js +136 -0
  16. package/dist/cjs/foundation/PermissionMatrix.js.map +1 -0
  17. package/dist/cjs/foundation/approvalModel.js +87 -0
  18. package/dist/cjs/foundation/approvalModel.js.map +1 -0
  19. package/dist/cjs/foundation/foundationComponentMetadata.js +21 -0
  20. package/dist/cjs/foundation/foundationComponentMetadata.js.map +1 -1
  21. package/dist/cjs/foundation/foundationDescriptors.js +118 -0
  22. package/dist/cjs/foundation/foundationDescriptors.js.map +1 -1
  23. package/dist/cjs/foundation/foundationSamples.js +116 -0
  24. package/dist/cjs/foundation/foundationSamples.js.map +1 -1
  25. package/dist/cjs/foundation/foundationStrings.js +12 -1
  26. package/dist/cjs/foundation/foundationStrings.js.map +1 -1
  27. package/dist/cjs/foundation/orgModel.js +106 -0
  28. package/dist/cjs/foundation/orgModel.js.map +1 -0
  29. package/dist/cjs/foundation/permissionModel.js +84 -0
  30. package/dist/cjs/foundation/permissionModel.js.map +1 -0
  31. package/dist/cjs/index.js +26 -0
  32. package/dist/cjs/index.js.map +1 -1
  33. package/dist/esm/ComponentName.d.ts +4 -1
  34. package/dist/esm/ComponentName.d.ts.map +1 -1
  35. package/dist/esm/ComponentName.js +3 -0
  36. package/dist/esm/ComponentName.js.map +1 -1
  37. package/dist/esm/defaultBlueprint.js +1 -0
  38. package/dist/esm/defaultBlueprint.js.map +1 -1
  39. package/dist/esm/defaultBlueprintComponentMetadata.js +1 -0
  40. package/dist/esm/defaultBlueprintComponentMetadata.js.map +1 -1
  41. package/dist/esm/defaultBlueprintComponents.d.ts.map +1 -1
  42. package/dist/esm/defaultBlueprintComponents.js +7 -1
  43. package/dist/esm/defaultBlueprintComponents.js.map +1 -1
  44. package/dist/esm/foundation/ApprovalChainStepper.d.ts +3 -0
  45. package/dist/esm/foundation/ApprovalChainStepper.d.ts.map +1 -0
  46. package/dist/esm/foundation/ApprovalChainStepper.js +128 -0
  47. package/dist/esm/foundation/ApprovalChainStepper.js.map +1 -0
  48. package/dist/esm/foundation/Foundation.stories.d.ts +8 -0
  49. package/dist/esm/foundation/Foundation.stories.d.ts.map +1 -1
  50. package/dist/esm/foundation/Foundation.stories.js +8 -0
  51. package/dist/esm/foundation/Foundation.stories.js.map +1 -1
  52. package/dist/esm/foundation/OrgTree.d.ts +3 -0
  53. package/dist/esm/foundation/OrgTree.d.ts.map +1 -0
  54. package/dist/esm/foundation/OrgTree.js +186 -0
  55. package/dist/esm/foundation/OrgTree.js.map +1 -0
  56. package/dist/esm/foundation/PermissionMatrix.d.ts +3 -0
  57. package/dist/esm/foundation/PermissionMatrix.d.ts.map +1 -0
  58. package/dist/esm/foundation/PermissionMatrix.js +134 -0
  59. package/dist/esm/foundation/PermissionMatrix.js.map +1 -0
  60. package/dist/esm/foundation/approvalModel.d.ts +27 -0
  61. package/dist/esm/foundation/approvalModel.d.ts.map +1 -0
  62. package/dist/esm/foundation/approvalModel.js +81 -0
  63. package/dist/esm/foundation/approvalModel.js.map +1 -0
  64. package/dist/esm/foundation/foundationComponentMetadata.d.ts.map +1 -1
  65. package/dist/esm/foundation/foundationComponentMetadata.js +21 -0
  66. package/dist/esm/foundation/foundationComponentMetadata.js.map +1 -1
  67. package/dist/esm/foundation/foundationDescriptors.d.ts.map +1 -1
  68. package/dist/esm/foundation/foundationDescriptors.js +118 -0
  69. package/dist/esm/foundation/foundationDescriptors.js.map +1 -1
  70. package/dist/esm/foundation/foundationSamples.d.ts.map +1 -1
  71. package/dist/esm/foundation/foundationSamples.js +116 -0
  72. package/dist/esm/foundation/foundationSamples.js.map +1 -1
  73. package/dist/esm/foundation/foundationStrings.d.ts +11 -0
  74. package/dist/esm/foundation/foundationStrings.d.ts.map +1 -1
  75. package/dist/esm/foundation/foundationStrings.js +12 -1
  76. package/dist/esm/foundation/foundationStrings.js.map +1 -1
  77. package/dist/esm/foundation/index.d.ts +6 -0
  78. package/dist/esm/foundation/index.d.ts.map +1 -1
  79. package/dist/esm/foundation/index.js +6 -0
  80. package/dist/esm/foundation/index.js.map +1 -1
  81. package/dist/esm/foundation/orgModel.d.ts +20 -0
  82. package/dist/esm/foundation/orgModel.d.ts.map +1 -0
  83. package/dist/esm/foundation/orgModel.js +99 -0
  84. package/dist/esm/foundation/orgModel.js.map +1 -0
  85. package/dist/esm/foundation/permissionModel.d.ts +24 -0
  86. package/dist/esm/foundation/permissionModel.d.ts.map +1 -0
  87. package/dist/esm/foundation/permissionModel.js +77 -0
  88. package/dist/esm/foundation/permissionModel.js.map +1 -0
  89. package/dist/esm/index.js +6 -0
  90. package/dist/esm/index.js.map +1 -1
  91. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  92. package/foundation/ApprovalChainStepper.tsx +66 -0
  93. package/foundation/Foundation.stories.tsx +8 -0
  94. package/foundation/OrgTree.tsx +101 -0
  95. package/foundation/PermissionMatrix.tsx +82 -0
  96. package/foundation/approvalModel.ts +88 -0
  97. package/foundation/foundationComponentMetadata.ts +3 -0
  98. package/foundation/foundationDescriptors.ts +74 -0
  99. package/foundation/foundationSamples.ts +30 -0
  100. package/foundation/foundationStrings.ts +11 -0
  101. package/foundation/index.ts +6 -0
  102. package/foundation/orgModel.ts +85 -0
  103. package/foundation/permissionModel.ts +85 -0
  104. package/package.json +8 -8
  105. package/shell/layout.css +184 -0
@@ -109,13 +109,24 @@
109
109
  approvalRejected: 'Rejected',
110
110
  approvalSkipped: 'Skipped',
111
111
  approvalChain: 'Approval chain',
112
+ approvalStep: 'Step {n} of {total}',
113
+ approvalNotReached: 'Not reached',
114
+ approvalOutcomeApproved: 'Approved by everyone',
115
+ approvalOutcomeRejected: 'Rejected',
116
+ approvalOutcomeInProgress: 'Waiting for a decision',
117
+ approvalOutcomePending: 'Not started',
112
118
  orgExpand: 'Expand {name}',
113
119
  orgCollapse: 'Collapse {name}',
114
120
  orgReports: '{count} reports',
121
+ orgTree: 'Organization',
122
+ orgNone: 'There is nobody in the organization yet',
115
123
  matrixAllowed: 'Allowed',
116
124
  matrixDenied: 'Not allowed',
117
125
  matrixGrant: 'Grant {permission} to {role}',
118
- matrixReadOnly: 'Read-only'
126
+ matrixReadOnly: 'Read-only',
127
+ matrixPermission: 'Permission',
128
+ matrixScroll: 'Permission matrix, scrolls sideways',
129
+ matrixGroupAll: 'Other'
119
130
  };
120
131
  /**
121
132
  * The foundation strings with the element's own `strings` property laid over them.
@@ -1 +1 @@
1
- {"version":3,"file":"foundationStrings.js","sources":["../../../foundation/foundationStrings.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ExternalComponent } from '@cratis/scene.model';\n\n/**\n * Every piece of text the foundation components say themselves, as opposed to text a screen author or a bound query\n * supplies. Nothing is hard-coded in a component (spec Part B 1.5): a component reads its text from here, merged with\n * the `strings` property of the element, so an application localizes by supplying a table - and a bound string\n * (a `{name}` placeholder is replaced by the values the component passes) arrives the same way any other property does.\n */\nexport const foundationStrings = {\n loading: 'Loading',\n emptyHeadline: 'Nothing here yet',\n emptyHint: 'There is nothing to show for now.',\n errorHeadline: 'This could not be loaded',\n errorHint: 'Something went wrong while loading. Try again in a moment.',\n retry: 'Try again',\n noPermissionHeadline: 'You do not have access',\n noPermissionHint: 'Ask an administrator to grant you access to {subject}.',\n noPermissionSubject: 'this content',\n partialHeadline: 'Some parts could not be loaded',\n partialHint: 'The unavailable parts are: {regions}.',\n disabledNoPermission: 'You do not have permission to do this',\n trendUp: 'up {value}',\n trendDown: 'down {value}',\n trendFlat: 'unchanged',\n trendComparison: 'compared to {period}',\n statusSuccess: 'Success',\n statusWarning: 'Warning',\n statusDanger: 'Problem',\n statusInfo: 'Information',\n statusNeutral: 'Status',\n chartNoData: 'No data to chart',\n chartDataTable: 'Chart data',\n chartSeries: 'Series',\n chartCategory: 'Category',\n filterAdd: 'Add condition',\n filterAddGroup: 'Add group',\n filterRemove: 'Remove condition',\n filterRemoveGroup: 'Remove group',\n filterMatchAll: 'Match all (AND)',\n filterMatchAny: 'Match any (OR)',\n filterField: 'Field',\n filterOperator: 'Operator',\n filterValue: 'Value',\n filterClear: 'Clear filters',\n filterCondition: 'Condition {n}',\n filterGroup: 'Group {n}',\n filterNoFields: 'There are no fields to filter on',\n opContains: 'contains',\n opEquals: 'equals',\n opNotEquals: 'does not equal',\n opStartsWith: 'starts with',\n opIsEmpty: 'is empty',\n opGreater: 'is greater than',\n opGreaterOrEqual: 'is at least',\n opLess: 'is less than',\n opLessOrEqual: 'is at most',\n opBefore: 'is before',\n opAfter: 'is after',\n opOn: 'is on',\n opIs: 'is',\n opIsNot: 'is not',\n opTrue: 'is yes',\n opFalse: 'is no',\n filterSummary: '{count} active filters',\n filterSummaryOne: '1 active filter',\n columnsChoose: 'Columns',\n columnsLocked: 'always shown',\n columnsReset: 'Show all columns',\n columnsMoveUp: 'Move {name} up',\n columnsMoveDown: 'Move {name} down',\n columnsShown: '{shown} of {total} shown',\n columnsNone: 'There are no columns to choose from',\n viewsLabel: 'Saved views',\n viewsDefault: 'All items',\n viewsSave: 'Save current view',\n viewsManage: 'Manage views',\n viewsNone: 'There are no saved views',\n checklistProgress: '{done} of {total} complete',\n checklistOwner: 'Owner',\n checklistOverdue: 'Overdue',\n checklistDone: 'Done',\n checklistOpen: 'Open',\n checklistItemProgress: 'Progress of {title}',\n checklistNone: 'This checklist has no tasks',\n checklistDue: 'Due',\n activityEmpty: 'No activity yet',\n activityComment: 'Comment',\n activityChange: 'Change',\n activityStatus: 'Status',\n activitySystem: 'System',\n activityBy: 'by {actor}',\n avatarOverflow: '{count} more',\n avatarPeople: '{count} people',\n uploadDrop: 'Drop files here or',\n uploadLimits: 'Up to {limit} each',\n uploadAccepts: 'Accepts {types}',\n uploadSelected: 'Selected files',\n uploadQueued: 'Ready to upload',\n uploadSingle: 'Only one file can be uploaded at a time',\n uploadBrowse: 'Browse files',\n uploadRemove: 'Remove {name}',\n uploadTooLarge: '{name} is larger than {limit}',\n uploadWrongType: '{name} is not an accepted file type',\n uploadUploading: 'Uploading',\n uploadDone: 'Uploaded',\n uploadFailed: 'Upload failed',\n approvalPending: 'Pending',\n approvalCurrent: 'Awaiting decision',\n approvalApproved: 'Approved',\n approvalRejected: 'Rejected',\n approvalSkipped: 'Skipped',\n approvalChain: 'Approval chain',\n orgExpand: 'Expand {name}',\n orgCollapse: 'Collapse {name}',\n orgReports: '{count} reports',\n matrixAllowed: 'Allowed',\n matrixDenied: 'Not allowed',\n matrixGrant: 'Grant {permission} to {role}',\n matrixReadOnly: 'Read-only',\n} as const;\n\n/** The name of one of the foundation strings. */\nexport type FoundationStringName = keyof typeof foundationStrings;\n\n/** The text table a foundation component works with. */\nexport type FoundationStrings = Record<FoundationStringName, string>;\n\n/**\n * The foundation strings with the element's own `strings` property laid over them.\n *\n * Only string values of known names are taken, so a typo in an application's table falls back to the default text\n * rather than rendering nothing.\n */\nexport function readFoundationStrings(element: ExternalComponent): FoundationStrings {\n const supplied = element.properties.strings;\n const result: FoundationStrings = { ...foundationStrings };\n if (typeof supplied !== 'object' || supplied === null || Array.isArray(supplied)) return result;\n\n for (const [name, value] of Object.entries(supplied as Record<string, unknown>)) {\n if (name in foundationStrings && typeof value === 'string') result[name as FoundationStringName] = value;\n }\n\n return result;\n}\n\n/** Replaces each `{name}` in a string with the value of the same name, leaving an unknown placeholder visible rather than blank. */\nexport function formatText(text: string, values: Record<string, string | number> = {}): string {\n return text.replace(/\\{(\\w+)\\}/g, (placeholder, name: string) => (name in values ? String(values[name]) : placeholder));\n}\n"],"names":["foundationStrings","loading","emptyHeadline","emptyHint","errorHeadline","errorHint","retry","noPermissionHeadline","noPermissionHint","noPermissionSubject","partialHeadline","partialHint","disabledNoPermission","trendUp","trendDown","trendFlat","trendComparison","statusSuccess","statusWarning","statusDanger","statusInfo","statusNeutral","chartNoData","chartDataTable","chartSeries","chartCategory","filterAdd","filterAddGroup","filterRemove","filterRemoveGroup","filterMatchAll","filterMatchAny","filterField","filterOperator","filterValue","filterClear","filterCondition","filterGroup","filterNoFields","opContains","opEquals","opNotEquals","opStartsWith","opIsEmpty","opGreater","opGreaterOrEqual","opLess","opLessOrEqual","opBefore","opAfter","opOn","opIs","opIsNot","opTrue","opFalse","filterSummary","filterSummaryOne","columnsChoose","columnsLocked","columnsReset","columnsMoveUp","columnsMoveDown","columnsShown","columnsNone","viewsLabel","viewsDefault","viewsSave","viewsManage","viewsNone","checklistProgress","checklistOwner","checklistOverdue","checklistDone","checklistOpen","checklistItemProgress","checklistNone","checklistDue","activityEmpty","activityComment","activityChange","activityStatus","activitySystem","activityBy","avatarOverflow","avatarPeople","uploadDrop","uploadLimits","uploadAccepts","uploadSelected","uploadQueued","uploadSingle","uploadBrowse","uploadRemove","uploadTooLarge","uploadWrongType","uploadUploading","uploadDone","uploadFailed","approvalPending","approvalCurrent","approvalApproved","approvalRejected","approvalSkipped","approvalChain","orgExpand","orgCollapse","orgReports","matrixAllowed","matrixDenied","matrixGrant","matrixReadOnly","readFoundationStrings","element","supplied","properties","strings","result","Array","isArray","name","value","Object","entries","formatText","text","values","replace","placeholder","String"],"mappings":"AAAA;AACA;AAIA;;;;;UAMaA,iBAAAA,GAAoB;IAC7BC,OAAAA,EAAS,SAAA;IACTC,aAAAA,EAAe,kBAAA;IACfC,SAAAA,EAAW,mCAAA;IACXC,aAAAA,EAAe,0BAAA;IACfC,SAAAA,EAAW,4DAAA;IACXC,KAAAA,EAAO,WAAA;IACPC,oBAAAA,EAAsB,wBAAA;IACtBC,gBAAAA,EAAkB,wDAAA;IAClBC,mBAAAA,EAAqB,cAAA;IACrBC,eAAAA,EAAiB,gCAAA;IACjBC,WAAAA,EAAa,uCAAA;IACbC,oBAAAA,EAAsB,uCAAA;IACtBC,OAAAA,EAAS,YAAA;IACTC,SAAAA,EAAW,cAAA;IACXC,SAAAA,EAAW,WAAA;IACXC,eAAAA,EAAiB,sBAAA;IACjBC,aAAAA,EAAe,SAAA;IACfC,aAAAA,EAAe,SAAA;IACfC,YAAAA,EAAc,SAAA;IACdC,UAAAA,EAAY,aAAA;IACZC,aAAAA,EAAe,QAAA;IACfC,WAAAA,EAAa,kBAAA;IACbC,cAAAA,EAAgB,YAAA;IAChBC,WAAAA,EAAa,QAAA;IACbC,aAAAA,EAAe,UAAA;IACfC,SAAAA,EAAW,eAAA;IACXC,cAAAA,EAAgB,WAAA;IAChBC,YAAAA,EAAc,kBAAA;IACdC,iBAAAA,EAAmB,cAAA;IACnBC,cAAAA,EAAgB,iBAAA;IAChBC,cAAAA,EAAgB,gBAAA;IAChBC,WAAAA,EAAa,OAAA;IACbC,cAAAA,EAAgB,UAAA;IAChBC,WAAAA,EAAa,OAAA;IACbC,WAAAA,EAAa,eAAA;IACbC,eAAAA,EAAiB,eAAA;IACjBC,WAAAA,EAAa,WAAA;IACbC,cAAAA,EAAgB,kCAAA;IAChBC,UAAAA,EAAY,UAAA;IACZC,QAAAA,EAAU,QAAA;IACVC,WAAAA,EAAa,gBAAA;IACbC,YAAAA,EAAc,aAAA;IACdC,SAAAA,EAAW,UAAA;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C,YAAA,EAAc,CAACC,WAAAA,EAAaR,IAAAA,GAAkBA,IAAAA,IAAQM,MAAAA,GAASG,MAAAA,CAAOH,MAAM,CAACN,KAAK,CAAA,GAAIQ,WAAAA,CAAAA;AAC9G;;"}
1
+ {"version":3,"file":"foundationStrings.js","sources":["../../../foundation/foundationStrings.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ExternalComponent } from '@cratis/scene.model';\n\n/**\n * Every piece of text the foundation components say themselves, as opposed to text a screen author or a bound query\n * supplies. Nothing is hard-coded in a component (spec Part B 1.5): a component reads its text from here, merged with\n * the `strings` property of the element, so an application localizes by supplying a table - and a bound string\n * (a `{name}` placeholder is replaced by the values the component passes) arrives the same way any other property does.\n */\nexport const foundationStrings = {\n loading: 'Loading',\n emptyHeadline: 'Nothing here yet',\n emptyHint: 'There is nothing to show for now.',\n errorHeadline: 'This could not be loaded',\n errorHint: 'Something went wrong while loading. Try again in a moment.',\n retry: 'Try again',\n noPermissionHeadline: 'You do not have access',\n noPermissionHint: 'Ask an administrator to grant you access to {subject}.',\n noPermissionSubject: 'this content',\n partialHeadline: 'Some parts could not be loaded',\n partialHint: 'The unavailable parts are: {regions}.',\n disabledNoPermission: 'You do not have permission to do this',\n trendUp: 'up {value}',\n trendDown: 'down {value}',\n trendFlat: 'unchanged',\n trendComparison: 'compared to {period}',\n statusSuccess: 'Success',\n statusWarning: 'Warning',\n statusDanger: 'Problem',\n statusInfo: 'Information',\n statusNeutral: 'Status',\n chartNoData: 'No data to chart',\n chartDataTable: 'Chart data',\n chartSeries: 'Series',\n chartCategory: 'Category',\n filterAdd: 'Add condition',\n filterAddGroup: 'Add group',\n filterRemove: 'Remove condition',\n filterRemoveGroup: 'Remove group',\n filterMatchAll: 'Match all (AND)',\n filterMatchAny: 'Match any (OR)',\n filterField: 'Field',\n filterOperator: 'Operator',\n filterValue: 'Value',\n filterClear: 'Clear filters',\n filterCondition: 'Condition {n}',\n filterGroup: 'Group {n}',\n filterNoFields: 'There are no fields to filter on',\n opContains: 'contains',\n opEquals: 'equals',\n opNotEquals: 'does not equal',\n opStartsWith: 'starts with',\n opIsEmpty: 'is empty',\n opGreater: 'is greater than',\n opGreaterOrEqual: 'is at least',\n opLess: 'is less than',\n opLessOrEqual: 'is at most',\n opBefore: 'is before',\n opAfter: 'is after',\n opOn: 'is on',\n opIs: 'is',\n opIsNot: 'is not',\n opTrue: 'is yes',\n opFalse: 'is no',\n filterSummary: '{count} active filters',\n filterSummaryOne: '1 active filter',\n columnsChoose: 'Columns',\n columnsLocked: 'always shown',\n columnsReset: 'Show all columns',\n columnsMoveUp: 'Move {name} up',\n columnsMoveDown: 'Move {name} down',\n columnsShown: '{shown} of {total} shown',\n columnsNone: 'There are no columns to choose from',\n viewsLabel: 'Saved views',\n viewsDefault: 'All items',\n viewsSave: 'Save current view',\n viewsManage: 'Manage views',\n viewsNone: 'There are no saved views',\n checklistProgress: '{done} of {total} complete',\n checklistOwner: 'Owner',\n checklistOverdue: 'Overdue',\n checklistDone: 'Done',\n checklistOpen: 'Open',\n checklistItemProgress: 'Progress of {title}',\n checklistNone: 'This checklist has no tasks',\n checklistDue: 'Due',\n activityEmpty: 'No activity yet',\n activityComment: 'Comment',\n activityChange: 'Change',\n activityStatus: 'Status',\n activitySystem: 'System',\n activityBy: 'by {actor}',\n avatarOverflow: '{count} more',\n avatarPeople: '{count} people',\n uploadDrop: 'Drop files here or',\n uploadLimits: 'Up to {limit} each',\n uploadAccepts: 'Accepts {types}',\n uploadSelected: 'Selected files',\n uploadQueued: 'Ready to upload',\n uploadSingle: 'Only one file can be uploaded at a time',\n uploadBrowse: 'Browse files',\n uploadRemove: 'Remove {name}',\n uploadTooLarge: '{name} is larger than {limit}',\n uploadWrongType: '{name} is not an accepted file type',\n uploadUploading: 'Uploading',\n uploadDone: 'Uploaded',\n uploadFailed: 'Upload failed',\n approvalPending: 'Pending',\n approvalCurrent: 'Awaiting decision',\n approvalApproved: 'Approved',\n approvalRejected: 'Rejected',\n approvalSkipped: 'Skipped',\n approvalChain: 'Approval chain',\n approvalStep: 'Step {n} of {total}',\n approvalNotReached: 'Not reached',\n approvalOutcomeApproved: 'Approved by everyone',\n approvalOutcomeRejected: 'Rejected',\n approvalOutcomeInProgress: 'Waiting for a decision',\n approvalOutcomePending: 'Not started',\n orgExpand: 'Expand {name}',\n orgCollapse: 'Collapse {name}',\n orgReports: '{count} reports',\n orgTree: 'Organization',\n orgNone: 'There is nobody in the organization yet',\n matrixAllowed: 'Allowed',\n matrixDenied: 'Not allowed',\n matrixGrant: 'Grant {permission} to {role}',\n matrixReadOnly: 'Read-only',\n matrixPermission: 'Permission',\n matrixScroll: 'Permission matrix, scrolls sideways',\n matrixGroupAll: 'Other',\n} as const;\n\n/** The name of one of the foundation strings. */\nexport type FoundationStringName = keyof typeof foundationStrings;\n\n/** The text table a foundation component works with. */\nexport type FoundationStrings = Record<FoundationStringName, string>;\n\n/**\n * The foundation strings with the element's own `strings` property laid over them.\n *\n * Only string values of known names are taken, so a typo in an application's table falls back to the default text\n * rather than rendering nothing.\n */\nexport function readFoundationStrings(element: ExternalComponent): FoundationStrings {\n const supplied = element.properties.strings;\n const result: FoundationStrings = { ...foundationStrings };\n if (typeof supplied !== 'object' || supplied === null || Array.isArray(supplied)) return result;\n\n for (const [name, value] of Object.entries(supplied as Record<string, unknown>)) {\n if (name in foundationStrings && typeof value === 'string') result[name as FoundationStringName] = value;\n }\n\n return result;\n}\n\n/** Replaces each `{name}` in a string with the value of the same name, leaving an unknown placeholder visible rather than blank. */\nexport function formatText(text: string, values: Record<string, string | number> = {}): string {\n return text.replace(/\\{(\\w+)\\}/g, (placeholder, name: string) => (name in values ? String(values[name]) : placeholder));\n}\n"],"names":["foundationStrings","loading","emptyHeadline","emptyHint","errorHeadline","errorHint","retry","noPermissionHeadline","noPermissionHint","noPermissionSubject","partialHeadline","partialHint","disabledNoPermission","trendUp","trendDown","trendFlat","trendComparison","statusSuccess","statusWarning","statusDanger","statusInfo","statusNeutral","chartNoData","chartDataTable","chartSeries","chartCategory","filterAdd","filterAddGroup","filterRemove","filterRemoveGroup","filterMatchAll","filterMatchAny","filterField","filterOperator","filterValue","filterClear","filterCondition","filterGroup","filterNoFields","opContains","opEquals","opNotEquals","opStartsWith","opIsEmpty","opGreater","opGreaterOrEqual","opLess","opLessOrEqual","opBefore","opAfter","opOn","opIs","opIsNot","opTrue","opFalse","filterSummary","filterSummaryOne","columnsChoose","columnsLocked","columnsReset","columnsMoveUp","columnsMoveDown","columnsShown","columnsNone","viewsLabel","viewsDefault","viewsSave","viewsManage","viewsNone","checklistProgress","checklistOwner","checklistOverdue","checklistDone","checklistOpen","checklistItemProgress","checklistNone","checklistDue","activityEmpty","activityComment","activityChange","activityStatus","activitySystem","activityBy","avatarOverflow","avatarPeople","uploadDrop","uploadLimits","uploadAccepts","uploadSelected","uploadQueued","uploadSingle","uploadBrowse","uploadRemove","uploadTooLarge","uploadWrongType","uploadUploading","uploadDone","uploadFailed","approvalPending","approvalCurrent","approvalApproved","approvalRejected","approvalSkipped","approvalChain","approvalStep","approvalNotReached","approvalOutcomeApproved","approvalOutcomeRejected","approvalOutcomeInProgress","approvalOutcomePending","orgExpand","orgCollapse","orgReports","orgTree","orgNone","matrixAllowed","matrixDenied","matrixGrant","matrixReadOnly","matrixPermission","matrixScroll","matrixGroupAll","readFoundationStrings","element","supplied","properties","strings","result","Array","isArray","name","value","Object","entries","formatText","text","values","replace","placeholder","String"],"mappings":"AAAA;AACA;AAIA;;;;;UAMaA,iBAAAA,GAAoB;IAC7BC,OAAAA,EAAS,SAAA;IACTC,aAAAA,EAAe,kBAAA;IACfC,SAAAA,EAAW,mCAAA;IACXC,aAAAA,EAAe,0BAAA;IACfC,SAAAA,EAAW,4DAAA;IACXC,KAAAA,EAAO,WAAA;IACPC,oBAAAA,EAAsB,wBAAA;IACtBC,gBAAAA,EAAkB,wDAAA;IAClBC,mBAAAA,EAAqB,cA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C,WAAAA,EAAaR,IAAAA,GAAkBA,IAAAA,IAAQM,MAAAA,GAASG,MAAAA,CAAOH,MAAM,CAACN,KAAK,CAAA,GAAIQ,WAAAA,CAAAA;AAC9G;;"}
@@ -27,6 +27,12 @@ export * from './AvatarStack';
27
27
  export * from './uploadModel';
28
28
  export * from './FileUploaderHandler';
29
29
  export * from './FileUploader';
30
+ export * from './approvalModel';
31
+ export * from './ApprovalChainStepper';
32
+ export * from './orgModel';
33
+ export * from './OrgTree';
34
+ export * from './permissionModel';
35
+ export * from './PermissionMatrix';
30
36
  export * from './foundationDescriptors';
31
37
  export * from './foundationComponentMetadata';
32
38
  export * from './foundationSamples';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../foundation/index.ts"],"names":[],"mappings":"AAGA,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACt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27,6 +27,12 @@ export * from './AvatarStack';
27
27
  export * from './uploadModel';
28
28
  export * from './FileUploaderHandler';
29
29
  export * from './FileUploader';
30
+ export * from './approvalModel';
31
+ export * from './ApprovalChainStepper';
32
+ export * from './orgModel';
33
+ export * from './OrgTree';
34
+ export * from './permissionModel';
35
+ export * from './PermissionMatrix';
30
36
  export * from './foundationDescriptors';
31
37
  export * from './foundationComponentMetadata';
32
38
  export * from './foundationSamples';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../foundation/index.ts"],"names":[],"mappings":"AAGA,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../foundation/index.ts"],"names":[],"mappings":"AAGA,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,20 @@
1
+ export interface OrgNode {
2
+ id: string;
3
+ label: string;
4
+ title?: string;
5
+ parentId?: string;
6
+ }
7
+ export interface OrgTreeNode extends OrgNode {
8
+ children: OrgTreeNode[];
9
+ depth: number;
10
+ }
11
+ export declare function readOrgNodes(value: unknown): OrgNode[];
12
+ export declare function buildOrgTree(nodes: OrgNode[]): OrgTreeNode[];
13
+ export declare function visibleNodes(roots: OrgTreeNode[], expanded: ReadonlySet<string>): OrgTreeNode[];
14
+ export declare function expandedToDepth(roots: OrgTreeNode[], depth: number): Set<string>;
15
+ export declare const descendantCount: (node: OrgTreeNode) => number;
16
+ export declare function placements(roots: OrgTreeNode[]): Map<string, {
17
+ siblings: OrgTreeNode[];
18
+ parent?: OrgTreeNode;
19
+ }>;
20
+ //# sourceMappingURL=orgModel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orgModel.d.ts","sourceRoot":"","sources":["../../../foundation/orgModel.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,OAAO;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,WAAW,WAAY,SAAQ,OAAO;IACxC,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACjB;AAGD,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,EAAE,CAWtD;AAQD,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,WAAW,EAAE,CAuB5D;AAGD,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,WAAW,EAAE,CAE/F;AAGD,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAKhF;AAGD,eAAO,MAAM,eAAe,SAAU,WAAW,KAAG,MAAmF,CAAC;AAGxI,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE;IAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC,CAK/G"}
@@ -0,0 +1,99 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ /** A person or unit in an organization, with who they report to. */ /** Reads nodes out of a property value, dropping entries without an id and keeping the first of a repeated id. */ function readOrgNodes(value) {
4
+ if (!Array.isArray(value)) return [];
5
+ const seen = new Set();
6
+ return value.flatMap((entry)=>{
7
+ if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) return [];
8
+ const { id, label, title, parentId } = entry;
9
+ if (typeof id !== 'string' || id.length === 0 || seen.has(id)) return [];
10
+ seen.add(id);
11
+ return [
12
+ {
13
+ id,
14
+ label: typeof label === 'string' && label.length > 0 ? label : id,
15
+ ...typeof title === 'string' ? {
16
+ title
17
+ } : {},
18
+ ...typeof parentId === 'string' && parentId.length > 0 ? {
19
+ parentId
20
+ } : {}
21
+ }
22
+ ];
23
+ });
24
+ }
25
+ /**
26
+ * Builds the tree from the flat rows a query returns.
27
+ *
28
+ * Someone whose manager is not in the data becomes a root rather than vanishing, and a reporting cycle is broken at the node that closes it
29
+ * - which becomes a root - so malformed data draws something and never loops. Siblings keep the order of the rows.
30
+ */ function buildOrgTree(nodes) {
31
+ const known = new Set(nodes.map((node)=>node.id));
32
+ const parentOf = new Map(nodes.map((node)=>[
33
+ node.id,
34
+ node.parentId !== undefined && known.has(node.parentId) && node.parentId !== node.id ? node.parentId : undefined
35
+ ]));
36
+ for (const node of nodes){
37
+ const path = new Set([
38
+ node.id
39
+ ]);
40
+ for(let current = parentOf.get(node.id); current !== undefined; current = parentOf.get(current)){
41
+ if (path.has(current)) {
42
+ parentOf.set(node.id, undefined);
43
+ break;
44
+ }
45
+ path.add(current);
46
+ }
47
+ }
48
+ const placed = new Map(nodes.map((node)=>[
49
+ node.id,
50
+ {
51
+ ...node,
52
+ children: [],
53
+ depth: 0
54
+ }
55
+ ]));
56
+ const roots = [];
57
+ for (const node of nodes){
58
+ const parent = parentOf.get(node.id);
59
+ if (parent === undefined) roots.push(placed.get(node.id));
60
+ else placed.get(parent).children.push(placed.get(node.id));
61
+ }
62
+ const assignDepth = (level, depth)=>level.forEach((node)=>{
63
+ node.depth = depth;
64
+ assignDepth(node.children, depth + 1);
65
+ });
66
+ assignDepth(roots, 1);
67
+ return roots;
68
+ }
69
+ /** The nodes that can be reached from the roots with the given expansion, in the order they are drawn. */ function visibleNodes(roots, expanded) {
70
+ return roots.flatMap((node)=>[
71
+ node,
72
+ ...expanded.has(node.id) ? visibleNodes(node.children, expanded) : []
73
+ ]);
74
+ }
75
+ /** The ids of every node down to a depth: what is expanded when the tree first opens. */ function expandedToDepth(roots, depth) {
76
+ const result = new Set();
77
+ const walk = (level)=>level.forEach((node)=>{
78
+ if (node.depth < depth && node.children.length > 0) result.add(node.id);
79
+ walk(node.children);
80
+ });
81
+ walk(roots);
82
+ return result;
83
+ }
84
+ /** The number of people below a node, at any depth. */ const descendantCount = (node)=>node.children.reduce((sum, child)=>sum + 1 + descendantCount(child), 0);
85
+ /** For each node, the nodes that share its parent (itself included, in order) and its parent: what a tree needs for its set size and position, and for Left to go up. */ function placements(roots) {
86
+ const result = new Map();
87
+ const walk = (level, parent)=>level.forEach((node)=>{
88
+ result.set(node.id, {
89
+ siblings: level,
90
+ parent
91
+ });
92
+ walk(node.children, node);
93
+ });
94
+ walk(roots);
95
+ return result;
96
+ }
97
+
98
+ export { buildOrgTree, descendantCount, expandedToDepth, placements, readOrgNodes, visibleNodes };
99
+ //# sourceMappingURL=orgModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orgModel.js","sources":["../../../foundation/orgModel.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/** A person or unit in an organization, with who they report to. */\nexport interface OrgNode {\n id: string;\n label: string;\n title?: string;\n parentId?: string;\n}\n\n/** A node placed in the tree. */\nexport interface OrgTreeNode extends OrgNode {\n children: OrgTreeNode[];\n depth: number;\n}\n\n/** Reads nodes out of a property value, dropping entries without an id and keeping the first of a repeated id. */\nexport function readOrgNodes(value: unknown): OrgNode[] {\n if (!Array.isArray(value)) return [];\n\n const seen = new Set<string>();\n return value.flatMap((entry): OrgNode[] => {\n if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) return [];\n const { id, label, title, parentId } = entry as Record<string, unknown>;\n if (typeof id !== 'string' || id.length === 0 || seen.has(id)) return [];\n seen.add(id);\n return [{ id, label: typeof label === 'string' && label.length > 0 ? label : id, ...(typeof title === 'string' ? { title } : {}), ...(typeof parentId === 'string' && parentId.length > 0 ? { parentId } : {}) }];\n });\n}\n\n/**\n * Builds the tree from the flat rows a query returns.\n *\n * Someone whose manager is not in the data becomes a root rather than vanishing, and a reporting cycle is broken at the node that closes it\n * - which becomes a root - so malformed data draws something and never loops. Siblings keep the order of the rows.\n */\nexport function buildOrgTree(nodes: OrgNode[]): OrgTreeNode[] {\n const known = new Set(nodes.map(node => node.id));\n const parentOf = new Map<string, string | undefined>(nodes.map(node => [node.id, node.parentId !== undefined && known.has(node.parentId) && node.parentId !== node.id ? node.parentId : undefined]));\n\n for (const node of nodes) {\n const path = new Set<string>([node.id]);\n for (let current = parentOf.get(node.id); current !== undefined; current = parentOf.get(current)) {\n if (path.has(current)) { parentOf.set(node.id, undefined); break; }\n path.add(current);\n }\n }\n\n const placed = new Map<string, OrgTreeNode>(nodes.map(node => [node.id, { ...node, children: [], depth: 0 }]));\n const roots: OrgTreeNode[] = [];\n for (const node of nodes) {\n const parent = parentOf.get(node.id);\n if (parent === undefined) roots.push(placed.get(node.id)!);\n else placed.get(parent)!.children.push(placed.get(node.id)!);\n }\n\n const assignDepth = (level: OrgTreeNode[], depth: number) => level.forEach(node => { node.depth = depth; assignDepth(node.children, depth + 1); });\n assignDepth(roots, 1);\n return roots;\n}\n\n/** The nodes that can be reached from the roots with the given expansion, in the order they are drawn. */\nexport function visibleNodes(roots: OrgTreeNode[], expanded: ReadonlySet<string>): OrgTreeNode[] {\n return roots.flatMap(node => [node, ...(expanded.has(node.id) ? visibleNodes(node.children, expanded) : [])]);\n}\n\n/** The ids of every node down to a depth: what is expanded when the tree first opens. */\nexport function expandedToDepth(roots: OrgTreeNode[], depth: number): Set<string> {\n const result = new Set<string>();\n const walk = (level: OrgTreeNode[]) => level.forEach(node => { if (node.depth < depth && node.children.length > 0) result.add(node.id); walk(node.children); });\n walk(roots);\n return result;\n}\n\n/** The number of people below a node, at any depth. */\nexport const descendantCount = (node: OrgTreeNode): number => node.children.reduce((sum, child) => sum + 1 + descendantCount(child), 0);\n\n/** For each node, the nodes that share its parent (itself included, in order) and its parent: what a tree needs for its set size and position, and for Left to go up. */\nexport function placements(roots: OrgTreeNode[]): Map<string, { siblings: OrgTreeNode[]; parent?: OrgTreeNode }> {\n const result = new Map<string, { siblings: OrgTreeNode[]; parent?: OrgTreeNode }>();\n const walk = (level: OrgTreeNode[], parent?: OrgTreeNode) => level.forEach(node => { result.set(node.id, { siblings: level, parent }); walk(node.children, node); });\n walk(roots);\n return result;\n}\n"],"names":["readOrgNodes","value","Array","isArray","seen","Set","flatMap","entry","id","label","title","parentId","length","has","add","buildOrgTree","nodes","known","map","node","parentOf","Map","undefined","path","current","get","set","placed","children","depth","roots","parent","push","assignDepth","level","forEach","visibleNodes","expanded","expandedToDepth","result","walk","descendantCount","reduce","sum","child","placements","siblings"],"mappings":"AAAA;AACA;AAEA,wLAeO,SAASA,aAAaC,KAAc,EAAA;AACvC,IAAA,IAAI,CAACC,KAAAA,CAAMC,OAAO,CAACF,KAAAA,CAAAA,EAAQ,OAAO,EAAE;AAEpC,IAAA,MAAMG,OAAO,IAAIC,GAAAA,EAAAA;IACjB,OAAOJ,KAAAA,CAAMK,OAAO,CAAC,CAACC,KAAAA,GAAAA;QAClB,IAAI,OAAOA,KAAAA,KAAU,QAAA,IAA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ACX;AAEA,wDACO,MAAME,kBAAkB,CAACtB,IAAAA,GAA8BA,KAAKS,QAAQ,CAACc,MAAM,CAAC,CAACC,GAAAA,EAAKC,KAAAA,GAAUD,MAAM,CAAA,GAAIF,eAAAA,CAAgBG,QAAQ,CAAA;AAErI,0KACO,SAASC,UAAAA,CAAWf,KAAoB,EAAA;AAC3C,IAAA,MAAMS,SAAS,IAAIlB,GAAAA,EAAAA;AACnB,IAAA,MAAMmB,OAAO,CAACN,KAAAA,EAAsBH,SAAyBG,KAAAA,CAAMC,OAAO,CAAChB,CAAAA,IAAAA,GAAAA;AAAUoB,YAAAA,MAAAA,CAAOb,GAAG,CAACP,IAAAA,CAAKX,EAAE,EAAE;gBAAEsC,QAAAA,EAAUZ,KAAAA;AAAOH,gBAAAA;AAAO,aAAA,CAAA;YAAIS,IAAAA,CAAKrB,IAAAA,CAAKS,QAAQ,EAAET,IAAAA,CAAAA;AAAO,QAAA,CAAA,CAAA;IAClKqB,IAAAA,CAAKV,KAAAA,CAAAA;IACL,OAAOS,MAAAA;AACX;;"}
@@ -0,0 +1,24 @@
1
+ export interface MatrixRole {
2
+ id: string;
3
+ label: string;
4
+ }
5
+ export interface MatrixPermission {
6
+ id: string;
7
+ label: string;
8
+ group?: string;
9
+ }
10
+ export interface MatrixGrant {
11
+ role: string;
12
+ permission: string;
13
+ }
14
+ export interface MatrixSection {
15
+ group?: string;
16
+ permissions: MatrixPermission[];
17
+ }
18
+ export declare function readRoles(value: unknown): MatrixRole[];
19
+ export declare function readPermissions(value: unknown): MatrixPermission[];
20
+ export declare function readGrants(value: unknown, roles: MatrixRole[], permissions: MatrixPermission[]): MatrixGrant[];
21
+ export declare const isGranted: (grants: MatrixGrant[], role: string, permission: string) => boolean;
22
+ export declare const setGrant: (grants: MatrixGrant[], role: string, permission: string, granted: boolean) => MatrixGrant[];
23
+ export declare function sectionsOf(permissions: MatrixPermission[]): MatrixSection[];
24
+ //# sourceMappingURL=permissionModel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissionModel.d.ts","sourceRoot":"","sources":["../../../foundation/permissionModel.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,UAAU;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACjB;AAGD,MAAM,WAAW,gBAAgB;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAGD,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACtB;AAGD,MAAM,WAAW,aAAa;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,gBAAgB,EAAE,CAAC;CACnC;AAMD,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,EAAE,CAOtD;AAGD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,EAAE,CAOlE;AAGD,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,WAAW,EAAE,gBAAgB,EAAE,GAAG,WAAW,EAAE,CAa9G;AAGD,eAAO,MAAM,SAAS,WAAY,WAAW,EAAE,QAAQ,MAAM,cAAc,MAAM,KAAG,OAAuF,CAAC;AAG5K,eAAO,MAAM,QAAQ,WAAY,WAAW,EAAE,QAAQ,MAAM,cAAc,MAAM,WAAW,OAAO,KAAG,WAAW,EACoE,CAAC;AAGrL,wBAAgB,UAAU,CAAC,WAAW,EAAE,gBAAgB,EAAE,GAAG,aAAa,EAAE,CAS3E"}
@@ -0,0 +1,77 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ /** A role: a column of the matrix. */ const records = (value)=>Array.isArray(value) ? value.filter((entry)=>typeof entry === 'object' && entry !== null && !Array.isArray(entry)) : [];
4
+ /** Reads roles, dropping those without an id and repeated ids. */ function readRoles(value) {
5
+ const seen = new Set();
6
+ return records(value).flatMap((entry)=>{
7
+ if (typeof entry.id !== 'string' || entry.id.length === 0 || seen.has(entry.id)) return [];
8
+ seen.add(entry.id);
9
+ return [
10
+ {
11
+ id: entry.id,
12
+ label: typeof entry.label === 'string' && entry.label.length > 0 ? entry.label : entry.id
13
+ }
14
+ ];
15
+ });
16
+ }
17
+ /** Reads permissions, dropping those without an id and repeated ids. */ function readPermissions(value) {
18
+ const seen = new Set();
19
+ return records(value).flatMap((entry)=>{
20
+ if (typeof entry.id !== 'string' || entry.id.length === 0 || seen.has(entry.id)) return [];
21
+ seen.add(entry.id);
22
+ return [
23
+ {
24
+ id: entry.id,
25
+ label: typeof entry.label === 'string' && entry.label.length > 0 ? entry.label : entry.id,
26
+ ...typeof entry.group === 'string' && entry.group.length > 0 ? {
27
+ group: entry.group
28
+ } : {}
29
+ }
30
+ ];
31
+ });
32
+ }
33
+ /** Reads grants, keeping each pair once and only for a role and a permission that exist: a grant of something that was deleted is not shown as held. */ function readGrants(value, roles, permissions) {
34
+ const roleIds = new Set(roles.map((role)=>role.id));
35
+ const permissionIds = new Set(permissions.map((permission)=>permission.id));
36
+ const seen = new Set();
37
+ return records(value).flatMap((entry)=>{
38
+ const { role, permission } = entry;
39
+ if (typeof role !== 'string' || typeof permission !== 'string' || !roleIds.has(role) || !permissionIds.has(permission)) return [];
40
+ const key = `${role}\u0000${permission}`;
41
+ if (seen.has(key)) return [];
42
+ seen.add(key);
43
+ return [
44
+ {
45
+ role,
46
+ permission
47
+ }
48
+ ];
49
+ });
50
+ }
51
+ /** Whether a role holds a permission. */ const isGranted = (grants, role, permission)=>grants.some((grant)=>grant.role === role && grant.permission === permission);
52
+ /** Grants a permission to a role, or takes it away, leaving every other grant as it was. */ const setGrant = (grants, role, permission, granted)=>granted ? isGranted(grants, role, permission) ? grants : [
53
+ ...grants,
54
+ {
55
+ role,
56
+ permission
57
+ }
58
+ ] : grants.filter((grant)=>!(grant.role === role && grant.permission === permission));
59
+ /** Groups the permissions into runs by their group, in the order first seen, with the ungrouped ones in a run of their own. */ function sectionsOf(permissions) {
60
+ const sections = [];
61
+ for (const permission of permissions){
62
+ const section = sections.find((candidate)=>candidate.group === permission.group);
63
+ if (section) section.permissions.push(permission);
64
+ else sections.push({
65
+ ...permission.group === undefined ? {} : {
66
+ group: permission.group
67
+ },
68
+ permissions: [
69
+ permission
70
+ ]
71
+ });
72
+ }
73
+ return sections;
74
+ }
75
+
76
+ export { isGranted, readGrants, readPermissions, readRoles, sectionsOf, setGrant };
77
+ //# sourceMappingURL=permissionModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissionModel.js","sources":["../../../foundation/permissionModel.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/** A role: a column of the matrix. */\nexport interface MatrixRole {\n id: string;\n label: string;\n}\n\n/** A permission: a row of the matrix, optionally in a named group. */\nexport interface MatrixPermission {\n id: string;\n label: string;\n group?: string;\n}\n\n/** One role holding one permission. */\nexport interface MatrixGrant {\n role: string;\n permission: string;\n}\n\n/** A named run of permissions, for the group heading rows. */\nexport interface MatrixSection {\n group?: string;\n permissions: MatrixPermission[];\n}\n\nconst records = (value: unknown): Record<string, unknown>[] =>\n Array.isArray(value) ? value.filter((entry): entry is Record<string, unknown> => typeof entry === 'object' && entry !== null && !Array.isArray(entry)) : [];\n\n/** Reads roles, dropping those without an id and repeated ids. */\nexport function readRoles(value: unknown): MatrixRole[] {\n const seen = new Set<string>();\n return records(value).flatMap(entry => {\n if (typeof entry.id !== 'string' || entry.id.length === 0 || seen.has(entry.id)) return [];\n seen.add(entry.id);\n return [{ id: entry.id, label: typeof entry.label === 'string' && entry.label.length > 0 ? entry.label : entry.id }];\n });\n}\n\n/** Reads permissions, dropping those without an id and repeated ids. */\nexport function readPermissions(value: unknown): MatrixPermission[] {\n const seen = new Set<string>();\n return records(value).flatMap(entry => {\n if (typeof entry.id !== 'string' || entry.id.length === 0 || seen.has(entry.id)) return [];\n seen.add(entry.id);\n return [{ id: entry.id, label: typeof entry.label === 'string' && entry.label.length > 0 ? entry.label : entry.id, ...(typeof entry.group === 'string' && entry.group.length > 0 ? { group: entry.group } : {}) }];\n });\n}\n\n/** Reads grants, keeping each pair once and only for a role and a permission that exist: a grant of something that was deleted is not shown as held. */\nexport function readGrants(value: unknown, roles: MatrixRole[], permissions: MatrixPermission[]): MatrixGrant[] {\n const roleIds = new Set(roles.map(role => role.id));\n const permissionIds = new Set(permissions.map(permission => permission.id));\n const seen = new Set<string>();\n\n return records(value).flatMap(entry => {\n const { role, permission } = entry;\n if (typeof role !== 'string' || typeof permission !== 'string' || !roleIds.has(role) || !permissionIds.has(permission)) return [];\n const key = `${role}\\u0000${permission}`;\n if (seen.has(key)) return [];\n seen.add(key);\n return [{ role, permission }];\n });\n}\n\n/** Whether a role holds a permission. */\nexport const isGranted = (grants: MatrixGrant[], role: string, permission: string): boolean => grants.some(grant => grant.role === role && grant.permission === permission);\n\n/** Grants a permission to a role, or takes it away, leaving every other grant as it was. */\nexport const setGrant = (grants: MatrixGrant[], role: string, permission: string, granted: boolean): MatrixGrant[] =>\n granted ? (isGranted(grants, role, permission) ? grants : [...grants, { role, permission }]) : grants.filter(grant => !(grant.role === role && grant.permission === permission));\n\n/** Groups the permissions into runs by their group, in the order first seen, with the ungrouped ones in a run of their own. */\nexport function sectionsOf(permissions: MatrixPermission[]): MatrixSection[] {\n const sections: MatrixSection[] = [];\n for (const permission of permissions) {\n const section = sections.find(candidate => candidate.group === permission.group);\n if (section) section.permissions.push(permission);\n else sections.push({ ...(permission.group === undefined ? {} : { group: permission.group }), permissions: [permission] });\n }\n\n return sections;\n}\n"],"names":["records","value","Array","isArray","filter","entry","readRoles","seen","Set","flatMap","id","length","has","add","label","readPermissions","group","readGrants","roles","permissions","roleIds","map","role","permissionIds","permission","key","isGranted","grants","some","grant","setGrant","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IAAI,CAACC,CAAAA,YAAaA,SAAAA,CAAUpB,KAAK,KAAKQ,UAAAA,CAAWR,KAAK,CAAA;AAC/E,QAAA,IAAIkB,OAAAA,EAASA,OAAAA,CAAQf,WAAW,CAACkB,IAAI,CAACb,UAAAA,CAAAA;AACjCS,aAAAA,QAAAA,CAASI,IAAI,CAAC;AAAE,YAAA,GAAIb,UAAAA,CAAWR,KAAK,KAAKsB,SAAAA,GAAY,EAAC,GAAI;AAAEtB,gBAAAA,KAAAA,EAAOQ,WAAWR;aAAO;YAAGG,WAAAA,EAAa;AAACK,gBAAAA;AAAW;AAAC,SAAA,CAAA;AAC3H,IAAA;IAEA,OAAOS,QAAAA;AACX;;"}
package/dist/esm/index.js CHANGED
@@ -81,6 +81,12 @@ export { AvatarStack } from './foundation/AvatarStack.js';
81
81
  export { UploadRefusal, UploadStatus, checkSelection, formatBytes, matchesAccept } from './foundation/uploadModel.js';
82
82
  export { FileUploaderHandlerProvider, useFileUploaderHandler } from './foundation/FileUploaderHandler.js';
83
83
  export { FileUploader } from './foundation/FileUploader.js';
84
+ export { ApprovalState, ChainOutcome, chainOutcome, effectiveSteps, readSteps } from './foundation/approvalModel.js';
85
+ export { ApprovalChainStepper } from './foundation/ApprovalChainStepper.js';
86
+ export { buildOrgTree, descendantCount, expandedToDepth, placements, readOrgNodes, visibleNodes } from './foundation/orgModel.js';
87
+ export { OrgTree } from './foundation/OrgTree.js';
88
+ export { isGranted, readGrants, readPermissions, readRoles, sectionsOf, setGrant } from './foundation/permissionModel.js';
89
+ export { PermissionMatrix } from './foundation/PermissionMatrix.js';
84
90
  export { bindable, foundationDescriptors, list, standardStateProperties } from './foundation/foundationDescriptors.js';
85
91
  export { foundationComponentMetadata } from './foundation/foundationComponentMetadata.js';
86
92
  export { foundationElement, foundationSamples } from './foundation/foundationSamples.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}