@cratis/scene.blueprint.default 4.36.0 → 4.37.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
@@ -0,0 +1,136 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var react = require('react');
5
+ var scene_react = require('@cratis/scene.react');
6
+ var ComponentState = require('./ComponentState.js');
7
+ var FoundationIcon = require('./FoundationIcon.js');
8
+ var foundationStrings = require('./foundationStrings.js');
9
+ var permissionModel = require('./permissionModel.js');
10
+ var PermissionRule = require('./PermissionRule.js');
11
+ var StateFrame = require('./StateFrame.js');
12
+
13
+ /**
14
+ * The `permissionMatrix` component: roles across, permissions down, a checkbox where they meet.
15
+ *
16
+ * `roles` and `permissions` (optionally grouped) give the axes and `grants` - rows of `role` and `permission` - what is held; a grant of a role
17
+ * or permission that does not exist is ignored. Each box is named in words ("Grant Edit deals to Sales") and every header is a real header
18
+ * cell, so a screen reader announces the row and column of the box it is on. Changes are published as the `value` output - the grants,
19
+ * in the same shape - for the screen to save. With `editPermission` not enabled the matrix is read-only and each cell says "Allowed" or
20
+ * "Not allowed" in words and by icon. Wide matrices scroll sideways inside a keyboard-focusable region, keeping the permission column in view.
21
+ */ function PermissionMatrix({ element, interactions, bindingOutputs }) {
22
+ const roles = react.useMemo(()=>permissionModel.readRoles(element.properties.roles), [
23
+ element.properties.roles
24
+ ]);
25
+ const permissions = react.useMemo(()=>permissionModel.readPermissions(element.properties.permissions), [
26
+ element.properties.permissions
27
+ ]);
28
+ const supplied = react.useMemo(()=>permissionModel.readGrants(element.properties.grants, roles, permissions), [
29
+ element.properties.grants,
30
+ roles,
31
+ permissions
32
+ ]);
33
+ const suppliedKey = JSON.stringify(supplied);
34
+ const [grants, setGrants] = react.useState(supplied);
35
+ const strings = foundationStrings.readFoundationStrings(element);
36
+ const state = ComponentState.readComponentState(element, roles.length > 0 && permissions.length > 0);
37
+ const readOnly = PermissionRule.readPermissionRule(element, 'editPermission') !== 'enabled';
38
+ const sections = react.useMemo(()=>permissionModel.sectionsOf(permissions), [
39
+ permissions
40
+ ]);
41
+ react.useEffect(()=>setGrants(supplied), [
42
+ suppliedKey
43
+ ]);
44
+ scene_react.useValueOutput(bindingOutputs, grants);
45
+ return /*#__PURE__*/ jsxRuntime.jsx(StateFrame.FoundationFrame, {
46
+ element: element,
47
+ interactions: interactions,
48
+ name: "permission-matrix",
49
+ state: state,
50
+ skeleton: [
51
+ 100,
52
+ 100,
53
+ 100,
54
+ 100
55
+ ],
56
+ children: (state === ComponentState.ComponentState.Ready || state === ComponentState.ComponentState.Partial) && /*#__PURE__*/ jsxRuntime.jsx("div", {
57
+ className: "foundation-matrix-scroll",
58
+ role: "region",
59
+ tabIndex: 0,
60
+ "aria-label": strings.matrixScroll,
61
+ children: /*#__PURE__*/ jsxRuntime.jsxs("table", {
62
+ className: "foundation-matrix",
63
+ children: [
64
+ /*#__PURE__*/ jsxRuntime.jsx("thead", {
65
+ children: /*#__PURE__*/ jsxRuntime.jsxs("tr", {
66
+ children: [
67
+ /*#__PURE__*/ jsxRuntime.jsx("th", {
68
+ scope: "col",
69
+ children: strings.matrixPermission
70
+ }),
71
+ roles.map((role)=>/*#__PURE__*/ jsxRuntime.jsx("th", {
72
+ scope: "col",
73
+ children: role.label
74
+ }, role.id))
75
+ ]
76
+ })
77
+ }),
78
+ /*#__PURE__*/ jsxRuntime.jsx("tbody", {
79
+ children: sections.map((section, index)=>/*#__PURE__*/ jsxRuntime.jsxs(react.Fragment, {
80
+ children: [
81
+ section.group && /*#__PURE__*/ jsxRuntime.jsx("tr", {
82
+ className: "foundation-matrix-group",
83
+ children: /*#__PURE__*/ jsxRuntime.jsx("th", {
84
+ scope: "colgroup",
85
+ colSpan: roles.length + 1,
86
+ children: section.group
87
+ })
88
+ }),
89
+ section.permissions.map((permission)=>/*#__PURE__*/ jsxRuntime.jsxs("tr", {
90
+ children: [
91
+ /*#__PURE__*/ jsxRuntime.jsx("th", {
92
+ scope: "row",
93
+ children: permission.label
94
+ }),
95
+ roles.map((role)=>{
96
+ const granted = permissionModel.isGranted(grants, role.id, permission.id);
97
+ return /*#__PURE__*/ jsxRuntime.jsx("td", {
98
+ "data-granted": granted,
99
+ children: readOnly ? /*#__PURE__*/ jsxRuntime.jsxs("span", {
100
+ className: "foundation-matrix-state",
101
+ children: [
102
+ /*#__PURE__*/ jsxRuntime.jsx(FoundationIcon.FoundationIcon, {
103
+ name: granted ? 'check' : 'minus'
104
+ }),
105
+ /*#__PURE__*/ jsxRuntime.jsx("span", {
106
+ className: "foundation-visually-hidden",
107
+ children: granted ? strings.matrixAllowed : strings.matrixDenied
108
+ })
109
+ ]
110
+ }) : /*#__PURE__*/ jsxRuntime.jsx("input", {
111
+ type: "checkbox",
112
+ checked: granted,
113
+ "aria-label": foundationStrings.formatText(strings.matrixGrant, {
114
+ permission: permission.label,
115
+ role: role.label
116
+ }),
117
+ onChange: (event)=>{
118
+ setGrants(permissionModel.setGrant(grants, role.id, permission.id, event.target.checked));
119
+ interactions?.onChange?.();
120
+ }
121
+ })
122
+ }, role.id);
123
+ })
124
+ ]
125
+ }, permission.id))
126
+ ]
127
+ }, section.group ?? `ungrouped-${index}`))
128
+ })
129
+ ]
130
+ })
131
+ })
132
+ });
133
+ }
134
+
135
+ exports.PermissionMatrix = PermissionMatrix;
136
+ //# sourceMappingURL=PermissionMatrix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PermissionMatrix.js","sources":["../../../foundation/PermissionMatrix.tsx"],"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 { Fragment, useEffect, useMemo, useState } from 'react';\nimport { RegisteredComponentProps, useValueOutput } from '@cratis/scene.react';\nimport { ComponentState, readComponentState } from './ComponentState';\nimport { FoundationIcon } from './FoundationIcon';\nimport { formatText, readFoundationStrings } from './foundationStrings';\nimport { isGranted, MatrixGrant, readGrants, readPermissions, readRoles, sectionsOf, setGrant } from './permissionModel';\nimport { readPermissionRule } from './PermissionRule';\nimport { FoundationFrame } from './StateFrame';\n\n/**\n * The `permissionMatrix` component: roles across, permissions down, a checkbox where they meet.\n *\n * `roles` and `permissions` (optionally grouped) give the axes and `grants` - rows of `role` and `permission` - what is held; a grant of a role\n * or permission that does not exist is ignored. Each box is named in words (\"Grant Edit deals to Sales\") and every header is a real header\n * cell, so a screen reader announces the row and column of the box it is on. Changes are published as the `value` output - the grants,\n * in the same shape - for the screen to save. With `editPermission` not enabled the matrix is read-only and each cell says \"Allowed\" or\n * \"Not allowed\" in words and by icon. Wide matrices scroll sideways inside a keyboard-focusable region, keeping the permission column in view.\n */\nexport function PermissionMatrix({ element, interactions, bindingOutputs }: RegisteredComponentProps) {\n const roles = useMemo(() => readRoles(element.properties.roles), [element.properties.roles]);\n const permissions = useMemo(() => readPermissions(element.properties.permissions), [element.properties.permissions]);\n const supplied = useMemo(() => readGrants(element.properties.grants, roles, permissions), [element.properties.grants, roles, permissions]);\n const suppliedKey = JSON.stringify(supplied);\n const [grants, setGrants] = useState<MatrixGrant[]>(supplied);\n const strings = readFoundationStrings(element);\n const state = readComponentState(element, roles.length > 0 && permissions.length > 0);\n const readOnly = readPermissionRule(element, 'editPermission') !== 'enabled';\n const sections = useMemo(() => sectionsOf(permissions), [permissions]);\n\n useEffect(() => setGrants(supplied), [suppliedKey]);\n useValueOutput(bindingOutputs, grants);\n\n return (\n <FoundationFrame element={element} interactions={interactions} name='permission-matrix' state={state} skeleton={[100, 100, 100, 100]}>\n {(state === ComponentState.Ready || state === ComponentState.Partial) && (\n <div className='foundation-matrix-scroll' role='region' tabIndex={0} aria-label={strings.matrixScroll}>\n <table className='foundation-matrix'>\n <thead>\n <tr>\n <th scope='col'>{strings.matrixPermission}</th>\n {roles.map(role => <th key={role.id} scope='col'>{role.label}</th>)}\n </tr>\n </thead>\n <tbody>\n {sections.map((section, index) => (\n <Fragment key={section.group ?? `ungrouped-${index}`}>\n {section.group && (\n <tr className='foundation-matrix-group'><th scope='colgroup' colSpan={roles.length + 1}>{section.group}</th></tr>\n )}\n {section.permissions.map(permission => (\n <tr key={permission.id}>\n <th scope='row'>{permission.label}</th>\n {roles.map(role => {\n const granted = isGranted(grants, role.id, permission.id);\n return (\n <td key={role.id} data-granted={granted}>\n {readOnly ? (\n <span className='foundation-matrix-state'>\n <FoundationIcon name={granted ? 'check' : 'minus'} />\n <span className='foundation-visually-hidden'>{granted ? strings.matrixAllowed : strings.matrixDenied}</span>\n </span>\n ) : (\n <input type='checkbox' checked={granted} aria-label={formatText(strings.matrixGrant, { permission: permission.label, role: role.label })}\n onChange={event => { setGrants(setGrant(grants, role.id, permission.id, event.target.checked)); interactions?.onChange?.(); }} />\n )}\n </td>\n );\n })}\n </tr>\n ))}\n </Fragment>\n ))}\n </tbody>\n </table>\n </div>\n )}\n </FoundationFrame>\n );\n}\n"],"names":["PermissionMatrix","element","interactions","bindingOutputs","roles","useMemo","readRoles","properties","permissions","readPermissions","supplied","readGrants","grants","suppliedKey","JSON","stringify","setGrants","useState","strings","readFoundationStrings","state","readComponentState","length","readOnly","readPermissionRule","sections","sectionsOf","useEffect","useValueOutput","_jsx","FoundationFrame","name","skeleton","ComponentState","Ready","Partial","div","className","role","tabIndex","aria-label","matrixScroll","_jsxs","table","thead","tr","th","scope","matrixPermission","map","label","id","tbody","section","index","Fragment","group","colSpan","permission","granted","isGranted","td","data-granted","span","FoundationIcon","matrixAllowed","matrixDenied","input","type","checked","formatText","matrixGrant","onChange","event","setGrant","target"],"mappings":";;;;;;;;;;;;AAYA;;;;;;;;IASO,SAASA,gBAAAA,CAAiB,EAAEC,OAAO,EAAEC,YAAY,EAAEC,cAAc,EAA4B,EAAA;IAChG,MAAMC,KAAAA,GAAQC,cAAQ,IAAMC,yBAAAA,CAAUL,QAAQM,UAAU,CAACH,KAAK,CAAA,EAAG;QA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,CAAAA,KAAAA,GAAAA;gEAAWzD,SAAAA,CAAU0D,wBAAAA,CAAS9D,MAAAA,EAAQ0B,IAAAA,CAAKa,EAAE,EAAEO,UAAAA,CAAWP,EAAE,EAAEsB,KAAAA,CAAME,MAAM,CAACN,OAAO,CAAA,CAAA;gEAAInE,YAAAA,EAAcsE,QAAAA,IAAAA;AAAc,4DAAA;;AAR/HlC,qDAAAA,EAAAA,IAAAA,CAAKa,EAAE,CAAA;AAYxB,gDAAA,CAAA;;AAjBKO,yCAAAA,EAAAA,UAAAA,CAAWP,EAAE,CAAA;;AALfE,6BAAAA,EAAAA,OAAAA,CAAQG,KAAK,IAAI,CAAC,UAAU,EAAEF,KAAAA,CAAAA,CAAO,CAAA;;;;;;AAiCpF;;"}
@@ -0,0 +1,87 @@
1
+ 'use strict';
2
+
3
+ // Copyright (c) Cratis. All rights reserved.
4
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
5
+ /** Where one step of an approval chain stands. */ var ApprovalState = /*#__PURE__*/ function(ApprovalState) {
6
+ ApprovalState["Pending"] = "pending";
7
+ ApprovalState["Current"] = "current";
8
+ ApprovalState["Approved"] = "approved";
9
+ ApprovalState["Rejected"] = "rejected";
10
+ ApprovalState["Skipped"] = "skipped";
11
+ return ApprovalState;
12
+ }({});
13
+ /** How the chain as a whole stands. */ var ChainOutcome = /*#__PURE__*/ function(ChainOutcome) {
14
+ /** Every step approved. */ ChainOutcome["Approved"] = "approved";
15
+ /** A step rejected: the chain stops there. */ ChainOutcome["Rejected"] = "rejected";
16
+ /** At least one step is decided and the rest are waiting. */ ChainOutcome["InProgress"] = "inProgress";
17
+ /** Nothing decided yet. */ ChainOutcome["Pending"] = "pending";
18
+ return ChainOutcome;
19
+ }({});
20
+ /** Reads steps out of a property value, dropping entries without a label; an unknown state is pending. */ function readSteps(value) {
21
+ if (!Array.isArray(value)) return [];
22
+ return value.flatMap((entry)=>{
23
+ if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) return [];
24
+ const { label, approver, state, at, comment } = entry;
25
+ if (typeof label !== 'string' || label.length === 0) return [];
26
+ return [
27
+ {
28
+ label,
29
+ state: Object.values(ApprovalState).includes(state) ? state : "pending",
30
+ ...typeof approver === 'string' ? {
31
+ approver
32
+ } : {},
33
+ ...typeof at === 'string' ? {
34
+ at
35
+ } : {},
36
+ ...typeof comment === 'string' && comment.length > 0 ? {
37
+ comment
38
+ } : {}
39
+ }
40
+ ];
41
+ });
42
+ }
43
+ /**
44
+ * Applies the chain's rules to the steps as written.
45
+ *
46
+ * A rejection stops the chain: every step after the first rejected one has not been reached, so it is drawn skipped however it was written.
47
+ * With no step marked current and no rejection, the first step that is not yet decided is the current one - the person the chain is waiting
48
+ * for - so a chain written only as approved and pending steps still says whose turn it is. Only one step is ever current.
49
+ */ function effectiveSteps(steps) {
50
+ const rejected = steps.findIndex((step)=>step.state === "rejected");
51
+ const explicitCurrent = steps.findIndex((step)=>step.state === "current");
52
+ const waiting = rejected >= 0 ? -1 : explicitCurrent >= 0 ? explicitCurrent : steps.findIndex((step)=>step.state === "pending");
53
+ return steps.map((step, index)=>{
54
+ if (rejected >= 0 && index > rejected) return {
55
+ ...step,
56
+ state: "skipped",
57
+ notReached: true
58
+ };
59
+ if (step.state === "current" && index !== waiting) return {
60
+ ...step,
61
+ state: "pending",
62
+ notReached: false
63
+ };
64
+ if (index === waiting && step.state === "pending") return {
65
+ ...step,
66
+ state: "current",
67
+ notReached: false
68
+ };
69
+ return {
70
+ ...step,
71
+ notReached: false
72
+ };
73
+ });
74
+ }
75
+ /** The state of the chain as a whole. A skipped step counts as decided, because it was never going to be asked. */ function chainOutcome(steps) {
76
+ const effective = effectiveSteps(steps);
77
+ if (effective.some((step)=>step.state === "rejected")) return "rejected";
78
+ if (effective.length > 0 && effective.every((step)=>step.state === "approved" || step.state === "skipped")) return "approved";
79
+ return effective.some((step)=>step.state === "approved") ? "inProgress" : "pending";
80
+ }
81
+
82
+ exports.ApprovalState = ApprovalState;
83
+ exports.ChainOutcome = ChainOutcome;
84
+ exports.chainOutcome = chainOutcome;
85
+ exports.effectiveSteps = effectiveSteps;
86
+ exports.readSteps = readSteps;
87
+ //# sourceMappingURL=approvalModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approvalModel.js","sources":["../../../foundation/approvalModel.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/** Where one step of an approval chain stands. */\nexport enum ApprovalState {\n Pending = 'pending',\n Current = 'current',\n Approved = 'approved',\n Rejected = 'rejected',\n Skipped = 'skipped',\n}\n\n/** One step of an approval chain: who decides, and what they decided. */\nexport interface ApprovalStep {\n label: string;\n approver?: string;\n state: ApprovalState;\n at?: string;\n comment?: string;\n}\n\n/** A step as it is drawn, after the chain's own rules are applied. */\nexport interface EffectiveStep extends ApprovalStep {\n /** True when an earlier rejection stopped the chain before this step was reached. */\n notReached: boolean;\n}\n\n/** How the chain as a whole stands. */\nexport enum ChainOutcome {\n /** Every step approved. */\n Approved = 'approved',\n\n /** A step rejected: the chain stops there. */\n Rejected = 'rejected',\n\n /** At least one step is decided and the rest are waiting. */\n InProgress = 'inProgress',\n\n /** Nothing decided yet. */\n Pending = 'pending',\n}\n\n/** Reads steps out of a property value, dropping entries without a label; an unknown state is pending. */\nexport function readSteps(value: unknown): ApprovalStep[] {\n if (!Array.isArray(value)) return [];\n\n return value.flatMap((entry): ApprovalStep[] => {\n if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) return [];\n const { label, approver, state, at, comment } = entry as Record<string, unknown>;\n if (typeof label !== 'string' || label.length === 0) return [];\n\n return [{\n label,\n state: (Object.values(ApprovalState) as string[]).includes(state as string) ? (state as ApprovalState) : ApprovalState.Pending,\n ...(typeof approver === 'string' ? { approver } : {}),\n ...(typeof at === 'string' ? { at } : {}),\n ...(typeof comment === 'string' && comment.length > 0 ? { comment } : {}),\n }];\n });\n}\n\n/**\n * Applies the chain's rules to the steps as written.\n *\n * A rejection stops the chain: every step after the first rejected one has not been reached, so it is drawn skipped however it was written.\n * With no step marked current and no rejection, the first step that is not yet decided is the current one - the person the chain is waiting\n * for - so a chain written only as approved and pending steps still says whose turn it is. Only one step is ever current.\n */\nexport function effectiveSteps(steps: ApprovalStep[]): EffectiveStep[] {\n const rejected = steps.findIndex(step => step.state === ApprovalState.Rejected);\n const explicitCurrent = steps.findIndex(step => step.state === ApprovalState.Current);\n const waiting = rejected >= 0 ? -1 : explicitCurrent >= 0 ? explicitCurrent : steps.findIndex(step => step.state === ApprovalState.Pending);\n\n return steps.map((step, index) => {\n if (rejected >= 0 && index > rejected) return { ...step, state: ApprovalState.Skipped, notReached: true };\n if (step.state === ApprovalState.Current && index !== waiting) return { ...step, state: ApprovalState.Pending, notReached: false };\n if (index === waiting && step.state === ApprovalState.Pending) return { ...step, state: ApprovalState.Current, notReached: false };\n return { ...step, notReached: false };\n });\n}\n\n/** The state of the chain as a whole. A skipped step counts as decided, because it was never going to be asked. */\nexport function chainOutcome(steps: ApprovalStep[]): ChainOutcome {\n const effective = effectiveSteps(steps);\n if (effective.some(step => step.state === ApprovalState.Rejected)) return ChainOutcome.Rejected;\n if (effective.length > 0 && effective.every(step => step.state === ApprovalState.Approved || step.state === ApprovalState.Skipped)) return ChainOutcome.Approved;\n return effective.some(step => step.state === ApprovalState.Approved) ? ChainOutcome.InProgress : ChainOutcome.Pending;\n}\n"],"names":["ApprovalState","ChainOutcome","readSteps","value","Array","isArray","flatMap","entry","label","approver","state","at","comment","length","Object","values","includes","effectiveSteps","steps","rejected","findIndex","step","explicitCurrent","waiting","map","index","notReached","chainOutcome","effective","some","every"],"mappings":";;AAAA;AACA;AAEA,mDACO,IAAKA,aAAAA,iBAAAA,SAAAA,aAAAA,EAAAA;;;;;;AAAAA,IAAAA,OAAAA,aAAAA;AAMX,CAAA,CAAA,EAAA;AAiBD,wCACO,IAAKC,YAAAA,iBAAAA,SAAAA,YAAAA,EAAAA;gCACiB,YAAA,CAAA,UAA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CAAAA;AACjC,IAAA,IAAIU,UAAUC,IAAI,CAACR,CAAAA,IAAAA,GAAQA,IAAAA,CAAKX,KAAK,KAAA,UAAA,CAAA,EAA8B,OAAA,UAAA;AACnE,IAAA,IAAIkB,SAAAA,CAAUf,MAAM,GAAG,CAAA,IAAKe,UAAUE,KAAK,CAACT,CAAAA,IAAAA,GAAQA,IAAAA,CAAKX,KAAK,KAAA,UAAA,IAA+BW,IAAAA,CAAKX,KAAK,KAAA,SAAA,CAAA,EAA6B,OAAA,UAAA;AACpI,IAAA,OAAOkB,UAAUC,IAAI,CAACR,CAAAA,IAAAA,GAAQA,KAAKX,KAAK,KAAA,UAAA,CAAA,GAAA,YAAA,GAAA,SAAA;AAC5C;;;;;;"}
@@ -88,6 +88,27 @@ var ComponentName = require('../ComponentName.js');
88
88
  'files',
89
89
  'drop zone',
90
90
  'documents'
91
+ ]),
92
+ [ComponentName.ComponentName.ApprovalChainStepper]: scene_react.componentMetadata('Approval chain', scene_model.ComponentCategory.Navigation, 'workflow', [
93
+ 'approvals',
94
+ 'steps',
95
+ 'workflow',
96
+ 'sign off',
97
+ 'stepper'
98
+ ]),
99
+ [ComponentName.ComponentName.OrgTree]: scene_react.componentMetadata('Org tree', scene_model.ComponentCategory.DataDisplay, 'network', [
100
+ 'organization',
101
+ 'hierarchy',
102
+ 'org chart',
103
+ 'reports to',
104
+ 'tree'
105
+ ]),
106
+ [ComponentName.ComponentName.PermissionMatrix]: scene_react.componentMetadata('Permission matrix', scene_model.ComponentCategory.Input, 'shield-check', [
107
+ 'roles',
108
+ 'permissions',
109
+ 'access',
110
+ 'grants',
111
+ 'rbac'
91
112
  ])
92
113
  };
93
114
 
@@ -1 +1 @@
1
- {"version":3,"file":"foundationComponentMetadata.js","sources":["../../../foundation/foundationComponentMetadata.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 { ComponentCategory } from '@cratis/scene.model';\nimport { ComponentMetadata, componentMetadata as m } from '@cratis/scene.react';\nimport { ComponentName } from '../ComponentName';\n\n/**\n * The category, icon, keywords and picker badge of every foundation component (CMP1), keyed by bare component name.\n * The names are those of `ComponentName`; the metadata of the rest of the package lives in `defaultBlueprintComponentMetadata`.\n */\nexport const foundationComponentMetadata: Record<string, ComponentMetadata> = {\n [ComponentName.EmptyState]: m('Empty state', ComponentCategory.Feedback, 'inbox', ['no data', 'nothing', 'blank slate', 'zero state']),\n [ComponentName.StatCard]: m('Stat card', ComponentCategory.DataDisplay, 'gauge', ['kpi', 'metric', 'figure', 'number', 'dashboard']),\n [ComponentName.TrendChip]: m('Trend chip', ComponentCategory.DataDisplay, 'trending-up', ['delta', 'change', 'arrow', 'comparison']),\n [ComponentName.StatusChip]: m('Status chip', ComponentCategory.DataDisplay, 'badge-check', ['badge', 'state', 'tag', 'label']),\n [ComponentName.ChartWrapper]: m('Chart', ComponentCategory.DataDisplay, 'chart-line', ['graph', 'line', 'bar', 'stacked', 'donut', 'pie', 'funnel', 'plot']),\n [ComponentName.FilterBuilder]: m('Filter builder', ComponentCategory.Input, 'list-filter', ['filter', 'query', 'conditions', 'and or', 'search']),\n [ComponentName.ColumnChooser]: m('Column chooser', ComponentCategory.Actions, 'columns-3', ['columns', 'fields', 'show hide', 'table']),\n [ComponentName.SavedViewsMenu]: m('Saved views menu', ComponentCategory.Actions, 'bookmark', ['views', 'presets', 'saved filters']),\n [ComponentName.ChecklistSection]: m('Checklist', ComponentCategory.DataDisplay, 'list-checks', ['tasks', 'todo', 'onboarding', 'progress', 'steps']),\n [ComponentName.ActivityFeed]: m('Activity feed', ComponentCategory.DataDisplay, 'activity', ['timeline', 'history', 'comments', 'audit', 'log']),\n [ComponentName.AvatarStack]: m('Avatar stack', ComponentCategory.DataDisplay, 'users', ['people', 'members', 'assignees', 'team']),\n [ComponentName.FileUploader]: m('File uploader', ComponentCategory.Input, 'upload', ['attachments', 'files', 'drop zone', 'documents']),\n};\n"],"names":["foundationComponentMetadata","ComponentName","EmptyState","m","ComponentCategory","Feedback","StatCard","DataDisplay","TrendChip","StatusChip","ChartWrapper","FilterBuilder","Input","ColumnChooser","Actions","SavedViewsMenu","ChecklistSection","ActivityFeed","AvatarStack","FileUploader"],"mappings":";;;;;;AAAA;AACA;AAMA;;;UAIaA,2BAAAA,GAAiE;IAC1E,CAACC,2BAAAA,CAAcC,UAAU,GAAGC,8BAAE,aAAA,EAAeC,6BAAAA,CAAkBC,QAAQ,EAAE,OAAA,EAAS;AAAC,QAAA,SAAA;AAAW,QAAA,SAAA;AAAW,QAAA,aAAA;AAAe,QAAA;AAAa,KAAA,CAAA;IACrI,CAACJ,2BAAAA,CAAcK,QAAQ,GAAGH,8BAAE,WAAA,EAAaC,6BAAAA,CAAkBG,WAAW,EAAE,OAAA,EAAS;AAAC,QAAA,KAAA;AAAO,QAAA,QAAA;AAAU,QAAA,QAAA;AAAU,QAAA,QAAA;AAAU,QAAA;AAAY,KAAA,CAAA;IACnI,CAACN,2BAAAA,CAAcO,SAAS,GAAGL,8BAAE,YAAA,EAAcC,6BAAAA,CAAkBG,WAAW,EAAE,aAAA,EAAe;AAAC,QAAA,OAAA;AAAS,QAAA,QAAA;AAAU,QAAA,OAAA;AAAS,QAAA;AAAa,KAAA,CAAA;IACnI,CAACN,2BAAAA,CAAcQ,UAAU,GAAGN,8BAAE,aAAA,EAAeC,6BAAAA,CAAkBG,WAAW,EAAE,aAAA,EAAe;AAAC,QAAA,OAAA;AAAS,QAAA,OAAA;AAAS,QAAA,KAAA;AAAO,QAAA;AAAQ,KAAA,CAAA;IAC7H,CAACN,2BAAAA,CAAcS,YAAY,GAAGP,8BAAE,OAAA,EAASC,6BAAAA,CAAkBG,WAAW,EAAE,YAAA,EAAc;AAAC,QAAA,OAAA;AAAS,QAAA,MAAA;AAAQ,QAAA,KAAA;AAAO,QAAA,SAAA;AAAW,QAAA,OAAA;AAAS,QAAA,KAAA;AAAO,QAAA,QAAA;AAAU,QAAA;AAAO,KAAA,CAAA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AA,EAAiBC,6BAAAA,CAAkBQ,KAAK,EAAE,QAAA,EAAU;AAAC,QAAA,aAAA;AAAe,QAAA,OAAA;AAAS,QAAA,WAAA;AAAa,QAAA;AAAY,KAAA;AAC1I;;"}
1
+ {"version":3,"file":"foundationComponentMetadata.js","sources":["../../../foundation/foundationComponentMetadata.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 { ComponentCategory } from '@cratis/scene.model';\nimport { ComponentMetadata, componentMetadata as m } from '@cratis/scene.react';\nimport { ComponentName } from '../ComponentName';\n\n/**\n * The category, icon, keywords and picker badge of every foundation component (CMP1), keyed by bare component name.\n * The names are those of `ComponentName`; the metadata of the rest of the package lives in `defaultBlueprintComponentMetadata`.\n */\nexport const foundationComponentMetadata: Record<string, ComponentMetadata> = {\n [ComponentName.EmptyState]: m('Empty state', ComponentCategory.Feedback, 'inbox', ['no data', 'nothing', 'blank slate', 'zero state']),\n [ComponentName.StatCard]: m('Stat card', ComponentCategory.DataDisplay, 'gauge', ['kpi', 'metric', 'figure', 'number', 'dashboard']),\n [ComponentName.TrendChip]: m('Trend chip', ComponentCategory.DataDisplay, 'trending-up', ['delta', 'change', 'arrow', 'comparison']),\n [ComponentName.StatusChip]: m('Status chip', ComponentCategory.DataDisplay, 'badge-check', ['badge', 'state', 'tag', 'label']),\n [ComponentName.ChartWrapper]: m('Chart', ComponentCategory.DataDisplay, 'chart-line', ['graph', 'line', 'bar', 'stacked', 'donut', 'pie', 'funnel', 'plot']),\n [ComponentName.FilterBuilder]: m('Filter builder', ComponentCategory.Input, 'list-filter', ['filter', 'query', 'conditions', 'and or', 'search']),\n [ComponentName.ColumnChooser]: m('Column chooser', ComponentCategory.Actions, 'columns-3', ['columns', 'fields', 'show hide', 'table']),\n [ComponentName.SavedViewsMenu]: m('Saved views menu', ComponentCategory.Actions, 'bookmark', ['views', 'presets', 'saved filters']),\n [ComponentName.ChecklistSection]: m('Checklist', ComponentCategory.DataDisplay, 'list-checks', ['tasks', 'todo', 'onboarding', 'progress', 'steps']),\n [ComponentName.ActivityFeed]: m('Activity feed', ComponentCategory.DataDisplay, 'activity', ['timeline', 'history', 'comments', 'audit', 'log']),\n [ComponentName.AvatarStack]: m('Avatar stack', ComponentCategory.DataDisplay, 'users', ['people', 'members', 'assignees', 'team']),\n [ComponentName.FileUploader]: m('File uploader', ComponentCategory.Input, 'upload', ['attachments', 'files', 'drop zone', 'documents']),\n [ComponentName.ApprovalChainStepper]: m('Approval chain', ComponentCategory.Navigation, 'workflow', ['approvals', 'steps', 'workflow', 'sign off', 'stepper']),\n [ComponentName.OrgTree]: m('Org tree', ComponentCategory.DataDisplay, 'network', ['organization', 'hierarchy', 'org chart', 'reports to', 'tree']),\n [ComponentName.PermissionMatrix]: m('Permission matrix', ComponentCategory.Input, 'shield-check', ['roles', 'permissions', 'access', 'grants', 'rbac']),\n};\n"],"names":["foundationComponentMetadata","ComponentName","EmptyState","m","ComponentCategory","Feedback","StatCard","DataDisplay","TrendChip","StatusChip","ChartWrapper","FilterBuilder","Input","ColumnChooser","Actions","SavedViewsMenu","ChecklistSection","ActivityFeed","AvatarStack","FileUploader","ApprovalChainStepper","Navigation","OrgTree","PermissionMatrix"],"mappings":";;;;;;AAAA;AACA;AAMA;;;UAIaA,2BAAAA,GAAiE;IAC1E,CAACC,2BAAAA,CAAcC,UAAU,GAAGC,8BAAE,aAAA,EAAeC,6BAAAA,CAAkBC,QAAQ,EAAE,OAAA,EAAS;AAAC,QAAA,SAAA;AAAW,QAAA,SAAA;AAAW,QAAA,aAAA;AAAe,QAAA;AAAa,KAAA,CAAA;IACrI,CAACJ,2BAAAA,CAAcK,QAAQ,GAAGH,8BAAE,WAAA,EAAaC,6BAAAA,CAAkBG,WAAW,EAAE,OAAA,EAAS;AAAC,QAAA,KAAA;AAAO,QAAA,QAAA;AAAU,QAAA,QAAA;AAAU,QAAA,QAAA;AAAU,QAAA;AAAY,KAAA,CAAA;IAC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GAAGpB,8BAAE,mBAAA,EAAqBC,6BAAAA,CAAkBQ,KAAK,EAAE,cAAA,EAAgB;AAAC,QAAA,OAAA;AAAS,QAAA,aAAA;AAAe,QAAA,QAAA;AAAU,QAAA,QAAA;AAAU,QAAA;AAAO,KAAA;AAC1J;;"}
@@ -5,6 +5,7 @@ var scene_react = require('@cratis/scene.react');
5
5
  var ComponentName = require('../ComponentName.js');
6
6
  var packageName = require('../packageName.js');
7
7
  var activityModel = require('./activityModel.js');
8
+ var approvalModel = require('./approvalModel.js');
8
9
  var chartGeometry = require('./chartGeometry.js');
9
10
  var ComponentState = require('./ComponentState.js');
10
11
  var filterModel = require('./filterModel.js');
@@ -503,6 +504,123 @@ const formats = {
503
504
  scene_react.valueOutputProperty(scene_model.PropertyValueType.Json, 'The files chosen - name, size, type and status - published as they change.'),
504
505
  ...standardStateProperties.filter((property)=>property.path !== 'actionPermission')
505
506
  ]
507
+ },
508
+ {
509
+ component: key(ComponentName.ComponentName.ApprovalChainStepper),
510
+ displayName: 'Approval chain',
511
+ description: 'The steps a request goes through, who decides each and where it stands. A rejection stops the chain; the first undecided step is the current one.',
512
+ properties: [
513
+ {
514
+ ...list('steps', 'Steps', 'Data', 'Step', [
515
+ text('label', 'Step', 'Content', undefined, {
516
+ constraints: {
517
+ required: true
518
+ }
519
+ }),
520
+ text('approver', 'Approver', 'Data'),
521
+ choice('state', 'State', 'Data', {
522
+ [approvalModel.ApprovalState.Pending]: 'Pending',
523
+ [approvalModel.ApprovalState.Current]: 'Awaiting decision',
524
+ [approvalModel.ApprovalState.Approved]: 'Approved',
525
+ [approvalModel.ApprovalState.Rejected]: 'Rejected',
526
+ [approvalModel.ApprovalState.Skipped]: 'Skipped'
527
+ }, approvalModel.ApprovalState.Pending),
528
+ text('at', 'Decided at', 'Data', 'An ISO 8601 date and time.'),
529
+ text('comment', 'Comment', 'Data')
530
+ ], 'The approvers in order.'),
531
+ acceptedBindingKinds: bindable
532
+ },
533
+ choice('orientation', 'Orientation', 'Appearance', {
534
+ horizontal: 'Horizontal',
535
+ vertical: 'Vertical'
536
+ }, 'horizontal', 'A phone always reads vertically.'),
537
+ ...standardStateProperties
538
+ ]
539
+ },
540
+ {
541
+ component: key(ComponentName.ComponentName.OrgTree),
542
+ displayName: 'Org tree',
543
+ description: 'An organization as an expandable tree built from rows of who reports to whom. Publishes the selected id as the value output.',
544
+ properties: [
545
+ {
546
+ ...list('nodes', 'People', 'Data', 'Person', [
547
+ text('id', 'Id', 'Data', undefined, {
548
+ constraints: {
549
+ required: true
550
+ },
551
+ editorKind: scene_model.PropertyEditorKind.Field
552
+ }),
553
+ text('label', 'Name', 'Data', undefined, {
554
+ editorKind: scene_model.PropertyEditorKind.Field
555
+ }),
556
+ text('title', 'Title', 'Data', undefined, {
557
+ editorKind: scene_model.PropertyEditorKind.Field
558
+ }),
559
+ text('parentId', 'Reports to', 'Data', 'The id of the person above; empty for the top.', {
560
+ editorKind: scene_model.PropertyEditorKind.Field
561
+ })
562
+ ], 'One row per person or unit.'),
563
+ acceptedBindingKinds: bindable
564
+ },
565
+ number('expandedDepth', 'Levels open at first', 'Appearance', undefined, {
566
+ default: 2,
567
+ constraints: {
568
+ minimum: 1,
569
+ integer: true
570
+ }
571
+ }),
572
+ text('selected', 'Selected', 'Data', 'The id of the selected node; bind it to start from one.'),
573
+ scene_react.valueOutputProperty(scene_model.PropertyValueType.String, 'The id of the selected node, published as the user selects.'),
574
+ ...standardStateProperties
575
+ ]
576
+ },
577
+ {
578
+ component: key(ComponentName.ComponentName.PermissionMatrix),
579
+ displayName: 'Permission matrix',
580
+ description: 'Roles across, permissions down, a checkbox where they meet. Publishes the grants as the value output.',
581
+ properties: [
582
+ {
583
+ ...list('roles', 'Roles', 'Data', 'Role', [
584
+ text('id', 'Id', 'Data', undefined, {
585
+ constraints: {
586
+ required: true
587
+ }
588
+ }),
589
+ text('label', 'Name', 'Data')
590
+ ], 'The columns.'),
591
+ acceptedBindingKinds: bindable
592
+ },
593
+ {
594
+ ...list('permissions', 'Permissions', 'Data', 'Permission', [
595
+ text('id', 'Id', 'Data', undefined, {
596
+ constraints: {
597
+ required: true
598
+ }
599
+ }),
600
+ text('label', 'Name', 'Data'),
601
+ text('group', 'Group', 'Data', 'A heading the permission is listed under.')
602
+ ], 'The rows.'),
603
+ acceptedBindingKinds: bindable
604
+ },
605
+ {
606
+ ...list('grants', 'Grants', 'Data', 'Grant', [
607
+ text('role', 'Role', 'Data', 'The id of a role.', {
608
+ constraints: {
609
+ required: true
610
+ }
611
+ }),
612
+ text('permission', 'Permission', 'Data', 'The id of a permission.', {
613
+ constraints: {
614
+ required: true
615
+ }
616
+ })
617
+ ], 'What each role holds.'),
618
+ acceptedBindingKinds: bindable
619
+ },
620
+ rule('editPermission', 'Edit permission', 'Enabled lets the user change grants; otherwise the matrix is read-only.'),
621
+ scene_react.valueOutputProperty(scene_model.PropertyValueType.Json, 'The grants as the user has changed them: rows of role and permission, published as they change.'),
622
+ ...standardStateProperties
623
+ ]
506
624
  }
507
625
  ];
508
626