@elaraai/east-codex-plugin 1.0.105 → 1.0.107

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "version": 2,
3
3
  "stats": {
4
- "totalEntries": 1314,
5
- "totalFiles": 221,
4
+ "totalEntries": 1347,
5
+ "totalFiles": 222,
6
6
  "packages": {
7
- "east": 584,
7
+ "east": 587,
8
8
  "east-node-std": 55,
9
9
  "east-node-io": 63,
10
10
  "east-py-datascience": 94,
11
11
  "east-ui": 308,
12
- "e3-ui": 172,
12
+ "e3-ui": 202,
13
13
  "e3": 24,
14
14
  "e3-ui-cli": 8,
15
15
  "e3-create": 6
@@ -5172,6 +5172,80 @@
5172
5172
  "FloatMultiply"
5173
5173
  ]
5174
5174
  },
5175
+ {
5176
+ "id": "east:crosslang.examples.ts:crosslangIntegerNamedCases",
5177
+ "skill": "east",
5178
+ "package": "east",
5179
+ "file": "east/test/crosslang.examples.ts",
5180
+ "suite": "",
5181
+ "test": "A match over a variant whose case names look like integers: its cases and its arms in the order their names sort",
5182
+ "keywords": [
5183
+ "cross-language",
5184
+ "python",
5185
+ "variant",
5186
+ "match",
5187
+ "case order",
5188
+ "integer-like names"
5189
+ ],
5190
+ "imports": [
5191
+ "import {"
5192
+ ],
5193
+ "languages": [
5194
+ "typescript",
5195
+ "python"
5196
+ ],
5197
+ "ir": "{\"type\":\"Function\",\"value\":{\"type\":{\"type\":\"Function\",\"value\":{\"inputs\":[{\"type\":\"Variant\",\"value\":[{\"name\":\"100\",\"type\":{\"type\":\"Null\",\"value\":null}},{\"name\":\"50\",\"type\":{\"type\":\"Null\",\"value\":null}},{\"name\":\"a\",\"type\":{\"type\":\"Integer\",\"value\":null}}]}],\"output\":{\"type\":\"Integer\",\"value\":null}}},\"loc_id\":\"0\",\"captures\":[],\"parameters\":[{\"type\":\"Variable\",\"value\":{\"type\":{\"type\":\"Variant\",\"value\":{\"$ref\":\"5#type/Function/inputs/0/Variant\"}},\"loc_id\":\"0\",\"name\":\"s\",\"mutable\":false,\"captured\":false}}],\"body\":{\"type\":\"Match\",\"value\":{\"type\":{\"type\":\"Integer\",\"value\":null},\"loc_id\":\"0\",\"variant\":{\"type\":\"Variable\",\"value\":{\"type\":{\"type\":\"Variant\",\"value\":{\"$ref\":\"6#type/Function/inputs/0/Variant\"}},\"loc_id\":\"0\",\"name\":\"s\",\"mutable\":false,\"captured\":false}},\"cases\":[{\"case\":\"100\",\"variable\":{\"type\":\"Variable\",\"value\":{\"type\":{\"type\":\"Null\",\"value\":null},\"loc_id\":\"0\",\"name\":\"_v\",\"mutable\":false,\"captured\":false}},\"body\":{\"type\":\"Value\",\"value\":{\"type\":{\"type\":\"Integer\",\"value\":null},\"loc_id\":\"0\",\"value\":{\"type\":\"Integer\",\"value\":\"100\"}}}},{\"case\":\"50\",\"variable\":{\"type\":\"Variable\",\"value\":{\"type\":{\"type\":\"Null\",\"value\":null},\"loc_id\":\"0\",\"name\":\"_v\",\"mutable\":false,\"captured\":false}},\"body\":{\"type\":\"Value\",\"value\":{\"type\":{\"type\":\"Integer\",\"value\":null},\"loc_id\":\"0\",\"value\":{\"type\":\"Integer\",\"value\":\"50\"}}}},{\"case\":\"a\",\"variable\":{\"type\":\"Variable\",\"value\":{\"type\":{\"type\":\"Integer\",\"value\":null},\"loc_id\":\"0\",\"name\":\"n\",\"mutable\":false,\"captured\":false}},\"body\":{\"type\":\"Variable\",\"value\":{\"type\":{\"type\":\"Integer\",\"value\":null},\"loc_id\":\"0\",\"name\":\"n\",\"mutable\":false,\"captured\":false}}}]}}}}",
5198
+ "ts": "// Generated by east-node transpile — East IR printed as the East.function\n// builder surface. Rebuilding this module yields the same IR (normalized).\nimport { East, NullType, IntegerType, VariantType } from \"@elaraai/east\";\n\nexport const crosslangIntegerNamedCases = East.function(\n [VariantType({ \"100\": NullType, \"50\": NullType, a: IntegerType })],\n IntegerType,\n ($, s) => s.match({ \"100\": ($, _v) => 100n, \"50\": ($, _v) => 50n, a: ($, n) => n }),\n);\n",
5199
+ "python": "# Generated by east-py transpile — East IR printed as the East.function\n# builder surface. Rebuilding this module yields the same IR (normalized).\nfrom east import East, NullType, IntegerType, VariantType\n\n@East.function(\n [VariantType([('100', NullType), ('50', NullType), ('a', IntegerType)])],\n IntegerType,\n)\ndef crosslangIntegerNamedCases(b, s):\n return s.match({'100': lambda b, _v: 100, '50': lambda b, _v: 50, 'a': lambda b, n: n})\n",
5200
+ "signature": {
5201
+ "inputs": [
5202
+ "VariantType({ \"100\": NullType, \"50\": NullType, a: IntegerType })"
5203
+ ],
5204
+ "output": "IntegerType",
5205
+ "async": false
5206
+ },
5207
+ "inputs": "[{\"type\":\"100\",\"value\":null}]",
5208
+ "returns": "\"100\"",
5209
+ "builtins": []
5210
+ },
5211
+ {
5212
+ "id": "east:crosslang.examples.ts:crosslangIntegerNamedFields",
5213
+ "skill": "east",
5214
+ "package": "east",
5215
+ "file": "east/test/crosslang.examples.ts",
5216
+ "suite": "",
5217
+ "test": "A struct whose field names look like integers, declared as a list: its fields, and a literal of it, in the order its type lists them",
5218
+ "keywords": [
5219
+ "cross-language",
5220
+ "python",
5221
+ "struct",
5222
+ "field order",
5223
+ "integer-like names",
5224
+ "StructType list"
5225
+ ],
5226
+ "imports": [
5227
+ "import {"
5228
+ ],
5229
+ "languages": [
5230
+ "typescript",
5231
+ "python"
5232
+ ],
5233
+ "ir": "{\"type\":\"Function\",\"value\":{\"type\":{\"type\":\"Function\",\"value\":{\"inputs\":[{\"type\":\"Struct\",\"value\":[{\"name\":\"b\",\"type\":{\"type\":\"Integer\",\"value\":null}},{\"name\":\"10\",\"type\":{\"type\":\"Integer\",\"value\":null}},{\"name\":\"2\",\"type\":{\"type\":\"Integer\",\"value\":null}}]}],\"output\":{\"type\":\"Struct\",\"value\":{\"$ref\":\"2#inputs/0/Struct\"}}}},\"loc_id\":\"0\",\"captures\":[],\"parameters\":[{\"type\":\"Variable\",\"value\":{\"type\":{\"type\":\"Struct\",\"value\":{\"$ref\":\"5#type/Function/inputs/0/Struct\"}},\"loc_id\":\"0\",\"name\":\"c\",\"mutable\":false,\"captured\":false}}],\"body\":{\"type\":\"Struct\",\"value\":{\"type\":{\"type\":\"Struct\",\"value\":{\"$ref\":\"4#type/Function/inputs/0/Struct\"}},\"loc_id\":\"0\",\"fields\":[{\"name\":\"b\",\"value\":{\"type\":\"GetField\",\"value\":{\"type\":{\"type\":\"Integer\",\"value\":null},\"loc_id\":\"0\",\"field\":\"2\",\"struct\":{\"type\":\"Variable\",\"value\":{\"type\":{\"type\":\"Struct\",\"value\":{\"$ref\":\"10#type/Function/inputs/0/Struct\"}},\"loc_id\":\"0\",\"name\":\"c\",\"mutable\":false,\"captured\":false}}}}},{\"name\":\"10\",\"value\":{\"type\":\"Builtin\",\"value\":{\"type\":{\"type\":\"Integer\",\"value\":null},\"loc_id\":\"0\",\"builtin\":\"IntegerAdd\",\"type_parameters\":[],\"arguments\":[{\"type\":\"GetField\",\"value\":{\"type\":{\"type\":\"Integer\",\"value\":null},\"loc_id\":\"0\",\"field\":\"10\",\"struct\":{\"type\":\"Variable\",\"value\":{\"type\":{\"type\":\"Struct\",\"value\":{\"$ref\":\"13#type/Function/inputs/0/Struct\"}},\"loc_id\":\"0\",\"name\":\"c\",\"mutable\":false,\"captured\":false}}}},{\"type\":\"Value\",\"value\":{\"type\":{\"type\":\"Integer\",\"value\":null},\"loc_id\":\"0\",\"value\":{\"type\":\"Integer\",\"value\":\"1\"}}}]}}},{\"name\":\"2\",\"value\":{\"type\":\"GetField\",\"value\":{\"type\":{\"type\":\"Integer\",\"value\":null},\"loc_id\":\"0\",\"field\":\"b\",\"struct\":{\"type\":\"Variable\",\"value\":{\"type\":{\"type\":\"Struct\",\"value\":{\"$ref\":\"10#type/Function/inputs/0/Struct\"}},\"loc_id\":\"0\",\"name\":\"c\",\"mutable\":false,\"captured\":false}}}}}]}}}}",
5234
+ "ts": "// Generated by east-node transpile — East IR printed as the East.function\n// builder surface. Rebuilding this module yields the same IR (normalized).\nimport { East, IntegerType, StructType } from \"@elaraai/east\";\n\nexport const crosslangIntegerNamedFields = East.function(\n [StructType([[\"b\", IntegerType], [\"10\", IntegerType], [\"2\", IntegerType]])],\n StructType([[\"b\", IntegerType], [\"10\", IntegerType], [\"2\", IntegerType]]),\n ($, c) => ({ b: c[\"2\"], \"10\": c[\"10\"].add(1n), \"2\": c.b }),\n);\n",
5235
+ "python": "# Generated by east-py transpile — East IR printed as the East.function\n# builder surface. Rebuilding this module yields the same IR (normalized).\nfrom east import East, IntegerType, StructType\n\n@East.function(\n [StructType([('b', IntegerType), ('10', IntegerType), ('2', IntegerType)])],\n StructType([('b', IntegerType), ('10', IntegerType), ('2', IntegerType)]),\n)\ndef crosslangIntegerNamedFields(b, c):\n return {'b': c.field('2'), '10': (c.field('10') + 1), '2': c.b}\n",
5236
+ "signature": {
5237
+ "inputs": [
5238
+ "StructType([[\"b\", IntegerType], [\"10\", IntegerType], [\"2\", IntegerType]])"
5239
+ ],
5240
+ "output": "StructType([[\"b\", IntegerType], [\"10\", IntegerType], [\"2\", IntegerType]])",
5241
+ "async": false
5242
+ },
5243
+ "inputs": "[{\"2\":\"3\",\"10\":\"2\",\"b\":\"1\"}]",
5244
+ "returns": "{\"2\":\"1\",\"10\":\"3\",\"b\":\"3\"}",
5245
+ "builtins": [
5246
+ "IntegerAdd"
5247
+ ]
5248
+ },
5175
5249
  {
5176
5250
  "id": "east:crosslang.examples.ts:crosslangDictSet",
5177
5251
  "skill": "east",
@@ -19638,6 +19712,44 @@
19638
19712
  "Parse"
19639
19713
  ]
19640
19714
  },
19715
+ {
19716
+ "id": "east:struct.examples.ts:structIntegerNamedFields",
19717
+ "skill": "east",
19718
+ "package": "east",
19719
+ "file": "east/test/struct.examples.ts",
19720
+ "suite": "Fields named like integers",
19721
+ "test": "Declare a struct whose fields are named like integers as a list of its fields, which keeps their order",
19722
+ "keywords": [
19723
+ "struct",
19724
+ "StructType",
19725
+ "field order",
19726
+ "integer-like names",
19727
+ "list of fields",
19728
+ "print"
19729
+ ],
19730
+ "imports": [
19731
+ "import { East, IntegerType, StringType, StructType, BooleanType, example } from \"@elaraai/east\";"
19732
+ ],
19733
+ "languages": [
19734
+ "typescript",
19735
+ "python"
19736
+ ],
19737
+ "ir": "{\"type\":\"Function\",\"value\":{\"type\":{\"type\":\"Function\",\"value\":{\"inputs\":[{\"type\":\"Struct\",\"value\":[{\"name\":\"b\",\"type\":{\"type\":\"Integer\",\"value\":null}},{\"name\":\"10\",\"type\":{\"type\":\"Integer\",\"value\":null}},{\"name\":\"2\",\"type\":{\"type\":\"Integer\",\"value\":null}}]}],\"output\":{\"type\":\"String\",\"value\":null}}},\"loc_id\":\"0\",\"captures\":[],\"parameters\":[{\"type\":\"Variable\",\"value\":{\"type\":{\"type\":\"Struct\",\"value\":{\"$ref\":\"5#type/Function/inputs/0/Struct\"}},\"loc_id\":\"0\",\"name\":\"counts\",\"mutable\":false,\"captured\":false}}],\"body\":{\"type\":\"Builtin\",\"value\":{\"type\":{\"type\":\"String\",\"value\":null},\"loc_id\":\"0\",\"builtin\":\"Print\",\"type_parameters\":[{\"type\":\"Struct\",\"value\":{\"$ref\":\"5#type/Function/inputs/0/Struct\"}}],\"arguments\":[{\"type\":\"Variable\",\"value\":{\"type\":{\"type\":\"Struct\",\"value\":{\"$ref\":\"7#type/Function/inputs/0/Struct\"}},\"loc_id\":\"0\",\"name\":\"counts\",\"mutable\":false,\"captured\":false}}]}}}}",
19738
+ "ts": "// Generated by east-node transpile — East IR printed as the East.function\n// builder surface. Rebuilding this module yields the same IR (normalized).\nimport { East, IntegerType, StringType, StructType } from \"@elaraai/east\";\n\nexport const structIntegerNamedFields = East.function(\n [StructType([[\"b\", IntegerType], [\"10\", IntegerType], [\"2\", IntegerType]])],\n StringType,\n ($, counts) => East.print(counts),\n);\n",
19739
+ "python": "# Generated by east-py transpile — East IR printed as the East.function\n# builder surface. Rebuilding this module yields the same IR (normalized).\nfrom east import East, IntegerType, StringType, StructType\n\n@East.function(\n [StructType([('b', IntegerType), ('10', IntegerType), ('2', IntegerType)])],\n StringType,\n)\ndef structIntegerNamedFields(b, counts):\n return East.String.print(\n StructType([('b', IntegerType), ('10', IntegerType), ('2', IntegerType)]),\n counts,\n )\n",
19740
+ "signature": {
19741
+ "inputs": [
19742
+ "StructType([[\"b\", IntegerType], [\"10\", IntegerType], [\"2\", IntegerType]])"
19743
+ ],
19744
+ "output": "StringType",
19745
+ "async": false
19746
+ },
19747
+ "inputs": "[{\"2\":\"3\",\"10\":\"2\",\"b\":\"1\"}]",
19748
+ "returns": "\"(b=1, `10`=2, `2`=3)\"",
19749
+ "builtins": [
19750
+ "Print"
19751
+ ]
19752
+ },
19641
19753
  {
19642
19754
  "id": "east:variant.examples.ts:variantCreate",
19643
19755
  "skill": "east",
@@ -39940,7 +40052,7 @@
39940
40052
  "Save"
39941
40053
  ],
39942
40054
  "imports": [
39943
- "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40055
+ "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, SetType, StringType, example, none, some, variant } from \"@elaraai/east\";",
39944
40056
  "import e3 from \"@elaraai/e3\";",
39945
40057
  "import { Box, Button, Field, HStack, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
39946
40058
  "import { Allocation, Data, Func, Record, Schedule } from \"@elaraai/e3-ui\";",
@@ -39973,7 +40085,7 @@
39973
40085
  "Reactive"
39974
40086
  ],
39975
40087
  "imports": [
39976
- "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40088
+ "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, SetType, StringType, example, none, some, variant } from \"@elaraai/east\";",
39977
40089
  "import e3 from \"@elaraai/e3\";",
39978
40090
  "import { Box, Button, Field, HStack, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
39979
40091
  "import { Allocation, Data, Func, Record, Schedule } from \"@elaraai/e3-ui\";",
@@ -39990,7 +40102,7 @@
39990
40102
  "package": "e3-ui",
39991
40103
  "file": "east-ui/packages/e3-ui/test/allocation/allocation.examples.tsx",
39992
40104
  "suite": "",
39993
- "test": "The kiln yard's board over its own records: its bins, each with the yard's spec and grade beside the board's roles, read a day at a time through the slice; the days it publishes; a check over the bins' own fields; the rail over the bays, the kilns and the loads — each source with its icon, and each narrowing every place its rows appear, the Library's tabs included; the yard's fields as columns; the Arrivals and Resources library; the inspector; and the yard's greedy fit on e3.",
40105
+ "test": "The kiln yard's board over its own records: its bins, each with the yard's spec and grade beside the board's roles, read a day at a time through the slice; the days it publishes; a check over the bins' own fields; a booked bin's own fields from its load's `values`, a reservation's from the bin kind's; the rail over the bays, the kilns and the loads — each source with its icon, and each narrowing every place its rows appear, the Library's tabs included; the yard's fields as columns; the Arrivals and Resources library; the inspector; and the yard's greedy fit on e3.",
39994
40106
  "keywords": [
39995
40107
  "Allocation",
39996
40108
  "Schedule.events",
@@ -40002,6 +40114,9 @@
40002
40114
  "Func.bind",
40003
40115
  "fit",
40004
40116
  "check",
40117
+ "values",
40118
+ "reservation",
40119
+ "Allocation.Types.NewBin",
40005
40120
  "columns",
40006
40121
  "links",
40007
40122
  "Publish",
@@ -40009,7 +40124,7 @@
40009
40124
  "narrowing"
40010
40125
  ],
40011
40126
  "imports": [
40012
- "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40127
+ "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, SetType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40013
40128
  "import e3 from \"@elaraai/e3\";",
40014
40129
  "import { Box, Button, Field, HStack, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
40015
40130
  "import { Allocation, Data, Func, Record, Schedule } from \"@elaraai/e3-ui\";",
@@ -40018,7 +40133,7 @@
40018
40133
  "languages": [
40019
40134
  "tsx"
40020
40135
  ],
40021
- "source": "// The kiln yard's board over its own records: its bins, each with the yard's spec and grade beside the board's roles, read a day at a time through the slice; the days it publishes; a check over the bins' own fields; the rail over the bays, the kilns and the loads — each source with its icon, and each narrowing every place its rows appear, the Library's tabs included; the yard's fields as columns; the Arrivals and Resources library; the inspector; and the yard's greedy fit on e3.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The days of the yard's plan, what the board publishes: Tue 4 May issued, Tue 11 and Wed 12 drafts. */\nexport const yardDays = e3.record(\"yard_days\", DictType(DateTimeType, YardDay), {\n initial: yardDayRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The yard's fit's body: the built-in rules, then a greedy look-ahead over the day's other loads. */\nexport const yardFitBody = East.function([Allocation.Types.FitRequest(KilnBin)], Allocation.Types.FitResult, ($, req) => {\n const answer = $.const(Allocation.answer(KilnBin));\n const rule = $.const(Allocation.fit);\n const ahead = $.const(Allocation.lookahead(KilnBin));\n return answer(req, East.function([Allocation.Types.Candidate], Allocation.Types.Fit, (_$2, c) => ahead(req, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n});\n\nexport const yardFit = e3.function(\"yard_fit\", yardFitBody);\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n // What the board writes: the bins and the days of the plan, each through its patch door.\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n const days = $.let(Record.bind(yardDays));\n // Every bay, kiln and load is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\", \"yard_bays_by_cover\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group_max\", \"kilns_by_name\"] }));\n const loadIndex = $.let(Data.bindPaged(arrivals, { indexes: [\"arrivals_by_spec\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationKilnYard\", {\n // The day's bins: the board's navigation writes the range; no chip picks the day.\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, icon: { prefix: \"fas\", name: \"warehouse\" },\n fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] }, cover: { label: \"Cover\", hints: [\"Covered\", \"Open\"] } } },\n // A max narrows within a group (one index on group, then max); a name is searched by its start.\n kilns: { source: kilnIndex, icon: { prefix: \"fas\", name: \"fire\" },\n fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] }, max: { label: \"Max m³\" }, name: { label: \"Name\" } } },\n arrivals: { source: loadIndex, icon: { prefix: \"fas\", name: \"truck\" }, fields: { spec: { label: \"Spec\", hints: [\"MC08\", \"MC10\", \"MC12\", \"MC14\", \"MC16\", \"MC18\", \"MC20\", \"MC22\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(yardFit));\n // The yard's check reads its own fields: a bin measured off its booked spec is flagged, never refused.\n const check = $.const(East.function([Allocation.Types.CheckContext(KilnBin)], ArrayType(Allocation.Types.Issue), ($2, cx) => {\n const issues = $2.let([], ArrayType(Allocation.Types.Issue));\n $2.for(cx.plan.bins, ($3, bin, id) => {\n $3.match(bin.arrival, { some: ($4, code) => {\n $4.if(East.notEqual(bin.row.specBooked, bin.row.specMeasured), ($5) => {\n $5(issues.pushLast({ kind: variant(\"custom\", \"Spec mismatch\"), tone: variant(\"neutral\", null),\n title: East.str`${code} · bin ${id}`,\n detail: East.str`Spec booked ${bin.row.specBooked} · measured ${bin.row.specMeasured} · ${bin.lane} ${bin.at.printFormatted(\"HH:mm\")}`,\n bin: some(id), resource: none, flag: some(\"≠ spec\"), fix: none }));\n });\n } });\n });\n return issues;\n }));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationKilnYard\" title=\"Kiln loading\" fit={fit} check={check} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n // A booked bin's own fields: the ones no role maps.\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40136
+ "source": "// The kiln yard's board over its own records: its bins, each with the yard's spec and grade beside the board's roles, read a day at a time through the slice; the days it publishes; a check over the bins' own fields; a booked bin's own fields from its load's `values`, a reservation's from the bin kind's; the rail over the bays, the kilns and the loads — each source with its icon, and each narrowing every place its rows appear, the Library's tabs included; the yard's fields as columns; the Arrivals and Resources library; the inspector; and the yard's greedy fit on e3.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The days of the yard's plan, what the board publishes: Tue 4 May issued, Tue 11 and Wed 12 drafts. */\nexport const yardDays = e3.record(\"yard_days\", DictType(DateTimeType, YardDay), {\n initial: yardDayRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The yard's fit's body: the built-in rules, then a greedy look-ahead over the day's other loads. */\nexport const yardFitBody = East.function([Allocation.Types.FitRequest(KilnBin)], Allocation.Types.FitResult, ($, req) => {\n const answer = $.const(Allocation.answer(KilnBin));\n const rule = $.const(Allocation.fit);\n const ahead = $.const(Allocation.lookahead(KilnBin));\n return answer(req, East.function([Allocation.Types.Candidate], Allocation.Types.Fit, (_$2, c) => ahead(req, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n});\n\nexport const yardFit = e3.function(\"yard_fit\", yardFitBody);\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n // What the board writes: the bins and the days of the plan, each through its patch door.\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n const days = $.let(Record.bind(yardDays));\n // Every bay, kiln and load is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\", \"yard_bays_by_cover\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group_max\", \"kilns_by_name\"] }));\n const loadIndex = $.let(Data.bindPaged(arrivals, { indexes: [\"arrivals_by_spec\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationKilnYard\", {\n // The day's bins: the board's navigation writes the range; no chip picks the day.\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, icon: { prefix: \"fas\", name: \"warehouse\" },\n fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] }, cover: { label: \"Cover\", hints: [\"Covered\", \"Open\"] } } },\n // A max narrows within a group (one index on group, then max); a name is searched by its start.\n kilns: { source: kilnIndex, icon: { prefix: \"fas\", name: \"fire\" },\n fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] }, max: { label: \"Max m³\" }, name: { label: \"Name\" } } },\n arrivals: { source: loadIndex, icon: { prefix: \"fas\", name: \"truck\" }, fields: { spec: { label: \"Spec\", hints: [\"MC08\", \"MC10\", \"MC12\", \"MC14\", \"MC16\", \"MC18\", \"MC20\", \"MC22\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(yardFit));\n // The yard's check reads its own fields: a bin measured off its booked spec is flagged, never refused.\n const check = $.const(East.function([Allocation.Types.CheckContext(KilnBin)], ArrayType(Allocation.Types.Issue), ($2, cx) => {\n const issues = $2.let([], ArrayType(Allocation.Types.Issue));\n $2.for(cx.plan.bins, ($3, bin, id) => {\n $3.match(bin.arrival, { some: ($4, code) => {\n $4.if(East.notEqual(bin.row.specBooked, bin.row.specMeasured), ($5) => {\n $5(issues.pushLast({ kind: variant(\"custom\", \"Spec mismatch\"), tone: variant(\"neutral\", null),\n title: East.str`${code} · bin ${id}`,\n detail: East.str`Spec booked ${bin.row.specBooked} · measured ${bin.row.specMeasured} · ${bin.lane} ${bin.at.printFormatted(\"HH:mm\")}`,\n bin: some(id), resource: none, flag: some(\"≠ spec\"), fix: none }));\n });\n } });\n });\n return issues;\n }));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationKilnYard\" title=\"Kiln loading\" fit={fit} check={check} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n // A reservation's own fields, the yard's: its kind's spec, booked and measured alike — empty, as a reservation holds\n // no kind until a load comes — no grade yet, and its instruction. A bin booked from a load takes the load's `values` below.\n values: r => ({\n specBooked: r.kind.unwrap(\"some\", () => \"\"), specMeasured: r.kind.unwrap(\"some\", () => \"\"),\n gradeBooked: \"\", gradeMeasured: \"\", instruction: some(\"Hold for the next load\"),\n }),\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n // A booked bin's own fields: the ones no role maps.\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40022
40137
  },
40023
40138
  {
40024
40139
  "id": "e3-ui:allocation.examples.tsx:allocationTable",
@@ -40040,7 +40155,7 @@
40040
40155
  "Slice.bindRecords"
40041
40156
  ],
40042
40157
  "imports": [
40043
- "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40158
+ "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, SetType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40044
40159
  "import e3 from \"@elaraai/e3\";",
40045
40160
  "import { Box, Button, Field, HStack, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
40046
40161
  "import { Allocation, Data, Func, Record, Schedule } from \"@elaraai/e3-ui\";",
@@ -40070,7 +40185,7 @@
40070
40185
  "Func.bind"
40071
40186
  ],
40072
40187
  "imports": [
40073
- "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40188
+ "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, SetType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40074
40189
  "import e3 from \"@elaraai/e3\";",
40075
40190
  "import { Box, Button, Field, HStack, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
40076
40191
  "import { Allocation, Data, Func, Record, Schedule } from \"@elaraai/e3-ui\";",
@@ -40102,7 +40217,7 @@
40102
40217
  "Allocation.arrivals"
40103
40218
  ],
40104
40219
  "imports": [
40105
- "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40220
+ "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, SetType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40106
40221
  "import e3 from \"@elaraai/e3\";",
40107
40222
  "import { Box, Button, Field, HStack, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
40108
40223
  "import { Allocation, Data, Func, Record, Schedule } from \"@elaraai/e3-ui\";",
@@ -40129,7 +40244,7 @@
40129
40244
  "Record.bind"
40130
40245
  ],
40131
40246
  "imports": [
40132
- "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40247
+ "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, SetType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40133
40248
  "import e3 from \"@elaraai/e3\";",
40134
40249
  "import { Box, Button, Field, HStack, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
40135
40250
  "import { Allocation, Data, Func, Record, Schedule } from \"@elaraai/e3-ui\";",
@@ -40140,6 +40255,36 @@
40140
40255
  ],
40141
40256
  "source": "// A published day, Tue 4 May, its status the yard's own day issued: read-only under its banner; navigation, the narrowing, the focus, links and the inspector still work.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The days of the yard's plan, what the board publishes: Tue 4 May issued, Tue 11 and Wed 12 drafts. */\nexport const yardDays = e3.record(\"yard_days\", DictType(DateTimeType, YardDay), {\n initial: yardDayRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The yard's fit's body: the built-in rules, then a greedy look-ahead over the day's other loads. */\nexport const yardFitBody = East.function([Allocation.Types.FitRequest(KilnBin)], Allocation.Types.FitResult, ($, req) => {\n const answer = $.const(Allocation.answer(KilnBin));\n const rule = $.const(Allocation.fit);\n const ahead = $.const(Allocation.lookahead(KilnBin));\n return answer(req, East.function([Allocation.Types.Candidate], Allocation.Types.Fit, (_$2, c) => ahead(req, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n});\n\nexport const yardFit = e3.function(\"yard_fit\", yardFitBody);\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n const days = $.let(Record.bind(yardDays));\n // Every bay and kiln is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationPublished\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(yardFit));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationPublished\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardPublishedDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40142
40257
  },
40258
+ {
40259
+ "id": "e3-ui:allocation.examples.tsx:allocationWeekly",
40260
+ "skill": "e3-ui",
40261
+ "package": "e3-ui",
40262
+ "file": "east-ui/packages/e3-ui/test/allocation/allocation.examples.tsx",
40263
+ "suite": "",
40264
+ "test": "The kiln yard publishing a week at a time (#1550): `periods` over the yard's weeks, `Schedule.periods(weeks, { every: \"week\", status })`, each row keyed by the first day of its week, which `week={{ start }}` names — Monday here, as by default. Publish writes the week holding the day in view, after Save; every day of a published week is read-only under its banner, and the picker marks each day with its week's status. The week of Mon 3 May is issued, the plan day's week a draft.",
40265
+ "keywords": [
40266
+ "Allocation",
40267
+ "Schedule.periods",
40268
+ "every",
40269
+ "week",
40270
+ "week.start",
40271
+ "Publish",
40272
+ "published",
40273
+ "readOnly",
40274
+ "Record.bind"
40275
+ ],
40276
+ "imports": [
40277
+ "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, SetType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40278
+ "import e3 from \"@elaraai/e3\";",
40279
+ "import { Box, Button, Field, HStack, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
40280
+ "import { Allocation, Data, Func, Record, Schedule } from \"@elaraai/e3-ui\";",
40281
+ "import {"
40282
+ ],
40283
+ "languages": [
40284
+ "tsx"
40285
+ ],
40286
+ "source": "// The kiln yard publishing a week at a time (#1550): `periods` over the yard's weeks, `Schedule.periods(weeks, { every: \"week\", status })`, each row keyed by the first day of its week, which `week={{ start }}` names — Monday here, as by default. Publish writes the week holding the day in view, after Save; every day of a published week is read-only under its banner, and the picker marks each day with its week's status. The week of Mon 3 May is issued, the plan day's week a draft.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The weeks of the yard's plan, for a board publishing a week at a time (#1550): each keyed by its Monday, the week of 3 May issued, the plan day's a draft. */\nexport const yardWeeks = e3.record(\"yard_weeks\", DictType(DateTimeType, YardWeek), {\n initial: yardWeekRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The yard's fit's body: the built-in rules, then a greedy look-ahead over the day's other loads. */\nexport const yardFitBody = East.function([Allocation.Types.FitRequest(KilnBin)], Allocation.Types.FitResult, ($, req) => {\n const answer = $.const(Allocation.answer(KilnBin));\n const rule = $.const(Allocation.fit);\n const ahead = $.const(Allocation.lookahead(KilnBin));\n return answer(req, East.function([Allocation.Types.Candidate], Allocation.Types.Fit, (_$2, c) => ahead(req, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n});\n\nexport const yardFit = e3.function(\"yard_fit\", yardFitBody);\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n // What the board publishes: the yard's weeks, each through the record's patch door.\n const weeks = $.let(Record.bind(yardWeeks));\n // Every bay and kiln is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationWeekly\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n }));\n const fit = $.let(Func.bind(yardFit));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationWeekly\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardDay }} week={{ start: \"monday\" }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(weeks, { every: \"week\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })} />\n </Box>;\n }}</Reactive>)"
40287
+ },
40143
40288
  {
40144
40289
  "id": "e3-ui:allocation.examples.tsx:allocationNoPublish",
40145
40290
  "skill": "e3-ui",
@@ -40156,7 +40301,7 @@
40156
40301
  "Record.bind"
40157
40302
  ],
40158
40303
  "imports": [
40159
- "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40304
+ "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, SetType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40160
40305
  "import e3 from \"@elaraai/e3\";",
40161
40306
  "import { Box, Button, Field, HStack, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
40162
40307
  "import { Allocation, Data, Func, Record, Schedule } from \"@elaraai/e3-ui\";",
@@ -40184,7 +40329,7 @@
40184
40329
  "Schedule.events"
40185
40330
  ],
40186
40331
  "imports": [
40187
- "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40332
+ "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, SetType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40188
40333
  "import e3 from \"@elaraai/e3\";",
40189
40334
  "import { Box, Button, Field, HStack, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
40190
40335
  "import { Allocation, Data, Func, Record, Schedule } from \"@elaraai/e3-ui\";",
@@ -40217,7 +40362,7 @@
40217
40362
  "Publish"
40218
40363
  ],
40219
40364
  "imports": [
40220
- "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40365
+ "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, SetType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40221
40366
  "import e3 from \"@elaraai/e3\";",
40222
40367
  "import { Box, Button, Field, HStack, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
40223
40368
  "import { Allocation, Data, Func, Record, Schedule } from \"@elaraai/e3-ui\";",
@@ -40244,7 +40389,7 @@
40244
40389
  "Record.bind"
40245
40390
  ],
40246
40391
  "imports": [
40247
- "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40392
+ "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, SetType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40248
40393
  "import e3 from \"@elaraai/e3\";",
40249
40394
  "import { Box, Button, Field, HStack, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
40250
40395
  "import { Allocation, Data, Func, Record, Schedule } from \"@elaraai/e3-ui\";",
@@ -40271,7 +40416,7 @@
40271
40416
  "typed form"
40272
40417
  ],
40273
40418
  "imports": [
40274
- "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40419
+ "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, SetType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40275
40420
  "import e3 from \"@elaraai/e3\";",
40276
40421
  "import { Box, Button, Field, HStack, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
40277
40422
  "import { Allocation, Data, Func, Record, Schedule } from \"@elaraai/e3-ui\";",
@@ -40299,7 +40444,7 @@
40299
40444
  "rule"
40300
40445
  ],
40301
40446
  "imports": [
40302
- "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40447
+ "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, SetType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40303
40448
  "import e3 from \"@elaraai/e3\";",
40304
40449
  "import { Box, Button, Field, HStack, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
40305
40450
  "import { Allocation, Data, Func, Record, Schedule } from \"@elaraai/e3-ui\";",
@@ -40333,7 +40478,7 @@
40333
40478
  "Save"
40334
40479
  ],
40335
40480
  "imports": [
40336
- "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40481
+ "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, SetType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40337
40482
  "import e3 from \"@elaraai/e3\";",
40338
40483
  "import { Box, Button, Field, HStack, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
40339
40484
  "import { Allocation, Data, Func, Record, Schedule } from \"@elaraai/e3-ui\";",
@@ -40344,6 +40489,40 @@
40344
40489
  ],
40345
40490
  "source": "// Your edits meeting someone else's save, in one window — move a bin or change its m³ in the panel, then press Someone else saves, which saves another person's change to the same bins (every bin a quarter hour later, 1 m³ more on each of its kilns), so yours conflict and wait to be chosen, an m³ and its split across kilns one card\n// inputs: []\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The smallest board's fit's body (§6.5): the built-in rules over its own bins. */\nexport const minimalFitBody = East.function([Allocation.Types.FitRequest(MinimalBin)], Allocation.Types.FitResult, ($, req) => {\n const answer = $.const(Allocation.answer(MinimalBin));\n const rule = $.const(Allocation.fit);\n return answer(req, rule, \"ranked by load, kind and spare days\");\n});\n\nexport const minimalFit = e3.function(\"yard_minimal_fit\", minimalFitBody);\n\n/** The bins the conflicts example edits, in a record of their own, so no other example's edits meet them. */\nexport const conflictBins = e3.record(\"kiln_conflict_bins\", DictType(StringType, MinimalBin), {\n initial: yardMinimalBinRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n // Someone else's save: every bin a quarter hour later, and 1 m³ more on each of its kilns, its m³ with them.\n elsewhere: mutation.reduce(East.function([DictType(StringType, MinimalBin)], DictType(StringType, MinimalBin), (_$, bins) =>\n bins.map((_$2, bin) => ({\n bay: bin.bay, at: bin.at.addMinutes(15n), load: bin.load,\n m3: bin.m3.add(bin.kilns.size().toFloat()),\n kilns: bin.kilns.map((_$3, share) => share.add(1.0)),\n dryFor: bin.dryFor,\n })))),\n }),\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(conflictBins, [\"patch\"]));\n const others = $.let(Record.bind(conflictBins, [\"elsewhere\"]));\n const theirs = $.const(East.function([], NullType, ($) => { $(others.mutate.elsewhere()); }));\n const loads = $.let(Data.bind(arrivals));\n const yard = $.let(Data.bind(kilns));\n const bays = $.let(Data.bind(yardBays));\n const fit = $.let(Func.bind(minimalFit));\n return <VStack gap=\"3\" align=\"stretch\">\n <HStack gap=\"3\">\n <Button variant=\"outline\" onClick={theirs} loading={others.mutate.pending()}>Someone else saves</Button>\n <Text color=\"fg.muted\">Their change: every bin a quarter hour later, 1 m³ more on each of its kilns</Text>\n </HStack>\n <Box width=\"100%\" height=\"760px\"><Allocation id=\"allocationConflicts\" fit={fit} inspector view={{ date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\",\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\",\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, min: k => k.min, max: k => k.max, jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), { label: l => l.code, quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays) })} />\n </Box>\n </VStack>;\n }}</Reactive>)"
40346
40491
  },
40492
+ {
40493
+ "id": "e3-ui:allocation.examples.tsx:allocationDeliveries",
40494
+ "skill": "e3-ui",
40495
+ "package": "e3-ui",
40496
+ "file": "east-ui/packages/e3-ui/test/allocation/allocation.examples.tsx",
40497
+ "suite": "",
40498
+ "test": "A board over its mills' delivery schedule (#1551): a second record of the yard's, bound as the slice's `reference` source — a paged read through an interval index over each delivery's hour, `range: \"from\"` — which nothing draws and the rail offers no field of. The board writes its day into it as into the bins' source, and the check, from Allocation.Types.CheckContext(MinimalBin, Delivery), is given that day's deliveries by load as `reference`: it flags a bin booked off its load's bay or hour, a bin whose load the day's schedule delivers none of, and a delivery the day books no bin of. Step to Wed 12 May and LD-2214, moved there, is the delivery to book.",
40499
+ "keywords": [
40500
+ "Allocation",
40501
+ "check",
40502
+ "reference",
40503
+ "Allocation.Types.CheckContext",
40504
+ "Allocation.Types.Issue",
40505
+ "delivery schedule",
40506
+ "two records",
40507
+ "Slice.bindRecords",
40508
+ "Data.bindPaged",
40509
+ "interval",
40510
+ "indexes",
40511
+ "Schedule.events",
40512
+ "Allocation.arrivals"
40513
+ ],
40514
+ "imports": [
40515
+ "import { ArrayType, DateTimeType, DictType, East, FunctionType, NullType, PatchType, SetType, StringType, example, none, some, variant } from \"@elaraai/east\";",
40516
+ "import e3 from \"@elaraai/e3\";",
40517
+ "import { Box, Button, Field, HStack, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
40518
+ "import { Allocation, Data, Func, Record, Schedule } from \"@elaraai/e3-ui\";",
40519
+ "import {"
40520
+ ],
40521
+ "languages": [
40522
+ "tsx"
40523
+ ],
40524
+ "source": "// A board over its mills' delivery schedule (#1551): a second record of the yard's, bound as the slice's `reference` source — a paged read through an interval index over each delivery's hour, `range: \"from\"` — which nothing draws and the rail offers no field of. The board writes its day into it as into the bins' source, and the check, from Allocation.Types.CheckContext(MinimalBin, Delivery), is given that day's deliveries by load as `reference`: it flags a bin booked off its load's bay or hour, a bin whose load the day's schedule delivers none of, and a delivery the day books no bin of. Step to Wed 12 May and LD-2214, moved there, is the delivery to book.\n// inputs: []\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The smallest board's fit's body (§6.5): the built-in rules over its own bins. */\nexport const minimalFitBody = East.function([Allocation.Types.FitRequest(MinimalBin)], Allocation.Types.FitResult, ($, req) => {\n const answer = $.const(Allocation.answer(MinimalBin));\n const rule = $.const(Allocation.fit);\n return answer(req, rule, \"ranked by load, kind and spare days\");\n});\n\nexport const minimalFit = e3.function(\"yard_minimal_fit\", minimalFitBody);\n\n/** The smallest board's bins again, read a day at a time through the slice, for the board over its mills' delivery schedule (#1551). */\nexport const kilnScheduledBins = e3.record(\"kiln_scheduled_bins\", DictType(StringType, MinimalBin), {\n initial: yardMinimalBinRows,\n indexes: (index) => ({\n kiln_scheduled_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The mills' delivery schedule (#1551): each load's bay and hour, by load, read through an interval index over the hour — what the board's check reads beside its bins. */\nexport const yardDeliveries = e3.record(\"yard_deliveries\", DictType(StringType, Delivery), {\n initial: yardDeliveryRows,\n indexes: (index) => ({\n yard_deliveries_by_time: index.interval({ from: \"from\", to: \"to\" }),\n }),\n mutations: (mutation) => ({\n // The schedule's patch door: the mills' change, as the renderer's tests on e3 commit it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnScheduledBins));\n const entries = $.let(Data.bindPaged(kilnScheduledBins));\n const byTime = $.let(Data.bindPaged(kilnScheduledBins, { indexes: [\"kiln_scheduled_bins_by_time\"] }));\n // The mills' schedule, read a day at a time through its interval index: the check's reference, never the record whole.\n const schedule = $.let(Data.bindPaged(yardDeliveries, { indexes: [\"yard_deliveries_by_time\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationDeliveries\", {\n bin: { source: byTime, range: \"at\" },\n reference: { source: schedule, range: \"from\" },\n }));\n const loads = $.let(Data.bind(arrivals));\n const yard = $.let(Data.bind(kilns));\n const bays = $.let(Data.bind(yardBays));\n const fit = $.let(Func.bind(minimalFit));\n // The yard's check over its bins and the day's deliveries: each flagged, never refused.\n const check = $.const(East.function([Allocation.Types.CheckContext(MinimalBin, Delivery)], ArrayType(Allocation.Types.Issue), ($2, cx) => {\n const issues = $2.let([], ArrayType(Allocation.Types.Issue));\n const booked = $2.let(new Set([]), SetType(StringType));\n $2.for(cx.plan.bins, ($3, bin, id) => {\n $3.match(bin.arrival, { some: ($4, code) => {\n $4(booked.tryInsert(code));\n $4.if(cx.reference.has(code).not(), ($5) => {\n $5(issues.pushLast({ kind: variant(\"custom\", \"No delivery on the day\"), tone: variant(\"warning\", null),\n title: East.str`${code} · bin ${id}`, detail: East.str`The mills' schedule delivers ${code} on another day`,\n bin: some(id), resource: none, flag: some(\"no delivery\"), fix: none }));\n }).else(($5) => {\n const delivery = $5.const(cx.reference.get(code));\n $5.if(East.notEqual(delivery.bay, bin.lane).or(() => East.less(bin.at, delivery.from)).or(() => East.greaterEqual(bin.at, delivery.to)), ($6) => {\n $6(issues.pushLast({ kind: variant(\"custom\", \"Delivery moved\"), tone: variant(\"warning\", null),\n title: East.str`${code} · bin ${id}`,\n detail: East.str`Delivered to ${delivery.bay} at ${delivery.from.printFormatted(\"HH:mm\")} now · booked ${bin.lane} ${bin.at.printFormatted(\"HH:mm\")}`,\n bin: some(id), resource: none, flag: some(\"≠ delivery\"), fix: none }));\n });\n });\n } });\n });\n // The day's deliveries no bin books: the reference holds the rows overlapping the day, so a delivery starting the day before is left to it.\n const next = $2.const(cx.day.addDays(1n));\n $2.for(cx.reference, ($3, delivery, code) => {\n $3.if(booked.has(code).not().and(() => East.greaterEqual(delivery.from, cx.day)).and(() => East.less(delivery.from, next)), ($4) => {\n $4(issues.pushLast({ kind: variant(\"custom\", \"Delivery not booked\"), tone: variant(\"warning\", null),\n title: code, detail: East.str`Delivered to ${delivery.bay} at ${delivery.from.printFormatted(\"HH:mm\")}`,\n bin: none, resource: none, flag: none, fix: none }));\n });\n });\n return issues;\n }));\n return <Box width=\"100%\" height=\"760px\"><Allocation id=\"allocationDeliveries\" fit={fit} check={check} slice={{ slice }} inspector view={{ date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\",\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, min: k => k.min, max: k => k.max, jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), { label: l => l.code, quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays) })} />\n </Box>;\n }}</Reactive>)"
40525
+ },
40347
40526
  {
40348
40527
  "id": "e3-ui:fit.examples.ts:allocationDayLoads",
40349
40528
  "skill": "e3-ui",
@@ -41395,7 +41574,7 @@
41395
41574
  "package": "e3-ui",
41396
41575
  "file": "east-ui/packages/e3-ui/test/calendar/calendar.examples.tsx",
41397
41576
  "suite": "",
41398
- "test": "A metal fabrication calendar over three event records and bound machines, people and templates: Calendar, Resources and Timeline share one frame, one Slice.bindRecords rail — a source per event kind, resource kind and template record — and Save history. Its library schedules the event record's backlog and assigns technicians; overlapping production and maintenance warn without blocking Save.",
41577
+ "test": "A metal fabrication calendar over three event records and bound machines, people and templates: Calendar, Resources and Timeline share one frame, one Slice.bindRecords rail — a source per event kind, resource kind and template record — and Save history. Its library schedules the event record's backlog and assigns technicians; overlapping production and maintenance warn without blocking Save, and a stored job booked past the four hours a run takes is a warning beside the toolbar's issues, holding no Save.",
41399
41578
  "keywords": [
41400
41579
  "Calendar",
41401
41580
  "Record.bind",
@@ -41412,10 +41591,15 @@
41412
41591
  "backlog",
41413
41592
  "inspector",
41414
41593
  "overlaps",
41415
- "Save"
41594
+ "Save",
41595
+ "Calendar.field",
41596
+ "max",
41597
+ "bounds",
41598
+ "warning",
41599
+ "out of range"
41416
41600
  ],
41417
41601
  "imports": [
41418
- "import { ArrayType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
41602
+ "import { ArrayType, BooleanType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
41419
41603
  "import { Box, Button, HStack, Input, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
41420
41604
  "import { Calendar, Data, Record } from \"@elaraai/e3-ui\";",
41421
41605
  "import e3 from \"@elaraai/e3\";"
@@ -41423,7 +41607,7 @@
41423
41607
  "languages": [
41424
41608
  "tsx"
41425
41609
  ],
41426
- "source": "// A metal fabrication calendar over three event records and bound machines, people and templates: Calendar, Resources and Timeline share one frame, one Slice.bindRecords rail — a source per event kind, resource kind and template record — and Save history. Its library schedules the event record's backlog and assigns technicians; overlapping production and maintenance warn without blocking Save.\n// inputs: []\n/** The resources of a small metal fabrication shop. */\nexport const CalendarMachine = StructType({ name: StringType, area: StringType });\n\n/** People the shifts run on and the maintenance library assigns. */\nexport const CalendarPerson = StructType({ name: StringType, team: StringType });\n\n/** A job's lifecycle. */\nexport const CalendarJobState = VariantType({ planned: NullType, active: NullType, done: NullType });\n\n/** A job may wait in the backlog; its own record holds its unscheduled rows. */\nexport const CalendarJob = StructType({ title: StringType, start: OptionType(DateTimeType), end: OptionType(DateTimeType), machine: OptionType(StringType),\n status: CalendarJobState, hours: FloatType, customer: StringType, due: OptionType(DateTimeType) });\n\n/** The initial job fields a template record supplies. */\nexport const CalendarJobValues = StructType({ title: StringType, status: CalendarJobState, hours: FloatType, customer: StringType, due: OptionType(DateTimeType) });\n\n/** Maintenance is a different record, with its own fields and patch mutation. */\nexport const CalendarService = StructType({ title: StringType, start: DateTimeType, end: DateTimeType, machine: StringType, technician: StringType, notes: StringType });\n\n/** A person's shift is its own event kind. */\nexport const CalendarShift = StructType({ title: StringType, start: DateTimeType, end: DateTimeType, person: StringType, notes: StringType });\n\n/** Job templates are live record data, including their duration and initial values; each has a group, which the rail narrows them by. */\nexport const CalendarJobTemplate = StructType({ name: StringType, group: StringType, hours: FloatType, values: CalendarJobValues });\n\n/** Maintenance templates are also bound data, grouped as the job templates are. */\nexport const CalendarServiceTemplate = StructType({ name: StringType, group: StringType, hours: FloatType, values: StructType({ title: StringType, technician: StringType, notes: StringType }) });\n\n/** Shift templates start at their hour when dropped on a day. */\nexport const CalendarShiftTemplate = StructType({ name: StringType, group: StringType, hour: IntegerType, values: StructType({ title: StringType, notes: StringType }) });\n\nexport const calendarMachines = e3.record(\"calendar_machines\", DictType(StringType, CalendarMachine), {\n initial: new Map([\n [\"press1\", { name: \"Press 1\", area: \"Press shop\" }], [\"press2\", { name: \"Press 2\", area: \"Press shop\" }],\n [\"lathe1\", { name: \"Lathe 1\", area: \"Machine shop\" }], [\"lathe2\", { name: \"Lathe 2\", area: \"Machine shop\" }],\n ]),\n indexes: (index) => ({\n calendar_machines_by_area: index.on([\"area\"]),\n }),\n mutations: (mutation) => ({\n // The shop edits its machines and job templates elsewhere, each through its patch door; the Calendar reads them live.\n patch: mutation.patch(),\n }),\n});\n\nexport const calendarPeople = e3.record(\"calendar_people\", DictType(StringType, CalendarPerson), {\n initial: new Map([\n [\"ash\", { name: \"A. Ash\", team: \"Maintenance\" }], [\"birch\", { name: \"B. Birch\", team: \"Production\" }], [\"cedar\", { name: \"C. Cedar\", team: \"Maintenance\" }],\n ]),\n indexes: (index) => ({\n calendar_people_by_team: index.on([\"team\"]),\n }),\n});\n\nexport const calendarJobs = e3.record(\"calendar_jobs\", DictType(StringType, CalendarJob), {\n initial: new Map([\n [\"job1\", { title: \"Mounting brackets · batch 42\", start: some(new Date(\"2026-10-01T06:00:00Z\")), end: some(new Date(\"2026-10-01T10:00:00Z\")), machine: some(\"press1\"), status: variant(\"active\", null), hours: 4.0, customer: \"Alder Works\", due: some(new Date(\"2026-10-02T00:00:00Z\")) }],\n [\"job2\", { title: \"Pump housings\", start: some(new Date(\"2026-10-01T08:00:00Z\")), end: some(new Date(\"2026-10-01T13:00:00Z\")), machine: some(\"lathe1\"), status: variant(\"planned\", null), hours: 5.0, customer: \"Birch Engineering\", due: none }],\n [\"job3\", { title: \"Long title: stainless steel mounting plates for the prototype assembly\", start: some(new Date(\"2026-10-01T11:00:00Z\")), end: some(new Date(\"2026-10-01T11:30:00Z\")), machine: some(\"press2\"), status: variant(\"planned\", null), hours: 0.5, customer: \"Cedar Fabrication\", due: none }],\n [\"job4\", { title: \"Bearing collars\", start: some(new Date(\"2026-10-02T09:00:00Z\")), end: some(new Date(\"2026-10-02T12:00:00Z\")), machine: some(\"lathe2\"), status: variant(\"planned\", null), hours: 3.0, customer: \"Alder Works\", due: none }],\n [\"job5\", { title: \"Overnight batch\", start: some(new Date(\"2026-10-01T22:00:00Z\")), end: some(new Date(\"2026-10-02T02:00:00Z\")), machine: some(\"press1\"), status: variant(\"planned\", null), hours: 4.0, customer: \"Birch Engineering\", due: none }],\n [\"job6\", { title: \"September closeout\", start: some(new Date(\"2026-09-30T08:00:00Z\")), end: some(new Date(\"2026-09-30T10:00:00Z\")), machine: some(\"press2\"), status: variant(\"done\", null), hours: 2.0, customer: \"Alder Works\", due: none }],\n [\"backlog1\", { title: \"Torque-test fixtures\", start: none, end: none, machine: some(\"press1\"), status: variant(\"planned\", null), hours: 2.0, customer: \"Alder Works\", due: some(new Date(\"2026-10-02T00:00:00Z\")) }],\n [\"backlog2\", { title: \"Valve bodies\", start: none, end: none, machine: none, status: variant(\"planned\", null), hours: 3.0, customer: \"Cedar Fabrication\", due: some(new Date(\"2026-10-06T00:00:00Z\")) }],\n [\"backlog3\", { title: \"Replacement shims\", start: none, end: none, machine: none, status: variant(\"planned\", null), hours: 1.0, customer: \"Birch Engineering\", due: some(new Date(\"2026-10-20T00:00:00Z\")) }],\n [\"backlog4\", { title: \"Prototype spacers\", start: none, end: none, machine: none, status: variant(\"planned\", null), hours: 2.5, customer: \"Alder Works\", due: none }],\n ]),\n indexes: (index) => ({\n // The rail narrows each record through its own indexes (#1343): each event kind over its interval index — on its own,\n // and after its status, its machine or its person — so a narrowing keeps every event overlapping the window once.\n calendar_jobs_by_time: index.interval({ from: \"start\", to: \"end\" }),\n calendar_jobs_by_status_time: index.interval({ on: [\"status\"], from: \"start\", to: \"end\" }),\n calendar_jobs_by_machine_time: index.interval({ on: [\"machine\"], from: \"start\", to: \"end\" }),\n // Each job is indexed under every UTC day it touches, leaving an exact midnight end out.\n calendar_jobs_by_day: index.keys(East.function([StringType, CalendarJob], SetType(DateTimeType), ($, _key, row) => {\n const days = $.const(Calendar.days);\n return row.start.match({\n some: (_$, start) => row.end.match({ some: (_$, end) => days(start, end), none: () => East.value(new Set<Date>(), SetType(DateTimeType)) }),\n none: () => East.value(new Set<Date>(), SetType(DateTimeType)),\n });\n })),\n // The unscheduled rows are indexed by due date; they remain in the jobs record.\n calendar_jobs_unscheduled: index.keys(East.function([StringType, CalendarJob], SetType(OptionType(DateTimeType)), ($, _key, row) => {\n const unscheduled = $.const(Calendar.unscheduled);\n return unscheduled(row.start, row.due);\n })),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const calendarServices = e3.record(\"calendar_services\", DictType(StringType, CalendarService), {\n initial: new Map([\n [\"service1\", { title: \"Preventive maintenance\", start: new Date(\"2026-10-01T09:00:00Z\"), end: new Date(\"2026-10-01T11:00:00Z\"), machine: \"press1\", technician: \"ash\", notes: \"Inspect the tooling and check torque.\" }],\n [\"service2\", { title: \"Calibration\", start: new Date(\"2026-10-02T13:00:00Z\"), end: new Date(\"2026-10-02T14:00:00Z\"), machine: \"lathe1\", technician: \"cedar\", notes: \"Check against the reference gauge.\" }],\n ]),\n indexes: (index) => ({\n calendar_services_by_time: index.interval({ from: \"start\", to: \"end\" }),\n calendar_services_by_machine_time: index.interval({ on: [\"machine\"], from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const calendarShifts = e3.record(\"calendar_shifts\", DictType(StringType, CalendarShift), {\n initial: new Map([\n [\"shift1\", { title: \"Day shift\", start: new Date(\"2026-10-01T06:00:00Z\"), end: new Date(\"2026-10-01T14:00:00Z\"), person: \"ash\", notes: \"Press shop\" }],\n [\"shift2\", { title: \"Late shift\", start: new Date(\"2026-10-01T14:00:00Z\"), end: new Date(\"2026-10-01T22:00:00Z\"), person: \"birch\", notes: \"Machine shop\" }],\n ]),\n indexes: (index) => ({\n calendar_shifts_by_time: index.interval({ from: \"start\", to: \"end\" }),\n calendar_shifts_by_person_time: index.interval({ on: [\"person\"], from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const calendarJobTemplates = e3.record(\"calendar_job_templates\", DictType(StringType, CalendarJobTemplate), {\n initial: new Map([\n [\"brackets\", { name: \"Bracket batch\", group: \"Fabrication\", hours: 4.0, values: { title: \"Bracket batch\", status: variant(\"planned\", null), hours: 4.0, customer: \"\", due: none } }],\n [\"housings\", { name: \"Housing batch\", group: \"Machining\", hours: 2.0, values: { title: \"Housing batch\", status: variant(\"planned\", null), hours: 2.0, customer: \"\", due: none } }],\n ]),\n indexes: (index) => ({\n calendar_job_templates_by_group: index.on([\"group\"]),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const calendarServiceTemplates = e3.record(\"calendar_service_templates\", DictType(StringType, CalendarServiceTemplate), {\n initial: new Map([\n [\"calibration\", { name: \"Calibration\", group: \"Calibration\", hours: 1.0, values: { title: \"Calibration\", technician: \"cedar\", notes: \"Check against the reference gauge.\" } }],\n [\"service\", { name: \"Preventive maintenance\", group: \"Preventive\", hours: 2.0, values: { title: \"Preventive maintenance\", technician: \"ash\", notes: \"\" } }],\n ]),\n indexes: (index) => ({\n calendar_service_templates_by_group: index.on([\"group\"]),\n }),\n});\n\nexport const calendarShiftTemplates = e3.record(\"calendar_shift_templates\", DictType(StringType, CalendarShiftTemplate), {\n initial: new Map([\n [\"day\", { name: \"Day shift\", group: \"Day\", hour: 6n, values: { title: \"Day shift\", notes: \"\" } }],\n [\"late\", { name: \"Late shift\", group: \"Late\", hour: 14n, values: { title: \"Late shift\", notes: \"\" } }],\n ]),\n indexes: (index) => ({\n calendar_shift_templates_by_group: index.on([\"group\"]),\n }),\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n // What the Calendar reads whole binds with Data.bind, which keeps it loaded beside its pages; the event records\n // it writes bind with Record.bind, and it reads their events through their pages alone.\n const machines = $.let(Data.bind(calendarMachines));\n const people = $.let(Data.bind(calendarPeople));\n const jobs = $.let(Record.bind(calendarJobs));\n const services = $.let(Record.bind(calendarServices));\n const shifts = $.let(Record.bind(calendarShifts));\n const jobTemplates = $.let(Data.bind(calendarJobTemplates));\n const serviceTemplates = $.let(Data.bind(calendarServiceTemplates));\n const shiftTemplates = $.let(Data.bind(calendarShiftTemplates));\n // Every record paged: each event kind's interval indexes and its own entries, the others' fields' indexes.\n const jobIndex = $.let(Data.bindPaged(calendarJobs, { indexes: [\"calendar_jobs_by_time\", \"calendar_jobs_by_status_time\", \"calendar_jobs_by_machine_time\"] }));\n const serviceIndex = $.let(Data.bindPaged(calendarServices, { indexes: [\"calendar_services_by_time\", \"calendar_services_by_machine_time\"] }));\n const shiftIndex = $.let(Data.bindPaged(calendarShifts, { indexes: [\"calendar_shifts_by_time\", \"calendar_shifts_by_person_time\"] }));\n const machineIndex = $.let(Data.bindPaged(calendarMachines, { indexes: [\"calendar_machines_by_area\"] }));\n const peopleIndex = $.let(Data.bindPaged(calendarPeople, { indexes: [\"calendar_people_by_team\"] }));\n const jobTemplateIndex = $.let(Data.bindPaged(calendarJobTemplates, { indexes: [\"calendar_job_templates_by_group\"] }));\n const serviceTemplateIndex = $.let(Data.bindPaged(calendarServiceTemplates, { indexes: [\"calendar_service_templates_by_group\"] }));\n const shiftTemplateIndex = $.let(Data.bindPaged(calendarShiftTemplates, { indexes: [\"calendar_shift_templates_by_group\"] }));\n const jobEntries = $.let(Data.bindPaged(calendarJobs));\n const serviceEntries = $.let(Data.bindPaged(calendarServices));\n const shiftEntries = $.let(Data.bindPaged(calendarShifts));\n // One rail over every record, a source each (#1343): each event kind through its interval indexes, its range the\n // window the navigation writes in every kind at once; the machines, the people and each templates record by its fields.\n const slice = $.let(Slice.bindRecords(\"ex.calendarOperations\", {\n job: { source: jobIndex, icon: { prefix: \"fas\", name: \"industry\" },\n fields: { status: { label: \"Status\" }, machine: { label: \"Machine\", hints: [\"press1\", \"press2\", \"lathe1\", \"lathe2\", null] }, start: { label: \"Dates\" } }, range: \"start\" },\n service: { source: serviceIndex, icon: { prefix: \"fas\", name: \"screwdriver-wrench\" },\n fields: { machine: { label: \"Machine\", hints: [\"press1\", \"press2\", \"lathe1\", \"lathe2\"] }, start: { label: \"Dates\" } }, range: \"start\" },\n shift: { source: shiftIndex, icon: { prefix: \"fas\", name: \"user-clock\" },\n fields: { person: { label: \"Person\", hints: [\"ash\", \"birch\", \"cedar\"] }, start: { label: \"Dates\" } }, range: \"start\" },\n machines: { source: machineIndex, icon: { prefix: \"fas\", name: \"gears\" },\n fields: { area: { label: \"Area\", hints: [\"Press shop\", \"Machine shop\"] } } },\n people: { source: peopleIndex, icon: { prefix: \"fas\", name: \"users\" },\n fields: { team: { label: \"Team\", hints: [\"Maintenance\", \"Production\"] } } },\n jobTemplates: { source: jobTemplateIndex, icon: { prefix: \"fas\", name: \"layer-group\" },\n fields: { group: { label: \"Job template\", hints: [\"Fabrication\", \"Machining\"] } } },\n serviceTemplates: { source: serviceTemplateIndex, icon: { prefix: \"fas\", name: \"layer-group\" },\n fields: { group: { label: \"Service template\", hints: [\"Preventive\", \"Calibration\"] } } },\n shiftTemplates: { source: shiftTemplateIndex, icon: { prefix: \"fas\", name: \"layer-group\" },\n fields: { group: { label: \"Shift template\", hints: [\"Day\", \"Late\"] } } },\n }));\n return <Box height=\"760px\"><Calendar id=\"operations\" inspector view={{ date: new Date(\"2026-10-01T00:00:00Z\") }} now={new Date(\"2026-10-01T10:15:00Z\")}\n slice={{ slice }}\n resources={{\n machines: Calendar.resources(machines.read(), { name: \"Machines\", icon: \"gears\", label: row => row.name, meta: row => some(row.area) }),\n people: Calendar.resources(people.read(), { name: \"People\", icon: \"users\", label: row => row.name, meta: row => some(row.team) }),\n }}\n events={{\n job: Calendar.events(jobs, { name: \"Production\", icon: \"industry\", title: \"title\", start: \"start\", end: \"end\", resource: { field: \"machine\", of: \"machines\" },\n entries: jobEntries,\n status: { field: \"status\", cases: { planned: { label: \"Planned\", tone: variant(\"neutral\", null), ring: true }, active: { label: \"Active\", tone: variant(\"info\", null), ring: false }, done: { label: \"Done\", tone: variant(\"success\", null), ring: false } } },\n backlog: { duration: row => variant(\"hours\", row.hours), due: row => row.due },\n ready: row => row.hours.lessEqual(0).ifElse(() => variant(\"incomplete\", [{ field: \"hours\", message: \"Duration must be positive\" }]), () => variant(\"ready\", null)),\n templates: Calendar.templates(jobTemplates.read(), { name: row => row.name, group: row => some(row.group), duration: row => variant(\"hours\", row.hours), values: row => row.values, source: \"jobTemplates\" }),\n }),\n service: Calendar.events(services, { name: \"Maintenance\", icon: \"screwdriver-wrench\", title: \"title\", start: \"start\", end: \"end\", resource: { field: \"machine\", of: \"machines\" },\n entries: serviceEntries,\n fields: { technician: Calendar.field.reference({ of: \"people\" }) },\n templates: Calendar.templates(serviceTemplates.read(), { name: row => row.name, group: row => some(row.group), duration: row => variant(\"hours\", row.hours), values: row => row.values, source: \"serviceTemplates\" }),\n }),\n shift: Calendar.events(shifts, { name: \"Shift\", icon: \"user-clock\", title: \"title\", start: \"start\", end: \"end\", resource: { field: \"person\", of: \"people\" }, overlaps: \"allow\",\n entries: shiftEntries,\n templates: Calendar.templates(shiftTemplates.read(), { name: row => row.name, group: row => some(row.group), at: row => some({ hour: row.hour, minute: 0n }), duration: () => variant(\"hours\", 8.0), values: row => row.values, source: \"shiftTemplates\" }),\n }),\n }}\n library={[Calendar.library.templates(), Calendar.library.backlog(), Calendar.library.tab(people.read(), {\n name: \"Technicians\", icon: \"user-gear\", label: row => row.name, meta: row => some(row.team), group: row => row.team,\n drop: (_row, key) => Calendar.patch(CalendarService, { technician: key }), source: \"people\",\n })]} />\n </Box>;\n }}</Reactive>)"
41610
+ "source": "// A metal fabrication calendar over three event records and bound machines, people and templates: Calendar, Resources and Timeline share one frame, one Slice.bindRecords rail — a source per event kind, resource kind and template record — and Save history. Its library schedules the event record's backlog and assigns technicians; overlapping production and maintenance warn without blocking Save, and a stored job booked past the four hours a run takes is a warning beside the toolbar's issues, holding no Save.\n// inputs: []\n/** The resources of a small metal fabrication shop. */\nexport const CalendarMachine = StructType({ name: StringType, area: StringType });\n\n/** People the shifts run on and the maintenance library assigns. */\nexport const CalendarPerson = StructType({ name: StringType, team: StringType });\n\n/** A job's lifecycle. */\nexport const CalendarJobState = VariantType({ planned: NullType, active: NullType, done: NullType });\n\n/** A job may wait in the backlog; its own record holds its unscheduled rows. */\nexport const CalendarJob = StructType({ title: StringType, start: OptionType(DateTimeType), end: OptionType(DateTimeType), machine: OptionType(StringType),\n status: CalendarJobState, hours: FloatType, customer: StringType, due: OptionType(DateTimeType) });\n\n/** The initial job fields a template record supplies. */\nexport const CalendarJobValues = StructType({ title: StringType, status: CalendarJobState, hours: FloatType, customer: StringType, due: OptionType(DateTimeType) });\n\n/** Maintenance is a different record, with its own fields and patch mutation. */\nexport const CalendarService = StructType({ title: StringType, start: DateTimeType, end: DateTimeType, machine: StringType, technician: StringType, notes: StringType });\n\n/** A person's shift is its own event kind. */\nexport const CalendarShift = StructType({ title: StringType, start: DateTimeType, end: DateTimeType, person: StringType, notes: StringType });\n\n/** Job templates are live record data, including their duration and initial values; each has a group, which the rail narrows them by. */\nexport const CalendarJobTemplate = StructType({ name: StringType, group: StringType, hours: FloatType, values: CalendarJobValues });\n\n/** Maintenance templates are also bound data, grouped as the job templates are. */\nexport const CalendarServiceTemplate = StructType({ name: StringType, group: StringType, hours: FloatType, values: StructType({ title: StringType, technician: StringType, notes: StringType }) });\n\n/** Shift templates start at their hour when dropped on a day. */\nexport const CalendarShiftTemplate = StructType({ name: StringType, group: StringType, hour: IntegerType, values: StructType({ title: StringType, notes: StringType }) });\n\nexport const calendarMachines = e3.record(\"calendar_machines\", DictType(StringType, CalendarMachine), {\n initial: new Map([\n [\"press1\", { name: \"Press 1\", area: \"Press shop\" }], [\"press2\", { name: \"Press 2\", area: \"Press shop\" }],\n [\"lathe1\", { name: \"Lathe 1\", area: \"Machine shop\" }], [\"lathe2\", { name: \"Lathe 2\", area: \"Machine shop\" }],\n ]),\n indexes: (index) => ({\n calendar_machines_by_area: index.on([\"area\"]),\n }),\n mutations: (mutation) => ({\n // The shop edits its machines and job templates elsewhere, each through its patch door; the Calendar reads them live.\n patch: mutation.patch(),\n }),\n});\n\nexport const calendarPeople = e3.record(\"calendar_people\", DictType(StringType, CalendarPerson), {\n initial: new Map([\n [\"ash\", { name: \"A. Ash\", team: \"Maintenance\" }], [\"birch\", { name: \"B. Birch\", team: \"Production\" }], [\"cedar\", { name: \"C. Cedar\", team: \"Maintenance\" }],\n ]),\n indexes: (index) => ({\n calendar_people_by_team: index.on([\"team\"]),\n }),\n});\n\nexport const calendarJobs = e3.record(\"calendar_jobs\", DictType(StringType, CalendarJob), {\n initial: new Map([\n [\"job1\", { title: \"Mounting brackets · batch 42\", start: some(new Date(\"2026-10-01T06:00:00Z\")), end: some(new Date(\"2026-10-01T10:00:00Z\")), machine: some(\"press1\"), status: variant(\"active\", null), hours: 4.0, customer: \"Alder Works\", due: some(new Date(\"2026-10-02T00:00:00Z\")) }],\n [\"job2\", { title: \"Pump housings\", start: some(new Date(\"2026-10-01T08:00:00Z\")), end: some(new Date(\"2026-10-01T13:00:00Z\")), machine: some(\"lathe1\"), status: variant(\"planned\", null), hours: 5.0, customer: \"Birch Engineering\", due: none }],\n [\"job3\", { title: \"Long title: stainless steel mounting plates for the prototype assembly\", start: some(new Date(\"2026-10-01T11:00:00Z\")), end: some(new Date(\"2026-10-01T11:30:00Z\")), machine: some(\"press2\"), status: variant(\"planned\", null), hours: 0.5, customer: \"Cedar Fabrication\", due: none }],\n [\"job4\", { title: \"Bearing collars\", start: some(new Date(\"2026-10-02T09:00:00Z\")), end: some(new Date(\"2026-10-02T12:00:00Z\")), machine: some(\"lathe2\"), status: variant(\"planned\", null), hours: 3.0, customer: \"Alder Works\", due: none }],\n [\"job5\", { title: \"Overnight batch\", start: some(new Date(\"2026-10-01T22:00:00Z\")), end: some(new Date(\"2026-10-02T02:00:00Z\")), machine: some(\"press1\"), status: variant(\"planned\", null), hours: 4.0, customer: \"Birch Engineering\", due: none }],\n [\"job6\", { title: \"September closeout\", start: some(new Date(\"2026-09-30T08:00:00Z\")), end: some(new Date(\"2026-09-30T10:00:00Z\")), machine: some(\"press2\"), status: variant(\"done\", null), hours: 2.0, customer: \"Alder Works\", due: none }],\n [\"backlog1\", { title: \"Torque-test fixtures\", start: none, end: none, machine: some(\"press1\"), status: variant(\"planned\", null), hours: 2.0, customer: \"Alder Works\", due: some(new Date(\"2026-10-02T00:00:00Z\")) }],\n [\"backlog2\", { title: \"Valve bodies\", start: none, end: none, machine: none, status: variant(\"planned\", null), hours: 3.0, customer: \"Cedar Fabrication\", due: some(new Date(\"2026-10-06T00:00:00Z\")) }],\n [\"backlog3\", { title: \"Replacement shims\", start: none, end: none, machine: none, status: variant(\"planned\", null), hours: 1.0, customer: \"Birch Engineering\", due: some(new Date(\"2026-10-20T00:00:00Z\")) }],\n [\"backlog4\", { title: \"Prototype spacers\", start: none, end: none, machine: none, status: variant(\"planned\", null), hours: 2.5, customer: \"Alder Works\", due: none }],\n ]),\n indexes: (index) => ({\n // The rail narrows each record through its own indexes (#1343): each event kind over its interval index — on its own,\n // and after its status, its machine or its person — so a narrowing keeps every event overlapping the window once.\n calendar_jobs_by_time: index.interval({ from: \"start\", to: \"end\" }),\n calendar_jobs_by_status_time: index.interval({ on: [\"status\"], from: \"start\", to: \"end\" }),\n calendar_jobs_by_machine_time: index.interval({ on: [\"machine\"], from: \"start\", to: \"end\" }),\n // Each job is indexed under every UTC day it touches, leaving an exact midnight end out.\n calendar_jobs_by_day: index.keys(East.function([StringType, CalendarJob], SetType(DateTimeType), ($, _key, row) => {\n const days = $.const(Calendar.days);\n return row.start.match({\n some: (_$, start) => row.end.match({ some: (_$, end) => days(start, end), none: () => East.value(new Set<Date>(), SetType(DateTimeType)) }),\n none: () => East.value(new Set<Date>(), SetType(DateTimeType)),\n });\n })),\n // The unscheduled rows are indexed by due date; they remain in the jobs record.\n calendar_jobs_unscheduled: index.keys(East.function([StringType, CalendarJob], SetType(OptionType(DateTimeType)), ($, _key, row) => {\n const unscheduled = $.const(Calendar.unscheduled);\n return unscheduled(row.start, row.due);\n })),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const calendarServices = e3.record(\"calendar_services\", DictType(StringType, CalendarService), {\n initial: new Map([\n [\"service1\", { title: \"Preventive maintenance\", start: new Date(\"2026-10-01T09:00:00Z\"), end: new Date(\"2026-10-01T11:00:00Z\"), machine: \"press1\", technician: \"ash\", notes: \"Inspect the tooling and check torque.\" }],\n [\"service2\", { title: \"Calibration\", start: new Date(\"2026-10-02T13:00:00Z\"), end: new Date(\"2026-10-02T14:00:00Z\"), machine: \"lathe1\", technician: \"cedar\", notes: \"Check against the reference gauge.\" }],\n ]),\n indexes: (index) => ({\n calendar_services_by_time: index.interval({ from: \"start\", to: \"end\" }),\n calendar_services_by_machine_time: index.interval({ on: [\"machine\"], from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const calendarShifts = e3.record(\"calendar_shifts\", DictType(StringType, CalendarShift), {\n initial: new Map([\n [\"shift1\", { title: \"Day shift\", start: new Date(\"2026-10-01T06:00:00Z\"), end: new Date(\"2026-10-01T14:00:00Z\"), person: \"ash\", notes: \"Press shop\" }],\n [\"shift2\", { title: \"Late shift\", start: new Date(\"2026-10-01T14:00:00Z\"), end: new Date(\"2026-10-01T22:00:00Z\"), person: \"birch\", notes: \"Machine shop\" }],\n ]),\n indexes: (index) => ({\n calendar_shifts_by_time: index.interval({ from: \"start\", to: \"end\" }),\n calendar_shifts_by_person_time: index.interval({ on: [\"person\"], from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const calendarJobTemplates = e3.record(\"calendar_job_templates\", DictType(StringType, CalendarJobTemplate), {\n initial: new Map([\n [\"brackets\", { name: \"Bracket batch\", group: \"Fabrication\", hours: 4.0, values: { title: \"Bracket batch\", status: variant(\"planned\", null), hours: 4.0, customer: \"\", due: none } }],\n [\"housings\", { name: \"Housing batch\", group: \"Machining\", hours: 2.0, values: { title: \"Housing batch\", status: variant(\"planned\", null), hours: 2.0, customer: \"\", due: none } }],\n ]),\n indexes: (index) => ({\n calendar_job_templates_by_group: index.on([\"group\"]),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const calendarServiceTemplates = e3.record(\"calendar_service_templates\", DictType(StringType, CalendarServiceTemplate), {\n initial: new Map([\n [\"calibration\", { name: \"Calibration\", group: \"Calibration\", hours: 1.0, values: { title: \"Calibration\", technician: \"cedar\", notes: \"Check against the reference gauge.\" } }],\n [\"service\", { name: \"Preventive maintenance\", group: \"Preventive\", hours: 2.0, values: { title: \"Preventive maintenance\", technician: \"ash\", notes: \"\" } }],\n ]),\n indexes: (index) => ({\n calendar_service_templates_by_group: index.on([\"group\"]),\n }),\n});\n\nexport const calendarShiftTemplates = e3.record(\"calendar_shift_templates\", DictType(StringType, CalendarShiftTemplate), {\n initial: new Map([\n [\"day\", { name: \"Day shift\", group: \"Day\", hour: 6n, values: { title: \"Day shift\", notes: \"\" } }],\n [\"late\", { name: \"Late shift\", group: \"Late\", hour: 14n, values: { title: \"Late shift\", notes: \"\" } }],\n ]),\n indexes: (index) => ({\n calendar_shift_templates_by_group: index.on([\"group\"]),\n }),\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n // What the Calendar reads whole binds with Data.bind, which keeps it loaded beside its pages; the event records\n // it writes bind with Record.bind, and it reads their events through their pages alone.\n const machines = $.let(Data.bind(calendarMachines));\n const people = $.let(Data.bind(calendarPeople));\n const jobs = $.let(Record.bind(calendarJobs));\n const services = $.let(Record.bind(calendarServices));\n const shifts = $.let(Record.bind(calendarShifts));\n const jobTemplates = $.let(Data.bind(calendarJobTemplates));\n const serviceTemplates = $.let(Data.bind(calendarServiceTemplates));\n const shiftTemplates = $.let(Data.bind(calendarShiftTemplates));\n // Every record paged: each event kind's interval indexes and its own entries, the others' fields' indexes.\n const jobIndex = $.let(Data.bindPaged(calendarJobs, { indexes: [\"calendar_jobs_by_time\", \"calendar_jobs_by_status_time\", \"calendar_jobs_by_machine_time\"] }));\n const serviceIndex = $.let(Data.bindPaged(calendarServices, { indexes: [\"calendar_services_by_time\", \"calendar_services_by_machine_time\"] }));\n const shiftIndex = $.let(Data.bindPaged(calendarShifts, { indexes: [\"calendar_shifts_by_time\", \"calendar_shifts_by_person_time\"] }));\n const machineIndex = $.let(Data.bindPaged(calendarMachines, { indexes: [\"calendar_machines_by_area\"] }));\n const peopleIndex = $.let(Data.bindPaged(calendarPeople, { indexes: [\"calendar_people_by_team\"] }));\n const jobTemplateIndex = $.let(Data.bindPaged(calendarJobTemplates, { indexes: [\"calendar_job_templates_by_group\"] }));\n const serviceTemplateIndex = $.let(Data.bindPaged(calendarServiceTemplates, { indexes: [\"calendar_service_templates_by_group\"] }));\n const shiftTemplateIndex = $.let(Data.bindPaged(calendarShiftTemplates, { indexes: [\"calendar_shift_templates_by_group\"] }));\n const jobEntries = $.let(Data.bindPaged(calendarJobs));\n const serviceEntries = $.let(Data.bindPaged(calendarServices));\n const shiftEntries = $.let(Data.bindPaged(calendarShifts));\n // One rail over every record, a source each (#1343): each event kind through its interval indexes, its range the\n // window the navigation writes in every kind at once; the machines, the people and each templates record by its fields.\n const slice = $.let(Slice.bindRecords(\"ex.calendarOperations\", {\n job: { source: jobIndex, icon: { prefix: \"fas\", name: \"industry\" },\n fields: { status: { label: \"Status\" }, machine: { label: \"Machine\", hints: [\"press1\", \"press2\", \"lathe1\", \"lathe2\", null] }, start: { label: \"Dates\" } }, range: \"start\" },\n service: { source: serviceIndex, icon: { prefix: \"fas\", name: \"screwdriver-wrench\" },\n fields: { machine: { label: \"Machine\", hints: [\"press1\", \"press2\", \"lathe1\", \"lathe2\"] }, start: { label: \"Dates\" } }, range: \"start\" },\n shift: { source: shiftIndex, icon: { prefix: \"fas\", name: \"user-clock\" },\n fields: { person: { label: \"Person\", hints: [\"ash\", \"birch\", \"cedar\"] }, start: { label: \"Dates\" } }, range: \"start\" },\n machines: { source: machineIndex, icon: { prefix: \"fas\", name: \"gears\" },\n fields: { area: { label: \"Area\", hints: [\"Press shop\", \"Machine shop\"] } } },\n people: { source: peopleIndex, icon: { prefix: \"fas\", name: \"users\" },\n fields: { team: { label: \"Team\", hints: [\"Maintenance\", \"Production\"] } } },\n jobTemplates: { source: jobTemplateIndex, icon: { prefix: \"fas\", name: \"layer-group\" },\n fields: { group: { label: \"Job template\", hints: [\"Fabrication\", \"Machining\"] } } },\n serviceTemplates: { source: serviceTemplateIndex, icon: { prefix: \"fas\", name: \"layer-group\" },\n fields: { group: { label: \"Service template\", hints: [\"Preventive\", \"Calibration\"] } } },\n shiftTemplates: { source: shiftTemplateIndex, icon: { prefix: \"fas\", name: \"layer-group\" },\n fields: { group: { label: \"Shift template\", hints: [\"Day\", \"Late\"] } } },\n }));\n return <Box height=\"760px\"><Calendar id=\"operations\" inspector view={{ date: new Date(\"2026-10-01T00:00:00Z\") }} now={new Date(\"2026-10-01T10:15:00Z\")}\n slice={{ slice }}\n resources={{\n machines: Calendar.resources(machines.read(), { name: \"Machines\", icon: \"gears\", label: row => row.name, meta: row => some(row.area) }),\n people: Calendar.resources(people.read(), { name: \"People\", icon: \"users\", label: row => row.name, meta: row => some(row.team) }),\n }}\n events={{\n job: Calendar.events(jobs, { name: \"Production\", icon: \"industry\", title: \"title\", start: \"start\", end: \"end\", resource: { field: \"machine\", of: \"machines\" },\n entries: jobEntries,\n status: { field: \"status\", cases: { planned: { label: \"Planned\", tone: variant(\"neutral\", null), ring: true }, active: { label: \"Active\", tone: variant(\"info\", null), ring: false }, done: { label: \"Done\", tone: variant(\"success\", null), ring: false } } },\n backlog: { duration: row => variant(\"hours\", row.hours), due: row => row.due },\n // The shop books a machine for at most four hours at a time, half a shift, so a longer job is split\n // into runs: the pump housings' five hours are booked as one.\n fields: { hours: Calendar.field.number({ label: \"Hours\", max: 4.0 }) },\n ready: row => row.hours.lessEqual(0).ifElse(() => variant(\"incomplete\", [{ field: \"hours\", message: \"Duration must be positive\" }]), () => variant(\"ready\", null)),\n templates: Calendar.templates(jobTemplates.read(), { name: row => row.name, group: row => some(row.group), duration: row => variant(\"hours\", row.hours), values: row => row.values, source: \"jobTemplates\" }),\n }),\n service: Calendar.events(services, { name: \"Maintenance\", icon: \"screwdriver-wrench\", title: \"title\", start: \"start\", end: \"end\", resource: { field: \"machine\", of: \"machines\" },\n entries: serviceEntries,\n fields: { technician: Calendar.field.reference({ of: \"people\" }) },\n templates: Calendar.templates(serviceTemplates.read(), { name: row => row.name, group: row => some(row.group), duration: row => variant(\"hours\", row.hours), values: row => row.values, source: \"serviceTemplates\" }),\n }),\n shift: Calendar.events(shifts, { name: \"Shift\", icon: \"user-clock\", title: \"title\", start: \"start\", end: \"end\", resource: { field: \"person\", of: \"people\" }, overlaps: \"allow\",\n entries: shiftEntries,\n templates: Calendar.templates(shiftTemplates.read(), { name: row => row.name, group: row => some(row.group), at: row => some({ hour: row.hour, minute: 0n }), duration: () => variant(\"hours\", 8.0), values: row => row.values, source: \"shiftTemplates\" }),\n }),\n }}\n library={[Calendar.library.templates(), Calendar.library.backlog(), Calendar.library.tab(people.read(), {\n name: \"Technicians\", icon: \"user-gear\", label: row => row.name, meta: row => some(row.team), group: row => row.team,\n drop: (_row, key) => Calendar.patch(CalendarService, { technician: key }), source: \"people\",\n })]} />\n </Box>;\n }}</Reactive>)"
41427
41611
  },
41428
41612
  {
41429
41613
  "id": "e3-ui:calendar.examples.tsx:calendarWording",
@@ -41444,7 +41628,7 @@
41444
41628
  "Slice.bindRecords"
41445
41629
  ],
41446
41630
  "imports": [
41447
- "import { ArrayType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
41631
+ "import { ArrayType, BooleanType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
41448
41632
  "import { Box, Button, HStack, Input, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
41449
41633
  "import { Calendar, Data, Record } from \"@elaraai/e3-ui\";",
41450
41634
  "import e3 from \"@elaraai/e3\";"
@@ -41473,7 +41657,7 @@
41473
41657
  "templates"
41474
41658
  ],
41475
41659
  "imports": [
41476
- "import { ArrayType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
41660
+ "import { ArrayType, BooleanType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
41477
41661
  "import { Box, Button, HStack, Input, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
41478
41662
  "import { Calendar, Data, Record } from \"@elaraai/e3-ui\";",
41479
41663
  "import e3 from \"@elaraai/e3\";"
@@ -41498,7 +41682,7 @@
41498
41682
  "overlaps"
41499
41683
  ],
41500
41684
  "imports": [
41501
- "import { ArrayType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
41685
+ "import { ArrayType, BooleanType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
41502
41686
  "import { Box, Button, HStack, Input, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
41503
41687
  "import { Calendar, Data, Record } from \"@elaraai/e3-ui\";",
41504
41688
  "import e3 from \"@elaraai/e3\";"
@@ -41524,7 +41708,7 @@
41524
41708
  "optional panes"
41525
41709
  ],
41526
41710
  "imports": [
41527
- "import { ArrayType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
41711
+ "import { ArrayType, BooleanType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
41528
41712
  "import { Box, Button, HStack, Input, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
41529
41713
  "import { Calendar, Data, Record } from \"@elaraai/e3-ui\";",
41530
41714
  "import e3 from \"@elaraai/e3\";"
@@ -41561,7 +41745,7 @@
41561
41745
  "Reactive"
41562
41746
  ],
41563
41747
  "imports": [
41564
- "import { ArrayType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
41748
+ "import { ArrayType, BooleanType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
41565
41749
  "import { Box, Button, HStack, Input, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
41566
41750
  "import { Calendar, Data, Record } from \"@elaraai/e3-ui\";",
41567
41751
  "import e3 from \"@elaraai/e3\";"
@@ -41571,6 +41755,67 @@
41571
41755
  ],
41572
41756
  "source": "// Which layouts an instance offers, chosen as the page runs: a multi-select wired into `views`, an expression of an array of Calendar.Types.Layout. A layout left out loses its button and is never drawn; with one left no switch shows, and with none chosen, all three. `views={[\"calendar\", \"timeline\"]}` writes the same choice in the code. A second multi-select does the same for the periods through `viewPeriods`.\n// inputs: []\n/** The resources of a small metal fabrication shop. */\nexport const CalendarMachine = StructType({ name: StringType, area: StringType });\n\n/** A job's lifecycle. */\nexport const CalendarJobState = VariantType({ planned: NullType, active: NullType, done: NullType });\n\n/** A job may wait in the backlog; its own record holds its unscheduled rows. */\nexport const CalendarJob = StructType({ title: StringType, start: OptionType(DateTimeType), end: OptionType(DateTimeType), machine: OptionType(StringType),\n status: CalendarJobState, hours: FloatType, customer: StringType, due: OptionType(DateTimeType) });\n\nexport const calendarMachines = e3.record(\"calendar_machines\", DictType(StringType, CalendarMachine), {\n initial: new Map([\n [\"press1\", { name: \"Press 1\", area: \"Press shop\" }], [\"press2\", { name: \"Press 2\", area: \"Press shop\" }],\n [\"lathe1\", { name: \"Lathe 1\", area: \"Machine shop\" }], [\"lathe2\", { name: \"Lathe 2\", area: \"Machine shop\" }],\n ]),\n indexes: (index) => ({\n calendar_machines_by_area: index.on([\"area\"]),\n }),\n mutations: (mutation) => ({\n // The shop edits its machines and job templates elsewhere, each through its patch door; the Calendar reads them live.\n patch: mutation.patch(),\n }),\n});\n\nexport const calendarJobs = e3.record(\"calendar_jobs\", DictType(StringType, CalendarJob), {\n initial: new Map([\n [\"job1\", { title: \"Mounting brackets · batch 42\", start: some(new Date(\"2026-10-01T06:00:00Z\")), end: some(new Date(\"2026-10-01T10:00:00Z\")), machine: some(\"press1\"), status: variant(\"active\", null), hours: 4.0, customer: \"Alder Works\", due: some(new Date(\"2026-10-02T00:00:00Z\")) }],\n [\"job2\", { title: \"Pump housings\", start: some(new Date(\"2026-10-01T08:00:00Z\")), end: some(new Date(\"2026-10-01T13:00:00Z\")), machine: some(\"lathe1\"), status: variant(\"planned\", null), hours: 5.0, customer: \"Birch Engineering\", due: none }],\n [\"job3\", { title: \"Long title: stainless steel mounting plates for the prototype assembly\", start: some(new Date(\"2026-10-01T11:00:00Z\")), end: some(new Date(\"2026-10-01T11:30:00Z\")), machine: some(\"press2\"), status: variant(\"planned\", null), hours: 0.5, customer: \"Cedar Fabrication\", due: none }],\n [\"job4\", { title: \"Bearing collars\", start: some(new Date(\"2026-10-02T09:00:00Z\")), end: some(new Date(\"2026-10-02T12:00:00Z\")), machine: some(\"lathe2\"), status: variant(\"planned\", null), hours: 3.0, customer: \"Alder Works\", due: none }],\n [\"job5\", { title: \"Overnight batch\", start: some(new Date(\"2026-10-01T22:00:00Z\")), end: some(new Date(\"2026-10-02T02:00:00Z\")), machine: some(\"press1\"), status: variant(\"planned\", null), hours: 4.0, customer: \"Birch Engineering\", due: none }],\n [\"job6\", { title: \"September closeout\", start: some(new Date(\"2026-09-30T08:00:00Z\")), end: some(new Date(\"2026-09-30T10:00:00Z\")), machine: some(\"press2\"), status: variant(\"done\", null), hours: 2.0, customer: \"Alder Works\", due: none }],\n [\"backlog1\", { title: \"Torque-test fixtures\", start: none, end: none, machine: some(\"press1\"), status: variant(\"planned\", null), hours: 2.0, customer: \"Alder Works\", due: some(new Date(\"2026-10-02T00:00:00Z\")) }],\n [\"backlog2\", { title: \"Valve bodies\", start: none, end: none, machine: none, status: variant(\"planned\", null), hours: 3.0, customer: \"Cedar Fabrication\", due: some(new Date(\"2026-10-06T00:00:00Z\")) }],\n [\"backlog3\", { title: \"Replacement shims\", start: none, end: none, machine: none, status: variant(\"planned\", null), hours: 1.0, customer: \"Birch Engineering\", due: some(new Date(\"2026-10-20T00:00:00Z\")) }],\n [\"backlog4\", { title: \"Prototype spacers\", start: none, end: none, machine: none, status: variant(\"planned\", null), hours: 2.5, customer: \"Alder Works\", due: none }],\n ]),\n indexes: (index) => ({\n // The rail narrows each record through its own indexes (#1343): each event kind over its interval index — on its own,\n // and after its status, its machine or its person — so a narrowing keeps every event overlapping the window once.\n calendar_jobs_by_time: index.interval({ from: \"start\", to: \"end\" }),\n calendar_jobs_by_status_time: index.interval({ on: [\"status\"], from: \"start\", to: \"end\" }),\n calendar_jobs_by_machine_time: index.interval({ on: [\"machine\"], from: \"start\", to: \"end\" }),\n // Each job is indexed under every UTC day it touches, leaving an exact midnight end out.\n calendar_jobs_by_day: index.keys(East.function([StringType, CalendarJob], SetType(DateTimeType), ($, _key, row) => {\n const days = $.const(Calendar.days);\n return row.start.match({\n some: (_$, start) => row.end.match({ some: (_$, end) => days(start, end), none: () => East.value(new Set<Date>(), SetType(DateTimeType)) }),\n none: () => East.value(new Set<Date>(), SetType(DateTimeType)),\n });\n })),\n // The unscheduled rows are indexed by due date; they remain in the jobs record.\n calendar_jobs_unscheduled: index.keys(East.function([StringType, CalendarJob], SetType(OptionType(DateTimeType)), ($, _key, row) => {\n const unscheduled = $.const(Calendar.unscheduled);\n return unscheduled(row.start, row.due);\n })),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const machines = $.let(Record.bind(calendarMachines, []));\n const jobs = $.let(Record.bind(calendarJobs));\n // The tags the multi-select holds, and the layouts they name.\n const chosen = $.let(State.bind([ArrayType(StringType)], \"ex.calendarViews.views\", []));\n const tags = $.let(chosen.read());\n const onViews = $.const(East.function([ArrayType(StringType)], NullType, ($, next) => { $(chosen.write(next)); }));\n const every = $.const([variant(\"calendar\", null), variant(\"resources\", null), variant(\"timeline\", null)], ArrayType(Calendar.Types.Layout));\n const views = $.let(every.filter(($, view) => tags.toSet().has(view.getTag())));\n // And the periods.\n const chosenPeriods = $.let(State.bind([ArrayType(StringType)], \"ex.calendarViews.periods\", []));\n const periodTags = $.let(chosenPeriods.read());\n const onPeriods = $.const(East.function([ArrayType(StringType)], NullType, ($, next) => { $(chosenPeriods.write(next)); }));\n const everyPeriod = $.const([variant(\"day\", null), variant(\"week\", null), variant(\"month\", null)], ArrayType(Calendar.Types.Period));\n const viewPeriods = $.let(everyPeriod.filter(($, period) => periodTags.toSet().has(period.getTag())));\n return <VStack gap=\"3\" align=\"stretch\" width=\"100%\">\n <HStack gap=\"2\" align=\"center\"><Text>Views</Text><Select value=\"\" placeholder=\"Every view\" multiple={true} onChangeMultiple={onViews}\n items={[Select.Item(\"calendar\", \"Calendar\"), Select.Item(\"resources\", \"Resources\"), Select.Item(\"timeline\", \"Timeline\")]} /></HStack>\n <HStack gap=\"2\" align=\"center\"><Text>Periods</Text><Select value=\"\" placeholder=\"Every period\" multiple={true} onChangeMultiple={onPeriods}\n items={[Select.Item(\"day\", \"Day\"), Select.Item(\"week\", \"Week\"), Select.Item(\"month\", \"Month\")]} /></HStack>\n <Box height=\"620px\"><Calendar id=\"calendarViews\" views={views} viewPeriods={viewPeriods} view={{ period: \"day\", date: new Date(\"2026-10-01T00:00:00Z\") }} now={new Date(\"2026-10-01T10:15:00Z\")}\n resources={{ machines: Calendar.resources(machines.read(), { name: \"Machines\", icon: \"gears\", label: row => row.name }) }}\n events={{ job: Calendar.events(jobs, { name: \"Production\", icon: \"industry\", title: \"title\", start: \"start\", end: \"end\", resource: { field: \"machine\", of: \"machines\" }, backlog: { duration: row => variant(\"hours\", row.hours), due: row => row.due } }) }} />\n </Box>\n </VStack>;\n }}</Reactive>)"
41573
41757
  },
41758
+ {
41759
+ "id": "e3-ui:calendar.examples.tsx:calendarEventTitles",
41760
+ "skill": "e3-ui",
41761
+ "package": "e3-ui",
41762
+ "file": "east-ui/packages/e3-ui/test/calendar/calendar.examples.tsx",
41763
+ "suite": "",
41764
+ "test": "Events titled by what they are, where no String field of the row says it: a machine's bookings hold their kind as a variant, so `title` is a function of the row, a word per case. Its value is the event's title wherever one is drawn or read: the grids, the Timeline, the agenda, the inspector and a search. The title is a String field's name everywhere else.",
41765
+ "keywords": [
41766
+ "Calendar",
41767
+ "Calendar.events",
41768
+ "Schedule.events",
41769
+ "title",
41770
+ "function of the row",
41771
+ "accessor",
41772
+ "variant",
41773
+ "match",
41774
+ "status",
41775
+ "Timeline",
41776
+ "Record.bind"
41777
+ ],
41778
+ "imports": [
41779
+ "import { ArrayType, BooleanType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
41780
+ "import { Box, Button, HStack, Input, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
41781
+ "import { Calendar, Data, Record } from \"@elaraai/e3-ui\";",
41782
+ "import e3 from \"@elaraai/e3\";"
41783
+ ],
41784
+ "languages": [
41785
+ "tsx"
41786
+ ],
41787
+ "source": "// Events titled by what they are, where no String field of the row says it: a machine's bookings hold their kind as a variant, so `title` is a function of the row, a word per case. Its value is the event's title wherever one is drawn or read: the grids, the Timeline, the agenda, the inspector and a search. The title is a String field's name everywhere else.\n// inputs: []\n/** The resources of a small metal fabrication shop. */\nexport const CalendarMachine = StructType({ name: StringType, area: StringType });\n\nexport const calendarMachines = e3.record(\"calendar_machines\", DictType(StringType, CalendarMachine), {\n initial: new Map([\n [\"press1\", { name: \"Press 1\", area: \"Press shop\" }], [\"press2\", { name: \"Press 2\", area: \"Press shop\" }],\n [\"lathe1\", { name: \"Lathe 1\", area: \"Machine shop\" }], [\"lathe2\", { name: \"Lathe 2\", area: \"Machine shop\" }],\n ]),\n indexes: (index) => ({\n calendar_machines_by_area: index.on([\"area\"]),\n }),\n mutations: (mutation) => ({\n // The shop edits its machines and job templates elsewhere, each through its patch door; the Calendar reads them live.\n patch: mutation.patch(),\n }),\n});\n\n/** What a machine's booking is for: a variant, so no String field of the row says it. */\nexport const CalendarBookingKind = VariantType({ preventive: NullType, calibration: NullType, repair: NullType });\n\n/** A machine's booking: which machine and what for. */\nexport const CalendarBooking = StructType({ machine: StringType, kind: CalendarBookingKind, start: DateTimeType, end: DateTimeType });\n\nexport const calendarBookings = e3.record(\"calendar_bookings\", DictType(StringType, CalendarBooking), {\n initial: new Map([\n [\"b1\", { machine: \"press1\", kind: variant(\"preventive\", null), start: new Date(\"2026-09-29T08:00:00Z\"), end: new Date(\"2026-09-29T12:00:00Z\") }],\n [\"b2\", { machine: \"lathe1\", kind: variant(\"calibration\", null), start: new Date(\"2026-10-01T09:00:00Z\"), end: new Date(\"2026-10-01T11:00:00Z\") }],\n [\"b3\", { machine: \"press2\", kind: variant(\"repair\", null), start: new Date(\"2026-10-01T13:00:00Z\"), end: new Date(\"2026-10-01T17:00:00Z\") }],\n [\"b4\", { machine: \"lathe2\", kind: variant(\"preventive\", null), start: new Date(\"2026-10-02T07:00:00Z\"), end: new Date(\"2026-10-02T10:00:00Z\") }],\n ]),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const machines = $.let(Record.bind(calendarMachines, []));\n const bookings = $.let(Record.bind(calendarBookings));\n return <Box height=\"560px\"><Calendar id=\"bookings\" inspector view={{ layout: \"timeline\", period: \"week\", date: new Date(\"2026-10-01T00:00:00Z\") }} now={new Date(\"2026-10-01T10:15:00Z\")}\n resources={{ machines: Calendar.resources(machines.read(), { name: \"Machines\", icon: \"gears\", label: row => row.name }) }}\n events={{ booking: Calendar.events(bookings, { name: \"Maintenance\", icon: \"screwdriver-wrench\",\n title: row => row.kind.match({ preventive: () => \"Preventive\", calibration: () => \"Calibration\", repair: () => \"Repair\" }),\n start: \"start\", end: \"end\", resource: { field: \"machine\", of: \"machines\" },\n status: { field: \"kind\", cases: { preventive: { label: \"Preventive\", tone: variant(\"info\", null), ring: false }, calibration: { label: \"Calibration\", tone: variant(\"neutral\", null), ring: false }, repair: { label: \"Repair\", tone: variant(\"success\", null), ring: false } } },\n }) }} />\n </Box>;\n }}</Reactive>)"
41788
+ },
41789
+ {
41790
+ "id": "e3-ui:calendar.examples.tsx:calendarTimelineAlone",
41791
+ "skill": "e3-ui",
41792
+ "package": "e3-ui",
41793
+ "file": "east-ui/packages/e3-ui/test/calendar/calendar.examples.tsx",
41794
+ "suite": "",
41795
+ "test": "A Calendar offering the Timeline alone, over two of its periods: `views` lists the layouts it offers and `viewPeriods` the periods, by the names `view.layout` and `view.period` take. One layout listed, no layout switch shows, and events laid out by resource never pile into a day's cell. A `view` outside either list is refused as the page is built, naming both.",
41796
+ "keywords": [
41797
+ "Calendar",
41798
+ "views",
41799
+ "viewPeriods",
41800
+ "Timeline",
41801
+ "layout",
41802
+ "period",
41803
+ "view",
41804
+ "resources",
41805
+ "no switch",
41806
+ "Record.bind"
41807
+ ],
41808
+ "imports": [
41809
+ "import { ArrayType, BooleanType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
41810
+ "import { Box, Button, HStack, Input, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
41811
+ "import { Calendar, Data, Record } from \"@elaraai/e3-ui\";",
41812
+ "import e3 from \"@elaraai/e3\";"
41813
+ ],
41814
+ "languages": [
41815
+ "tsx"
41816
+ ],
41817
+ "source": "// A Calendar offering the Timeline alone, over two of its periods: `views` lists the layouts it offers and `viewPeriods` the periods, by the names `view.layout` and `view.period` take. One layout listed, no layout switch shows, and events laid out by resource never pile into a day's cell. A `view` outside either list is refused as the page is built, naming both.\n// inputs: []\n/** The resources of a small metal fabrication shop. */\nexport const CalendarMachine = StructType({ name: StringType, area: StringType });\n\n/** A job's lifecycle. */\nexport const CalendarJobState = VariantType({ planned: NullType, active: NullType, done: NullType });\n\n/** A job may wait in the backlog; its own record holds its unscheduled rows. */\nexport const CalendarJob = StructType({ title: StringType, start: OptionType(DateTimeType), end: OptionType(DateTimeType), machine: OptionType(StringType),\n status: CalendarJobState, hours: FloatType, customer: StringType, due: OptionType(DateTimeType) });\n\nexport const calendarMachines = e3.record(\"calendar_machines\", DictType(StringType, CalendarMachine), {\n initial: new Map([\n [\"press1\", { name: \"Press 1\", area: \"Press shop\" }], [\"press2\", { name: \"Press 2\", area: \"Press shop\" }],\n [\"lathe1\", { name: \"Lathe 1\", area: \"Machine shop\" }], [\"lathe2\", { name: \"Lathe 2\", area: \"Machine shop\" }],\n ]),\n indexes: (index) => ({\n calendar_machines_by_area: index.on([\"area\"]),\n }),\n mutations: (mutation) => ({\n // The shop edits its machines and job templates elsewhere, each through its patch door; the Calendar reads them live.\n patch: mutation.patch(),\n }),\n});\n\nexport const calendarJobs = e3.record(\"calendar_jobs\", DictType(StringType, CalendarJob), {\n initial: new Map([\n [\"job1\", { title: \"Mounting brackets · batch 42\", start: some(new Date(\"2026-10-01T06:00:00Z\")), end: some(new Date(\"2026-10-01T10:00:00Z\")), machine: some(\"press1\"), status: variant(\"active\", null), hours: 4.0, customer: \"Alder Works\", due: some(new Date(\"2026-10-02T00:00:00Z\")) }],\n [\"job2\", { title: \"Pump housings\", start: some(new Date(\"2026-10-01T08:00:00Z\")), end: some(new Date(\"2026-10-01T13:00:00Z\")), machine: some(\"lathe1\"), status: variant(\"planned\", null), hours: 5.0, customer: \"Birch Engineering\", due: none }],\n [\"job3\", { title: \"Long title: stainless steel mounting plates for the prototype assembly\", start: some(new Date(\"2026-10-01T11:00:00Z\")), end: some(new Date(\"2026-10-01T11:30:00Z\")), machine: some(\"press2\"), status: variant(\"planned\", null), hours: 0.5, customer: \"Cedar Fabrication\", due: none }],\n [\"job4\", { title: \"Bearing collars\", start: some(new Date(\"2026-10-02T09:00:00Z\")), end: some(new Date(\"2026-10-02T12:00:00Z\")), machine: some(\"lathe2\"), status: variant(\"planned\", null), hours: 3.0, customer: \"Alder Works\", due: none }],\n [\"job5\", { title: \"Overnight batch\", start: some(new Date(\"2026-10-01T22:00:00Z\")), end: some(new Date(\"2026-10-02T02:00:00Z\")), machine: some(\"press1\"), status: variant(\"planned\", null), hours: 4.0, customer: \"Birch Engineering\", due: none }],\n [\"job6\", { title: \"September closeout\", start: some(new Date(\"2026-09-30T08:00:00Z\")), end: some(new Date(\"2026-09-30T10:00:00Z\")), machine: some(\"press2\"), status: variant(\"done\", null), hours: 2.0, customer: \"Alder Works\", due: none }],\n [\"backlog1\", { title: \"Torque-test fixtures\", start: none, end: none, machine: some(\"press1\"), status: variant(\"planned\", null), hours: 2.0, customer: \"Alder Works\", due: some(new Date(\"2026-10-02T00:00:00Z\")) }],\n [\"backlog2\", { title: \"Valve bodies\", start: none, end: none, machine: none, status: variant(\"planned\", null), hours: 3.0, customer: \"Cedar Fabrication\", due: some(new Date(\"2026-10-06T00:00:00Z\")) }],\n [\"backlog3\", { title: \"Replacement shims\", start: none, end: none, machine: none, status: variant(\"planned\", null), hours: 1.0, customer: \"Birch Engineering\", due: some(new Date(\"2026-10-20T00:00:00Z\")) }],\n [\"backlog4\", { title: \"Prototype spacers\", start: none, end: none, machine: none, status: variant(\"planned\", null), hours: 2.5, customer: \"Alder Works\", due: none }],\n ]),\n indexes: (index) => ({\n // The rail narrows each record through its own indexes (#1343): each event kind over its interval index — on its own,\n // and after its status, its machine or its person — so a narrowing keeps every event overlapping the window once.\n calendar_jobs_by_time: index.interval({ from: \"start\", to: \"end\" }),\n calendar_jobs_by_status_time: index.interval({ on: [\"status\"], from: \"start\", to: \"end\" }),\n calendar_jobs_by_machine_time: index.interval({ on: [\"machine\"], from: \"start\", to: \"end\" }),\n // Each job is indexed under every UTC day it touches, leaving an exact midnight end out.\n calendar_jobs_by_day: index.keys(East.function([StringType, CalendarJob], SetType(DateTimeType), ($, _key, row) => {\n const days = $.const(Calendar.days);\n return row.start.match({\n some: (_$, start) => row.end.match({ some: (_$, end) => days(start, end), none: () => East.value(new Set<Date>(), SetType(DateTimeType)) }),\n none: () => East.value(new Set<Date>(), SetType(DateTimeType)),\n });\n })),\n // The unscheduled rows are indexed by due date; they remain in the jobs record.\n calendar_jobs_unscheduled: index.keys(East.function([StringType, CalendarJob], SetType(OptionType(DateTimeType)), ($, _key, row) => {\n const unscheduled = $.const(Calendar.unscheduled);\n return unscheduled(row.start, row.due);\n })),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const machines = $.let(Record.bind(calendarMachines, []));\n const jobs = $.let(Record.bind(calendarJobs));\n return <Box height=\"560px\"><Calendar id=\"timelineAlone\" views={[\"timeline\"]} viewPeriods={[\"week\", \"month\"]} view={{ layout: \"timeline\", period: \"week\", date: new Date(\"2026-10-01T00:00:00Z\") }} now={new Date(\"2026-10-01T10:15:00Z\")}\n resources={{ machines: Calendar.resources(machines.read(), { name: \"Machines\", icon: \"gears\", label: row => row.name }) }}\n events={{ job: Calendar.events(jobs, { name: \"Production\", icon: \"industry\", title: \"title\", start: \"start\", end: \"end\", resource: { field: \"machine\", of: \"machines\" } }) }} />\n </Box>;\n }}</Reactive>)"
41818
+ },
41574
41819
  {
41575
41820
  "id": "e3-ui:calendar.examples.tsx:calendarWindowed",
41576
41821
  "skill": "e3-ui",
@@ -41590,7 +41835,7 @@
41590
41835
  "Save"
41591
41836
  ],
41592
41837
  "imports": [
41593
- "import { ArrayType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
41838
+ "import { ArrayType, BooleanType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
41594
41839
  "import { Box, Button, HStack, Input, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
41595
41840
  "import { Calendar, Data, Record } from \"@elaraai/e3-ui\";",
41596
41841
  "import e3 from \"@elaraai/e3\";"
@@ -41615,7 +41860,7 @@
41615
41860
  "Save"
41616
41861
  ],
41617
41862
  "imports": [
41618
- "import { ArrayType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
41863
+ "import { ArrayType, BooleanType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
41619
41864
  "import { Box, Button, HStack, Input, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
41620
41865
  "import { Calendar, Data, Record } from \"@elaraai/e3-ui\";",
41621
41866
  "import e3 from \"@elaraai/e3\";"
@@ -41641,7 +41886,7 @@
41641
41886
  "Record.bind"
41642
41887
  ],
41643
41888
  "imports": [
41644
- "import { ArrayType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
41889
+ "import { ArrayType, BooleanType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
41645
41890
  "import { Box, Button, HStack, Input, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
41646
41891
  "import { Calendar, Data, Record } from \"@elaraai/e3-ui\";",
41647
41892
  "import e3 from \"@elaraai/e3\";"
@@ -41651,6 +41896,36 @@
41651
41896
  ],
41652
41897
  "source": "// A typed custom appointment inspector updates the whole row through Calendar's shared Undo, Redo and Save session.\n// inputs: []\n/** The smallest event record needs only its title and two instants. */\nexport const CalendarAppointment = StructType({ title: StringType, start: DateTimeType, end: DateTimeType });\n\nexport const calendarAppointments = e3.record(\"calendar_appointments\", DictType(StringType, CalendarAppointment), {\n initial: new Map([\n [\"check\", { title: \"Safety check\", start: new Date(\"2026-10-01T09:00:00Z\"), end: new Date(\"2026-10-01T10:00:00Z\") }],\n [\"review\", { title: \"Production review\", start: new Date(\"2026-10-01T11:00:00Z\"), end: new Date(\"2026-10-01T12:00:00Z\") }],\n ]),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const appointments = $.let(Record.bind(calendarAppointments));\n const inspect = $.const(East.function([CalendarAppointment, FunctionType([CalendarAppointment], NullType)], UIComponentType, ($2, row, update) => {\n const change = $2.const(East.function([StringType], NullType, ($3, title) => { $3(update({ title, start: row.start, end: row.end })); }));\n return <Input.String value={row.title} placeholder=\"Appointment title\" onChange={change} />;\n }));\n return <Box height=\"640px\"><Calendar inspector view={{ period: \"day\", date: new Date(\"2026-10-01T00:00:00Z\") }}\n events={{ appointment: Calendar.events(appointments, { name: \"Appointment\", icon: \"calendar\", title: \"title\", start: \"start\", end: \"end\", inspector: inspect }) }} />\n </Box>;\n }}</Reactive>)"
41653
41898
  },
41899
+ {
41900
+ "id": "e3-ui:calendar.examples.tsx:calendarAutosave",
41901
+ "skill": "e3-ui",
41902
+ "package": "e3-ui",
41903
+ "file": "east-ui/packages/e3-ui/test/calendar/calendar.examples.tsx",
41904
+ "suite": "",
41905
+ "test": "Where Autosave begins is the author's to say: `autosave` takes a literal (`autosave`, `autosave={false}`) or an expression — here an input of the app's, so its data decides. The switch in Save's menu starts on, and each change is saved by itself a pause after the viewer's last act; an Undo or a Redo waits for a press of Save. A viewer's own flick of the switch is kept in their browser, and stands over what the author says.",
41906
+ "keywords": [
41907
+ "Calendar",
41908
+ "autosave",
41909
+ "Autosave",
41910
+ "Save",
41911
+ "default",
41912
+ "Data.bind",
41913
+ "input",
41914
+ "Record.bind",
41915
+ "editing",
41916
+ "history"
41917
+ ],
41918
+ "imports": [
41919
+ "import { ArrayType, BooleanType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
41920
+ "import { Box, Button, HStack, Input, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
41921
+ "import { Calendar, Data, Record } from \"@elaraai/e3-ui\";",
41922
+ "import e3 from \"@elaraai/e3\";"
41923
+ ],
41924
+ "languages": [
41925
+ "tsx"
41926
+ ],
41927
+ "source": "// Where Autosave begins is the author's to say: `autosave` takes a literal (`autosave`, `autosave={false}`) or an expression — here an input of the app's, so its data decides. The switch in Save's menu starts on, and each change is saved by itself a pause after the viewer's last act; an Undo or a Redo waits for a press of Save. A viewer's own flick of the switch is kept in their browser, and stands over what the author says.\n// inputs: []\n/** The smallest event record needs only its title and two instants. */\nexport const CalendarAppointment = StructType({ title: StringType, start: DateTimeType, end: DateTimeType });\n\n/** Where the visits' Autosave begins: the app's own setting — a Boolean a settings screen or a task writes. */\nexport const calendarAutosaveSetting = e3.input(\"calendar_autosave_setting\", BooleanType, variant(\"value\", true));\n\n/** The visits the Autosave example edits, in a record of their own: what it saves by itself meets no other example's rows. */\nexport const calendarVisits = e3.record(\"calendar_visits\", DictType(StringType, CalendarAppointment), {\n initial: new Map([\n [\"intake\", { title: \"Intake call\", start: new Date(\"2026-10-01T09:00:00Z\"), end: new Date(\"2026-10-01T10:00:00Z\") }],\n [\"survey\", { title: \"Site survey\", start: new Date(\"2026-10-01T13:00:00Z\"), end: new Date(\"2026-10-01T14:30:00Z\") }],\n ]),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const visits = $.let(Record.bind(calendarVisits));\n // The app's own setting: whoever writes the input decides where every viewer's switch begins.\n const setting = $.let(Data.bind(calendarAutosaveSetting));\n const begins = $.let(setting.read());\n return <Box height=\"640px\"><Calendar id=\"autosave\" autosave={begins} view={{ period: \"day\", date: new Date(\"2026-10-01T00:00:00Z\") }}\n events={{ visit: Calendar.events(visits, { name: \"Visit\", icon: \"calendar\", title: \"title\", start: \"start\", end: \"end\" }) }} />\n </Box>;\n }}</Reactive>)"
41928
+ },
41654
41929
  {
41655
41930
  "id": "e3-ui:calendar.examples.tsx:calendarConflicts",
41656
41931
  "skill": "e3-ui",
@@ -41673,7 +41948,7 @@
41673
41948
  "Save"
41674
41949
  ],
41675
41950
  "imports": [
41676
- "import { ArrayType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
41951
+ "import { ArrayType, BooleanType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
41677
41952
  "import { Box, Button, HStack, Input, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
41678
41953
  "import { Calendar, Data, Record } from \"@elaraai/e3-ui\";",
41679
41954
  "import e3 from \"@elaraai/e3\";"
@@ -42358,6 +42633,42 @@
42358
42633
  ],
42359
42634
  "source": "// The support desk's minutes in state drawn to scale: the same uneven bins, each bar as wide as its span and as tall as its count over it — so its area is its count — the open last bin as wide as the one before it\n// inputs: []\nexport const DeskState = StructType({ name: StringType, stage: StringType });\n\nexport const DeskTransition = StructType({ from: StringType, to: StringType });\n\nexport const DeskStage = StructType({ label: StringType, seq: IntegerType });\n\nexport const deskStates = e3.input(\"flowchart_desk_states\", DictType(StringType, DeskState), variant(\"value\", new Map([\n [\"NEW\", { name: \"New\", stage: \"open\" }], [\"TRI\", { name: \"Triaged\", stage: \"open\" }],\n [\"WIP\", { name: \"In progress\", stage: \"work\" }], [\"WAI\", { name: \"Waiting on customer\", stage: \"work\" }],\n [\"RES\", { name: \"Resolved\", stage: \"close\" }],\n])));\n\nexport const deskTransitions = e3.input(\"flowchart_desk_transitions\", DictType(StringType, DeskTransition), variant(\"value\", new Map([\n [\"t1\", { from: \"NEW\", to: \"TRI\" }], [\"t2\", { from: \"TRI\", to: \"WIP\" }], [\"t3\", { from: \"WIP\", to: \"WAI\" }],\n [\"t4\", { from: \"WAI\", to: \"WIP\" }], [\"t5\", { from: \"WIP\", to: \"RES\" }],\n])));\n\nexport const deskStages = e3.input(\"flowchart_desk_stages\", DictType(StringType, DeskStage), variant(\"value\", new Map([\n [\"open\", { label: \"Open\", seq: 1n }], [\"work\", { label: \"Work\", seq: 2n }], [\"close\", { label: \"Close\", seq: 3n }],\n])));\n\nexport const TicketMinutes = StructType({ minutes: ArrayType(IntegerType) });\n\nexport const ticketMinutes = e3.input(\"flowchart_ticket_minutes\", DictType(StringType, TicketMinutes), variant(\"value\", new Map([\n [\"NEW\", { minutes: [140n, 96n, 120n, 64n, 30n, 22n, 9n, 4n, 2n, 1n, 0n, 0n] }],\n [\"TRI\", { minutes: [62n, 88n, 131n, 90n, 41n, 25n, 12n, 6n, 3n, 1n, 0n, 0n] }],\n [\"WIP\", { minutes: [3n, 8n, 41n, 96n, 120n, 150n, 132n, 88n, 40n, 18n, 9n, 4n] }],\n [\"WAI\", { minutes: [0n, 1n, 2n, 6n, 9n, 14n, 30n, 58n, 74n, 66n, 41n, 22n] }],\n // A resolved ticket stays resolved: the app counts no time in it, so its row is absent and its card says no data.\n])));\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const states = $.let(Data.bind(deskStates));\n const transitions = $.let(Data.bind(deskTransitions));\n const stages = $.let(Data.bind(deskStages));\n const minutes = $.let(Data.bind(ticketMinutes));\n return (\n <Box height=\"560px\">\n <Flowchart\n states={Flowchart.states(states, {\n label: \"name\", lane: \"stage\",\n details: Flowchart.details(minutes, {\n details: [Flowchart.histogram(\"minutes\", {\n unit: \"minutes\",\n label: \"Time in state\",\n counts: \"tickets\",\n bins: [0, 1, 2, 5, 10, 15, 30, 60, 120, 240, 480, 1440],\n // Each bar as wide as its span: the first hour is a sliver, the shift and the day most of the axis.\n scale: \"linear\",\n // The same ticks: to scale, 5m and 1h crowd 0 at the start and are left out.\n ticks: [5, 60, { at: 480, label: \"a shift\" }, { at: 1440, label: \"a day\" }],\n })],\n }),\n })}\n transitions={Flowchart.transitions(transitions, { from: \"from\", to: \"to\" })}\n lanes={Flowchart.lanes(stages, { label: \"label\", order: \"seq\" })}\n name=\"ticketMinutesLinear\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
42360
42635
  },
42636
+ {
42637
+ "id": "e3-ui:flowchart.examples.tsx:flowchartBakery",
42638
+ "skill": "e3-ui",
42639
+ "package": "e3-ui",
42640
+ "file": "east-ui/packages/e3-ui/test/flowchart/flowchart.examples.tsx",
42641
+ "suite": "",
42642
+ "test": "A bakery's line over records keyed as the bakery keys them: its steps and its stations by number, a new one numbered one past the largest, and each move by the two steps it joins — Connect makes the move, then its key from its ends, and a second move between the same two steps is refused; each step's portioning a variant whose cases hold data, edited in the inspector as a choice with the chosen case's fields in a block under it, a new step's a whole loaf from the states' `values`",
42643
+ "keywords": [
42644
+ "Flowchart",
42645
+ "key type",
42646
+ "IntegerType",
42647
+ "Integer keys",
42648
+ "struct keys",
42649
+ "key",
42650
+ "Flowchart.transitions",
42651
+ "Connect",
42652
+ "Fields.select",
42653
+ "cases",
42654
+ "variant",
42655
+ "block",
42656
+ "inspector",
42657
+ "records",
42658
+ "Record.bind",
42659
+ "values"
42660
+ ],
42661
+ "imports": [
42662
+ "import {",
42663
+ "import { Badge, Box, Fields, Reactive, Slice, State, UIComponentType, VStack } from \"@elaraai/east-ui\";",
42664
+ "import { Data, Flowchart, Record } from \"@elaraai/e3-ui\";",
42665
+ "import e3 from \"@elaraai/e3\";"
42666
+ ],
42667
+ "languages": [
42668
+ "tsx"
42669
+ ],
42670
+ "source": "// A bakery's line over records keyed as the bakery keys them: its steps and its stations by number, a new one numbered one past the largest, and each move by the two steps it joins — Connect makes the move, then its key from its ends, and a second move between the same two steps is refused; each step's portioning a variant whose cases hold data, edited in the inspector as a choice with the chosen case's fields in a block under it, a new step's a whole loaf from the states' `values`\n// inputs: []\nexport const BakeryPortion = VariantType({ whole: NullType, sliced: IntegerType, weighed: StructType({ grams: FloatType, tolerance: FloatType }) });\n\nexport const BakeryStep = StructType({ name: StringType, station: IntegerType, seq: FloatType, portion: BakeryPortion });\n\nexport const BakeryStation = StructType({ label: StringType, seq: FloatType });\n\nexport const BakeryMoveKey = StructType({ from: IntegerType, to: IntegerType });\n\nexport const BakeryMove = StructType({ from: IntegerType, to: IntegerType, note: OptionType(StringType) });\n\nexport const bakerySteps = e3.record(\"flowchart_bakery_steps\", DictType(IntegerType, BakeryStep), {\n initial: new Map([\n [10n, { name: \"Mix\", station: 1n, seq: 1, portion: variant(\"whole\", null) }],\n [20n, { name: \"Proof\", station: 1n, seq: 2, portion: variant(\"whole\", null) }],\n [30n, { name: \"Bake\", station: 2n, seq: 1, portion: variant(\"whole\", null) }],\n [40n, { name: \"Cool\", station: 3n, seq: 1, portion: variant(\"sliced\", 12n) }],\n ]),\n mutations: (mutation) => ({ patch: mutation.patch() }),\n});\n\nexport const bakeryStations = e3.record(\"flowchart_bakery_stations\", DictType(IntegerType, BakeryStation), {\n initial: new Map([[1n, { label: \"Bench\", seq: 1 }], [2n, { label: \"Oven\", seq: 2 }], [3n, { label: \"Cooling\", seq: 3 }]]),\n mutations: (mutation) => ({ patch: mutation.patch() }),\n});\n\nexport const bakeryMoves = e3.record(\"flowchart_bakery_moves\", DictType(BakeryMoveKey, BakeryMove), {\n initial: new SortedMap([\n [{ from: 10n, to: 20n }, { from: 10n, to: 20n, note: none }],\n [{ from: 20n, to: 30n }, { from: 20n, to: 30n, note: none }],\n [{ from: 30n, to: 40n }, { from: 30n, to: 40n, note: none }],\n ], compareFor(BakeryMoveKey)),\n mutations: (mutation) => ({ patch: mutation.patch() }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const steps = $.let(Record.bind(bakerySteps));\n const moves = $.let(Record.bind(bakeryMoves));\n const stations = $.let(Record.bind(bakeryStations));\n return (\n <Box height=\"560px\">\n <Flowchart\n states={Flowchart.states(steps, {\n label: \"name\", lane: \"station\", order: \"seq\",\n // A new step starts as a whole loaf. Its portion's type default, Sliced at 0, is under the\n // least its Slices field allows: the form holds what it makes to that least, never a value given it.\n values: () => ({ portion: variant(\"whole\", null) }),\n fields: {\n // A variant whose cases hold data: a choice, and the chosen case's fields in a block under it.\n portion: Fields.select({\n labels: { whole: \"Whole loaf\", sliced: \"Sliced\", weighed: \"By weight\" },\n cases: { sliced: Fields.number({ label: \"Slices\", unit: \"slices\", min: 1n }), weighed: { grams: Fields.number({ unit: \"g\", min: 0 }) } },\n }),\n },\n })}\n transitions={Flowchart.transitions(moves, {\n from: \"from\", to: \"to\",\n // Connect makes the row, then its key from it: a move is keyed by its two ends.\n key: (move) => ({ from: move.from, to: move.to }),\n })}\n lanes={Flowchart.lanes(stations, { label: \"label\", order: \"seq\" })}\n name=\"bakery\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
42671
+ },
42361
42672
  {
42362
42673
  "id": "e3-ui:ontology.examples.tsx:supplyChainOntology",
42363
42674
  "skill": "e3-ui",
@@ -42627,7 +42938,7 @@
42627
42938
  "package": "e3-ui",
42628
42939
  "file": "east-ui/packages/e3-ui/test/plan/plan-events.examples.tsx",
42629
42940
  "suite": "",
42630
- "test": "The print works from plates to dispatch — jobs, stops and shifts on grouped presses and crews, nested bindery resources, deliveries in AM/PM lanes on a bay or a van, status and readiness, links between event kinds, utilisation and paper stock; one Slice.bindRecords rail — the jobs and the shifts through their interval indexes, their range the one window, the presses, the customers and each kind's templates record — and the shared library, inspector and Save session",
42941
+ "test": "The print works from plates to dispatch — jobs, stops and shifts on grouped presses and crews, nested bindery resources, deliveries in AM/PM lanes on a bay or a van, status and readiness, links between event kinds, utilisation and paper stock; one Slice.bindRecords rail — the jobs and the shifts through their interval indexes, their range the one window, the presses, the customers and each kind's templates record — and the shared library, inspector and Save session; a stored job over the sheets a press run takes is a warning beside the toolbar's issues, holding no Save",
42631
42942
  "keywords": [
42632
42943
  "Plan",
42633
42944
  "Schedule",
@@ -42711,7 +43022,11 @@
42711
43022
  "templates record",
42712
43023
  "Plan.eventRef",
42713
43024
  "Plan.over",
42714
- "#1344"
43025
+ "#1344",
43026
+ "max",
43027
+ "bounds",
43028
+ "warning",
43029
+ "out of range"
42715
43030
  ],
42716
43031
  "imports": [
42717
43032
  "import {",
@@ -42722,7 +43037,7 @@
42722
43037
  "languages": [
42723
43038
  "tsx"
42724
43039
  ],
42725
- "source": "// The print works from plates to dispatch — jobs, stops and shifts on grouped presses and crews, nested bindery resources, deliveries in AM/PM lanes on a bay or a van, status and readiness, links between event kinds, utilisation and paper stock; one Slice.bindRecords rail — the jobs and the shifts through their interval indexes, their range the one window, the presses, the customers and each kind's templates record — and the shared library, inspector and Save session\n// inputs: []\n/** A press: its name, its hall and the sheets it prints an hour. */\nexport const PrintPress = StructType({ name: StringType, hall: StringType, sheets_per_hour: FloatType });\n\n/** A crew: its name and its hall. */\nexport const PrintCrew = StructType({ name: StringType, hall: StringType });\n\n/**\n * A print job: when it runs and on which press — none of the three while it\n * waits in the backlog — the lifecycle it wears, its sheets, and the\n * customer's details.\n */\nexport const PrintJob = StructType({\n title: StringType,\n start: OptionType(DateTimeType),\n end: OptionType(DateTimeType),\n press: OptionType(StringType),\n state: EventStateType,\n sheets: FloatType,\n customer: StringType,\n stock: VariantType({ coated: NullType, uncoated: NullType, board: NullType }),\n due: OptionType(DateTimeType),\n});\n\n/** A stop on a press, at one instant: a plate change or a service. */\nexport const PrintStop = StructType({\n title: StringType,\n at: DateTimeType,\n press: StringType,\n kind: VariantType({ plate_change: NullType, service: NullType }),\n});\n\n/** A crew's shift. */\nexport const PrintShift = StructType({ title: StringType, start: DateTimeType, end: DateTimeType, crew: StringType, state: EventStateType });\n\n/** A customer: its name, the district it is in and its trade. */\nexport const PrintCustomer = StructType({ name: StringType, district: StringType, trade: StringType });\n\n/** The presses: three in each hall. A Plan never writes its resources. */\nexport const planPrintPresses = e3.record(\"plan_print_presses\", DictType(StringType, PrintPress), {\n initial: new Map([\n [\"a1\", { name: \"Press A1\", hall: \"Hall A\", sheets_per_hour: 12000.0 }],\n [\"a2\", { name: \"Press A2\", hall: \"Hall A\", sheets_per_hour: 10000.0 }],\n [\"a3\", { name: \"Press A3\", hall: \"Hall A\", sheets_per_hour: 8000.0 }],\n [\"b1\", { name: \"Press B1\", hall: \"Hall B\", sheets_per_hour: 15000.0 }],\n [\"b2\", { name: \"Press B2\", hall: \"Hall B\", sheets_per_hour: 12000.0 }],\n [\"b3\", { name: \"Press B3\", hall: \"Hall B\", sheets_per_hour: 6000.0 }],\n ]),\n indexes: (index) => ({\n plan_print_presses_by_hall: index.on([\"hall\"]),\n }),\n mutations: (mutation) => ({\n // The presses' patch door: the works edits its presses elsewhere, and a Plan reads them live.\n patch: mutation.patch(),\n }),\n});\n\n/** The crews: two in each hall. */\nexport const planPrintCrews = e3.record(\"plan_print_crews\", DictType(StringType, PrintCrew), {\n initial: new Map([\n [\"c1\", { name: \"Crew 1\", hall: \"Hall A\" }],\n [\"c2\", { name: \"Crew 2\", hall: \"Hall A\" }],\n [\"c3\", { name: \"Crew 3\", hall: \"Hall B\" }],\n [\"c4\", { name: \"Crew 4\", hall: \"Hall B\" }],\n ]),\n});\n\n/**\n * The print jobs: actual before 14 October, in progress on it, confirmed,\n * proposed and estimated after it; two overlapping on Press B2 on the 20th;\n * and eight with no start waiting in the backlog, two due this week, two next\n * week, two later and two with no due date.\n */\nexport const planPrintJobs = e3.record(\"plan_print_jobs\", DictType(StringType, PrintJob), {\n initial: new Map([\n [\"J-1001\", { title: \"Spring catalogue\", start: some(new Date(\"2026-10-05T06:00:00Z\")), end: some(new Date(\"2026-10-05T14:00:00Z\")), press: some(\"a1\"), state: variant(\"actual\", null), sheets: 96000.0, customer: \"Alder & Finch\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-07T00:00:00Z\")) }],\n [\"J-1002\", { title: \"Museum guide\", start: some(new Date(\"2026-10-07T06:00:00Z\")), end: some(new Date(\"2026-10-07T12:00:00Z\")), press: some(\"a1\"), state: variant(\"actual\", null), sheets: 72000.0, customer: \"Driftwood Museum\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-09T00:00:00Z\")) }],\n [\"J-1003\", { title: \"Event posters\", start: some(new Date(\"2026-10-14T07:00:00Z\")), end: some(new Date(\"2026-10-14T12:00:00Z\")), press: some(\"a1\"), state: variant(\"in-progress\", null), sheets: 60000.0, customer: \"Granite Hall\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-10-15T00:00:00Z\")) }],\n [\"J-1004\", { title: \"Course handbook\", start: some(new Date(\"2026-10-19T06:00:00Z\")), end: some(new Date(\"2026-10-19T18:00:00Z\")), press: some(\"a1\"), state: variant(\"confirmed\", null), sheets: 144000.0, customer: \"Elmway College\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-10-23T00:00:00Z\")) }],\n [\"J-1005\", { title: \"Menu cards\", start: some(new Date(\"2026-10-27T06:00:00Z\")), end: some(new Date(\"2026-10-27T08:00:00Z\")), press: some(\"a1\"), state: variant(\"proposed\", variant(\"recommended\", null)), sheets: 24000.0, customer: \"Copperleaf Cafe\", stock: variant(\"board\", null), due: some(new Date(\"2026-10-30T00:00:00Z\")) }],\n [\"J-1006\", { title: \"Tour brochure\", start: some(new Date(\"2026-10-06T06:00:00Z\")), end: some(new Date(\"2026-10-06T14:00:00Z\")), press: some(\"a2\"), state: variant(\"actual\", null), sheets: 80000.0, customer: \"Bluewater Tours\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-08T00:00:00Z\")) }],\n [\"J-1007\", { title: \"Annual report\", start: some(new Date(\"2026-10-14T06:00:00Z\")), end: some(new Date(\"2026-10-14T12:00:00Z\")), press: some(\"a2\"), state: variant(\"in-progress\", null), sheets: 60000.0, customer: \"Harbour Arts Society\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-16T00:00:00Z\")) }],\n [\"J-1008\", { title: \"Seed catalogue\", start: some(new Date(\"2026-10-21T06:00:00Z\")), end: some(new Date(\"2026-10-21T16:00:00Z\")), press: some(\"a2\"), state: variant(\"proposed\", variant(\"added\", null)), sheets: 100000.0, customer: \"Foxglove Gardens\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-24T00:00:00Z\")) }],\n [\"J-1009\", { title: \"Season flyers\", start: some(new Date(\"2026-10-28T06:00:00Z\")), end: some(new Date(\"2026-10-28T09:00:00Z\")), press: some(\"a2\"), state: variant(\"estimated\", null), sheets: 30000.0, customer: \"Heathfield Theatre\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-10-31T00:00:00Z\")) }],\n [\"J-1010\", { title: \"Club newsletter\", start: some(new Date(\"2026-10-08T06:00:00Z\")), end: some(new Date(\"2026-10-08T08:00:00Z\")), press: some(\"a3\"), state: variant(\"actual\", null), sheets: 16000.0, customer: \"Kestrel Cycling Club\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-10-09T00:00:00Z\")) }],\n [\"J-1011\", { title: \"Stationery set\", start: some(new Date(\"2026-10-15T06:00:00Z\")), end: some(new Date(\"2026-10-15T09:00:00Z\")), press: some(\"a3\"), state: variant(\"confirmed\", null), sheets: 24000.0, customer: \"Ivy Lane Studio\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-10-16T00:00:00Z\")) }],\n [\"J-1012\", { title: \"Gift boxes\", start: some(new Date(\"2026-10-22T06:00:00Z\")), end: some(new Date(\"2026-10-22T12:00:00Z\")), press: some(\"a3\"), state: variant(\"proposed\", variant(\"recommended\", null)), sheets: 48000.0, customer: \"Juniper Toys\", stock: variant(\"board\", null), due: some(new Date(\"2026-10-26T00:00:00Z\")) }],\n [\"J-1013\", { title: \"Holiday catalogue\", start: some(new Date(\"2026-10-05T06:00:00Z\")), end: some(new Date(\"2026-10-05T22:00:00Z\")), press: some(\"b1\"), state: variant(\"actual\", null), sheets: 240000.0, customer: \"Larkspur Home\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-09T00:00:00Z\")) }],\n [\"J-1014\", { title: \"Magazine run\", start: some(new Date(\"2026-10-12T06:00:00Z\")), end: some(new Date(\"2026-10-12T18:00:00Z\")), press: some(\"b1\"), state: variant(\"actual\", null), sheets: 180000.0, customer: \"Meridian Monthly\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-13T00:00:00Z\")) }],\n [\"J-1015\", { title: \"Store flyers\", start: some(new Date(\"2026-10-14T06:00:00Z\")), end: some(new Date(\"2026-10-14T16:00:00Z\")), press: some(\"b1\"), state: variant(\"in-progress\", null), sheets: 150000.0, customer: \"Northwind Outfitters\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-10-16T00:00:00Z\")) }],\n [\"J-1016\", { title: \"Exhibition book\", start: some(new Date(\"2026-10-26T06:00:00Z\")), end: some(new Date(\"2026-10-26T12:00:00Z\")), press: some(\"b1\"), state: variant(\"estimated\", null), sheets: 90000.0, customer: \"Driftwood Museum\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-30T00:00:00Z\")) }],\n [\"J-1017\", { title: \"Timetables\", start: some(new Date(\"2026-10-09T06:00:00Z\")), end: some(new Date(\"2026-10-09T10:00:00Z\")), press: some(\"b2\"), state: variant(\"actual\", null), sheets: 48000.0, customer: \"Bluewater Tours\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-10-12T00:00:00Z\")) }],\n [\"J-1018\", { title: \"Market posters\", start: some(new Date(\"2026-10-20T06:00:00Z\")), end: some(new Date(\"2026-10-20T12:00:00Z\")), press: some(\"b2\"), state: variant(\"confirmed\", null), sheets: 72000.0, customer: \"Orchard Street Market\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-22T00:00:00Z\")) }],\n [\"J-1019\", { title: \"Loyalty cards\", start: some(new Date(\"2026-10-20T10:00:00Z\")), end: some(new Date(\"2026-10-20T13:00:00Z\")), press: some(\"b2\"), state: variant(\"proposed\", variant(\"added\", null)), sheets: 36000.0, customer: \"Copperleaf Cafe\", stock: variant(\"board\", null), due: some(new Date(\"2026-10-23T00:00:00Z\")) }],\n [\"J-1020\", { title: \"Ticket books\", start: some(new Date(\"2026-10-29T06:00:00Z\")), end: some(new Date(\"2026-10-29T08:00:00Z\")), press: some(\"b2\"), state: variant(\"estimated\", null), sheets: 24000.0, customer: \"Heathfield Theatre\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-11-02T00:00:00Z\")) }],\n [\"J-1021\", { title: \"Handbook covers\", start: some(new Date(\"2026-10-16T06:00:00Z\")), end: some(new Date(\"2026-10-16T08:00:00Z\")), press: some(\"b3\"), state: variant(\"confirmed\", null), sheets: 12000.0, customer: \"Elmway College\", stock: variant(\"board\", null), due: some(new Date(\"2026-10-19T00:00:00Z\")) }],\n [\"J-1022\", { title: \"Box sleeves\", start: some(new Date(\"2026-10-20T06:00:00Z\")), end: some(new Date(\"2026-10-20T09:00:00Z\")), press: some(\"b3\"), state: variant(\"proposed\", variant(\"recommended\", null)), sheets: 18000.0, customer: \"Juniper Toys\", stock: variant(\"board\", null), due: some(new Date(\"2026-10-22T00:00:00Z\")) }],\n [\"J-1023\", { title: \"Guide reprint\", start: none, end: none, press: none, state: variant(\"estimated\", null), sheets: 24000.0, customer: \"Driftwood Museum\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-16T00:00:00Z\")) }],\n [\"J-1024\", { title: \"Order forms\", start: none, end: none, press: none, state: variant(\"proposed\", variant(\"added\", null)), sheets: 40000.0, customer: \"Larkspur Home\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-10-17T00:00:00Z\")) }],\n [\"J-1025\", { title: \"Winter brochure\", start: none, end: none, press: none, state: variant(\"estimated\", null), sheets: 64000.0, customer: \"Bluewater Tours\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-21T00:00:00Z\")) }],\n [\"J-1026\", { title: \"Wall calendars\", start: none, end: none, press: none, state: variant(\"estimated\", null), sheets: 50000.0, customer: \"Foxglove Gardens\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-23T00:00:00Z\")) }],\n [\"J-1027\", { title: \"Prospectus\", start: none, end: none, press: none, state: variant(\"estimated\", null), sheets: 100000.0, customer: \"Elmway College\", stock: variant(\"coated\", null), due: some(new Date(\"2026-11-06T00:00:00Z\")) }],\n [\"J-1028\", { title: \"Price lists\", start: none, end: none, press: none, state: variant(\"estimated\", null), sheets: 16000.0, customer: \"Northwind Outfitters\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-11-13T00:00:00Z\")) }],\n [\"J-1029\", { title: \"Spare covers\", start: none, end: none, press: none, state: variant(\"estimated\", null), sheets: 8000.0, customer: \"Meridian Monthly\", stock: variant(\"board\", null), due: none }],\n [\"J-1030\", { title: \"Proof sheets\", start: none, end: none, press: none, state: variant(\"estimated\", null), sheets: 2000.0, customer: \"Alder & Finch\", stock: variant(\"uncoated\", null), due: none }],\n ]),\n indexes: (index) => ({\n // The rail narrows each record through its own indexes (#1344): the jobs and the shifts over their interval\n // indexes — on their own, and after a job's stock — so a narrowing keeps every event overlapping the window once;\n // the presses by hall, the customers by district, and each templates record by its group.\n plan_print_jobs_by_time: index.interval({ from: \"start\", to: \"end\" }),\n plan_print_jobs_by_stock_time: index.interval({ on: [\"stock\"], from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n // The jobs' patch door: every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\n/** The stops: plate changes and services across the presses. */\nexport const planPrintStops = e3.record(\"plan_print_stops\", DictType(StringType, PrintStop), {\n initial: new Map([\n [\"S-01\", { title: \"Plate change\", at: new Date(\"2026-10-07T12:00:00Z\"), press: \"a1\", kind: variant(\"plate_change\", null) }],\n [\"S-02\", { title: \"Service\", at: new Date(\"2026-10-12T04:00:00Z\"), press: \"b1\", kind: variant(\"service\", null) }],\n [\"S-03\", { title: \"Plate change\", at: new Date(\"2026-10-14T12:00:00Z\"), press: \"a2\", kind: variant(\"plate_change\", null) }],\n [\"S-04\", { title: \"Plate change\", at: new Date(\"2026-10-19T18:00:00Z\"), press: \"a1\", kind: variant(\"plate_change\", null) }],\n [\"S-05\", { title: \"Service\", at: new Date(\"2026-10-26T14:00:00Z\"), press: \"a3\", kind: variant(\"service\", null) }],\n [\"S-06\", { title: \"Plate change\", at: new Date(\"2026-10-28T10:00:00Z\"), press: \"b2\", kind: variant(\"plate_change\", null) }],\n ]),\n mutations: (mutation) => ({\n // The stops' patch door.\n patch: mutation.patch(),\n }),\n});\n\n/** The shifts: each crew's early and late shifts, confirmed for the first two weeks and proposed for the last two. */\nexport const planPrintShifts = e3.record(\"plan_print_shifts\", DictType(StringType, PrintShift), {\n initial: new Map([\n [\"SH-01\", { title: \"Early\", start: new Date(\"2026-10-05T06:00:00Z\"), end: new Date(\"2026-10-05T14:00:00Z\"), crew: \"c1\", state: variant(\"confirmed\", null) }],\n [\"SH-02\", { title: \"Early\", start: new Date(\"2026-10-07T06:00:00Z\"), end: new Date(\"2026-10-07T14:00:00Z\"), crew: \"c1\", state: variant(\"confirmed\", null) }],\n [\"SH-03\", { title: \"Late\", start: new Date(\"2026-10-13T14:00:00Z\"), end: new Date(\"2026-10-13T22:00:00Z\"), crew: \"c1\", state: variant(\"confirmed\", null) }],\n [\"SH-04\", { title: \"Late\", start: new Date(\"2026-10-15T14:00:00Z\"), end: new Date(\"2026-10-15T22:00:00Z\"), crew: \"c1\", state: variant(\"confirmed\", null) }],\n [\"SH-05\", { title: \"Early\", start: new Date(\"2026-10-19T06:00:00Z\"), end: new Date(\"2026-10-19T14:00:00Z\"), crew: \"c1\", state: variant(\"proposed\", variant(\"recommended\", null)) }],\n [\"SH-06\", { title: \"Early\", start: new Date(\"2026-10-26T06:00:00Z\"), end: new Date(\"2026-10-26T14:00:00Z\"), crew: \"c1\", state: variant(\"proposed\", variant(\"recommended\", null)) }],\n [\"SH-07\", { title: \"Late\", start: new Date(\"2026-10-05T14:00:00Z\"), end: new Date(\"2026-10-05T22:00:00Z\"), crew: \"c2\", state: variant(\"confirmed\", null) }],\n [\"SH-08\", { title: \"Late\", start: new Date(\"2026-10-07T14:00:00Z\"), end: new Date(\"2026-10-07T22:00:00Z\"), crew: \"c2\", state: variant(\"confirmed\", null) }],\n [\"SH-09\", { title: \"Early\", start: new Date(\"2026-10-13T06:00:00Z\"), end: new Date(\"2026-10-13T14:00:00Z\"), crew: \"c2\", state: variant(\"confirmed\", null) }],\n [\"SH-10\", { title: \"Early\", start: new Date(\"2026-10-15T06:00:00Z\"), end: new Date(\"2026-10-15T14:00:00Z\"), crew: \"c2\", state: variant(\"confirmed\", null) }],\n [\"SH-11\", { title: \"Late\", start: new Date(\"2026-10-19T14:00:00Z\"), end: new Date(\"2026-10-19T22:00:00Z\"), crew: \"c2\", state: variant(\"proposed\", variant(\"recommended\", null)) }],\n [\"SH-12\", { title: \"Late\", start: new Date(\"2026-10-26T14:00:00Z\"), end: new Date(\"2026-10-26T22:00:00Z\"), crew: \"c2\", state: variant(\"proposed\", variant(\"recommended\", null)) }],\n [\"SH-13\", { title: \"Early\", start: new Date(\"2026-10-06T06:00:00Z\"), end: new Date(\"2026-10-06T14:00:00Z\"), crew: \"c3\", state: variant(\"confirmed\", null) }],\n [\"SH-14\", { title: \"Early\", start: new Date(\"2026-10-08T06:00:00Z\"), end: new Date(\"2026-10-08T14:00:00Z\"), crew: \"c3\", state: variant(\"confirmed\", null) }],\n [\"SH-15\", { title: \"Late\", start: new Date(\"2026-10-12T14:00:00Z\"), end: new Date(\"2026-10-12T22:00:00Z\"), crew: \"c3\", state: variant(\"confirmed\", null) }],\n [\"SH-16\", { title: \"Late\", start: new Date(\"2026-10-14T14:00:00Z\"), end: new Date(\"2026-10-14T22:00:00Z\"), crew: \"c3\", state: variant(\"confirmed\", null) }],\n [\"SH-17\", { title: \"Early\", start: new Date(\"2026-10-20T06:00:00Z\"), end: new Date(\"2026-10-20T14:00:00Z\"), crew: \"c3\", state: variant(\"proposed\", variant(\"recommended\", null)) }],\n [\"SH-18\", { title: \"Early\", start: new Date(\"2026-10-27T06:00:00Z\"), end: new Date(\"2026-10-27T14:00:00Z\"), crew: \"c3\", state: variant(\"proposed\", variant(\"added\", null)) }],\n [\"SH-19\", { title: \"Late\", start: new Date(\"2026-10-06T14:00:00Z\"), end: new Date(\"2026-10-06T22:00:00Z\"), crew: \"c4\", state: variant(\"confirmed\", null) }],\n [\"SH-20\", { title: \"Late\", start: new Date(\"2026-10-08T14:00:00Z\"), end: new Date(\"2026-10-08T22:00:00Z\"), crew: \"c4\", state: variant(\"confirmed\", null) }],\n [\"SH-21\", { title: \"Early\", start: new Date(\"2026-10-12T06:00:00Z\"), end: new Date(\"2026-10-12T14:00:00Z\"), crew: \"c4\", state: variant(\"confirmed\", null) }],\n [\"SH-22\", { title: \"Early\", start: new Date(\"2026-10-14T06:00:00Z\"), end: new Date(\"2026-10-14T14:00:00Z\"), crew: \"c4\", state: variant(\"confirmed\", null) }],\n [\"SH-23\", { title: \"Late\", start: new Date(\"2026-10-20T14:00:00Z\"), end: new Date(\"2026-10-20T22:00:00Z\"), crew: \"c4\", state: variant(\"proposed\", variant(\"recommended\", null)) }],\n [\"SH-24\", { title: \"Late\", start: new Date(\"2026-10-27T14:00:00Z\"), end: new Date(\"2026-10-27T22:00:00Z\"), crew: \"c4\", state: variant(\"proposed\", variant(\"added\", null)) }],\n ]),\n indexes: (index) => ({\n plan_print_shifts_by_time: index.interval({ from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n // The shifts' patch door.\n patch: mutation.patch(),\n }),\n});\n\n/** The customers the jobs are printed for, by account, in three districts: what the print works' library lists. A Plan never writes them. */\nexport const planPrintCustomers = e3.record(\"plan_print_customers\", DictType(StringType, PrintCustomer), {\n initial: new Map([\n [\"alder-finch\", { name: \"Alder & Finch\", district: \"Old Town\", trade: \"Retail\" }],\n [\"bluewater-tours\", { name: \"Bluewater Tours\", district: \"North Quay\", trade: \"Travel\" }],\n [\"copperleaf-cafe\", { name: \"Copperleaf Cafe\", district: \"Old Town\", trade: \"Hospitality\" }],\n [\"driftwood-museum\", { name: \"Driftwood Museum\", district: \"North Quay\", trade: \"Arts\" }],\n [\"elmway-college\", { name: \"Elmway College\", district: \"Riverside\", trade: \"Education\" }],\n [\"foxglove-gardens\", { name: \"Foxglove Gardens\", district: \"Riverside\", trade: \"Retail\" }],\n [\"granite-hall\", { name: \"Granite Hall\", district: \"Old Town\", trade: \"Events\" }],\n [\"harbour-arts\", { name: \"Harbour Arts Society\", district: \"North Quay\", trade: \"Arts\" }],\n [\"heathfield\", { name: \"Heathfield Theatre\", district: \"Old Town\", trade: \"Arts\" }],\n [\"ivy-lane\", { name: \"Ivy Lane Studio\", district: \"Riverside\", trade: \"Design\" }],\n [\"juniper-toys\", { name: \"Juniper Toys\", district: \"Riverside\", trade: \"Retail\" }],\n [\"kestrel-cycling\", { name: \"Kestrel Cycling Club\", district: \"Riverside\", trade: \"Sport\" }],\n [\"larkspur-home\", { name: \"Larkspur Home\", district: \"Old Town\", trade: \"Retail\" }],\n [\"meridian-monthly\", { name: \"Meridian Monthly\", district: \"North Quay\", trade: \"Publishing\" }],\n [\"northwind\", { name: \"Northwind Outfitters\", district: \"North Quay\", trade: \"Retail\" }],\n [\"orchard-market\", { name: \"Orchard Street Market\", district: \"Old Town\", trade: \"Markets\" }],\n ]),\n indexes: (index) => ({\n plan_print_customers_by_district: index.on([\"district\"]),\n }),\n mutations: (mutation) => ({\n // The customers' patch door: the works edits its customers elsewhere, and a Plan reads them live.\n patch: mutation.patch(),\n }),\n});\n\n/**\n * Each press's utilisation (%): a reading a day from 5 October, as the\n * dataflow measures it, idle at the weekends. Press B2's 97 on the 20th is\n * the day its two jobs overlap.\n */\nexport const planPrintUtilisation = e3.input(\"plan_print_utilisation\", DictType(StringType, ArrayType(FloatType)), variant(\"value\", new Map([\n [\"a1\", [50.0, 12.0, 38.0, 20.0, 15.0, 0.0, 0.0, 22.0, 18.0, 31.0, 25.0, 20.0, 0.0, 0.0, 75.0, 40.0, 30.0, 28.0, 20.0, 0.0, 0.0, 18.0, 13.0, 10.0, 8.0, 6.0, 0.0, 0.0]],\n [\"a2\", [20.0, 50.0, 25.0, 18.0, 15.0, 0.0, 0.0, 24.0, 20.0, 38.0, 30.0, 22.0, 0.0, 0.0, 26.0, 30.0, 63.0, 35.0, 22.0, 0.0, 0.0, 20.0, 18.0, 19.0, 12.0, 10.0, 0.0, 0.0]],\n [\"a3\", [10.0, 12.0, 14.0, 13.0, 18.0, 0.0, 0.0, 15.0, 16.0, 20.0, 19.0, 22.0, 0.0, 0.0, 24.0, 28.0, 30.0, 38.0, 25.0, 0.0, 0.0, 14.0, 20.0, 12.0, 10.0, 8.0, 0.0, 0.0]],\n [\"b1\", [100.0, 45.0, 30.0, 28.0, 26.0, 0.0, 0.0, 75.0, 40.0, 63.0, 48.0, 36.0, 0.0, 0.0, 30.0, 34.0, 28.0, 26.0, 24.0, 0.0, 0.0, 38.0, 22.0, 18.0, 14.0, 12.0, 0.0, 0.0]],\n [\"b2\", [18.0, 20.0, 22.0, 24.0, 25.0, 0.0, 0.0, 26.0, 28.0, 30.0, 32.0, 30.0, 0.0, 0.0, 34.0, 97.0, 40.0, 36.0, 30.0, 0.0, 0.0, 26.0, 24.0, 22.0, 13.0, 10.0, 0.0, 0.0]],\n [\"b3\", [8.0, 10.0, 12.0, 10.0, 9.0, 0.0, 0.0, 12.0, 14.0, 16.0, 18.0, 13.0, 0.0, 0.0, 20.0, 19.0, 16.0, 14.0, 12.0, 0.0, 0.0, 10.0, 9.0, 8.0, 7.0, 6.0, 0.0, 0.0]],\n])));\n\n/** The sheets printed each day from 5 October, across every press. */\nexport const planPrintOutput = e3.input(\"plan_print_output\", ArrayType(FloatType), variant(\"value\", [\n 336000.0, 80000.0, 72000.0, 16000.0, 48000.0, 0.0, 0.0,\n 180000.0, 0.0, 270000.0, 24000.0, 12000.0, 0.0, 0.0,\n 144000.0, 126000.0, 100000.0, 48000.0, 0.0, 0.0, 0.0,\n 90000.0, 24000.0, 30000.0, 24000.0, 0.0, 0.0, 0.0,\n]));\n\n/** A paper stock: its name, and its level in thousands of sheets, a reading a week keyed by its week (#1436). */\nexport const PrintStock = StructType({ name: StringType, weekly: DictType(DateTimeType, FloatType) });\n\n/** The paper in stock. */\nexport const planLinkStock = e3.input(\"plan_link_stock\", DictType(StringType, PrintStock), variant(\"value\", new Map([\n [\"board\", { name: \"Board\", weekly: new SortedMap([\n [new Date(\"2026-10-05T00:00:00Z\"), 40.0], [new Date(\"2026-10-12T00:00:00Z\"), 22.0], [new Date(\"2026-10-19T00:00:00Z\"), 31.0], [new Date(\"2026-10-26T00:00:00Z\"), 18.0],\n ], compareFor(DateTimeType)) }],\n [\"coated\", { name: \"Coated\", weekly: new SortedMap([\n [new Date(\"2026-10-05T00:00:00Z\"), 520.0], [new Date(\"2026-10-12T00:00:00Z\"), 410.0], [new Date(\"2026-10-19T00:00:00Z\"), 460.0], [new Date(\"2026-10-26T00:00:00Z\"), 380.0],\n ], compareFor(DateTimeType)) }],\n [\"uncoated\", { name: \"Uncoated\", weekly: new SortedMap([\n [new Date(\"2026-10-05T00:00:00Z\"), 300.0], [new Date(\"2026-10-12T00:00:00Z\"), 260.0], [new Date(\"2026-10-19T00:00:00Z\"), 280.0], [new Date(\"2026-10-26T00:00:00Z\"), 240.0],\n ], compareFor(DateTimeType)) }],\n])));\n\n/** A work centre a job passes through on its way out: the platesetter, the bindery's folder and binder, the dispatch bay. */\nexport const PrintCentre = StructType({ name: StringType });\n\n/** A set of plates the platesetter makes for a job, at the moment it makes them. */\nexport const PrintPlates = StructType({ title: StringType, at: DateTimeType, setter: StringType });\n\n/** A bindery job — folding a press job's sections, or binding them — on the folder or the binder. */\nexport const PrintBinding = StructType({ title: StringType, start: DateTimeType, end: DateTimeType, line: StringType, state: EventStateType });\n\n/** The platesetter. A Plan never writes its resources. */\nexport const planLinkSetters = e3.record(\"plan_link_setters\", DictType(StringType, PrintCentre), {\n initial: new Map([\n [\"ps\", { name: \"Platesetter\" }],\n ]),\n});\n\n/** The bindery's two lines. */\nexport const planLinkLines = e3.record(\"plan_link_lines\", DictType(StringType, PrintCentre), {\n initial: new Map([\n [\"fold\", { name: \"Folder\" }],\n [\"bind\", { name: \"Binder\" }],\n ]),\n});\n\n/** The dispatch bay. */\nexport const planLinkBays = e3.record(\"plan_link_bays\", DictType(StringType, PrintCentre), {\n initial: new Map([\n [\"bay\", { name: \"Dispatch bay\" }],\n ]),\n});\n\n/** The parent of the shared folder and binder, held in a record like every other resource. */\nexport const planPrintBindery = e3.record(\"plan_print_bindery\", DictType(StringType, PrintCentre), {\n initial: new Map([\n [\"bindery\", { name: \"Bindery\" }],\n ]),\n});\n\n/** The vans a delivery can move onto from the dispatch bay. */\nexport const planPrintVans = e3.record(\"plan_print_vans\", DictType(StringType, PrintCentre), {\n initial: new Map([\n [\"van1\", { name: \"Van 1\" }], [\"van2\", { name: \"Van 2\" }],\n ]),\n});\n\n/** A delivery's own status, separate from the schedule's lifecycle. */\nexport const PrintDispatchStatus = VariantType({ queued: NullType, ready: NullType, dispatched: NullType });\n\n/** A delivery on a bay or a van: the variant preserves the resource kind when it moves. */\nexport const PrintDispatch = StructType({\n title: StringType, at: DateTimeType,\n location: VariantType({ bay: StringType, van: StringType }),\n lane: StringType, status: PrintDispatchStatus, pallets: FloatType,\n});\n\n/** The print works' own plate orders, timed before its existing jobs. */\nexport const planPrintPlates = e3.record(\"plan_print_plates\", DictType(StringType, PrintPlates), {\n initial: new Map([\n [\"P-101\", { title: \"Handbook plates\", at: new Date(\"2026-10-16T14:00:00Z\"), setter: \"ps\" }],\n [\"P-102\", { title: \"Poster plates\", at: new Date(\"2026-10-13T14:00:00Z\"), setter: \"ps\" }],\n ]),\n mutations: (mutation) => ({\n // The print works' plates commit through their own patch door.\n patch: mutation.patch(),\n }),\n});\n\n/** Two foldings run in parallel, followed by binding, after the handbook leaves Press A1. */\nexport const planPrintBindings = e3.record(\"plan_print_bindings\", DictType(StringType, PrintBinding), {\n initial: new Map([\n [\"B-101\", { title: \"Fold handbook sections\", start: new Date(\"2026-10-20T06:00:00Z\"), end: new Date(\"2026-10-20T14:00:00Z\"), line: \"fold\", state: variant(\"confirmed\", null) }],\n [\"B-102\", { title: \"Fold handbook inserts\", start: new Date(\"2026-10-20T10:00:00Z\"), end: new Date(\"2026-10-20T16:00:00Z\"), line: \"fold\", state: variant(\"confirmed\", null) }],\n [\"B-103\", { title: \"Bind handbooks\", start: new Date(\"2026-10-21T06:00:00Z\"), end: new Date(\"2026-10-21T14:00:00Z\"), line: \"bind\", state: variant(\"confirmed\", null) }],\n ]),\n mutations: (mutation) => ({\n // The print works' bindery jobs commit through their own patch door.\n patch: mutation.patch(),\n }),\n});\n\n/** Deliveries occupy AM/PM lanes and carry each of the dispatch statuses. */\nexport const planPrintDeliveries = e3.record(\"plan_print_deliveries\", DictType(StringType, PrintDispatch), {\n initial: new Map([\n [\"D-101\", { title: \"Handbooks\", at: new Date(\"2026-10-22T10:00:00Z\"), location: variant(\"bay\", \"bay\"), lane: \"AM\", status: variant(\"queued\", null), pallets: 3.0 }],\n [\"D-102\", { title: \"Event posters\", at: new Date(\"2026-10-15T14:00:00Z\"), location: variant(\"van\", \"van1\"), lane: \"PM\", status: variant(\"ready\", null), pallets: 2.0 }],\n [\"D-103\", { title: \"Museum guides\", at: new Date(\"2026-10-09T10:00:00Z\"), location: variant(\"van\", \"van2\"), lane: \"AM\", status: variant(\"dispatched\", null), pallets: 1.0 }],\n ]),\n mutations: (mutation) => ({\n // The print works' deliveries commit through their own patch door.\n patch: mutation.patch(),\n }),\n});\n\n/** A job template: its name and group, how long the job it creates runs, and that job's fields. */\nexport const PrintJobTemplate = StructType({\n name: StringType, group: StringType, hours: FloatType,\n values: StructType({ title: StringType, state: EventStateType, sheets: FloatType, customer: StringType, stock: PrintJob.fields.stock, due: OptionType(DateTimeType) }),\n});\n\n/** A stop template: a stop is one instant, so it runs no time. */\nexport const PrintStopTemplate = StructType({ name: StringType, group: StringType, values: StructType({ title: StringType, kind: PrintStop.fields.kind }) });\n\n/** A shift template: the hour a shift dropped on a day starts at, eight hours long. */\nexport const PrintShiftTemplate = StructType({ name: StringType, group: StringType, hour: IntegerType, values: StructType({ title: StringType, state: EventStateType }) });\n\n/** A plates template: plates are made at one instant. */\nexport const PrintPlatesTemplate = StructType({ name: StringType, group: StringType, values: StructType({ title: StringType }) });\n\n/** A bindery template: how long the bindery job it creates runs. */\nexport const PrintBindingTemplate = StructType({ name: StringType, group: StringType, hours: FloatType, values: StructType({ title: StringType, state: EventStateType }) });\n\n/** A delivery template: the hour a delivery dropped on a day leaves at. */\nexport const PrintDeliveryTemplate = StructType({\n name: StringType, group: StringType, hour: IntegerType,\n values: StructType({ title: StringType, lane: StringType, status: PrintDispatchStatus, pallets: FloatType }),\n});\n\n/** The job templates. A Plan never writes them: the library lists them, and a drop creates a job from one. */\nexport const planPrintJobTemplates = e3.record(\"plan_print_job_templates\", DictType(StringType, PrintJobTemplate), {\n initial: new Map([\n [\"board\", { name: \"Board run\", group: \"Jobs\", hours: 8.0, values: { title: \"Board run\", state: variant(\"proposed\", variant(\"added\", null)), sheets: 24000.0, customer: \"\", stock: variant(\"board\", null), due: none } }],\n [\"brochure\", { name: \"Brochure run\", group: \"Jobs\", hours: 6.0, values: { title: \"Brochure run\", state: variant(\"proposed\", variant(\"added\", null)), sheets: 40000.0, customer: \"\", stock: variant(\"coated\", null), due: none } }],\n [\"catalogue\", { name: \"Catalogue run\", group: \"Jobs\", hours: 12.0, values: { title: \"Catalogue run\", state: variant(\"proposed\", variant(\"added\", null)), sheets: 96000.0, customer: \"\", stock: variant(\"coated\", null), due: none } }],\n [\"poster\", { name: \"Poster run\", group: \"Jobs\", hours: 4.0, values: { title: \"Poster run\", state: variant(\"proposed\", variant(\"added\", null)), sheets: 20000.0, customer: \"\", stock: variant(\"uncoated\", null), due: none } }],\n ]),\n indexes: (index) => ({\n plan_print_job_templates_by_group: index.on([\"group\"]),\n }),\n});\n\n/** The stop templates. */\nexport const planPrintStopTemplates = e3.record(\"plan_print_stop_templates\", DictType(StringType, PrintStopTemplate), {\n initial: new Map([\n [\"plates\", { name: \"Plate change\", group: \"Stops\", values: { title: \"Plate change\", kind: variant(\"plate_change\", null) } }],\n [\"service\", { name: \"Service\", group: \"Stops\", values: { title: \"Service\", kind: variant(\"service\", null) } }],\n ]),\n indexes: (index) => ({\n plan_print_stop_templates_by_group: index.on([\"group\"]),\n }),\n});\n\n/** The shift templates: early, late and night. */\nexport const planPrintShiftTemplates = e3.record(\"plan_print_shift_templates\", DictType(StringType, PrintShiftTemplate), {\n initial: new Map([\n [\"early\", { name: \"Early shift\", group: \"Shifts\", hour: 6n, values: { title: \"Early\", state: variant(\"confirmed\", null) } }],\n [\"late\", { name: \"Late shift\", group: \"Shifts\", hour: 14n, values: { title: \"Late\", state: variant(\"confirmed\", null) } }],\n [\"night\", { name: \"Night shift\", group: \"Shifts\", hour: 22n, values: { title: \"Night\", state: variant(\"proposed\", variant(\"added\", null)) } }],\n ]),\n indexes: (index) => ({\n plan_print_shift_templates_by_group: index.on([\"group\"]),\n }),\n});\n\n/** The plates templates. */\nexport const planPrintPlatesTemplates = e3.record(\"plan_print_plates_templates\", DictType(StringType, PrintPlatesTemplate), {\n initial: new Map([\n [\"plates\", { name: \"Job plates\", group: \"Plate room\", values: { title: \"Job plates\" } }],\n ]),\n indexes: (index) => ({\n plan_print_plates_templates_by_group: index.on([\"group\"]),\n }),\n});\n\n/** The bindery templates. */\nexport const planPrintBindingTemplates = e3.record(\"plan_print_binding_templates\", DictType(StringType, PrintBindingTemplate), {\n initial: new Map([\n [\"fold\", { name: \"Fold sections\", group: \"Bindery\", hours: 8.0, values: { title: \"Fold sections\", state: variant(\"confirmed\", null) } }],\n ]),\n indexes: (index) => ({\n plan_print_binding_templates_by_group: index.on([\"group\"]),\n }),\n});\n\n/** The delivery templates. */\nexport const planPrintDeliveryTemplates = e3.record(\"plan_print_delivery_templates\", DictType(StringType, PrintDeliveryTemplate), {\n initial: new Map([\n [\"delivery\", { name: \"Morning delivery\", group: \"Dispatch\", hour: 10n, values: { title: \"Delivery\", lane: \"AM\", status: variant(\"queued\", null), pallets: 1.0 } }],\n ]),\n indexes: (index) => ({\n plan_print_delivery_templates_by_group: index.on([\"group\"]),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n // What the Plan reads whole binds with Data.bind, which keeps it loaded beside its pages; the event\n // records it writes bind with Record.bind, and it reads the jobs' and the shifts' events through their\n // pages alone.\n const presses = $.let(Data.bind(planPrintPresses));\n const crews = $.let(Record.bind(planPrintCrews, []));\n const jobs = $.let(Record.bind(planPrintJobs));\n const stops = $.let(Record.bind(planPrintStops));\n const shifts = $.let(Record.bind(planPrintShifts));\n const customers = $.let(Data.bind(planPrintCustomers));\n const jobTemplates = $.let(Data.bind(planPrintJobTemplates));\n const stopTemplates = $.let(Data.bind(planPrintStopTemplates));\n const shiftTemplates = $.let(Data.bind(planPrintShiftTemplates));\n const platesTemplates = $.let(Data.bind(planPrintPlatesTemplates));\n const bindingTemplates = $.let(Data.bind(planPrintBindingTemplates));\n const deliveryTemplates = $.let(Data.bind(planPrintDeliveryTemplates));\n // One rail over the records, a source each (#1344): the jobs and the shifts through their interval\n // indexes, their range the one window the toolbar's dates, the resolution and the brush write; the\n // presses, the customers and each templates record by its fields.\n const slice = $.let(Slice.bindRecords(\"ex.planPrintWorks\", {\n job: { source: Data.bindPaged(planPrintJobs, { indexes: [\"plan_print_jobs_by_time\", \"plan_print_jobs_by_stock_time\"] }), icon: { prefix: \"fas\", name: \"file-lines\" },\n fields: { stock: { label: \"Stock\" }, start: { label: \"Dates\" } }, range: \"start\" },\n shift: { source: Data.bindPaged(planPrintShifts, { indexes: [\"plan_print_shifts_by_time\"] }), icon: { prefix: \"fas\", name: \"user-clock\" },\n fields: { start: { label: \"Dates\" } }, range: \"start\" },\n presses: { source: Data.bindPaged(planPrintPresses, { indexes: [\"plan_print_presses_by_hall\"] }), icon: { prefix: \"fas\", name: \"print\" },\n fields: { hall: { label: \"Hall\", hints: [\"Hall A\", \"Hall B\"] } } },\n customers: { source: Data.bindPaged(planPrintCustomers, { indexes: [\"plan_print_customers_by_district\"] }), icon: { prefix: \"fas\", name: \"building\" },\n fields: { district: { label: \"District\", hints: [\"North Quay\", \"Old Town\", \"Riverside\"] } } },\n jobTemplates: { source: Data.bindPaged(planPrintJobTemplates, { indexes: [\"plan_print_job_templates_by_group\"] }), icon: { prefix: \"fas\", name: \"layer-group\" },\n fields: { group: { label: \"Job templates\", hints: [\"Jobs\"] } } },\n stopTemplates: { source: Data.bindPaged(planPrintStopTemplates, { indexes: [\"plan_print_stop_templates_by_group\"] }), icon: { prefix: \"fas\", name: \"layer-group\" },\n fields: { group: { label: \"Stop templates\", hints: [\"Stops\"] } } },\n shiftTemplates: { source: Data.bindPaged(planPrintShiftTemplates, { indexes: [\"plan_print_shift_templates_by_group\"] }), icon: { prefix: \"fas\", name: \"layer-group\" },\n fields: { group: { label: \"Shift templates\", hints: [\"Shifts\"] } } },\n platesTemplates: { source: Data.bindPaged(planPrintPlatesTemplates, { indexes: [\"plan_print_plates_templates_by_group\"] }), icon: { prefix: \"fas\", name: \"layer-group\" },\n fields: { group: { label: \"Plates templates\", hints: [\"Plate room\"] } } },\n bindingTemplates: { source: Data.bindPaged(planPrintBindingTemplates, { indexes: [\"plan_print_binding_templates_by_group\"] }), icon: { prefix: \"fas\", name: \"layer-group\" },\n fields: { group: { label: \"Bindery templates\", hints: [\"Bindery\"] } } },\n deliveryTemplates: { source: Data.bindPaged(planPrintDeliveryTemplates, { indexes: [\"plan_print_delivery_templates_by_group\"] }), icon: { prefix: \"fas\", name: \"layer-group\" },\n fields: { group: { label: \"Delivery templates\", hints: [\"Dispatch\"] } } },\n }));\n // A kind narrowed through its source reads one event by its key through the record's own entries.\n const jobEntries = $.let(Data.bindPaged(planPrintJobs));\n const shiftEntries = $.let(Data.bindPaged(planPrintShifts));\n const setters = $.let(Record.bind(planLinkSetters, []));\n const lines = $.let(Record.bind(planLinkLines, []));\n const bindery = $.let(Record.bind(planPrintBindery, []));\n const bays = $.let(Record.bind(planLinkBays, []));\n const vans = $.let(Record.bind(planPrintVans, []));\n const plates = $.let(Record.bind(planPrintPlates));\n const bindings = $.let(Record.bind(planPrintBindings));\n const deliveries = $.let(Record.bind(planPrintDeliveries));\n const stock = $.let(Data.bind(planLinkStock));\n const lineRows = $.const(lines.read().union(bindery.read(), (_$2, line) => line));\n const util = $.let(Data.bind(planPrintUtilisation));\n const output = $.let(Data.bind(planPrintOutput));\n // The window's first day: each reading runs from it, a day apiece.\n const first = $.const(new Date(\"2026-10-05T00:00:00Z\"), DateTimeType);\n const parentLine = $.const(some(\"bindery\"), OptionType(StringType));\n const topLine = $.const(none, OptionType(StringType));\n // A press's readings as heat cells, one a day.\n const daily = $.const(East.function([ArrayType(FloatType)], ArrayType(Plan.Types.HeatCell), (_$2, readings) =>\n East.Array.generate(readings.size(), Plan.Types.HeatCell, (_$3, i) => ({\n at: Plan.at.time(first.addDays(i)), value: some(readings.get(i)), label: none,\n }))));\n // The sheets printed each day, as a chart's points.\n const PrintDay = StructType({ day: DateTimeType, sheets: FloatType });\n const printed = $.let(output.read());\n const days = $.let(East.Array.generate(printed.size(), PrintDay, (_$2, i) => ({ day: first.addDays(i), sheets: printed.get(i) })));\n const axis = $.let(Plan.axis({\n window: { min: new Date(\"2026-10-05T00:00:00Z\"), max: new Date(\"2026-11-02T00:00:00Z\") },\n resolution: \"day\", resolutions: [\"week\", \"day\"], now: new Date(\"2026-10-14T09:00:00Z\"),\n }));\n const canDrop = $.const(East.function([Schedule.Types.Candidate], OptionType(StringType), ($2, candidate) => {\n const reason = $2.let(none, OptionType(StringType));\n $2.match(candidate.resource, { some: ($3, resource) => {\n $3.if(resource.kind.equal(\"presses\").and(() => resource.key.equal(\"b3\")), $4 => {\n $4.assign(reason, some(\"Press B3 is in service; choose another press\"));\n });\n } });\n return reason;\n }));\n // A stop's own inspector: its title, and whether it is a plate change or a\n // service, chosen on a segment — the edited stop goes back through `update`.\n const StopKindType = PrintStop.fields.kind;\n const inspectStop = $.const(East.function([PrintStop, FunctionType([PrintStop], NullType)], UIComponentType, ($2, stop, update) => {\n const setKind = $2.const(East.function([StringType], NullType, ($3, picked) => {\n const kind = $3.const(picked.equal(\"service\").ifElse(\n () => East.value(variant(\"service\", null), StopKindType),\n () => East.value(variant(\"plate_change\", null), StopKindType)));\n // East has no struct spread: the stop, rebuilt with its new kind.\n $3(update({ title: stop.title, at: stop.at, press: stop.press, kind }));\n }));\n return (\n <VStack gap=\"3\" align=\"stretch\">\n <Text>{stop.title}</Text>\n <SegmentGroup value={stop.kind.getTag()} onChange={setKind} size=\"sm\"\n items={[SegmentGroup.Item(\"plate_change\", \"Plate change\"), SegmentGroup.Item(\"service\", \"Service\")]} />\n </VStack>\n );\n }));\n return (\n <Plan\n id=\"printWorks\"\n axis={axis}\n date={first}\n canDrop={canDrop}\n slice={{ slice }}\n resources={{\n presses: Schedule.resources(presses.read(), {\n name: \"Presses\", icon: \"print\",\n label: p => p.name, group: p => p.hall,\n sub: p => some(East.str`${East.Float.printCommaSeperated(p.sheets_per_hour, 0n)} sheets/h`),\n // A row under each press, from the dataflow's utilisation: an ordinary\n // heat series over the press rows, read only.\n measures: [\n Plan.series.heat(PrintPress, {\n key: \"util\", title: \"Utilisation\", label: () => \"Utilisation\",\n cells: (_p, key) => Plan.heatCells(daily(util.read().get(key)), { min: 0, max: 100, warnAt: 95 }),\n }),\n ],\n }),\n crews: Schedule.resources(crews.read(), { name: \"Crews\", icon: \"user-group\", label: c => c.name, group: c => c.hall }),\n setters: Schedule.resources(setters.read(), { name: \"Plate room\", icon: \"layer-group\", label: p => p.name, meta: () => some(\"Plates before printing\") }),\n lines: Schedule.resources(lineRows, {\n name: \"Bindery\", icon: \"book\", label: l => l.name,\n parent: (_l, key) => key.equal(\"bindery\").ifElse(() => topLine, () => parentLine),\n rollup: \"union\", collapsed: (_l, key) => key.equal(\"bindery\"),\n meta: () => some(\"Finishing\"), value: (_l, key) => key.equal(\"bindery\").ifElse(() => some(\"2 lines\"), () => topLine),\n }),\n bays: Schedule.resources(bays.read(), { name: \"Dispatch\", icon: \"warehouse\", label: b => b.name, meta: () => some(\"Loading\") }),\n vans: Schedule.resources(vans.read(), { name: \"Vans\", icon: \"truck\", label: v => v.name, meta: () => some(\"Delivery fleet\") }),\n }}\n events={{\n job: Schedule.events(jobs, {\n name: \"Print job\", icon: \"file-lines\", draw: \"span\",\n title: \"title\", start: \"start\", end: \"end\",\n resource: { field: \"press\", of: \"presses\" },\n state: \"state\",\n quantity: { field: \"sheets\", unit: \"sheets\" },\n backlog: { duration: j => variant(\"hours\", j.sheets.divide(8000.0)), due: j => j.due },\n fields: {\n customer: Schedule.field.text({ label: \"Customer\" }),\n stock: Schedule.field.select({ labels: { coated: \"Coated\", uncoated: \"Uncoated\", board: \"Board\" } }),\n sheets: Schedule.field.number({ label: \"Sheets\", step: 1000.0, min: 0.0 }),\n },\n // Narrowed through its source of the slice (`job`): one job is read by its key here.\n entries: jobEntries,\n templates: Schedule.templates(jobTemplates.read(), {\n name: t => t.name, group: t => some(t.group), duration: t => variant(\"hours\", t.hours), values: t => t.values, source: \"jobTemplates\",\n }),\n }),\n stop: Schedule.events(stops, {\n name: \"Stop\", icon: \"screwdriver-wrench\", draw: \"marks\",\n title: \"title\", at: \"at\",\n resource: { field: \"press\", of: \"presses\" },\n inspector: inspectStop,\n // A stop is one instant: its templates give no duration.\n templates: Schedule.templates(stopTemplates.read(), { name: t => t.name, group: t => some(t.group), values: t => t.values, source: \"stopTemplates\" }),\n }),\n shift: Schedule.events(shifts, {\n name: \"Crew shift\", icon: \"user-clock\", draw: \"cards\",\n title: \"title\", start: \"start\", end: \"end\",\n resource: { field: \"crew\", of: \"crews\" }, state: \"state\",\n entries: shiftEntries,\n templates: Schedule.templates(shiftTemplates.read(), {\n name: t => t.name, group: t => some(t.group), at: t => some({ hour: t.hour, minute: 0n }), duration: () => variant(\"hours\", 8.0),\n values: t => t.values, source: \"shiftTemplates\",\n }),\n }),\n plate: Schedule.events(plates, {\n name: \"Plates\", icon: \"clone\", title: \"title\", at: \"at\", resource: { field: \"setter\", of: \"setters\" },\n templates: Schedule.templates(platesTemplates.read(), { name: t => t.name, group: t => some(t.group), values: t => t.values, source: \"platesTemplates\" }),\n }),\n binding: Schedule.events(bindings, {\n name: \"Bindery job\", icon: \"book-open\", draw: \"cards\", title: \"title\", start: \"start\", end: \"end\",\n resource: { field: \"line\", of: \"lines\" }, state: \"state\", overlaps: \"allow\",\n templates: Schedule.templates(bindingTemplates.read(), {\n name: t => t.name, group: t => some(t.group), duration: t => variant(\"hours\", t.hours), values: t => t.values, source: \"bindingTemplates\",\n }),\n }),\n delivery: Schedule.events(deliveries, {\n name: \"Delivery\", icon: \"truck\", draw: \"buckets\", title: \"title\", at: \"at\",\n resource: { field: \"location\", of: { bay: \"bays\", van: \"vans\" } }, lane: \"lane\",\n status: { field: \"status\", cases: {\n queued: { label: \"Queued\", tone: variant(\"warning\", null), ring: true },\n ready: { label: \"Ready\", tone: variant(\"info\", null), ring: false },\n dispatched: { label: \"Dispatched\", tone: variant(\"success\", null), ring: false },\n } },\n ready: d => d.pallets.lessEqual(0.0).ifElse(\n () => variant(\"invalid\", [{ field: \"pallets\", message: \"Pallets must be positive\" }]),\n () => variant(\"ready\", null)),\n fields: { pallets: Schedule.field.number({ label: \"Pallets\", min: 0.0, step: 1.0 }) },\n templates: Schedule.templates(deliveryTemplates.read(), {\n name: t => t.name, group: t => some(t.group), at: t => some({ hour: t.hour, minute: 0n }), values: t => t.values, source: \"deliveryTemplates\",\n }),\n }),\n }}\n rows={[\n Plan.chart({\n key: \"output\", label: \"SHEETS / DAY\", id: true, pinned: true, height: \"spark\", expandable: true,\n layers: [Chart.Column(days, { x: r => r.day, y: r => r.sheets })],\n }),\n Plan.over(stock, [Plan.series.table(PrintStock, {\n key: \"stock\", title: \"Paper stock\", label: s => s.name,\n cells: Plan.tableCells(Plan.values(\"weekly\", (level) => ({ value: level }))), format: Format.Number({ maximumFractionDigits: 0n }),\n })]),\n ]}\n links={[\n Plan.link({ key: \"plates\", from: Plan.eventRef(\"plate\", \"P-101\"), to: Plan.eventRef(\"job\", \"J-1004\") }),\n Plan.link({ key: \"printed\", from: Plan.eventRef(\"job\", \"J-1004\"), to: Plan.eventRef(\"binding\", \"B-101\"), quantity: Plan.quantity(144, { unit: \"k sheets\" }) }),\n Plan.link({ key: \"folded\", from: Plan.eventRef(\"binding\", \"B-101\"), to: Plan.eventRef(\"binding\", \"B-103\") }),\n Plan.link({ key: \"dispatched\", from: Plan.eventRef(\"binding\", \"B-103\"), to: Plan.eventRef(\"delivery\", \"D-101\") }),\n ]}\n grain=\"resource\"\n library={[\n Plan.library.events(),\n Plan.library.backlog(),\n Plan.library.series(),\n // The customers, by district: a card dropped on a job sets its customer. The tab follows the\n // rail's `customers` source, by its rows' keys.\n Plan.library.tab(customers.read(), {\n name: \"Customers\", icon: \"building\",\n label: c => c.name, meta: c => some(c.trade), group: c => c.district,\n drop: c => Schedule.patch(PrintJob, { customer: c.name }), source: \"customers\",\n }),\n ]}\n inspector\n />\n );\n }}</Reactive>\n ))"
43040
+ "source": "// The print works from plates to dispatch — jobs, stops and shifts on grouped presses and crews, nested bindery resources, deliveries in AM/PM lanes on a bay or a van, status and readiness, links between event kinds, utilisation and paper stock; one Slice.bindRecords rail — the jobs and the shifts through their interval indexes, their range the one window, the presses, the customers and each kind's templates record — and the shared library, inspector and Save session; a stored job over the sheets a press run takes is a warning beside the toolbar's issues, holding no Save\n// inputs: []\n/** A press: its name, its hall and the sheets it prints an hour. */\nexport const PrintPress = StructType({ name: StringType, hall: StringType, sheets_per_hour: FloatType });\n\n/** A crew: its name and its hall. */\nexport const PrintCrew = StructType({ name: StringType, hall: StringType });\n\n/**\n * A print job: when it runs and on which press — none of the three while it\n * waits in the backlog — the lifecycle it wears, its sheets, and the\n * customer's details.\n */\nexport const PrintJob = StructType({\n title: StringType,\n start: OptionType(DateTimeType),\n end: OptionType(DateTimeType),\n press: OptionType(StringType),\n state: EventStateType,\n sheets: FloatType,\n customer: StringType,\n stock: VariantType({ coated: NullType, uncoated: NullType, board: NullType }),\n due: OptionType(DateTimeType),\n});\n\n/** A stop on a press, at one instant: a plate change or a service. */\nexport const PrintStop = StructType({\n title: StringType,\n at: DateTimeType,\n press: StringType,\n kind: VariantType({ plate_change: NullType, service: NullType }),\n});\n\n/** A crew's shift. */\nexport const PrintShift = StructType({ title: StringType, start: DateTimeType, end: DateTimeType, crew: StringType, state: EventStateType });\n\n/** A customer: its name, the district it is in and its trade. */\nexport const PrintCustomer = StructType({ name: StringType, district: StringType, trade: StringType });\n\n/** The presses: three in each hall. A Plan never writes its resources. */\nexport const planPrintPresses = e3.record(\"plan_print_presses\", DictType(StringType, PrintPress), {\n initial: new Map([\n [\"a1\", { name: \"Press A1\", hall: \"Hall A\", sheets_per_hour: 12000.0 }],\n [\"a2\", { name: \"Press A2\", hall: \"Hall A\", sheets_per_hour: 10000.0 }],\n [\"a3\", { name: \"Press A3\", hall: \"Hall A\", sheets_per_hour: 8000.0 }],\n [\"b1\", { name: \"Press B1\", hall: \"Hall B\", sheets_per_hour: 15000.0 }],\n [\"b2\", { name: \"Press B2\", hall: \"Hall B\", sheets_per_hour: 12000.0 }],\n [\"b3\", { name: \"Press B3\", hall: \"Hall B\", sheets_per_hour: 6000.0 }],\n ]),\n indexes: (index) => ({\n plan_print_presses_by_hall: index.on([\"hall\"]),\n }),\n mutations: (mutation) => ({\n // The presses' patch door: the works edits its presses elsewhere, and a Plan reads them live.\n patch: mutation.patch(),\n }),\n});\n\n/** The crews: two in each hall. */\nexport const planPrintCrews = e3.record(\"plan_print_crews\", DictType(StringType, PrintCrew), {\n initial: new Map([\n [\"c1\", { name: \"Crew 1\", hall: \"Hall A\" }],\n [\"c2\", { name: \"Crew 2\", hall: \"Hall A\" }],\n [\"c3\", { name: \"Crew 3\", hall: \"Hall B\" }],\n [\"c4\", { name: \"Crew 4\", hall: \"Hall B\" }],\n ]),\n});\n\n/**\n * The print jobs: actual before 14 October, in progress on it, confirmed,\n * proposed and estimated after it; two overlapping on Press B2 on the 20th;\n * and eight with no start waiting in the backlog, two due this week, two next\n * week, two later and two with no due date.\n */\nexport const planPrintJobs = e3.record(\"plan_print_jobs\", DictType(StringType, PrintJob), {\n initial: new Map([\n [\"J-1001\", { title: \"Spring catalogue\", start: some(new Date(\"2026-10-05T06:00:00Z\")), end: some(new Date(\"2026-10-05T14:00:00Z\")), press: some(\"a1\"), state: variant(\"actual\", null), sheets: 96000.0, customer: \"Alder & Finch\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-07T00:00:00Z\")) }],\n [\"J-1002\", { title: \"Museum guide\", start: some(new Date(\"2026-10-07T06:00:00Z\")), end: some(new Date(\"2026-10-07T12:00:00Z\")), press: some(\"a1\"), state: variant(\"actual\", null), sheets: 72000.0, customer: \"Driftwood Museum\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-09T00:00:00Z\")) }],\n [\"J-1003\", { title: \"Event posters\", start: some(new Date(\"2026-10-14T07:00:00Z\")), end: some(new Date(\"2026-10-14T12:00:00Z\")), press: some(\"a1\"), state: variant(\"in-progress\", null), sheets: 60000.0, customer: \"Granite Hall\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-10-15T00:00:00Z\")) }],\n [\"J-1004\", { title: \"Course handbook\", start: some(new Date(\"2026-10-19T06:00:00Z\")), end: some(new Date(\"2026-10-19T18:00:00Z\")), press: some(\"a1\"), state: variant(\"confirmed\", null), sheets: 144000.0, customer: \"Elmway College\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-10-23T00:00:00Z\")) }],\n [\"J-1005\", { title: \"Menu cards\", start: some(new Date(\"2026-10-27T06:00:00Z\")), end: some(new Date(\"2026-10-27T08:00:00Z\")), press: some(\"a1\"), state: variant(\"proposed\", variant(\"recommended\", null)), sheets: 24000.0, customer: \"Copperleaf Cafe\", stock: variant(\"board\", null), due: some(new Date(\"2026-10-30T00:00:00Z\")) }],\n [\"J-1006\", { title: \"Tour brochure\", start: some(new Date(\"2026-10-06T06:00:00Z\")), end: some(new Date(\"2026-10-06T14:00:00Z\")), press: some(\"a2\"), state: variant(\"actual\", null), sheets: 80000.0, customer: \"Bluewater Tours\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-08T00:00:00Z\")) }],\n [\"J-1007\", { title: \"Annual report\", start: some(new Date(\"2026-10-14T06:00:00Z\")), end: some(new Date(\"2026-10-14T12:00:00Z\")), press: some(\"a2\"), state: variant(\"in-progress\", null), sheets: 60000.0, customer: \"Harbour Arts Society\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-16T00:00:00Z\")) }],\n [\"J-1008\", { title: \"Seed catalogue\", start: some(new Date(\"2026-10-21T06:00:00Z\")), end: some(new Date(\"2026-10-21T16:00:00Z\")), press: some(\"a2\"), state: variant(\"proposed\", variant(\"added\", null)), sheets: 100000.0, customer: \"Foxglove Gardens\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-24T00:00:00Z\")) }],\n [\"J-1009\", { title: \"Season flyers\", start: some(new Date(\"2026-10-28T06:00:00Z\")), end: some(new Date(\"2026-10-28T09:00:00Z\")), press: some(\"a2\"), state: variant(\"estimated\", null), sheets: 30000.0, customer: \"Heathfield Theatre\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-10-31T00:00:00Z\")) }],\n [\"J-1010\", { title: \"Club newsletter\", start: some(new Date(\"2026-10-08T06:00:00Z\")), end: some(new Date(\"2026-10-08T08:00:00Z\")), press: some(\"a3\"), state: variant(\"actual\", null), sheets: 16000.0, customer: \"Kestrel Cycling Club\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-10-09T00:00:00Z\")) }],\n [\"J-1011\", { title: \"Stationery set\", start: some(new Date(\"2026-10-15T06:00:00Z\")), end: some(new Date(\"2026-10-15T09:00:00Z\")), press: some(\"a3\"), state: variant(\"confirmed\", null), sheets: 24000.0, customer: \"Ivy Lane Studio\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-10-16T00:00:00Z\")) }],\n [\"J-1012\", { title: \"Gift boxes\", start: some(new Date(\"2026-10-22T06:00:00Z\")), end: some(new Date(\"2026-10-22T12:00:00Z\")), press: some(\"a3\"), state: variant(\"proposed\", variant(\"recommended\", null)), sheets: 48000.0, customer: \"Juniper Toys\", stock: variant(\"board\", null), due: some(new Date(\"2026-10-26T00:00:00Z\")) }],\n [\"J-1013\", { title: \"Holiday catalogue\", start: some(new Date(\"2026-10-05T06:00:00Z\")), end: some(new Date(\"2026-10-05T22:00:00Z\")), press: some(\"b1\"), state: variant(\"actual\", null), sheets: 240000.0, customer: \"Larkspur Home\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-09T00:00:00Z\")) }],\n [\"J-1014\", { title: \"Magazine run\", start: some(new Date(\"2026-10-12T06:00:00Z\")), end: some(new Date(\"2026-10-12T18:00:00Z\")), press: some(\"b1\"), state: variant(\"actual\", null), sheets: 180000.0, customer: \"Meridian Monthly\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-13T00:00:00Z\")) }],\n [\"J-1015\", { title: \"Store flyers\", start: some(new Date(\"2026-10-14T06:00:00Z\")), end: some(new Date(\"2026-10-14T16:00:00Z\")), press: some(\"b1\"), state: variant(\"in-progress\", null), sheets: 150000.0, customer: \"Northwind Outfitters\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-10-16T00:00:00Z\")) }],\n [\"J-1016\", { title: \"Exhibition book\", start: some(new Date(\"2026-10-26T06:00:00Z\")), end: some(new Date(\"2026-10-26T12:00:00Z\")), press: some(\"b1\"), state: variant(\"estimated\", null), sheets: 90000.0, customer: \"Driftwood Museum\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-30T00:00:00Z\")) }],\n [\"J-1017\", { title: \"Timetables\", start: some(new Date(\"2026-10-09T06:00:00Z\")), end: some(new Date(\"2026-10-09T10:00:00Z\")), press: some(\"b2\"), state: variant(\"actual\", null), sheets: 48000.0, customer: \"Bluewater Tours\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-10-12T00:00:00Z\")) }],\n [\"J-1018\", { title: \"Market posters\", start: some(new Date(\"2026-10-20T06:00:00Z\")), end: some(new Date(\"2026-10-20T12:00:00Z\")), press: some(\"b2\"), state: variant(\"confirmed\", null), sheets: 72000.0, customer: \"Orchard Street Market\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-22T00:00:00Z\")) }],\n [\"J-1019\", { title: \"Loyalty cards\", start: some(new Date(\"2026-10-20T10:00:00Z\")), end: some(new Date(\"2026-10-20T13:00:00Z\")), press: some(\"b2\"), state: variant(\"proposed\", variant(\"added\", null)), sheets: 36000.0, customer: \"Copperleaf Cafe\", stock: variant(\"board\", null), due: some(new Date(\"2026-10-23T00:00:00Z\")) }],\n [\"J-1020\", { title: \"Ticket books\", start: some(new Date(\"2026-10-29T06:00:00Z\")), end: some(new Date(\"2026-10-29T08:00:00Z\")), press: some(\"b2\"), state: variant(\"estimated\", null), sheets: 24000.0, customer: \"Heathfield Theatre\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-11-02T00:00:00Z\")) }],\n [\"J-1021\", { title: \"Handbook covers\", start: some(new Date(\"2026-10-16T06:00:00Z\")), end: some(new Date(\"2026-10-16T08:00:00Z\")), press: some(\"b3\"), state: variant(\"confirmed\", null), sheets: 12000.0, customer: \"Elmway College\", stock: variant(\"board\", null), due: some(new Date(\"2026-10-19T00:00:00Z\")) }],\n [\"J-1022\", { title: \"Box sleeves\", start: some(new Date(\"2026-10-20T06:00:00Z\")), end: some(new Date(\"2026-10-20T09:00:00Z\")), press: some(\"b3\"), state: variant(\"proposed\", variant(\"recommended\", null)), sheets: 18000.0, customer: \"Juniper Toys\", stock: variant(\"board\", null), due: some(new Date(\"2026-10-22T00:00:00Z\")) }],\n [\"J-1023\", { title: \"Guide reprint\", start: none, end: none, press: none, state: variant(\"estimated\", null), sheets: 24000.0, customer: \"Driftwood Museum\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-16T00:00:00Z\")) }],\n [\"J-1024\", { title: \"Order forms\", start: none, end: none, press: none, state: variant(\"proposed\", variant(\"added\", null)), sheets: 40000.0, customer: \"Larkspur Home\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-10-17T00:00:00Z\")) }],\n [\"J-1025\", { title: \"Winter brochure\", start: none, end: none, press: none, state: variant(\"estimated\", null), sheets: 64000.0, customer: \"Bluewater Tours\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-21T00:00:00Z\")) }],\n [\"J-1026\", { title: \"Wall calendars\", start: none, end: none, press: none, state: variant(\"estimated\", null), sheets: 50000.0, customer: \"Foxglove Gardens\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-23T00:00:00Z\")) }],\n [\"J-1027\", { title: \"Prospectus\", start: none, end: none, press: none, state: variant(\"estimated\", null), sheets: 100000.0, customer: \"Elmway College\", stock: variant(\"coated\", null), due: some(new Date(\"2026-11-06T00:00:00Z\")) }],\n [\"J-1028\", { title: \"Price lists\", start: none, end: none, press: none, state: variant(\"estimated\", null), sheets: 16000.0, customer: \"Northwind Outfitters\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-11-13T00:00:00Z\")) }],\n [\"J-1029\", { title: \"Spare covers\", start: none, end: none, press: none, state: variant(\"estimated\", null), sheets: 8000.0, customer: \"Meridian Monthly\", stock: variant(\"board\", null), due: none }],\n [\"J-1030\", { title: \"Proof sheets\", start: none, end: none, press: none, state: variant(\"estimated\", null), sheets: 2000.0, customer: \"Alder & Finch\", stock: variant(\"uncoated\", null), due: none }],\n ]),\n indexes: (index) => ({\n // The rail narrows each record through its own indexes (#1344): the jobs and the shifts over their interval\n // indexes — on their own, and after a job's stock — so a narrowing keeps every event overlapping the window once;\n // the presses by hall, the customers by district, and each templates record by its group.\n plan_print_jobs_by_time: index.interval({ from: \"start\", to: \"end\" }),\n plan_print_jobs_by_stock_time: index.interval({ on: [\"stock\"], from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n // The jobs' patch door: every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\n/** The stops: plate changes and services across the presses. */\nexport const planPrintStops = e3.record(\"plan_print_stops\", DictType(StringType, PrintStop), {\n initial: new Map([\n [\"S-01\", { title: \"Plate change\", at: new Date(\"2026-10-07T12:00:00Z\"), press: \"a1\", kind: variant(\"plate_change\", null) }],\n [\"S-02\", { title: \"Service\", at: new Date(\"2026-10-12T04:00:00Z\"), press: \"b1\", kind: variant(\"service\", null) }],\n [\"S-03\", { title: \"Plate change\", at: new Date(\"2026-10-14T12:00:00Z\"), press: \"a2\", kind: variant(\"plate_change\", null) }],\n [\"S-04\", { title: \"Plate change\", at: new Date(\"2026-10-19T18:00:00Z\"), press: \"a1\", kind: variant(\"plate_change\", null) }],\n [\"S-05\", { title: \"Service\", at: new Date(\"2026-10-26T14:00:00Z\"), press: \"a3\", kind: variant(\"service\", null) }],\n [\"S-06\", { title: \"Plate change\", at: new Date(\"2026-10-28T10:00:00Z\"), press: \"b2\", kind: variant(\"plate_change\", null) }],\n ]),\n mutations: (mutation) => ({\n // The stops' patch door.\n patch: mutation.patch(),\n }),\n});\n\n/** The shifts: each crew's early and late shifts, confirmed for the first two weeks and proposed for the last two. */\nexport const planPrintShifts = e3.record(\"plan_print_shifts\", DictType(StringType, PrintShift), {\n initial: new Map([\n [\"SH-01\", { title: \"Early\", start: new Date(\"2026-10-05T06:00:00Z\"), end: new Date(\"2026-10-05T14:00:00Z\"), crew: \"c1\", state: variant(\"confirmed\", null) }],\n [\"SH-02\", { title: \"Early\", start: new Date(\"2026-10-07T06:00:00Z\"), end: new Date(\"2026-10-07T14:00:00Z\"), crew: \"c1\", state: variant(\"confirmed\", null) }],\n [\"SH-03\", { title: \"Late\", start: new Date(\"2026-10-13T14:00:00Z\"), end: new Date(\"2026-10-13T22:00:00Z\"), crew: \"c1\", state: variant(\"confirmed\", null) }],\n [\"SH-04\", { title: \"Late\", start: new Date(\"2026-10-15T14:00:00Z\"), end: new Date(\"2026-10-15T22:00:00Z\"), crew: \"c1\", state: variant(\"confirmed\", null) }],\n [\"SH-05\", { title: \"Early\", start: new Date(\"2026-10-19T06:00:00Z\"), end: new Date(\"2026-10-19T14:00:00Z\"), crew: \"c1\", state: variant(\"proposed\", variant(\"recommended\", null)) }],\n [\"SH-06\", { title: \"Early\", start: new Date(\"2026-10-26T06:00:00Z\"), end: new Date(\"2026-10-26T14:00:00Z\"), crew: \"c1\", state: variant(\"proposed\", variant(\"recommended\", null)) }],\n [\"SH-07\", { title: \"Late\", start: new Date(\"2026-10-05T14:00:00Z\"), end: new Date(\"2026-10-05T22:00:00Z\"), crew: \"c2\", state: variant(\"confirmed\", null) }],\n [\"SH-08\", { title: \"Late\", start: new Date(\"2026-10-07T14:00:00Z\"), end: new Date(\"2026-10-07T22:00:00Z\"), crew: \"c2\", state: variant(\"confirmed\", null) }],\n [\"SH-09\", { title: \"Early\", start: new Date(\"2026-10-13T06:00:00Z\"), end: new Date(\"2026-10-13T14:00:00Z\"), crew: \"c2\", state: variant(\"confirmed\", null) }],\n [\"SH-10\", { title: \"Early\", start: new Date(\"2026-10-15T06:00:00Z\"), end: new Date(\"2026-10-15T14:00:00Z\"), crew: \"c2\", state: variant(\"confirmed\", null) }],\n [\"SH-11\", { title: \"Late\", start: new Date(\"2026-10-19T14:00:00Z\"), end: new Date(\"2026-10-19T22:00:00Z\"), crew: \"c2\", state: variant(\"proposed\", variant(\"recommended\", null)) }],\n [\"SH-12\", { title: \"Late\", start: new Date(\"2026-10-26T14:00:00Z\"), end: new Date(\"2026-10-26T22:00:00Z\"), crew: \"c2\", state: variant(\"proposed\", variant(\"recommended\", null)) }],\n [\"SH-13\", { title: \"Early\", start: new Date(\"2026-10-06T06:00:00Z\"), end: new Date(\"2026-10-06T14:00:00Z\"), crew: \"c3\", state: variant(\"confirmed\", null) }],\n [\"SH-14\", { title: \"Early\", start: new Date(\"2026-10-08T06:00:00Z\"), end: new Date(\"2026-10-08T14:00:00Z\"), crew: \"c3\", state: variant(\"confirmed\", null) }],\n [\"SH-15\", { title: \"Late\", start: new Date(\"2026-10-12T14:00:00Z\"), end: new Date(\"2026-10-12T22:00:00Z\"), crew: \"c3\", state: variant(\"confirmed\", null) }],\n [\"SH-16\", { title: \"Late\", start: new Date(\"2026-10-14T14:00:00Z\"), end: new Date(\"2026-10-14T22:00:00Z\"), crew: \"c3\", state: variant(\"confirmed\", null) }],\n [\"SH-17\", { title: \"Early\", start: new Date(\"2026-10-20T06:00:00Z\"), end: new Date(\"2026-10-20T14:00:00Z\"), crew: \"c3\", state: variant(\"proposed\", variant(\"recommended\", null)) }],\n [\"SH-18\", { title: \"Early\", start: new Date(\"2026-10-27T06:00:00Z\"), end: new Date(\"2026-10-27T14:00:00Z\"), crew: \"c3\", state: variant(\"proposed\", variant(\"added\", null)) }],\n [\"SH-19\", { title: \"Late\", start: new Date(\"2026-10-06T14:00:00Z\"), end: new Date(\"2026-10-06T22:00:00Z\"), crew: \"c4\", state: variant(\"confirmed\", null) }],\n [\"SH-20\", { title: \"Late\", start: new Date(\"2026-10-08T14:00:00Z\"), end: new Date(\"2026-10-08T22:00:00Z\"), crew: \"c4\", state: variant(\"confirmed\", null) }],\n [\"SH-21\", { title: \"Early\", start: new Date(\"2026-10-12T06:00:00Z\"), end: new Date(\"2026-10-12T14:00:00Z\"), crew: \"c4\", state: variant(\"confirmed\", null) }],\n [\"SH-22\", { title: \"Early\", start: new Date(\"2026-10-14T06:00:00Z\"), end: new Date(\"2026-10-14T14:00:00Z\"), crew: \"c4\", state: variant(\"confirmed\", null) }],\n [\"SH-23\", { title: \"Late\", start: new Date(\"2026-10-20T14:00:00Z\"), end: new Date(\"2026-10-20T22:00:00Z\"), crew: \"c4\", state: variant(\"proposed\", variant(\"recommended\", null)) }],\n [\"SH-24\", { title: \"Late\", start: new Date(\"2026-10-27T14:00:00Z\"), end: new Date(\"2026-10-27T22:00:00Z\"), crew: \"c4\", state: variant(\"proposed\", variant(\"added\", null)) }],\n ]),\n indexes: (index) => ({\n plan_print_shifts_by_time: index.interval({ from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n // The shifts' patch door.\n patch: mutation.patch(),\n }),\n});\n\n/** The customers the jobs are printed for, by account, in three districts: what the print works' library lists. A Plan never writes them. */\nexport const planPrintCustomers = e3.record(\"plan_print_customers\", DictType(StringType, PrintCustomer), {\n initial: new Map([\n [\"alder-finch\", { name: \"Alder & Finch\", district: \"Old Town\", trade: \"Retail\" }],\n [\"bluewater-tours\", { name: \"Bluewater Tours\", district: \"North Quay\", trade: \"Travel\" }],\n [\"copperleaf-cafe\", { name: \"Copperleaf Cafe\", district: \"Old Town\", trade: \"Hospitality\" }],\n [\"driftwood-museum\", { name: \"Driftwood Museum\", district: \"North Quay\", trade: \"Arts\" }],\n [\"elmway-college\", { name: \"Elmway College\", district: \"Riverside\", trade: \"Education\" }],\n [\"foxglove-gardens\", { name: \"Foxglove Gardens\", district: \"Riverside\", trade: \"Retail\" }],\n [\"granite-hall\", { name: \"Granite Hall\", district: \"Old Town\", trade: \"Events\" }],\n [\"harbour-arts\", { name: \"Harbour Arts Society\", district: \"North Quay\", trade: \"Arts\" }],\n [\"heathfield\", { name: \"Heathfield Theatre\", district: \"Old Town\", trade: \"Arts\" }],\n [\"ivy-lane\", { name: \"Ivy Lane Studio\", district: \"Riverside\", trade: \"Design\" }],\n [\"juniper-toys\", { name: \"Juniper Toys\", district: \"Riverside\", trade: \"Retail\" }],\n [\"kestrel-cycling\", { name: \"Kestrel Cycling Club\", district: \"Riverside\", trade: \"Sport\" }],\n [\"larkspur-home\", { name: \"Larkspur Home\", district: \"Old Town\", trade: \"Retail\" }],\n [\"meridian-monthly\", { name: \"Meridian Monthly\", district: \"North Quay\", trade: \"Publishing\" }],\n [\"northwind\", { name: \"Northwind Outfitters\", district: \"North Quay\", trade: \"Retail\" }],\n [\"orchard-market\", { name: \"Orchard Street Market\", district: \"Old Town\", trade: \"Markets\" }],\n ]),\n indexes: (index) => ({\n plan_print_customers_by_district: index.on([\"district\"]),\n }),\n mutations: (mutation) => ({\n // The customers' patch door: the works edits its customers elsewhere, and a Plan reads them live.\n patch: mutation.patch(),\n }),\n});\n\n/**\n * Each press's utilisation (%): a reading a day from 5 October, as the\n * dataflow measures it, idle at the weekends. Press B2's 97 on the 20th is\n * the day its two jobs overlap.\n */\nexport const planPrintUtilisation = e3.input(\"plan_print_utilisation\", DictType(StringType, ArrayType(FloatType)), variant(\"value\", new Map([\n [\"a1\", [50.0, 12.0, 38.0, 20.0, 15.0, 0.0, 0.0, 22.0, 18.0, 31.0, 25.0, 20.0, 0.0, 0.0, 75.0, 40.0, 30.0, 28.0, 20.0, 0.0, 0.0, 18.0, 13.0, 10.0, 8.0, 6.0, 0.0, 0.0]],\n [\"a2\", [20.0, 50.0, 25.0, 18.0, 15.0, 0.0, 0.0, 24.0, 20.0, 38.0, 30.0, 22.0, 0.0, 0.0, 26.0, 30.0, 63.0, 35.0, 22.0, 0.0, 0.0, 20.0, 18.0, 19.0, 12.0, 10.0, 0.0, 0.0]],\n [\"a3\", [10.0, 12.0, 14.0, 13.0, 18.0, 0.0, 0.0, 15.0, 16.0, 20.0, 19.0, 22.0, 0.0, 0.0, 24.0, 28.0, 30.0, 38.0, 25.0, 0.0, 0.0, 14.0, 20.0, 12.0, 10.0, 8.0, 0.0, 0.0]],\n [\"b1\", [100.0, 45.0, 30.0, 28.0, 26.0, 0.0, 0.0, 75.0, 40.0, 63.0, 48.0, 36.0, 0.0, 0.0, 30.0, 34.0, 28.0, 26.0, 24.0, 0.0, 0.0, 38.0, 22.0, 18.0, 14.0, 12.0, 0.0, 0.0]],\n [\"b2\", [18.0, 20.0, 22.0, 24.0, 25.0, 0.0, 0.0, 26.0, 28.0, 30.0, 32.0, 30.0, 0.0, 0.0, 34.0, 97.0, 40.0, 36.0, 30.0, 0.0, 0.0, 26.0, 24.0, 22.0, 13.0, 10.0, 0.0, 0.0]],\n [\"b3\", [8.0, 10.0, 12.0, 10.0, 9.0, 0.0, 0.0, 12.0, 14.0, 16.0, 18.0, 13.0, 0.0, 0.0, 20.0, 19.0, 16.0, 14.0, 12.0, 0.0, 0.0, 10.0, 9.0, 8.0, 7.0, 6.0, 0.0, 0.0]],\n])));\n\n/** The sheets printed each day from 5 October, across every press. */\nexport const planPrintOutput = e3.input(\"plan_print_output\", ArrayType(FloatType), variant(\"value\", [\n 336000.0, 80000.0, 72000.0, 16000.0, 48000.0, 0.0, 0.0,\n 180000.0, 0.0, 270000.0, 24000.0, 12000.0, 0.0, 0.0,\n 144000.0, 126000.0, 100000.0, 48000.0, 0.0, 0.0, 0.0,\n 90000.0, 24000.0, 30000.0, 24000.0, 0.0, 0.0, 0.0,\n]));\n\n/** A paper stock: its name, and its level in thousands of sheets, a reading a week keyed by its week (#1436). */\nexport const PrintStock = StructType({ name: StringType, weekly: DictType(DateTimeType, FloatType) });\n\n/** The paper in stock. */\nexport const planLinkStock = e3.input(\"plan_link_stock\", DictType(StringType, PrintStock), variant(\"value\", new Map([\n [\"board\", { name: \"Board\", weekly: new SortedMap([\n [new Date(\"2026-10-05T00:00:00Z\"), 40.0], [new Date(\"2026-10-12T00:00:00Z\"), 22.0], [new Date(\"2026-10-19T00:00:00Z\"), 31.0], [new Date(\"2026-10-26T00:00:00Z\"), 18.0],\n ], compareFor(DateTimeType)) }],\n [\"coated\", { name: \"Coated\", weekly: new SortedMap([\n [new Date(\"2026-10-05T00:00:00Z\"), 520.0], [new Date(\"2026-10-12T00:00:00Z\"), 410.0], [new Date(\"2026-10-19T00:00:00Z\"), 460.0], [new Date(\"2026-10-26T00:00:00Z\"), 380.0],\n ], compareFor(DateTimeType)) }],\n [\"uncoated\", { name: \"Uncoated\", weekly: new SortedMap([\n [new Date(\"2026-10-05T00:00:00Z\"), 300.0], [new Date(\"2026-10-12T00:00:00Z\"), 260.0], [new Date(\"2026-10-19T00:00:00Z\"), 280.0], [new Date(\"2026-10-26T00:00:00Z\"), 240.0],\n ], compareFor(DateTimeType)) }],\n])));\n\n/** A work centre a job passes through on its way out: the platesetter, the bindery's folder and binder, the dispatch bay. */\nexport const PrintCentre = StructType({ name: StringType });\n\n/** A set of plates the platesetter makes for a job, at the moment it makes them. */\nexport const PrintPlates = StructType({ title: StringType, at: DateTimeType, setter: StringType });\n\n/** A bindery job — folding a press job's sections, or binding them — on the folder or the binder. */\nexport const PrintBinding = StructType({ title: StringType, start: DateTimeType, end: DateTimeType, line: StringType, state: EventStateType });\n\n/** The platesetter. A Plan never writes its resources. */\nexport const planLinkSetters = e3.record(\"plan_link_setters\", DictType(StringType, PrintCentre), {\n initial: new Map([\n [\"ps\", { name: \"Platesetter\" }],\n ]),\n});\n\n/** The bindery's two lines. */\nexport const planLinkLines = e3.record(\"plan_link_lines\", DictType(StringType, PrintCentre), {\n initial: new Map([\n [\"fold\", { name: \"Folder\" }],\n [\"bind\", { name: \"Binder\" }],\n ]),\n});\n\n/** The dispatch bay. */\nexport const planLinkBays = e3.record(\"plan_link_bays\", DictType(StringType, PrintCentre), {\n initial: new Map([\n [\"bay\", { name: \"Dispatch bay\" }],\n ]),\n});\n\n/** The parent of the shared folder and binder, held in a record like every other resource. */\nexport const planPrintBindery = e3.record(\"plan_print_bindery\", DictType(StringType, PrintCentre), {\n initial: new Map([\n [\"bindery\", { name: \"Bindery\" }],\n ]),\n});\n\n/** The vans a delivery can move onto from the dispatch bay. */\nexport const planPrintVans = e3.record(\"plan_print_vans\", DictType(StringType, PrintCentre), {\n initial: new Map([\n [\"van1\", { name: \"Van 1\" }], [\"van2\", { name: \"Van 2\" }],\n ]),\n});\n\n/** A delivery's own status, separate from the schedule's lifecycle. */\nexport const PrintDispatchStatus = VariantType({ queued: NullType, ready: NullType, dispatched: NullType });\n\n/** A delivery on a bay or a van: the variant preserves the resource kind when it moves. */\nexport const PrintDispatch = StructType({\n title: StringType, at: DateTimeType,\n location: VariantType({ bay: StringType, van: StringType }),\n lane: StringType, status: PrintDispatchStatus, pallets: FloatType,\n});\n\n/** The print works' own plate orders, timed before its existing jobs. */\nexport const planPrintPlates = e3.record(\"plan_print_plates\", DictType(StringType, PrintPlates), {\n initial: new Map([\n [\"P-101\", { title: \"Handbook plates\", at: new Date(\"2026-10-16T14:00:00Z\"), setter: \"ps\" }],\n [\"P-102\", { title: \"Poster plates\", at: new Date(\"2026-10-13T14:00:00Z\"), setter: \"ps\" }],\n ]),\n mutations: (mutation) => ({\n // The print works' plates commit through their own patch door.\n patch: mutation.patch(),\n }),\n});\n\n/** Two foldings run in parallel, followed by binding, after the handbook leaves Press A1. */\nexport const planPrintBindings = e3.record(\"plan_print_bindings\", DictType(StringType, PrintBinding), {\n initial: new Map([\n [\"B-101\", { title: \"Fold handbook sections\", start: new Date(\"2026-10-20T06:00:00Z\"), end: new Date(\"2026-10-20T14:00:00Z\"), line: \"fold\", state: variant(\"confirmed\", null) }],\n [\"B-102\", { title: \"Fold handbook inserts\", start: new Date(\"2026-10-20T10:00:00Z\"), end: new Date(\"2026-10-20T16:00:00Z\"), line: \"fold\", state: variant(\"confirmed\", null) }],\n [\"B-103\", { title: \"Bind handbooks\", start: new Date(\"2026-10-21T06:00:00Z\"), end: new Date(\"2026-10-21T14:00:00Z\"), line: \"bind\", state: variant(\"confirmed\", null) }],\n ]),\n mutations: (mutation) => ({\n // The print works' bindery jobs commit through their own patch door.\n patch: mutation.patch(),\n }),\n});\n\n/** Deliveries occupy AM/PM lanes and carry each of the dispatch statuses. */\nexport const planPrintDeliveries = e3.record(\"plan_print_deliveries\", DictType(StringType, PrintDispatch), {\n initial: new Map([\n [\"D-101\", { title: \"Handbooks\", at: new Date(\"2026-10-22T10:00:00Z\"), location: variant(\"bay\", \"bay\"), lane: \"AM\", status: variant(\"queued\", null), pallets: 3.0 }],\n [\"D-102\", { title: \"Event posters\", at: new Date(\"2026-10-15T14:00:00Z\"), location: variant(\"van\", \"van1\"), lane: \"PM\", status: variant(\"ready\", null), pallets: 2.0 }],\n [\"D-103\", { title: \"Museum guides\", at: new Date(\"2026-10-09T10:00:00Z\"), location: variant(\"van\", \"van2\"), lane: \"AM\", status: variant(\"dispatched\", null), pallets: 1.0 }],\n ]),\n mutations: (mutation) => ({\n // The print works' deliveries commit through their own patch door.\n patch: mutation.patch(),\n }),\n});\n\n/** A job template: its name and group, how long the job it creates runs, and that job's fields. */\nexport const PrintJobTemplate = StructType({\n name: StringType, group: StringType, hours: FloatType,\n values: StructType({ title: StringType, state: EventStateType, sheets: FloatType, customer: StringType, stock: PrintJob.fields.stock, due: OptionType(DateTimeType) }),\n});\n\n/** A stop template: a stop is one instant, so it runs no time. */\nexport const PrintStopTemplate = StructType({ name: StringType, group: StringType, values: StructType({ title: StringType, kind: PrintStop.fields.kind }) });\n\n/** A shift template: the hour a shift dropped on a day starts at, eight hours long. */\nexport const PrintShiftTemplate = StructType({ name: StringType, group: StringType, hour: IntegerType, values: StructType({ title: StringType, state: EventStateType }) });\n\n/** A plates template: plates are made at one instant. */\nexport const PrintPlatesTemplate = StructType({ name: StringType, group: StringType, values: StructType({ title: StringType }) });\n\n/** A bindery template: how long the bindery job it creates runs. */\nexport const PrintBindingTemplate = StructType({ name: StringType, group: StringType, hours: FloatType, values: StructType({ title: StringType, state: EventStateType }) });\n\n/** A delivery template: the hour a delivery dropped on a day leaves at. */\nexport const PrintDeliveryTemplate = StructType({\n name: StringType, group: StringType, hour: IntegerType,\n values: StructType({ title: StringType, lane: StringType, status: PrintDispatchStatus, pallets: FloatType }),\n});\n\n/** The job templates. A Plan never writes them: the library lists them, and a drop creates a job from one. */\nexport const planPrintJobTemplates = e3.record(\"plan_print_job_templates\", DictType(StringType, PrintJobTemplate), {\n initial: new Map([\n [\"board\", { name: \"Board run\", group: \"Jobs\", hours: 8.0, values: { title: \"Board run\", state: variant(\"proposed\", variant(\"added\", null)), sheets: 24000.0, customer: \"\", stock: variant(\"board\", null), due: none } }],\n [\"brochure\", { name: \"Brochure run\", group: \"Jobs\", hours: 6.0, values: { title: \"Brochure run\", state: variant(\"proposed\", variant(\"added\", null)), sheets: 40000.0, customer: \"\", stock: variant(\"coated\", null), due: none } }],\n [\"catalogue\", { name: \"Catalogue run\", group: \"Jobs\", hours: 12.0, values: { title: \"Catalogue run\", state: variant(\"proposed\", variant(\"added\", null)), sheets: 96000.0, customer: \"\", stock: variant(\"coated\", null), due: none } }],\n [\"poster\", { name: \"Poster run\", group: \"Jobs\", hours: 4.0, values: { title: \"Poster run\", state: variant(\"proposed\", variant(\"added\", null)), sheets: 20000.0, customer: \"\", stock: variant(\"uncoated\", null), due: none } }],\n ]),\n indexes: (index) => ({\n plan_print_job_templates_by_group: index.on([\"group\"]),\n }),\n});\n\n/** The stop templates. */\nexport const planPrintStopTemplates = e3.record(\"plan_print_stop_templates\", DictType(StringType, PrintStopTemplate), {\n initial: new Map([\n [\"plates\", { name: \"Plate change\", group: \"Stops\", values: { title: \"Plate change\", kind: variant(\"plate_change\", null) } }],\n [\"service\", { name: \"Service\", group: \"Stops\", values: { title: \"Service\", kind: variant(\"service\", null) } }],\n ]),\n indexes: (index) => ({\n plan_print_stop_templates_by_group: index.on([\"group\"]),\n }),\n});\n\n/** The shift templates: early, late and night. */\nexport const planPrintShiftTemplates = e3.record(\"plan_print_shift_templates\", DictType(StringType, PrintShiftTemplate), {\n initial: new Map([\n [\"early\", { name: \"Early shift\", group: \"Shifts\", hour: 6n, values: { title: \"Early\", state: variant(\"confirmed\", null) } }],\n [\"late\", { name: \"Late shift\", group: \"Shifts\", hour: 14n, values: { title: \"Late\", state: variant(\"confirmed\", null) } }],\n [\"night\", { name: \"Night shift\", group: \"Shifts\", hour: 22n, values: { title: \"Night\", state: variant(\"proposed\", variant(\"added\", null)) } }],\n ]),\n indexes: (index) => ({\n plan_print_shift_templates_by_group: index.on([\"group\"]),\n }),\n});\n\n/** The plates templates. */\nexport const planPrintPlatesTemplates = e3.record(\"plan_print_plates_templates\", DictType(StringType, PrintPlatesTemplate), {\n initial: new Map([\n [\"plates\", { name: \"Job plates\", group: \"Plate room\", values: { title: \"Job plates\" } }],\n ]),\n indexes: (index) => ({\n plan_print_plates_templates_by_group: index.on([\"group\"]),\n }),\n});\n\n/** The bindery templates. */\nexport const planPrintBindingTemplates = e3.record(\"plan_print_binding_templates\", DictType(StringType, PrintBindingTemplate), {\n initial: new Map([\n [\"fold\", { name: \"Fold sections\", group: \"Bindery\", hours: 8.0, values: { title: \"Fold sections\", state: variant(\"confirmed\", null) } }],\n ]),\n indexes: (index) => ({\n plan_print_binding_templates_by_group: index.on([\"group\"]),\n }),\n});\n\n/** The delivery templates. */\nexport const planPrintDeliveryTemplates = e3.record(\"plan_print_delivery_templates\", DictType(StringType, PrintDeliveryTemplate), {\n initial: new Map([\n [\"delivery\", { name: \"Morning delivery\", group: \"Dispatch\", hour: 10n, values: { title: \"Delivery\", lane: \"AM\", status: variant(\"queued\", null), pallets: 1.0 } }],\n ]),\n indexes: (index) => ({\n plan_print_delivery_templates_by_group: index.on([\"group\"]),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n // What the Plan reads whole binds with Data.bind, which keeps it loaded beside its pages; the event\n // records it writes bind with Record.bind, and it reads the jobs' and the shifts' events through their\n // pages alone.\n const presses = $.let(Data.bind(planPrintPresses));\n const crews = $.let(Record.bind(planPrintCrews, []));\n const jobs = $.let(Record.bind(planPrintJobs));\n const stops = $.let(Record.bind(planPrintStops));\n const shifts = $.let(Record.bind(planPrintShifts));\n const customers = $.let(Data.bind(planPrintCustomers));\n const jobTemplates = $.let(Data.bind(planPrintJobTemplates));\n const stopTemplates = $.let(Data.bind(planPrintStopTemplates));\n const shiftTemplates = $.let(Data.bind(planPrintShiftTemplates));\n const platesTemplates = $.let(Data.bind(planPrintPlatesTemplates));\n const bindingTemplates = $.let(Data.bind(planPrintBindingTemplates));\n const deliveryTemplates = $.let(Data.bind(planPrintDeliveryTemplates));\n // One rail over the records, a source each (#1344): the jobs and the shifts through their interval\n // indexes, their range the one window the toolbar's dates, the resolution and the brush write; the\n // presses, the customers and each templates record by its fields.\n const slice = $.let(Slice.bindRecords(\"ex.planPrintWorks\", {\n job: { source: Data.bindPaged(planPrintJobs, { indexes: [\"plan_print_jobs_by_time\", \"plan_print_jobs_by_stock_time\"] }), icon: { prefix: \"fas\", name: \"file-lines\" },\n fields: { stock: { label: \"Stock\" }, start: { label: \"Dates\" } }, range: \"start\" },\n shift: { source: Data.bindPaged(planPrintShifts, { indexes: [\"plan_print_shifts_by_time\"] }), icon: { prefix: \"fas\", name: \"user-clock\" },\n fields: { start: { label: \"Dates\" } }, range: \"start\" },\n presses: { source: Data.bindPaged(planPrintPresses, { indexes: [\"plan_print_presses_by_hall\"] }), icon: { prefix: \"fas\", name: \"print\" },\n fields: { hall: { label: \"Hall\", hints: [\"Hall A\", \"Hall B\"] } } },\n customers: { source: Data.bindPaged(planPrintCustomers, { indexes: [\"plan_print_customers_by_district\"] }), icon: { prefix: \"fas\", name: \"building\" },\n fields: { district: { label: \"District\", hints: [\"North Quay\", \"Old Town\", \"Riverside\"] } } },\n jobTemplates: { source: Data.bindPaged(planPrintJobTemplates, { indexes: [\"plan_print_job_templates_by_group\"] }), icon: { prefix: \"fas\", name: \"layer-group\" },\n fields: { group: { label: \"Job templates\", hints: [\"Jobs\"] } } },\n stopTemplates: { source: Data.bindPaged(planPrintStopTemplates, { indexes: [\"plan_print_stop_templates_by_group\"] }), icon: { prefix: \"fas\", name: \"layer-group\" },\n fields: { group: { label: \"Stop templates\", hints: [\"Stops\"] } } },\n shiftTemplates: { source: Data.bindPaged(planPrintShiftTemplates, { indexes: [\"plan_print_shift_templates_by_group\"] }), icon: { prefix: \"fas\", name: \"layer-group\" },\n fields: { group: { label: \"Shift templates\", hints: [\"Shifts\"] } } },\n platesTemplates: { source: Data.bindPaged(planPrintPlatesTemplates, { indexes: [\"plan_print_plates_templates_by_group\"] }), icon: { prefix: \"fas\", name: \"layer-group\" },\n fields: { group: { label: \"Plates templates\", hints: [\"Plate room\"] } } },\n bindingTemplates: { source: Data.bindPaged(planPrintBindingTemplates, { indexes: [\"plan_print_binding_templates_by_group\"] }), icon: { prefix: \"fas\", name: \"layer-group\" },\n fields: { group: { label: \"Bindery templates\", hints: [\"Bindery\"] } } },\n deliveryTemplates: { source: Data.bindPaged(planPrintDeliveryTemplates, { indexes: [\"plan_print_delivery_templates_by_group\"] }), icon: { prefix: \"fas\", name: \"layer-group\" },\n fields: { group: { label: \"Delivery templates\", hints: [\"Dispatch\"] } } },\n }));\n // A kind narrowed through its source reads one event by its key through the record's own entries.\n const jobEntries = $.let(Data.bindPaged(planPrintJobs));\n const shiftEntries = $.let(Data.bindPaged(planPrintShifts));\n const setters = $.let(Record.bind(planLinkSetters, []));\n const lines = $.let(Record.bind(planLinkLines, []));\n const bindery = $.let(Record.bind(planPrintBindery, []));\n const bays = $.let(Record.bind(planLinkBays, []));\n const vans = $.let(Record.bind(planPrintVans, []));\n const plates = $.let(Record.bind(planPrintPlates));\n const bindings = $.let(Record.bind(planPrintBindings));\n const deliveries = $.let(Record.bind(planPrintDeliveries));\n const stock = $.let(Data.bind(planLinkStock));\n const lineRows = $.const(lines.read().union(bindery.read(), (_$2, line) => line));\n const util = $.let(Data.bind(planPrintUtilisation));\n const output = $.let(Data.bind(planPrintOutput));\n // The window's first day: each reading runs from it, a day apiece.\n const first = $.const(new Date(\"2026-10-05T00:00:00Z\"), DateTimeType);\n const parentLine = $.const(some(\"bindery\"), OptionType(StringType));\n const topLine = $.const(none, OptionType(StringType));\n // A press's readings as heat cells, one a day.\n const daily = $.const(East.function([ArrayType(FloatType)], ArrayType(Plan.Types.HeatCell), (_$2, readings) =>\n East.Array.generate(readings.size(), Plan.Types.HeatCell, (_$3, i) => ({\n at: Plan.at.time(first.addDays(i)), value: some(readings.get(i)), label: none,\n }))));\n // The sheets printed each day, as a chart's points.\n const PrintDay = StructType({ day: DateTimeType, sheets: FloatType });\n const printed = $.let(output.read());\n const days = $.let(East.Array.generate(printed.size(), PrintDay, (_$2, i) => ({ day: first.addDays(i), sheets: printed.get(i) })));\n const axis = $.let(Plan.axis({\n window: { min: new Date(\"2026-10-05T00:00:00Z\"), max: new Date(\"2026-11-02T00:00:00Z\") },\n resolution: \"day\", resolutions: [\"week\", \"day\"], now: new Date(\"2026-10-14T09:00:00Z\"),\n }));\n const canDrop = $.const(East.function([Schedule.Types.Candidate], OptionType(StringType), ($2, candidate) => {\n const reason = $2.let(none, OptionType(StringType));\n $2.match(candidate.resource, { some: ($3, resource) => {\n $3.if(resource.kind.equal(\"presses\").and(() => resource.key.equal(\"b3\")), $4 => {\n $4.assign(reason, some(\"Press B3 is in service; choose another press\"));\n });\n } });\n return reason;\n }));\n // A stop's own inspector: its title, and whether it is a plate change or a\n // service, chosen on a segment — the edited stop goes back through `update`.\n const StopKindType = PrintStop.fields.kind;\n const inspectStop = $.const(East.function([PrintStop, FunctionType([PrintStop], NullType)], UIComponentType, ($2, stop, update) => {\n const setKind = $2.const(East.function([StringType], NullType, ($3, picked) => {\n const kind = $3.const(picked.equal(\"service\").ifElse(\n () => East.value(variant(\"service\", null), StopKindType),\n () => East.value(variant(\"plate_change\", null), StopKindType)));\n // East has no struct spread: the stop, rebuilt with its new kind.\n $3(update({ title: stop.title, at: stop.at, press: stop.press, kind }));\n }));\n return (\n <VStack gap=\"3\" align=\"stretch\">\n <Text>{stop.title}</Text>\n <SegmentGroup value={stop.kind.getTag()} onChange={setKind} size=\"sm\"\n items={[SegmentGroup.Item(\"plate_change\", \"Plate change\"), SegmentGroup.Item(\"service\", \"Service\")]} />\n </VStack>\n );\n }));\n return (\n <Plan\n id=\"printWorks\"\n axis={axis}\n date={first}\n canDrop={canDrop}\n slice={{ slice }}\n resources={{\n presses: Schedule.resources(presses.read(), {\n name: \"Presses\", icon: \"print\",\n label: p => p.name, group: p => p.hall,\n sub: p => some(East.str`${East.Float.printCommaSeperated(p.sheets_per_hour, 0n)} sheets/h`),\n // A row under each press, from the dataflow's utilisation: an ordinary\n // heat series over the press rows, read only.\n measures: [\n Plan.series.heat(PrintPress, {\n key: \"util\", title: \"Utilisation\", label: () => \"Utilisation\",\n cells: (_p, key) => Plan.heatCells(daily(util.read().get(key)), { min: 0, max: 100, warnAt: 95 }),\n }),\n ],\n }),\n crews: Schedule.resources(crews.read(), { name: \"Crews\", icon: \"user-group\", label: c => c.name, group: c => c.hall }),\n setters: Schedule.resources(setters.read(), { name: \"Plate room\", icon: \"layer-group\", label: p => p.name, meta: () => some(\"Plates before printing\") }),\n lines: Schedule.resources(lineRows, {\n name: \"Bindery\", icon: \"book\", label: l => l.name,\n parent: (_l, key) => key.equal(\"bindery\").ifElse(() => topLine, () => parentLine),\n rollup: \"union\", collapsed: (_l, key) => key.equal(\"bindery\"),\n meta: () => some(\"Finishing\"), value: (_l, key) => key.equal(\"bindery\").ifElse(() => some(\"2 lines\"), () => topLine),\n }),\n bays: Schedule.resources(bays.read(), { name: \"Dispatch\", icon: \"warehouse\", label: b => b.name, meta: () => some(\"Loading\") }),\n vans: Schedule.resources(vans.read(), { name: \"Vans\", icon: \"truck\", label: v => v.name, meta: () => some(\"Delivery fleet\") }),\n }}\n events={{\n job: Schedule.events(jobs, {\n name: \"Print job\", icon: \"file-lines\", draw: \"span\",\n title: \"title\", start: \"start\", end: \"end\",\n resource: { field: \"press\", of: \"presses\" },\n state: \"state\",\n quantity: { field: \"sheets\", unit: \"sheets\" },\n backlog: { duration: j => variant(\"hours\", j.sheets.divide(8000.0)), due: j => j.due },\n fields: {\n customer: Schedule.field.text({ label: \"Customer\" }),\n stock: Schedule.field.select({ labels: { coated: \"Coated\", uncoated: \"Uncoated\", board: \"Board\" } }),\n // A press is loaded with at most 200,000 sheets for one run, so a longer job is split into\n // runs: the holiday catalogue's 240,000 went on as one.\n sheets: Schedule.field.number({ label: \"Sheets\", step: 1000.0, min: 0.0, max: 200000.0 }),\n },\n // Narrowed through its source of the slice (`job`): one job is read by its key here.\n entries: jobEntries,\n templates: Schedule.templates(jobTemplates.read(), {\n name: t => t.name, group: t => some(t.group), duration: t => variant(\"hours\", t.hours), values: t => t.values, source: \"jobTemplates\",\n }),\n }),\n stop: Schedule.events(stops, {\n name: \"Stop\", icon: \"screwdriver-wrench\", draw: \"marks\",\n title: \"title\", at: \"at\",\n resource: { field: \"press\", of: \"presses\" },\n inspector: inspectStop,\n // A stop is one instant: its templates give no duration.\n templates: Schedule.templates(stopTemplates.read(), { name: t => t.name, group: t => some(t.group), values: t => t.values, source: \"stopTemplates\" }),\n }),\n shift: Schedule.events(shifts, {\n name: \"Crew shift\", icon: \"user-clock\", draw: \"cards\",\n title: \"title\", start: \"start\", end: \"end\",\n resource: { field: \"crew\", of: \"crews\" }, state: \"state\",\n entries: shiftEntries,\n templates: Schedule.templates(shiftTemplates.read(), {\n name: t => t.name, group: t => some(t.group), at: t => some({ hour: t.hour, minute: 0n }), duration: () => variant(\"hours\", 8.0),\n values: t => t.values, source: \"shiftTemplates\",\n }),\n }),\n plate: Schedule.events(plates, {\n name: \"Plates\", icon: \"clone\", title: \"title\", at: \"at\", resource: { field: \"setter\", of: \"setters\" },\n templates: Schedule.templates(platesTemplates.read(), { name: t => t.name, group: t => some(t.group), values: t => t.values, source: \"platesTemplates\" }),\n }),\n binding: Schedule.events(bindings, {\n name: \"Bindery job\", icon: \"book-open\", draw: \"cards\", title: \"title\", start: \"start\", end: \"end\",\n resource: { field: \"line\", of: \"lines\" }, state: \"state\", overlaps: \"allow\",\n templates: Schedule.templates(bindingTemplates.read(), {\n name: t => t.name, group: t => some(t.group), duration: t => variant(\"hours\", t.hours), values: t => t.values, source: \"bindingTemplates\",\n }),\n }),\n delivery: Schedule.events(deliveries, {\n name: \"Delivery\", icon: \"truck\", draw: \"buckets\", title: \"title\", at: \"at\",\n resource: { field: \"location\", of: { bay: \"bays\", van: \"vans\" } }, lane: \"lane\",\n status: { field: \"status\", cases: {\n queued: { label: \"Queued\", tone: variant(\"warning\", null), ring: true },\n ready: { label: \"Ready\", tone: variant(\"info\", null), ring: false },\n dispatched: { label: \"Dispatched\", tone: variant(\"success\", null), ring: false },\n } },\n ready: d => d.pallets.lessEqual(0.0).ifElse(\n () => variant(\"invalid\", [{ field: \"pallets\", message: \"Pallets must be positive\" }]),\n () => variant(\"ready\", null)),\n fields: { pallets: Schedule.field.number({ label: \"Pallets\", min: 0.0, step: 1.0 }) },\n templates: Schedule.templates(deliveryTemplates.read(), {\n name: t => t.name, group: t => some(t.group), at: t => some({ hour: t.hour, minute: 0n }), values: t => t.values, source: \"deliveryTemplates\",\n }),\n }),\n }}\n rows={[\n Plan.chart({\n key: \"output\", label: \"SHEETS / DAY\", id: true, pinned: true, height: \"spark\", expandable: true,\n layers: [Chart.Column(days, { x: r => r.day, y: r => r.sheets })],\n }),\n Plan.over(stock, [Plan.series.table(PrintStock, {\n key: \"stock\", title: \"Paper stock\", label: s => s.name,\n cells: Plan.tableCells(Plan.values(\"weekly\", (level) => ({ value: level }))), format: Format.Number({ maximumFractionDigits: 0n }),\n })]),\n ]}\n links={[\n Plan.link({ key: \"plates\", from: Plan.eventRef(\"plate\", \"P-101\"), to: Plan.eventRef(\"job\", \"J-1004\") }),\n Plan.link({ key: \"printed\", from: Plan.eventRef(\"job\", \"J-1004\"), to: Plan.eventRef(\"binding\", \"B-101\"), quantity: Plan.quantity(144, { unit: \"k sheets\" }) }),\n Plan.link({ key: \"folded\", from: Plan.eventRef(\"binding\", \"B-101\"), to: Plan.eventRef(\"binding\", \"B-103\") }),\n Plan.link({ key: \"dispatched\", from: Plan.eventRef(\"binding\", \"B-103\"), to: Plan.eventRef(\"delivery\", \"D-101\") }),\n ]}\n grain=\"resource\"\n library={[\n Plan.library.events(),\n Plan.library.backlog(),\n Plan.library.series(),\n // The customers, by district: a card dropped on a job sets its customer. The tab follows the\n // rail's `customers` source, by its rows' keys.\n Plan.library.tab(customers.read(), {\n name: \"Customers\", icon: \"building\",\n label: c => c.name, meta: c => some(c.trade), group: c => c.district,\n drop: c => Schedule.patch(PrintJob, { customer: c.name }), source: \"customers\",\n }),\n ]}\n inspector\n />\n );\n }}</Reactive>\n ))"
42726
43041
  },
42727
43042
  {
42728
43043
  "id": "e3-ui:plan-events.examples.tsx:planEventLinks",
@@ -44108,6 +44423,489 @@
44108
44423
  ],
44109
44424
  "source": "// The query library over the same record and data sources: one toolbar — the search, Sort, Grid · List and \"+ New query on orders\" — beside the data sources with their counts of saved queries and this viewer's recent runs; the seven saved queries as a gallery, each card a wireframe of its steps with its name, its description and what it gives, and \"Open in builder →\", which opens the query in the builder that shares its id\n// inputs: []\n/** One line of an order: a SKU, its unit price and the quantity ordered. */\nconst Line = StructType({ price: FloatType, qty: IntegerType, sku: StringType });\n\n/** Where an order stands: cancelled for a reason, pending, or shipped on a date. */\nconst Status = VariantType({ cancelled: StructType({ reason: StringType }), pending: NullType, shipped: StructType({ date: DateTimeType }) });\n\n/** An order: `discount` is the fraction taken off, when there is one, and `total` the lines' gross less it, to the cent. */\nconst Order = StructType({\n customer_id: StringType, discount: OptionType(FloatType), id: IntegerType, lines: ArrayType(Line), status: Status, total: FloatType,\n});\n\n/** A customer's tier. */\nconst Tier = VariantType({ gold: NullType, standard: NullType });\n\n/** A customer, and their tier. */\nconst Customer = StructType({ name: StringType, region: StringType, tier: Tier });\n\n/** Weekly demand by region: eight weeks, the first at index 0. */\nconst Forecast = StructType({ regions: DictType(StringType, StructType({ weekly: ArrayType(FloatType) })) });\n\n/** A part and the parts it is built from: a bill of materials. */\nconst Part = RecursiveType(self => StructType({ children: ArrayType(self), cost: FloatType, sku: StringType }));\n\n/** The demand model: units sold at a unit price in a region. */\nconst ModelInput = StructType({ price: FloatType, region: StringType });\n\nconst Model = FunctionType([ModelInput], FloatType);\n\n/** The orders, ids 1001–1040, in id order: the mock's forty, drawn from seed 875 (`Query Editor Spec.md` §6). */\nexport const orders = e3.input(\"orders\", ArrayType(Order), variant(\"value\", [\n { id: 1001n, customer_id: \"C01\", discount: some(0.1), total: 80.1, status: variant(\"shipped\", { date: new Date(\"2026-04-27T09:00:00.000Z\") }),\n lines: [{ price: 8.9, qty: 10n, sku: \"HNG-220\" }] },\n { id: 1002n, customer_id: \"C07\", discount: none, total: 1171.58, status: variant(\"shipped\", { date: new Date(\"2026-01-15T16:00:00.000Z\") }),\n lines: [{ price: 0.85, qty: 38n, sku: \"BLT-045\" }, { price: 46.0, qty: 24n, sku: \"PLT-310\" }, { price: 0.18, qty: 196n, sku: \"WSH-008\" }] },\n { id: 1003n, customer_id: \"C02\", discount: none, total: 453.0, status: variant(\"shipped\", { date: new Date(\"2026-04-06T16:00:00.000Z\") }),\n lines: [{ price: 12.4, qty: 15n, sku: \"BRK-100\" }, { price: 8.9, qty: 30n, sku: \"HNG-220\" }] },\n { id: 1004n, customer_id: \"C05\", discount: some(0.15), total: 128.61, status: variant(\"pending\", null),\n lines: [{ price: 8.9, qty: 17n, sku: \"HNG-220\" }] },\n { id: 1005n, customer_id: \"C02\", discount: none, total: 520.24, status: variant(\"pending\", null),\n lines: [{ price: 46.0, qty: 6n, sku: \"PLT-310\" }, { price: 12.4, qty: 19n, sku: \"BRK-100\" }, { price: 0.18, qty: 48n, sku: \"WSH-008\" }] },\n { id: 1006n, customer_id: \"C06\", discount: none, total: 210.8, status: variant(\"shipped\", { date: new Date(\"2026-06-03T14:00:00.000Z\") }),\n lines: [{ price: 12.4, qty: 17n, sku: \"BRK-100\" }] },\n { id: 1007n, customer_id: \"C05\", discount: some(0.1), total: 1162.92, status: variant(\"shipped\", { date: new Date(\"2026-04-06T09:00:00.000Z\") }),\n lines: [{ price: 0.32, qty: 184n, sku: \"SCR-012\" }, { price: 64.5, qty: 5n, sku: \"RAL-900\" }, { price: 46.0, qty: 7n, sku: \"PLT-310\" }, { price: 3.75, qty: 157n, sku: \"CLP-150\" }] },\n { id: 1008n, customer_id: \"C05\", discount: none, total: 1280.3, status: variant(\"pending\", null),\n lines: [{ price: 0.85, qty: 143n, sku: \"BLT-045\" }, { price: 64.5, qty: 10n, sku: \"RAL-900\" }, { price: 3.75, qty: 137n, sku: \"CLP-150\" }] },\n { id: 1009n, customer_id: \"C04\", discount: some(0.05), total: 409.51, status: variant(\"shipped\", { date: new Date(\"2025-11-18T09:00:00.000Z\") }),\n lines: [{ price: 64.5, qty: 6n, sku: \"RAL-900\" }, { price: 0.18, qty: 211n, sku: \"WSH-008\" }, { price: 0.32, qty: 19n, sku: \"SCR-012\" }] },\n { id: 1010n, customer_id: \"C05\", discount: some(0.05), total: 142.23, status: variant(\"shipped\", { date: new Date(\"2025-10-14T12:00:00.000Z\") }),\n lines: [{ price: 0.18, qty: 189n, sku: \"WSH-008\" }, { price: 8.9, qty: 13n, sku: \"HNG-220\" }] },\n { id: 1011n, customer_id: \"C08\", discount: none, total: 1027.4, status: variant(\"pending\", null),\n lines: [{ price: 8.9, qty: 29n, sku: \"HNG-220\" }, { price: 64.5, qty: 8n, sku: \"RAL-900\" }, { price: 0.85, qty: 298n, sku: \"BLT-045\" }] },\n { id: 1012n, customer_id: \"C02\", discount: none, total: 1109.6, status: variant(\"shipped\", { date: new Date(\"2026-04-01T08:00:00.000Z\") }),\n lines: [{ price: 12.4, qty: 19n, sku: \"BRK-100\" }, { price: 46.0, qty: 19n, sku: \"PLT-310\" }] },\n { id: 1013n, customer_id: \"C08\", discount: some(0.05), total: 311.37, status: variant(\"shipped\", { date: new Date(\"2026-04-27T10:00:00.000Z\") }),\n lines: [{ price: 64.5, qty: 4n, sku: \"RAL-900\" }, { price: 0.32, qty: 218n, sku: \"SCR-012\" }] },\n { id: 1014n, customer_id: \"C07\", discount: none, total: 1765.97, status: variant(\"shipped\", { date: new Date(\"2026-03-09T08:00:00.000Z\") }),\n lines: [{ price: 46.0, qty: 30n, sku: \"PLT-310\" }, { price: 0.18, qty: 254n, sku: \"WSH-008\" }, { price: 0.85, qty: 269n, sku: \"BLT-045\" }, { price: 12.4, qty: 9n, sku: \"BRK-100\" }] },\n { id: 1015n, customer_id: \"C03\", discount: none, total: 3646.84, status: variant(\"pending\", null),\n lines: [{ price: 46.0, qty: 19n, sku: \"PLT-310\" }, { price: 64.5, qty: 26n, sku: \"RAL-900\" }, { price: 3.75, qty: 276n, sku: \"CLP-150\" }, { price: 0.18, qty: 338n, sku: \"WSH-008\" }] },\n { id: 1016n, customer_id: \"C02\", discount: none, total: 1882.9, status: variant(\"pending\", null),\n lines: [{ price: 12.4, qty: 1n, sku: \"BRK-100\" }, { price: 64.5, qty: 29n, sku: \"RAL-900\" }] },\n { id: 1017n, customer_id: \"C02\", discount: some(0.05), total: 2005.59, status: variant(\"pending\", null),\n lines: [{ price: 0.85, qty: 89n, sku: \"BLT-045\" }, { price: 46.0, qty: 12n, sku: \"PLT-310\" }, { price: 64.5, qty: 23n, sku: \"RAL-900\" }] },\n { id: 1018n, customer_id: \"C03\", discount: none, total: 1372.99, status: variant(\"pending\", null),\n lines: [{ price: 46.0, qty: 26n, sku: \"PLT-310\" }, { price: 0.18, qty: 138n, sku: \"WSH-008\" }, { price: 0.85, qty: 179n, sku: \"BLT-045\" }] },\n { id: 1019n, customer_id: \"C05\", discount: none, total: 684.65, status: variant(\"pending\", null),\n lines: [{ price: 0.85, qty: 301n, sku: \"BLT-045\" }, { price: 12.4, qty: 26n, sku: \"BRK-100\" }, { price: 8.9, qty: 8n, sku: \"HNG-220\" }, { price: 0.32, qty: 110n, sku: \"SCR-012\" }] },\n { id: 1020n, customer_id: \"C01\", discount: some(0.05), total: 297.01, status: variant(\"shipped\", { date: new Date(\"2026-02-06T11:00:00.000Z\") }),\n lines: [{ price: 0.32, qty: 75n, sku: \"SCR-012\" }, { price: 0.18, qty: 88n, sku: \"WSH-008\" }, { price: 12.4, qty: 22n, sku: \"BRK-100\" }] },\n { id: 1021n, customer_id: \"C07\", discount: none, total: 1225.5, status: variant(\"shipped\", { date: new Date(\"2026-05-18T14:00:00.000Z\") }),\n lines: [{ price: 64.5, qty: 19n, sku: \"RAL-900\" }] },\n { id: 1022n, customer_id: \"C07\", discount: some(0.15), total: 36.26, status: variant(\"shipped\", { date: new Date(\"2026-01-03T10:00:00.000Z\") }),\n lines: [{ price: 0.18, qty: 237n, sku: \"WSH-008\" }] },\n { id: 1023n, customer_id: \"C01\", discount: some(0.1), total: 1352.32, status: variant(\"shipped\", { date: new Date(\"2026-01-08T12:00:00.000Z\") }),\n lines: [{ price: 0.32, qty: 32n, sku: \"SCR-012\" }, { price: 8.9, qty: 13n, sku: \"HNG-220\" }, { price: 0.18, qty: 123n, sku: \"WSH-008\" }, { price: 64.5, qty: 21n, sku: \"RAL-900\" }] },\n { id: 1024n, customer_id: \"C05\", discount: some(0.05), total: 623.52, status: variant(\"cancelled\", { reason: \"Customer request\" }),\n lines: [{ price: 46.0, qty: 4n, sku: \"PLT-310\" }, { price: 0.18, qty: 209n, sku: \"WSH-008\" }, { price: 0.32, qty: 351n, sku: \"SCR-012\" }, { price: 12.4, qty: 26n, sku: \"BRK-100\" }] },\n { id: 1025n, customer_id: \"C01\", discount: some(0.1), total: 2577.23, status: variant(\"cancelled\", { reason: \"Payment failed\" }),\n lines: [{ price: 0.18, qty: 213n, sku: \"WSH-008\" }, { price: 64.5, qty: 27n, sku: \"RAL-900\" }, { price: 3.75, qty: 289n, sku: \"CLP-150\" }] },\n { id: 1026n, customer_id: \"C03\", discount: none, total: 1913.4, status: variant(\"shipped\", { date: new Date(\"2026-03-07T08:00:00.000Z\") }),\n lines: [{ price: 0.85, qty: 354n, sku: \"BLT-045\" }, { price: 64.5, qty: 25n, sku: \"RAL-900\" }] },\n { id: 1027n, customer_id: \"C08\", discount: none, total: 808.19, status: variant(\"shipped\", { date: new Date(\"2026-06-26T10:00:00.000Z\") }),\n lines: [{ price: 0.85, qty: 3n, sku: \"BLT-045\" }, { price: 8.9, qty: 25n, sku: \"HNG-220\" }, { price: 64.5, qty: 8n, sku: \"RAL-900\" }, { price: 0.18, qty: 373n, sku: \"WSH-008\" }] },\n { id: 1028n, customer_id: \"C06\", discount: none, total: 173.45, status: variant(\"pending\", null),\n lines: [{ price: 0.85, qty: 47n, sku: \"BLT-045\" }, { price: 8.9, qty: 15n, sku: \"HNG-220\" }] },\n { id: 1029n, customer_id: \"C05\", discount: none, total: 64.96, status: variant(\"shipped\", { date: new Date(\"2026-03-19T16:00:00.000Z\") }),\n lines: [{ price: 0.32, qty: 203n, sku: \"SCR-012\" }] },\n { id: 1030n, customer_id: \"C03\", discount: none, total: 913.36, status: variant(\"pending\", null),\n lines: [{ price: 0.85, qty: 380n, sku: \"BLT-045\" }, { price: 3.75, qty: 4n, sku: \"CLP-150\" }, { price: 46.0, qty: 12n, sku: \"PLT-310\" }, { price: 0.32, qty: 73n, sku: \"SCR-012\" }] },\n { id: 1031n, customer_id: \"C06\", discount: none, total: 1537.52, status: variant(\"shipped\", { date: new Date(\"2026-05-31T13:00:00.000Z\") }),\n lines: [{ price: 0.18, qty: 264n, sku: \"WSH-008\" }, { price: 12.4, qty: 20n, sku: \"BRK-100\" }, { price: 46.0, qty: 27n, sku: \"PLT-310\" }] },\n { id: 1032n, customer_id: \"C02\", discount: none, total: 1892.81, status: variant(\"cancelled\", { reason: \"Out of stock\" }),\n lines: [{ price: 46.0, qty: 26n, sku: \"PLT-310\" }, { price: 3.75, qty: 183n, sku: \"CLP-150\" }, { price: 0.32, qty: 33n, sku: \"SCR-012\" }] },\n { id: 1033n, customer_id: \"C01\", discount: none, total: 1834.15, status: variant(\"pending\", null),\n lines: [{ price: 64.5, qty: 27n, sku: \"RAL-900\" }, { price: 0.85, qty: 109n, sku: \"BLT-045\" }] },\n { id: 1034n, customer_id: \"C03\", discount: none, total: 323.06, status: variant(\"pending\", null),\n lines: [{ price: 0.32, qty: 140n, sku: \"SCR-012\" }, { price: 12.4, qty: 19n, sku: \"BRK-100\" }, { price: 0.18, qty: 237n, sku: \"WSH-008\" }] },\n { id: 1035n, customer_id: \"C06\", discount: none, total: 2381.61, status: variant(\"shipped\", { date: new Date(\"2026-06-01T14:00:00.000Z\") }),\n lines: [{ price: 0.18, qty: 292n, sku: \"WSH-008\" }, { price: 3.75, qty: 279n, sku: \"CLP-150\" }, { price: 0.85, qty: 48n, sku: \"BLT-045\" }, { price: 46.0, qty: 27n, sku: \"PLT-310\" }] },\n { id: 1036n, customer_id: \"C01\", discount: some(0.05), total: 1041.68, status: variant(\"shipped\", { date: new Date(\"2026-05-26T13:00:00.000Z\") }),\n lines: [{ price: 64.5, qty: 17n, sku: \"RAL-900\" }] },\n { id: 1037n, customer_id: \"C08\", discount: none, total: 774.5, status: variant(\"pending\", null),\n lines: [{ price: 46.0, qty: 12n, sku: \"PLT-310\" }, { price: 8.9, qty: 25n, sku: \"HNG-220\" }] },\n { id: 1038n, customer_id: \"C01\", discount: none, total: 1758.0, status: variant(\"shipped\", { date: new Date(\"2025-10-28T08:00:00.000Z\") }),\n lines: [{ price: 64.5, qty: 8n, sku: \"RAL-900\" }, { price: 46.0, qty: 27n, sku: \"PLT-310\" }] },\n { id: 1039n, customer_id: \"C06\", discount: none, total: 471.06, status: variant(\"shipped\", { date: new Date(\"2026-04-04T13:00:00.000Z\") }),\n lines: [{ price: 8.9, qty: 15n, sku: \"HNG-220\" }, { price: 0.18, qty: 222n, sku: \"WSH-008\" }, { price: 12.4, qty: 24n, sku: \"BRK-100\" }] },\n { id: 1040n, customer_id: \"C02\", discount: none, total: 884.1, status: variant(\"shipped\", { date: new Date(\"2025-12-08T14:00:00.000Z\") }),\n lines: [{ price: 46.0, qty: 14n, sku: \"PLT-310\" }, { price: 8.9, qty: 18n, sku: \"HNG-220\" }, { price: 0.85, qty: 94n, sku: \"BLT-045\" }] },\n]));\n\n/** The customers, by id. */\nexport const customers = e3.input(\"customers\", DictType(StringType, Customer), variant(\"value\", new SortedMap([\n [\"C01\", { name: \"Harbour Foods\", region: \"NSW\", tier: variant(\"gold\", null) }],\n [\"C02\", { name: \"Coastline Retail\", region: \"NSW\", tier: variant(\"standard\", null) }],\n [\"C03\", { name: \"Ridge Grocers\", region: \"VIC\", tier: variant(\"gold\", null) }],\n [\"C04\", { name: \"Southbank Market\", region: \"VIC\", tier: variant(\"standard\", null) }],\n [\"C05\", { name: \"Sunfield Traders\", region: \"QLD\", tier: variant(\"standard\", null) }],\n [\"C06\", { name: \"Northgate Supply\", region: \"QLD\", tier: variant(\"gold\", null) }],\n [\"C07\", { name: \"Westend Provisions\", region: \"WA\", tier: variant(\"standard\", null) }],\n [\"C08\", { name: \"Ironbark Stores\", region: \"SA\", tier: variant(\"standard\", null) }],\n], compareFor(StringType))));\n\n/** Weekly demand by region: eight weeks of `base × (0.9 + 0.03w + 0.01i)`, to one place, for the region at index i of NSW, VIC, QLD, WA, SA. */\nexport const forecast = e3.input(\"forecast\", Forecast, variant(\"value\", {\n regions: new SortedMap([\n [\"NSW\", { weekly: [1080.0, 1116.0, 1152.0, 1188.0, 1224.0, 1260.0, 1296.0, 1332.0] }],\n [\"QLD\", { weekly: [791.2, 817.0, 842.8, 868.6, 894.4, 920.2, 946.0, 971.8] }],\n [\"SA\", { weekly: [385.4, 397.7, 410.0, 422.3, 434.6, 446.9, 459.2, 471.5] }],\n [\"VIC\", { weekly: [955.5, 987.0, 1018.5, 1050.0, 1081.5, 1113.0, 1144.5, 1176.0] }],\n [\"WA\", { weekly: [502.2, 518.4, 534.6, 550.8, 567.0, 583.2, 599.4, 615.6] }],\n ], compareFor(StringType)),\n}));\n\n/** The demand model, `round₂(base[region] × (price / 10)^−1.4)`: the units sold at a unit price in a region. */\nconst demandModel = East.function([ModelInput], FloatType, ($, input) => {\n const base = $.const(new SortedMap([[\"NSW\", 1200.0], [\"QLD\", 860.0], [\"SA\", 410.0], [\"VIC\", 1050.0], [\"WA\", 540.0]], compareFor(StringType)), DictType(StringType, FloatType));\n // A region the model does not know has a base of 300.\n const demand = base.get(input.region, () => 300.0).multiply(input.price.divide(10.0).pow(-1.4));\n const cents = $.const(demand.multiply(100.0).add(0.5));\n return cents.subtract(cents.remainder(1.0)).divide(100.0);\n});\n\n/** The demand model as data: an East function every runtime can call, which a query tries over a range. */\nexport const model = e3.input(\"model\", Model, variant(\"value\", East.compile(demandModel, [])));\n\n/** The bill of materials for PUMP-A. */\nexport const bom = e3.input(\"bom\", Part, variant(\"value\", {\n sku: \"PUMP-A\", cost: 42.0, children: [\n { sku: \"MOTOR-1\", cost: 120.0, children: [\n { sku: \"ROTOR-1\", cost: 18.5, children: [] }, { sku: \"STATOR-1\", cost: 22.0, children: [] }, { sku: \"BRG-6203\", cost: 3.2, children: [] },\n ] },\n { sku: \"HOUSING-2\", cost: 35.0, children: [{ sku: \"GASKET-9\", cost: 1.1, children: [] }, { sku: \"BOLT-M8\", cost: 0.4, children: [] }] },\n { sku: \"IMPELLER-3\", cost: 27.5, children: [] },\n { sku: \"SEAL-KIT\", cost: 6.8, children: [{ sku: \"ORING-12\", cost: 0.3, children: [] }, { sku: \"ORING-18\", cost: 0.35, children: [] }] },\n ],\n}));\n\n/**\n * The saved queries record: the mock's seven (`Query Editor Spec.md` §6),\n * each its canonical jq — what the builder's steps print — checked against the\n * data sources the builders bind when the package builds, and described where\n * the mock describes it; the rest describe themselves.\n */\nexport const queries = e3.record(\"queries\", Query.Types.Saved, {\n initial: Query.value({ orders, customers, forecast, model, bom }, [\n {\n name: \"Top shipped orders, 2026\",\n jq: `.customers as $customers\n | .orders\n | map(select(.status.type == \"shipped\") | select(.total >= 100 and (.status.value.date | year) == 2026))\n | map(. + {name: $customers[.customer_id].name, region: $customers[.customer_id].region})\n | map({order: .id, customer: .name, region, total, shipped: .status.value.date})\n | sort_by(-.total)\n | .[:10]`,\n savedAt: new Date(\"2026-10-01T09:00:00Z\"),\n },\n {\n name: \"Revenue by region\",\n jq: `.customers as $customers\n | .orders\n | map(select(.status.type == \"shipped\") | select(.total >= 100 and (.status.value.date | year) == 2026))\n | map(. + {region: $customers[.customer_id].region})\n | group_by(.region)\n | map({region: .[0].region, revenue: map(.total) | add, orders: length})\n | sort_by(-.revenue)\n | .[:3]`,\n description: \"Top 3 regions by shipped revenue in 2026, from orders of $100 or more.\",\n savedAt: new Date(\"2026-09-29T09:00:00Z\"),\n },\n {\n name: \"Shipped revenue by month\",\n jq: `.orders\n | map(select(.status.type == \"shipped\"))\n | map(. + {ship_month: .status.value.date | strftime(\"%Y-%m\")})\n | group_by(.ship_month)\n | map({ship_month: .[0].ship_month, revenue: map(.total) | add, orders: length})\n | sort_by(.ship_month)`,\n savedAt: new Date(\"2026-09-12T09:00:00Z\"),\n },\n {\n name: \"Large orders with no discount\",\n jq: `.orders\n | map(select(.total >= 1000 and .discount == null))\n | map({id, customer_id, total, status})\n | sort_by(-.total)`,\n savedAt: new Date(\"2026-09-03T09:00:00Z\"),\n },\n {\n name: \"Units by SKU\",\n jq: `.orders\n | [.[] | . as $order | .lines[] | . + {order_id: $order.id}]\n | group_by(.sku)\n | map({sku: .[0].sku, units: map(.qty) | add, orders: map(.order_id) | unique | length})\n | sort_by(-.units)`,\n savedAt: new Date(\"2026-08-28T09:00:00Z\"),\n },\n {\n name: \"Pump parts cost\",\n jq: `.bom\n | [recurse(.children[]) | {cost, sku}]\n | {total_cost: map(.cost) | add, parts: length, dearest: map(.cost) | max}`,\n description: \"Total cost, part count and dearest part in the PUMP-A bill of materials.\",\n savedAt: new Date(\"2026-08-20T09:00:00Z\"),\n },\n {\n name: \"Demand at $10–$12, NSW\",\n jq: `.model\n | [range(10.0; 12.0 + 0.5 / 2; 0.5) as $price | {price: $price, demand: call(.; {price: $price, region: \"NSW\"})}]`,\n description: \"Modelled demand in NSW at prices from $10 to $12, in $0.50 steps.\",\n savedAt: new Date(\"2026-08-14T09:00:00Z\"),\n },\n ]),\n mutations: (mutation) => ({\n // The record's one write.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const saved = $.let(Record.bind(queries));\n const orderRows = $.let(Data.bind(orders));\n const customerRows = $.let(Data.bind(customers));\n const weekly = $.let(Data.bind(forecast));\n const demand = $.let(Data.bind(model));\n const parts = $.let(Data.bind(bom));\n return (\n <Box height=\"720px\">\n <Query.Library queries={saved} id=\"top\"\n datasets={{ orders: orderRows, customers: customerRows, forecast: weekly, model: demand, bom: parts }} />\n </Box>\n );\n }}</Reactive>\n ))"
44110
44425
  },
44426
+ {
44427
+ "id": "e3-ui:record.examples.tsx:recordBasic",
44428
+ "skill": "e3-ui",
44429
+ "package": "e3-ui",
44430
+ "file": "east-ui/packages/e3-ui/test/record/record.examples.tsx",
44431
+ "suite": "",
44432
+ "test": "The least a Record takes: a record bound with its patch door, a title, a toggle on a Boolean and a cycle over a register's members, stepped by a click",
44433
+ "keywords": [
44434
+ "Record",
44435
+ "Record.column.title",
44436
+ "Record.column.toggle",
44437
+ "Record.column.cycle",
44438
+ "register",
44439
+ "scale",
44440
+ "system of records"
44441
+ ],
44442
+ "imports": [
44443
+ "import {",
44444
+ "import { Box, Button, Configurator, HStack, Reactive, SegmentGroup, Slice, State, StatusValueType, Style, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
44445
+ "import { Data, Record } from \"@elaraai/e3-ui\";",
44446
+ "import e3 from \"@elaraai/e3\";",
44447
+ "import { IndexedWork, indexedWorkOrders } from \"../sheet/sheet-records.examples.js\";"
44448
+ ],
44449
+ "languages": [
44450
+ "tsx"
44451
+ ],
44452
+ "source": "// The least a Record takes: a record bound with its patch door, a title, a toggle on a Boolean and a cycle over a register's members, stepped by a click\n// inputs: []\nexport const Crew = StructType({ name: StringType, inducted: BooleanType, forklift: StringType });\n\nexport const recordCrew = e3.record(\"record_crew\", DictType(StringType, Crew), {\n initial: new Map([\n [\"C-001\", { name: \"A. Morgan\", inducted: true, forklift: \"2\" }],\n [\"C-002\", { name: \"B. Ellis\", inducted: false, forklift: \"0\" }],\n [\"C-003\", { name: \"C. Patel\", inducted: true, forklift: \"1\" }],\n ]),\n mutations: (mutation) => ({\n // The crew's patch door — every Apply commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const members = $.let(Record.bind(recordCrew));\n const LevelType = StructType({ key: StringType, name: StringType });\n const levels = $.let([\n { key: \"0\", name: \"Not trained\" },\n { key: \"1\", name: \"Supervised\" },\n { key: \"2\", name: \"Competent\" },\n ], ArrayType(LevelType));\n return (\n <Box height=\"360px\">\n <Record\n record={members}\n title=\"Crew\"\n noun={{ singular: \"crew member\", plural: \"crew members\" }}\n registers={{ levels: Record.register.members(levels, { kind: \"level\", key: l => l.key, label: l => l.key, meta: l => some(l.name) }) }}\n columns={{\n name: Record.column.title(Crew, { header: \"Name\", width: \"160px\" }),\n inducted: Record.column.toggle(Crew, { header: \"Inducted\", width: \"80px\", on: \"yes\", off: \"no\" }),\n forklift: Record.column.cycle(Crew, \"levels\", { header: \"Forklift\", width: \"72px\", scale: true }),\n }}\n name=\"recordBasic\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
44453
+ },
44454
+ {
44455
+ "id": "e3-ui:record.examples.tsx:recordSkillsMatrix",
44456
+ "skill": "e3-ui",
44457
+ "package": "e3-ui",
44458
+ "file": "east-ui/packages/e3-ui/test/record/record.examples.tsx",
44459
+ "suite": "",
44460
+ "test": "The designer's skills matrix: ten cycle columns on the heat ramp under three column groups, the rail searching names and roles and filtering by role, the age warning past 90 days and the last change in blame mode",
44461
+ "keywords": [
44462
+ "Record",
44463
+ "skills matrix",
44464
+ "Record.column.cycle",
44465
+ "scale",
44466
+ "columnGroups",
44467
+ "Record.column.age",
44468
+ "Record.column.audit",
44469
+ "Record.Types.Change",
44470
+ "stale",
44471
+ "slice"
44472
+ ],
44473
+ "imports": [
44474
+ "import {",
44475
+ "import { Box, Button, Configurator, HStack, Reactive, SegmentGroup, Slice, State, StatusValueType, Style, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
44476
+ "import { Data, Record } from \"@elaraai/e3-ui\";",
44477
+ "import e3 from \"@elaraai/e3\";",
44478
+ "import { IndexedWork, indexedWorkOrders } from \"../sheet/sheet-records.examples.js\";"
44479
+ ],
44480
+ "languages": [
44481
+ "tsx"
44482
+ ],
44483
+ "source": "// The designer's skills matrix: ten cycle columns on the heat ramp under three column groups, the rail searching names and roles and filtering by role, the age warning past 90 days and the last change in blame mode\n// inputs: []\nexport const Skills = StructType({\n name: StringType, role: StringType,\n intake: StringType, review: StringType, dispatch: StringType, handover: StringType,\n scanner: StringType, console: StringType, reports: StringType,\n auditing: StringType, training: StringType, planning: StringType,\n updated: OptionType(Record.Types.Change),\n});\n\nexport const recordSkills = e3.record(\"record_skills\", DictType(StringType, Skills), {\n initial: new Map([\n [\"P-0401\", { name: \"A. Morgan\", role: \"Operator\", intake: \"2\", review: \"2\", dispatch: \"2\", handover: \"2\", scanner: \"1\", console: \"1\",\n reports: \"0\", auditing: \"0\", training: \"0\", planning: \"0\", updated: some({ at: new Date(\"2026-09-18T09:12:00Z\"), by: \"M. Hale\", verb: \"confirmed\" }) }],\n [\"P-0408\", { name: \"B. Ellis\", role: \"Operator\", intake: \"0\", review: \"0\", dispatch: \"0\", handover: \"0\", scanner: \"0\", console: \"0\",\n reports: \"0\", auditing: \"2\", training: \"2\", planning: \"2\", updated: some({ at: new Date(\"2026-10-17T14:40:00Z\"), by: \"S. Park\", verb: \"changed\" }) }],\n [\"P-0415\", { name: \"C. Patel\", role: \"Contractor\", intake: \"2\", review: \"1\", dispatch: \"1\", handover: \"1\", scanner: \"0\", console: \"0\",\n reports: \"0\", auditing: \"0\", training: \"0\", planning: \"0\", updated: some({ at: new Date(\"2026-11-02T11:05:00Z\"), by: \"J. Ortiz\", verb: \"changed\" }) }],\n [\"P-0450\", { name: \"H. Kim\", role: \"Operator\", intake: \"1\", review: \"0\", dispatch: \"1\", handover: \"0\", scanner: \"2\", console: \"2\",\n reports: \"2\", auditing: \"0\", training: \"0\", planning: \"0\", updated: some({ at: new Date(\"2026-07-10T08:30:00Z\"), by: \"A. Rowe\", verb: \"changed\" }) }],\n [\"P-0520\", { name: \"V. Lowe\", role: \"Team lead\", intake: \"2\", review: \"2\", dispatch: \"1\", handover: \"0\", scanner: \"0\", console: \"1\",\n reports: \"1\", auditing: \"1\", training: \"1\", planning: \"1\", updated: some({ at: new Date(\"2026-11-03T16:20:00Z\"), by: \"M. Hale\", verb: \"changed\" }) }],\n ]),\n indexes: (index) => ({\n // What the rail searches and filters by.\n record_skills_by_name: index.on([\"name\"]),\n record_skills_by_role: index.on([\"role\"]),\n }),\n mutations: (mutation) => ({\n // The people's patch door — every Apply commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const people = $.let(Record.bind(recordSkills));\n const slice = $.let(Slice.bindRecords(\"record.skills\", {\n rows: {\n source: Data.bindPaged(recordSkills, { indexes: [\"record_skills_by_name\", \"record_skills_by_role\"] }),\n label: \"People\",\n fields: { name: { label: \"Name\" }, role: { label: \"Role\", hints: [\"Operator\", \"Contractor\", \"Team lead\"] } },\n search: [\"name\", \"role\"],\n },\n }));\n const LevelType = StructType({ key: StringType, name: StringType });\n const levels = $.let([\n { key: \"0\", name: \"Not trained\" },\n { key: \"1\", name: \"Supervised\" },\n { key: \"2\", name: \"Competent\" },\n ], ArrayType(LevelType));\n const roles = $.let([\"Operator\", \"Contractor\", \"Team lead\"], ArrayType(StringType));\n return (\n <Box height=\"760px\">\n <Record\n slice={{ slice }}\n title=\"Skills matrix\"\n noun={{ singular: \"person\", plural: \"people\" }}\n registers={{\n levels: Record.register.members(levels, { kind: \"level\", key: l => l.key, label: l => l.key, meta: l => some(l.name) }),\n roles: Record.register.members(roles, { kind: \"role\", key: r => r, label: r => r }),\n }}\n columns={{\n name: Record.column.title(Skills, { header: \"Name\", width: \"156px\" }),\n role: Record.column.reference(Skills, \"roles\", { header: \"Role\", width: \"136px\" }),\n intake: Record.column.cycle(Skills, \"levels\", { header: \"Intake\", width: \"72px\", scale: true }),\n review: Record.column.cycle(Skills, \"levels\", { header: \"Review\", width: \"72px\", scale: true }),\n dispatch: Record.column.cycle(Skills, \"levels\", { header: \"Dispatch\", width: \"72px\", scale: true }),\n handover: Record.column.cycle(Skills, \"levels\", { header: \"Handover to next shift\", width: \"72px\", scale: true }),\n scanner: Record.column.cycle(Skills, \"levels\", { header: \"Scanner\", width: \"72px\", scale: true }),\n console: Record.column.cycle(Skills, \"levels\", { header: \"Console\", width: \"72px\", scale: true }),\n reports: Record.column.cycle(Skills, \"levels\", { header: \"Reports\", width: \"72px\", scale: true }),\n auditing: Record.column.cycle(Skills, \"levels\", { header: \"Auditing\", width: \"72px\", scale: true }),\n training: Record.column.cycle(Skills, \"levels\", { header: \"Training\", width: \"72px\", scale: true }),\n planning: Record.column.cycle(Skills, \"levels\", { header: \"Planning\", width: \"72px\", scale: true }),\n days_since: Record.column.age(Skills, { header: \"Days since\", width: \"92px\", since: p => p.updated, stale: 90n, absent: \"not confirmed\" }),\n updated: Record.column.audit(Skills, { header: \"Last updated\", width: \"264px\", mode: \"blame\" }),\n }}\n columnGroups={[\n { label: \"Core\", columnKeys: [\"intake\", \"review\", \"dispatch\", \"handover\"] },\n { label: \"Tools\", columnKeys: [\"scanner\", \"console\", \"reports\"] },\n { label: \"Advanced\", columnKeys: [\"auditing\", \"training\", \"planning\"] },\n ]}\n inspector\n onApply={Record.onApply(people, { keyed: true })}\n name=\"skills\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
44484
+ },
44485
+ {
44486
+ "id": "e3-ui:record.examples.tsx:recordShiftPreferences",
44487
+ "skill": "e3-ui",
44488
+ "package": "e3-ui",
44489
+ "file": "east-ui/packages/e3-ui/test/record/record.examples.tsx",
44490
+ "suite": "",
44491
+ "test": "The designer's shift preferences: cycles over a register whose members carry a tone and a digit alias, titles with their initials, three column groups one unlabelled, and the last change in date mode",
44492
+ "keywords": [
44493
+ "Record",
44494
+ "shift preferences",
44495
+ "Record.column.cycle",
44496
+ "tone",
44497
+ "aliases",
44498
+ "avatar",
44499
+ "columnGroups",
44500
+ "Record.column.audit"
44501
+ ],
44502
+ "imports": [
44503
+ "import {",
44504
+ "import { Box, Button, Configurator, HStack, Reactive, SegmentGroup, Slice, State, StatusValueType, Style, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
44505
+ "import { Data, Record } from \"@elaraai/e3-ui\";",
44506
+ "import e3 from \"@elaraai/e3\";",
44507
+ "import { IndexedWork, indexedWorkOrders } from \"../sheet/sheet-records.examples.js\";"
44508
+ ],
44509
+ "languages": [
44510
+ "tsx"
44511
+ ],
44512
+ "source": "// The designer's shift preferences: cycles over a register whose members carry a tone and a digit alias, titles with their initials, three column groups one unlabelled, and the last change in date mode\n// inputs: []\nexport const Preferences = StructType({\n name: StringType, role: StringType,\n days: StringType, afternoon: StringType, nights: StringType, sat: StringType, sun: StringType, overtime: StringType,\n updated: OptionType(Record.Types.Change),\n});\n\nexport const recordPreferences = e3.record(\"record_preferences\", DictType(StringType, Preferences), {\n initial: new Map([\n [\"P-0401\", { name: \"A. Morgan\", role: \"Operator\", days: \"prefer\", afternoon: \"can\", nights: \"can\", sat: \"can\", sun: \"can\", overtime: \"prefer\",\n updated: some({ at: new Date(\"2026-10-21T10:15:00Z\"), by: \"K. Lund\", verb: \"changed\" }) }],\n [\"P-0415\", { name: \"C. Patel\", role: \"Contractor\", days: \"can\", afternoon: \"prefer\", nights: \"cannot\", sat: \"prefer\", sun: \"cannot\", overtime: \"can\",\n updated: some({ at: new Date(\"2026-10-24T13:02:00Z\"), by: \"S. Park\", verb: \"changed\" }) }],\n [\"P-0422\", { name: \"D. Novak\", role: \"Operator\", days: \"prefer\", afternoon: \"can\", nights: \"can\", sat: \"can\", sun: \"can\", overtime: \"can\",\n updated: some({ at: new Date(\"2026-05-13T09:41:00Z\"), by: \"S. Park\", verb: \"changed\" }) }],\n ]),\n mutations: (mutation) => ({\n // The preferences' patch door — every Apply commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const people = $.let(Record.bind(recordPreferences));\n const ChoiceType = StructType({ key: StringType, label: StringType, name: StringType, aliases: ArrayType(StringType), tone: StatusValueType });\n const choices = $.let([\n { key: \"can\", label: \"can\", name: \"Can work\", aliases: [\"1\"], tone: variant(\"neutral\", null) },\n { key: \"prefer\", label: \"prefer\", name: \"Prefers\", aliases: [\"2\"], tone: variant(\"success\", null) },\n { key: \"cannot\", label: \"can't\", name: \"Can't work\", aliases: [\"3\"], tone: variant(\"danger\", null) },\n ], ArrayType(ChoiceType));\n const roles = $.let([\"Operator\", \"Contractor\"], ArrayType(StringType));\n return (\n <Box height=\"720px\">\n <Record\n record={people}\n title=\"Shift preferences\"\n noun={{ singular: \"person\", plural: \"people\" }}\n registers={{\n choices: Record.register.members(choices, { kind: \"choice\", key: c => c.key, label: c => c.label, meta: c => some(c.name),\n aliases: c => c.aliases, tone: c => some(c.tone) }),\n roles: Record.register.members(roles, { kind: \"role\", key: r => r, label: r => r }),\n }}\n columns={{\n name: Record.column.title(Preferences, { header: \"Name\", width: \"176px\", avatar: true }),\n role: Record.column.reference(Preferences, \"roles\", { header: \"Role\", width: \"136px\" }),\n days: Record.column.cycle(Preferences, \"choices\", { header: \"Days\", width: \"80px\" }),\n afternoon: Record.column.cycle(Preferences, \"choices\", { header: \"Afternoon\", width: \"80px\" }),\n nights: Record.column.cycle(Preferences, \"choices\", { header: \"Nights\", width: \"80px\" }),\n sat: Record.column.cycle(Preferences, \"choices\", { header: \"Sat\", width: \"80px\" }),\n sun: Record.column.cycle(Preferences, \"choices\", { header: \"Sun\", width: \"80px\" }),\n overtime: Record.column.cycle(Preferences, \"choices\", { header: \"Overtime\", width: \"80px\" }),\n days_since: Record.column.age(Preferences, { header: \"Days since\", width: \"92px\", since: p => p.updated, stale: 90n, absent: \"not confirmed\" }),\n updated: Record.column.audit(Preferences, { header: \"Last updated\", width: \"136px\" }),\n }}\n columnGroups={[\n { label: \"Shifts\", columnKeys: [\"days\", \"afternoon\", \"nights\"] },\n { label: \"Weekends\", columnKeys: [\"sat\", \"sun\"] },\n { label: \"\", columnKeys: [\"overtime\"] },\n ]}\n inspector\n name=\"preferences\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
44513
+ },
44514
+ {
44515
+ "id": "e3-ui:record.examples.tsx:recordEveryKind",
44516
+ "skill": "e3-ui",
44517
+ "package": "e3-ui",
44518
+ "file": "east-ui/packages/e3-ui/test/record/record.examples.tsx",
44519
+ "suite": "",
44520
+ "test": "Every kind a Record draws, as the cell-kind catalogue does: text, stamped, integer, a quantity with its unit, date, enum, reference, set, boolean, title, person, toggle and cycle, with an age and the last change",
44521
+ "keywords": [
44522
+ "Record",
44523
+ "column kinds",
44524
+ "Record.column.person",
44525
+ "Record.column.boolean",
44526
+ "Record.column.stamped",
44527
+ "Record.column.set",
44528
+ "Record.column.quantity",
44529
+ "unit",
44530
+ "avatar"
44531
+ ],
44532
+ "imports": [
44533
+ "import {",
44534
+ "import { Box, Button, Configurator, HStack, Reactive, SegmentGroup, Slice, State, StatusValueType, Style, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
44535
+ "import { Data, Record } from \"@elaraai/e3-ui\";",
44536
+ "import e3 from \"@elaraai/e3\";",
44537
+ "import { IndexedWork, indexedWorkOrders } from \"../sheet/sheet-records.examples.js\";"
44538
+ ],
44539
+ "languages": [
44540
+ "tsx"
44541
+ ],
44542
+ "source": "// Every kind a Record draws, as the cell-kind catalogue does: text, stamped, integer, a quantity with its unit, date, enum, reference, set, boolean, title, person, toggle and cycle, with an age and the last change\n// inputs: []\nexport const Operator = StructType({\n name: StringType, badge: StringType, notes: StringType, shifts: IntegerType, hours: FloatType,\n started: OptionType(DateTimeType), status: StringType, role: StringType, certificates: Record.Types.Link,\n inducted: BooleanType, supervisor: OptionType(StringType), night: BooleanType, preference: StringType,\n updated: OptionType(Record.Types.Change),\n});\n\nexport const recordOperators = e3.record(\"record_operators\", DictType(StringType, Operator), {\n initial: new Map([\n [\"P-0401\", { name: \"A. Morgan\", badge: \"EXT-88213\", notes: \"Prefers day shifts through March\", shifts: 1482n, hours: 38.5,\n started: some(new Date(\"2026-09-18T00:00:00Z\")), status: \"active\", role: \"Operator\",\n certificates: { from: [], to: [variant(\"identified\", { key: \"Forklift\" }), variant(\"identified\", { key: \"Confined space\" })] },\n inducted: true, supervisor: some(\"S. Park\"), night: false, preference: \"prefer\",\n updated: some({ at: new Date(\"2026-09-18T09:12:00Z\"), by: \"M. Hale\", verb: \"confirmed\" }) }],\n [\"P-0408\", { name: \"B. Ellis\", badge: \"EXT-88240\", notes: \"\", shifts: 96n, hours: 12.0,\n started: none, status: \"leave\", role: \"Contractor\", certificates: { from: [], to: [] },\n inducted: false, supervisor: none, night: true, preference: \"can\", updated: none }],\n ]),\n mutations: (mutation) => ({\n // The operators' patch door — every Apply commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const records = $.let(Record.bind(recordOperators));\n const StatusType = StructType({ key: StringType, label: StringType, tone: StatusValueType });\n const statuses = $.let([\n { key: \"active\", label: \"Active\", tone: variant(\"success\", null) },\n { key: \"leave\", label: \"On leave\", tone: variant(\"warning\", null) },\n { key: \"left\", label: \"Left\", tone: variant(\"neutral\", null) },\n ], ArrayType(StatusType));\n const roles = $.let([\"Operator\", \"Contractor\", \"Team lead\"], ArrayType(StringType));\n const certificates = $.let([\"Forklift\", \"Confined space\", \"First aid\", \"Working at height\"], ArrayType(StringType));\n const supervisors = $.let([\"S. Park\", \"M. Hale\", \"J. Ortiz\"], ArrayType(StringType));\n const ChoiceType = StructType({ key: StringType, label: StringType, name: StringType, tone: StatusValueType });\n const choices = $.let([\n { key: \"can\", label: \"can\", name: \"Can work\", tone: variant(\"neutral\", null) },\n { key: \"prefer\", label: \"prefer\", name: \"Prefers\", tone: variant(\"success\", null) },\n { key: \"cannot\", label: \"can't\", name: \"Can't work\", tone: variant(\"danger\", null) },\n ], ArrayType(ChoiceType));\n return (\n <Box height=\"480px\">\n <Record\n record={records}\n title=\"Operators\"\n noun={{ singular: \"operator\", plural: \"operators\" }}\n // The operators and their badges come from the Gatehouse: this Record edits them, and adds none.\n edits={{ insertRows: false }}\n registers={{\n statuses: Record.register.members(statuses, { kind: \"status\", key: s => s.key, label: s => s.label, tone: s => some(s.tone) }),\n roles: Record.register.members(roles, { kind: \"role\", key: r => r, label: r => r }),\n certificates: Record.register.members(certificates, { kind: \"certificate\", key: c => c, label: c => c }),\n supervisors: Record.register.members(supervisors, { kind: \"person\", key: p => p, label: p => p }),\n choices: Record.register.members(choices, { kind: \"choice\", key: c => c.key, label: c => c.label, meta: c => some(c.name), tone: c => some(c.tone) }),\n }}\n columns={{\n name: Record.column.title(Operator, { header: \"Name\", width: \"184px\", avatar: true }),\n badge: Record.column.stamped(Operator, { header: \"Badge\", width: \"120px\", owner: \"Gatehouse\" }),\n notes: Record.column.text(Operator, { header: \"Notes\", width: \"184px\" }),\n shifts: Record.column.integer(Operator, { header: \"Shifts\", width: \"120px\" }),\n hours: Record.column.quantity(Operator, { header: \"Hours\", width: \"120px\", unit: \"hrs\" }),\n started: Record.column.date(Operator, { header: \"Started\", width: \"120px\" }),\n status: Record.column.enum(Operator, \"statuses\", { header: \"Status\", width: \"120px\" }),\n role: Record.column.reference(Operator, \"roles\", { header: \"Role\", width: \"184px\" }),\n certificates: Record.column.set(Operator, \"certificates\", { header: \"Certificates\", width: \"248px\" }),\n inducted: Record.column.boolean(Operator, { header: \"Inducted\", width: \"72px\" }),\n supervisor: Record.column.person(Operator, \"supervisors\", { header: \"Supervisor\", width: \"160px\" }),\n night: Record.column.toggle(Operator, { header: \"Nights\", width: \"80px\", on: \"yes\", off: \"no\" }),\n preference: Record.column.cycle(Operator, \"choices\", { header: \"Overtime\", width: \"80px\" }),\n days_since: Record.column.age(Operator, { header: \"Days since\", width: \"96px\", since: o => o.updated, stale: 90n, absent: \"not confirmed\" }),\n updated: Record.column.audit(Operator, { header: \"Last updated\", width: \"232px\", mode: \"blame\" }),\n }}\n inspector\n name=\"operators\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
44543
+ },
44544
+ {
44545
+ "id": "e3-ui:record.examples.tsx:recordSkillsReadOnly",
44546
+ "skill": "e3-ui",
44547
+ "package": "e3-ui",
44548
+ "file": "east-ui/packages/e3-ui/test/record/record.examples.tsx",
44549
+ "suite": "",
44550
+ "test": "The skills matrix read only: the same cells with no hover, no select column and no Add or Delete; the rail still narrows and counts, and the inspector shows every field read only",
44551
+ "keywords": [
44552
+ "Record",
44553
+ "readOnly",
44554
+ "read only",
44555
+ "skills matrix",
44556
+ "slice"
44557
+ ],
44558
+ "imports": [
44559
+ "import {",
44560
+ "import { Box, Button, Configurator, HStack, Reactive, SegmentGroup, Slice, State, StatusValueType, Style, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
44561
+ "import { Data, Record } from \"@elaraai/e3-ui\";",
44562
+ "import e3 from \"@elaraai/e3\";",
44563
+ "import { IndexedWork, indexedWorkOrders } from \"../sheet/sheet-records.examples.js\";"
44564
+ ],
44565
+ "languages": [
44566
+ "tsx"
44567
+ ],
44568
+ "source": "// The skills matrix read only: the same cells with no hover, no select column and no Add or Delete; the rail still narrows and counts, and the inspector shows every field read only\n// inputs: []\nexport const Skills = StructType({\n name: StringType, role: StringType,\n intake: StringType, review: StringType, dispatch: StringType, handover: StringType,\n scanner: StringType, console: StringType, reports: StringType,\n auditing: StringType, training: StringType, planning: StringType,\n updated: OptionType(Record.Types.Change),\n});\n\nexport const recordSkills = e3.record(\"record_skills\", DictType(StringType, Skills), {\n initial: new Map([\n [\"P-0401\", { name: \"A. Morgan\", role: \"Operator\", intake: \"2\", review: \"2\", dispatch: \"2\", handover: \"2\", scanner: \"1\", console: \"1\",\n reports: \"0\", auditing: \"0\", training: \"0\", planning: \"0\", updated: some({ at: new Date(\"2026-09-18T09:12:00Z\"), by: \"M. Hale\", verb: \"confirmed\" }) }],\n [\"P-0408\", { name: \"B. Ellis\", role: \"Operator\", intake: \"0\", review: \"0\", dispatch: \"0\", handover: \"0\", scanner: \"0\", console: \"0\",\n reports: \"0\", auditing: \"2\", training: \"2\", planning: \"2\", updated: some({ at: new Date(\"2026-10-17T14:40:00Z\"), by: \"S. Park\", verb: \"changed\" }) }],\n [\"P-0415\", { name: \"C. Patel\", role: \"Contractor\", intake: \"2\", review: \"1\", dispatch: \"1\", handover: \"1\", scanner: \"0\", console: \"0\",\n reports: \"0\", auditing: \"0\", training: \"0\", planning: \"0\", updated: some({ at: new Date(\"2026-11-02T11:05:00Z\"), by: \"J. Ortiz\", verb: \"changed\" }) }],\n [\"P-0450\", { name: \"H. Kim\", role: \"Operator\", intake: \"1\", review: \"0\", dispatch: \"1\", handover: \"0\", scanner: \"2\", console: \"2\",\n reports: \"2\", auditing: \"0\", training: \"0\", planning: \"0\", updated: some({ at: new Date(\"2026-07-10T08:30:00Z\"), by: \"A. Rowe\", verb: \"changed\" }) }],\n [\"P-0520\", { name: \"V. Lowe\", role: \"Team lead\", intake: \"2\", review: \"2\", dispatch: \"1\", handover: \"0\", scanner: \"0\", console: \"1\",\n reports: \"1\", auditing: \"1\", training: \"1\", planning: \"1\", updated: some({ at: new Date(\"2026-11-03T16:20:00Z\"), by: \"M. Hale\", verb: \"changed\" }) }],\n ]),\n indexes: (index) => ({\n // What the rail searches and filters by.\n record_skills_by_name: index.on([\"name\"]),\n record_skills_by_role: index.on([\"role\"]),\n }),\n mutations: (mutation) => ({\n // The people's patch door — every Apply commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const slice = $.let(Slice.bindRecords(\"record.skills.readonly\", {\n rows: {\n source: Data.bindPaged(recordSkills, { indexes: [\"record_skills_by_name\", \"record_skills_by_role\"] }),\n label: \"People\",\n fields: { name: { label: \"Name\" }, role: { label: \"Role\", hints: [\"Operator\", \"Contractor\", \"Team lead\"] } },\n search: [\"name\", \"role\"],\n },\n }));\n const LevelType = StructType({ key: StringType, name: StringType });\n const levels = $.let([\n { key: \"0\", name: \"Not trained\" },\n { key: \"1\", name: \"Supervised\" },\n { key: \"2\", name: \"Competent\" },\n ], ArrayType(LevelType));\n const roles = $.let([\"Operator\", \"Contractor\", \"Team lead\"], ArrayType(StringType));\n return (\n <Box height=\"760px\">\n <Record\n slice={{ slice }}\n title=\"Skills matrix\"\n noun={{ singular: \"person\", plural: \"people\" }}\n registers={{\n levels: Record.register.members(levels, { kind: \"level\", key: l => l.key, label: l => l.key, meta: l => some(l.name) }),\n roles: Record.register.members(roles, { kind: \"role\", key: r => r, label: r => r }),\n }}\n columns={{\n name: Record.column.title(Skills, { header: \"Name\", width: \"156px\" }),\n role: Record.column.reference(Skills, \"roles\", { header: \"Role\", width: \"136px\" }),\n intake: Record.column.cycle(Skills, \"levels\", { header: \"Intake\", width: \"72px\", scale: true }),\n review: Record.column.cycle(Skills, \"levels\", { header: \"Review\", width: \"72px\", scale: true }),\n dispatch: Record.column.cycle(Skills, \"levels\", { header: \"Dispatch\", width: \"72px\", scale: true }),\n handover: Record.column.cycle(Skills, \"levels\", { header: \"Handover to next shift\", width: \"72px\", scale: true }),\n scanner: Record.column.cycle(Skills, \"levels\", { header: \"Scanner\", width: \"72px\", scale: true }),\n console: Record.column.cycle(Skills, \"levels\", { header: \"Console\", width: \"72px\", scale: true }),\n reports: Record.column.cycle(Skills, \"levels\", { header: \"Reports\", width: \"72px\", scale: true }),\n auditing: Record.column.cycle(Skills, \"levels\", { header: \"Auditing\", width: \"72px\", scale: true }),\n training: Record.column.cycle(Skills, \"levels\", { header: \"Training\", width: \"72px\", scale: true }),\n planning: Record.column.cycle(Skills, \"levels\", { header: \"Planning\", width: \"72px\", scale: true }),\n days_since: Record.column.age(Skills, { header: \"Days since\", width: \"92px\", since: p => p.updated, stale: 90n, absent: \"not confirmed\" }),\n updated: Record.column.audit(Skills, { header: \"Last updated\", width: \"264px\", mode: \"blame\" }),\n }}\n columnGroups={[\n { label: \"Core\", columnKeys: [\"intake\", \"review\", \"dispatch\", \"handover\"] },\n { label: \"Tools\", columnKeys: [\"scanner\", \"console\", \"reports\"] },\n { label: \"Advanced\", columnKeys: [\"auditing\", \"training\", \"planning\"] },\n ]}\n inspector\n readOnly\n name=\"skillsReadOnly\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
44569
+ },
44570
+ {
44571
+ "id": "e3-ui:record.examples.tsx:recordLooks",
44572
+ "skill": "e3-ui",
44573
+ "package": "e3-ui",
44574
+ "file": "east-ui/packages/e3-ui/test/record/record.examples.tsx",
44575
+ "suite": "",
44576
+ "test": "The Record's looks, as the designer's tweaks show them: a rota with a cell of every Record kind, each cycle and toggle as a chip and as a mark side by side, under a density control that steps its rows through comfortable, compact and condensed",
44577
+ "keywords": [
44578
+ "Record",
44579
+ "density",
44580
+ "compact",
44581
+ "condensed",
44582
+ "comfortable",
44583
+ "look",
44584
+ "chip",
44585
+ "mark",
44586
+ "pips",
44587
+ "Record.column.person",
44588
+ "Record.column.boolean",
44589
+ "Configurator"
44590
+ ],
44591
+ "imports": [
44592
+ "import {",
44593
+ "import { Box, Button, Configurator, HStack, Reactive, SegmentGroup, Slice, State, StatusValueType, Style, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
44594
+ "import { Data, Record } from \"@elaraai/e3-ui\";",
44595
+ "import e3 from \"@elaraai/e3\";",
44596
+ "import { IndexedWork, indexedWorkOrders } from \"../sheet/sheet-records.examples.js\";"
44597
+ ],
44598
+ "languages": [
44599
+ "tsx"
44600
+ ],
44601
+ "source": "// The Record's looks, as the designer's tweaks show them: a rota with a cell of every Record kind, each cycle and toggle as a chip and as a mark side by side, under a density control that steps its rows through comfortable, compact and condensed\n// inputs: []\nexport const Rota = StructType({\n name: StringType, supervisor: OptionType(StringType), inducted: BooleanType,\n nights: BooleanType, weekends: BooleanType, forklift: StringType, scanner: StringType, days: StringType, evenings: StringType,\n updated: OptionType(Record.Types.Change),\n});\n\nexport const recordRota = e3.record(\"record_rota\", DictType(StringType, Rota), {\n initial: new Map([\n [\"R-01\", { name: \"A. Morgan\", supervisor: some(\"S. Park\"), inducted: true, nights: false, weekends: true, forklift: \"2\", scanner: \"1\",\n days: \"prefer\", evenings: \"can\", updated: some({ at: new Date(\"2026-09-18T09:12:00Z\"), by: \"M. Hale\", verb: \"confirmed\" }) }],\n [\"R-02\", { name: \"B. Ellis\", supervisor: none, inducted: false, nights: true, weekends: false, forklift: \"0\", scanner: \"2\",\n days: \"can\", evenings: \"cannot\", updated: none }],\n [\"R-03\", { name: \"C. Patel\", supervisor: some(\"J. Ortiz\"), inducted: true, nights: true, weekends: true, forklift: \"1\", scanner: \"0\",\n days: \"cannot\", evenings: \"prefer\", updated: some({ at: new Date(\"2026-05-13T09:41:00Z\"), by: \"S. Park\", verb: \"changed\" }) }],\n ]),\n mutations: (mutation) => ({\n // The rota's patch door — every Apply commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const rota = $.let(Record.bind(recordRota));\n // The density control: each segment a density, and the Record takes the one chosen.\n const densities = $.const([variant(\"comfortable\", null), variant(\"compact\", null), variant(\"condensed\", null)], ArrayType(Style.Types.Density));\n const densityBind = $.let(State.bind([StringType], \"record_looks_density\", \"comfortable\"));\n const densityKey = $.let(densityBind.read());\n const onDensity = $.const(East.function([StringType], NullType, ($, next) => { $(densityBind.write(next)); }));\n const density = $.let(densities.filter((_$, d) => d.getTag().equal(densityKey)).get(0n));\n const LevelType = StructType({ key: StringType, name: StringType });\n const levels = $.let([\n { key: \"0\", name: \"Not trained\" },\n { key: \"1\", name: \"Supervised\" },\n { key: \"2\", name: \"Competent\" },\n ], ArrayType(LevelType));\n const ChoiceType = StructType({ key: StringType, label: StringType, name: StringType, tone: StatusValueType });\n const choices = $.let([\n { key: \"can\", label: \"can\", name: \"Can work\", tone: variant(\"neutral\", null) },\n { key: \"prefer\", label: \"prefer\", name: \"Prefers\", tone: variant(\"success\", null) },\n { key: \"cannot\", label: \"can't\", name: \"Can't work\", tone: variant(\"danger\", null) },\n ], ArrayType(ChoiceType));\n const supervisors = $.let([\"S. Park\", \"M. Hale\", \"J. Ortiz\"], ArrayType(StringType));\n return (\n <Configurator\n controls={[\n Configurator.Control(\"Density\", densityKey,\n <SegmentGroup value={densityKey} onChange={onDensity} size=\"sm\"\n items={densities.map((_$, d) => SegmentGroup.Item(d.getTag(), <Text>{d.getTag().upperCase()}</Text>))} />),\n ]}\n preview={\n <Box height=\"440px\" width=\"100%\">\n <Record\n record={rota}\n title=\"Rota\"\n noun={{ singular: \"person\", plural: \"people\" }}\n density={density}\n registers={{\n levels: Record.register.members(levels, { kind: \"level\", key: l => l.key, label: l => l.key, meta: l => some(l.name) }),\n choices: Record.register.members(choices, { kind: \"choice\", key: c => c.key, label: c => c.label, meta: c => some(c.name), tone: c => some(c.tone) }),\n supervisors: Record.register.members(supervisors, { kind: \"person\", key: p => p, label: p => p }),\n }}\n columns={{\n name: Record.column.title(Rota, { header: \"Name\", width: \"176px\", avatar: true }),\n supervisor: Record.column.person(Rota, \"supervisors\", { header: \"Supervisor\", width: \"152px\" }),\n inducted: Record.column.boolean(Rota, { header: \"Inducted\", width: \"80px\" }),\n nights: Record.column.toggle(Rota, { header: \"Nights\", width: \"80px\", on: \"yes\", off: \"no\" }),\n weekends: Record.column.toggle(Rota, { header: \"Weekends\", width: \"88px\", on: \"yes\", off: \"no\", look: \"mark\" }),\n forklift: Record.column.cycle(Rota, \"levels\", { header: \"Forklift\", width: \"72px\", scale: true }),\n scanner: Record.column.cycle(Rota, \"levels\", { header: \"Scanner\", width: \"72px\", scale: true, look: \"mark\" }),\n days: Record.column.cycle(Rota, \"choices\", { header: \"Days\", width: \"80px\" }),\n evenings: Record.column.cycle(Rota, \"choices\", { header: \"Evenings\", width: \"112px\", look: \"mark\" }),\n days_since: Record.column.age(Rota, { header: \"Days since\", width: \"136px\", since: r => r.updated, stale: 90n, absent: \"not confirmed\" }),\n updated: Record.column.audit(Rota, { header: \"Last updated\", width: \"232px\", mode: \"blame\" }),\n }}\n columnGroups={[\n { label: \"Shifts\", columnKeys: [\"nights\", \"weekends\"] },\n { label: \"Skills\", columnKeys: [\"forklift\", \"scanner\"] },\n { label: \"Preferences\", columnKeys: [\"days\", \"evenings\"] },\n ]}\n name=\"looks\"\n />\n </Box>\n }\n />\n );\n }}</Reactive>\n ))"
44602
+ },
44603
+ {
44604
+ "id": "e3-ui:record.examples.tsx:recordFinishes",
44605
+ "skill": "e3-ui",
44606
+ "package": "e3-ui",
44607
+ "file": "east-ui/packages/e3-ui/test/record/record.examples.tsx",
44608
+ "suite": "",
44609
+ "test": "A Record's inspector over a piece of joinery: its finish, a variant, chosen among its cases, with the fields of the case it holds in a block under the choice — a stain's shade, a paint's colour, coats and gloss, the gloss a choice of its own — each case hinted through the select's `cases`; and its bench, a reference to a record keyed by number, the register keying each bench by its number as East prints it and the form reading the one chosen back as a number",
44610
+ "keywords": [
44611
+ "Record",
44612
+ "Record.field.select",
44613
+ "cases",
44614
+ "variant",
44615
+ "block",
44616
+ "inspector",
44617
+ "Fields.select",
44618
+ "Record.field.reference",
44619
+ "Fields.reference",
44620
+ "register",
44621
+ "IntegerType",
44622
+ "Integer key"
44623
+ ],
44624
+ "imports": [
44625
+ "import {",
44626
+ "import { Box, Button, Configurator, HStack, Reactive, SegmentGroup, Slice, State, StatusValueType, Style, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
44627
+ "import { Data, Record } from \"@elaraai/e3-ui\";",
44628
+ "import e3 from \"@elaraai/e3\";",
44629
+ "import { IndexedWork, indexedWorkOrders } from \"../sheet/sheet-records.examples.js\";"
44630
+ ],
44631
+ "languages": [
44632
+ "tsx"
44633
+ ],
44634
+ "source": "// A Record's inspector over a piece of joinery: its finish, a variant, chosen among its cases, with the fields of the case it holds in a block under the choice — a stain's shade, a paint's colour, coats and gloss, the gloss a choice of its own — each case hinted through the select's `cases`; and its bench, a reference to a record keyed by number, the register keying each bench by its number as East prints it and the form reading the one chosen back as a number\n// inputs: []\n/** A bench of the joinery's shop, keyed by its number. */\nexport const Bench = StructType({ name: StringType });\n\nexport const recordBenches = e3.record(\"record_benches\", DictType(IntegerType, Bench), {\n initial: new Map([[1n, { name: \"Saw bench\" }], [2n, { name: \"Assembly bench\" }], [10n, { name: \"Finishing bench\" }]]),\n});\n\n/** How a piece is finished: left bare, stained a shade, or painted a colour in coats, matt or with a sheen. */\nexport const Finish = VariantType({\n bare: NullType,\n stain: StringType,\n paint: StructType({ colour: StringType, coats: IntegerType, gloss: VariantType({ matt: NullType, sheen: FloatType }) }),\n});\n\n/** A piece of joinery: the bench it is made at, by the bench's number, and how it is finished. */\nexport const Piece = StructType({ name: StringType, room: StringType, bench: IntegerType, finish: Finish });\n\nexport const recordPieces = e3.record(\"record_pieces\", DictType(StringType, Piece), {\n initial: new Map([\n [\"J-101\", { name: \"Hall door\", room: \"Hall\", bench: 2n, finish: variant(\"paint\", { colour: \"Teal\", coats: 2n, gloss: variant(\"sheen\", 0.4) }) }],\n [\"J-102\", { name: \"Stair rail\", room: \"Stairs\", bench: 1n, finish: variant(\"stain\", \"Walnut\") }],\n [\"J-103\", { name: \"Window seat\", room: \"Lounge\", bench: 10n, finish: variant(\"bare\", null) }],\n ]),\n mutations: (mutation) => ({\n // The joinery's patch door — every Apply commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const pieces = $.let(Record.bind(recordPieces));\n const benches = $.let(Data.bind(recordBenches));\n return (\n <Box height=\"480px\">\n <Record\n record={pieces}\n title=\"Joinery\"\n noun={{ singular: \"piece\", plural: \"pieces\" }}\n registers={{\n // A register's members are keyed by text: each bench by its number as East prints it.\n benches: Record.register.members(benches.read().toArray((_$, bench, number) => ({ number, name: bench.name })), {\n kind: \"bench\", key: (b) => East.print(b.number), label: (b) => b.name,\n }),\n }}\n columns={{\n name: Record.column.title(Piece, { header: \"Piece\", width: \"176px\" }),\n room: Record.column.text(Piece, { header: \"Room\", width: \"136px\" }),\n }}\n fields={{\n finish: Record.field.select({\n labels: { bare: \"Bare\", stain: \"Stain\", paint: \"Paint\" },\n cases: {\n stain: Record.field.text({ label: \"Shade\" }),\n paint: { colour: Record.field.text({ help: \"As the tin names it\" }), coats: Record.field.number({ min: 1n, max: 4n }) },\n },\n }),\n bench: Record.field.reference({ of: \"benches\", help: \"Where it is made\" }),\n }}\n inspector\n name=\"finishes\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
44635
+ },
44636
+ {
44637
+ "id": "e3-ui:record.examples.tsx:recordOrderStatus",
44638
+ "skill": "e3-ui",
44639
+ "package": "e3-ui",
44640
+ "file": "east-ui/packages/e3-ui/test/record/record.examples.tsx",
44641
+ "suite": "",
44642
+ "test": "A cycle over a variant: an order's status, stepped by a click in the order its `steps` give — received, picked, packed, shipped — rather than the alphabetical order East keeps a variant's cases in, each step a chip with its tone, Details offering the steps in that order as one line, and Apply writing the case",
44643
+ "keywords": [
44644
+ "Record",
44645
+ "Record.column.cycle",
44646
+ "steps",
44647
+ "variant",
44648
+ "VariantType",
44649
+ "cycle over a variant",
44650
+ "status"
44651
+ ],
44652
+ "imports": [
44653
+ "import {",
44654
+ "import { Box, Button, Configurator, HStack, Reactive, SegmentGroup, Slice, State, StatusValueType, Style, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
44655
+ "import { Data, Record } from \"@elaraai/e3-ui\";",
44656
+ "import e3 from \"@elaraai/e3\";",
44657
+ "import { IndexedWork, indexedWorkOrders } from \"../sheet/sheet-records.examples.js\";"
44658
+ ],
44659
+ "languages": [
44660
+ "tsx"
44661
+ ],
44662
+ "source": "// A cycle over a variant: an order's status, stepped by a click in the order its `steps` give — received, picked, packed, shipped — rather than the alphabetical order East keeps a variant's cases in, each step a chip with its tone, Details offering the steps in that order as one line, and Apply writing the case\n// inputs: []\n/** Where an order is. East keeps a variant's cases in alphabetical order — packed, picked, received, shipped — so the cycle gives its own. */\nexport const Status = VariantType({ received: NullType, picked: NullType, packed: NullType, shipped: NullType });\n\nexport const Order = StructType({ customer: StringType, status: Status });\n\nexport const recordOrders = e3.record(\"record_orders\", DictType(StringType, Order), {\n initial: new Map([\n [\"SO-1041\", { customer: \"Ashgrove Joinery\", status: variant(\"received\", null) }],\n [\"SO-1042\", { customer: \"Bellmoor Interiors\", status: variant(\"packed\", null) }],\n [\"SO-1043\", { customer: \"Corran Builders\", status: variant(\"shipped\", null) }],\n ]),\n mutations: (mutation) => ({\n // The orders' patch door — every Apply commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const orders = $.let(Record.bind(recordOrders));\n return (\n <Box height=\"440px\">\n <Record\n record={orders}\n title=\"Orders\"\n noun={{ singular: \"order\", plural: \"orders\" }}\n columns={{\n customer: Record.column.title(Order, { header: \"Customer\", width: \"200px\" }),\n status: Record.column.cycle(Order, Status, {\n header: \"Status\", width: \"96px\",\n steps: [\n { case: \"received\", label: \"Received\", tone: \"neutral\" },\n { case: \"picked\", label: \"Picked\", tone: \"info\" },\n { case: \"packed\", label: \"Packed\", tone: \"info\" },\n { case: \"shipped\", label: \"Shipped\", tone: \"success\" },\n ],\n }),\n }}\n inspector\n name=\"orders\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
44663
+ },
44664
+ {
44665
+ "id": "e3-ui:record.examples.tsx:recordHoursByProject",
44666
+ "skill": "e3-ui",
44667
+ "package": "e3-ui",
44668
+ "file": "east-ui/packages/e3-ui/test/record/record.examples.tsx",
44669
+ "suite": "",
44670
+ "test": "Columns from data: a person's hours by project, the field a Dict keyed by the project's code — a column for each project in the projects record, in its order and headed by its name, each under its client in the clients record's order, a project whose client that record lacks after them unlabelled, and a client with no projects drawing nothing; with no functions, a cell shows the person's entry, an edit sets it and a clear removes it",
44671
+ "keywords": [
44672
+ "Record",
44673
+ "columns from data",
44674
+ "each",
44675
+ "groups",
44676
+ "register",
44677
+ "parent",
44678
+ "Dict",
44679
+ "Record.column.quantity",
44680
+ "a column per member"
44681
+ ],
44682
+ "imports": [
44683
+ "import {",
44684
+ "import { Box, Button, Configurator, HStack, Reactive, SegmentGroup, Slice, State, StatusValueType, Style, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
44685
+ "import { Data, Record } from \"@elaraai/e3-ui\";",
44686
+ "import e3 from \"@elaraai/e3\";",
44687
+ "import { IndexedWork, indexedWorkOrders } from \"../sheet/sheet-records.examples.js\";"
44688
+ ],
44689
+ "languages": [
44690
+ "tsx"
44691
+ ],
44692
+ "source": "// Columns from data: a person's hours by project, the field a Dict keyed by the project's code — a column for each project in the projects record, in its order and headed by its name, each under its client in the clients record's order, a project whose client that record lacks after them unlabelled, and a client with no projects drawing nothing; with no functions, a cell shows the person's entry, an edit sets it and a clear removes it\n// inputs: []\n/** A client of the joinery. */\nexport const Client = StructType({ name: StringType });\n\n/** A project, for one client by the client's code. */\nexport const Project = StructType({ name: StringType, client: StringType });\n\n/** A person's hours on each project, by the project's code. */\nexport const Person = StructType({ name: StringType, hours: DictType(StringType, FloatType) });\n\nexport const recordClients = e3.record(\"record_clients\", DictType(StringType, Client), {\n initial: new Map([\n [\"C-01\", { name: \"Ashgrove Joinery\" }],\n [\"C-02\", { name: \"Bellmoor Interiors\" }],\n [\"C-03\", { name: \"Corran Builders\" }],\n ]),\n});\n\nexport const recordProjects = e3.record(\"record_projects\", DictType(StringType, Project), {\n initial: new Map([\n [\"P-100\", { name: \"Kitchen fit-out\", client: \"C-01\" }],\n [\"P-101\", { name: \"Stair rebuild\", client: \"C-01\" }],\n [\"P-200\", { name: \"Shop front\", client: \"C-02\" }],\n [\"P-900\", { name: \"Training\", client: \"\" }],\n ]),\n mutations: (mutation) => ({\n // Projects are added, moved and retired where they are run: the hours' columns follow.\n patch: mutation.patch(),\n }),\n});\n\nexport const recordHours = e3.record(\"record_hours\", DictType(StringType, Person), {\n initial: new Map([\n [\"H-01\", { name: \"A. Morgan\", hours: new Map([[\"P-100\", 12.5], [\"P-200\", 4.0]]) }],\n [\"H-02\", { name: \"B. Ellis\", hours: new Map([[\"P-101\", 30.0], [\"P-900\", 6.0]]) }],\n [\"H-03\", { name: \"C. Patel\", hours: new Map() }],\n ]),\n mutations: (mutation) => ({\n // Every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const staff = $.let(Record.bind(recordHours));\n const clientRows = $.let(Data.bind(recordClients));\n const projectRows = $.let(Data.bind(recordProjects));\n return (\n <Box height=\"440px\">\n <Record\n record={staff}\n title=\"Hours\"\n noun={{ singular: \"person\", plural: \"people\" }}\n registers={{\n clients: Record.register.members(clientRows.read(), { kind: \"client\", key: (_c, code) => code, label: (c) => c.name }),\n projects: Record.register.members(projectRows.read(), {\n kind: \"project\", key: (_p, code) => code, label: (p) => p.name, parent: (p) => some(p.client),\n }),\n }}\n columns={{\n name: Record.column.title(Person, { header: \"Name\", width: \"176px\" }),\n // The hours field: a column for each project, under its client.\n hours: Record.column.quantity(Person, { each: \"projects\", groups: \"clients\", unit: \"hrs\", width: \"128px\" }),\n }}\n inspector\n name=\"hours\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
44693
+ },
44694
+ {
44695
+ "id": "e3-ui:record.examples.tsx:recordRosterByDay",
44696
+ "skill": "e3-ui",
44697
+ "package": "e3-ui",
44698
+ "file": "east-ui/packages/e3-ui/test/record/record.examples.tsx",
44699
+ "suite": "",
44700
+ "test": "Columns from data over a struct's fields: a shift's heads for each day as one struct field, a column for each day in the order `each` gives and headed as it says, fixed when the page is built, under a column group that names them all by the column's key",
44701
+ "keywords": [
44702
+ "Record",
44703
+ "columns from data",
44704
+ "each",
44705
+ "struct",
44706
+ "fields",
44707
+ "Record.column.integer",
44708
+ "columnGroups",
44709
+ "a column per field"
44710
+ ],
44711
+ "imports": [
44712
+ "import {",
44713
+ "import { Box, Button, Configurator, HStack, Reactive, SegmentGroup, Slice, State, StatusValueType, Style, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
44714
+ "import { Data, Record } from \"@elaraai/e3-ui\";",
44715
+ "import e3 from \"@elaraai/e3\";",
44716
+ "import { IndexedWork, indexedWorkOrders } from \"../sheet/sheet-records.examples.js\";"
44717
+ ],
44718
+ "languages": [
44719
+ "tsx"
44720
+ ],
44721
+ "source": "// Columns from data over a struct's fields: a shift's heads for each day as one struct field, a column for each day in the order `each` gives and headed as it says, fixed when the page is built, under a column group that names them all by the column's key\n// inputs: []\n/** A week's heads, a day each. */\nexport const Week = StructType({\n mon: IntegerType, tue: IntegerType, wed: IntegerType, thu: IntegerType, fri: IntegerType, sat: IntegerType, sun: IntegerType,\n});\n\n/** A shift and the heads it needs each day of the week. */\nexport const Shift = StructType({ name: StringType, week: Week });\n\nexport const recordRoster = e3.record(\"record_roster\", DictType(StringType, Shift), {\n initial: new Map([\n [\"S-1\", { name: \"Early\", week: { mon: 4n, tue: 4n, wed: 4n, thu: 4n, fri: 4n, sat: 2n, sun: 0n } }],\n [\"S-2\", { name: \"Late\", week: { mon: 3n, tue: 3n, wed: 3n, thu: 3n, fri: 3n, sat: 1n, sun: 0n } }],\n [\"S-3\", { name: \"Night\", week: { mon: 2n, tue: 2n, wed: 2n, thu: 2n, fri: 2n, sat: 2n, sun: 2n } }],\n ]),\n mutations: (mutation) => ({\n // Every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const shifts = $.let(Record.bind(recordRoster));\n return (\n <Box height=\"440px\">\n <Record\n record={shifts}\n title=\"Roster\"\n noun={{ singular: \"shift\", plural: \"shifts\" }}\n columns={{\n name: Record.column.title(Shift, { header: \"Shift\", width: \"176px\" }),\n // The week field: a column for each day.\n week: Record.column.integer(Shift, {\n each: { mon: \"Mon\", tue: \"Tue\", wed: \"Wed\", thu: \"Thu\", fri: \"Fri\", sat: \"Sat\", sun: \"Sun\" },\n width: \"56px\",\n }),\n }}\n columnGroups={[{ label: \"Heads per day\", columnKeys: [\"week\"] }]}\n inspector\n name=\"roster\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
44722
+ },
44723
+ {
44724
+ "id": "e3-ui:record.examples.tsx:recordSkillHistory",
44725
+ "skill": "e3-ui",
44726
+ "package": "e3-ui",
44727
+ "file": "east-ui/packages/e3-ui/test/record/record.examples.tsx",
44728
+ "suite": "",
44729
+ "test": "The worked case's skills page: each person's skills held as a dated history, one row per change, with a column for each skill under its team. Each cell is the level in force at the Record's day, through the solution's `read`; a licence locks its cell and a lapsed level is noted, through its `mark`; and each step appends or replaces today's row, through its `write`. The name is the person's own, or their id where they have none, the page adds no one, and its side panel leaves out the preferences, which the preferences page edits",
44730
+ "keywords": [
44731
+ "Record",
44732
+ "columns from data",
44733
+ "worked case",
44734
+ "dated history",
44735
+ "each",
44736
+ "groups",
44737
+ "read",
44738
+ "write",
44739
+ "mark",
44740
+ "Record.Types.Mark",
44741
+ "lock",
44742
+ "Record.column.cycle",
44743
+ "steps",
44744
+ "Record.column.title",
44745
+ "value",
44746
+ "Record.field.hidden",
44747
+ "hidden"
44748
+ ],
44749
+ "imports": [
44750
+ "import {",
44751
+ "import { Box, Button, Configurator, HStack, Reactive, SegmentGroup, Slice, State, StatusValueType, Style, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
44752
+ "import { Data, Record } from \"@elaraai/e3-ui\";",
44753
+ "import e3 from \"@elaraai/e3\";",
44754
+ "import { IndexedWork, indexedWorkOrders } from \"../sheet/sheet-records.examples.js\";"
44755
+ ],
44756
+ "languages": [
44757
+ "tsx"
44758
+ ],
44759
+ "source": "// The worked case's skills page: each person's skills held as a dated history, one row per change, with a column for each skill under its team. Each cell is the level in force at the Record's day, through the solution's `read`; a licence locks its cell and a lapsed level is noted, through its `mark`; and each step appends or replaces today's row, through its `write`. The name is the person's own, or their id where they have none, the page adds no one, and its side panel leaves out the preferences, which the preferences page edits\n// inputs: []\nexport const Level = VariantType({ not_trained: NullType, trainee: NullType, competent: NullType });\n\nexport const Holding = StructType({\n skill: StringType,\n holding: VariantType({ level: Level, licence: BooleanType }),\n since: DateTimeType,\n expires: OptionType(DateTimeType),\n signed_off_by: OptionType(StringType),\n signed_off_at: OptionType(DateTimeType),\n});\n\nexport const Choice = VariantType({ cant: NullType, can: NullType, prefer: NullType });\n\nexport const PreferenceSnapshot = StructType({\n since: DateTimeType,\n basis: VariantType({ guessed: NullType, stated: NullType }),\n standard: StructType({ day: Choice, afternoon: Choice, night: Choice, saturday: Choice, sunday: Choice, sunday_night: Choice }),\n peak: StructType({ day: Choice, night: Choice, saturday: Choice, sunday: Choice, four_days: Choice, five_days: Choice, six_days: Choice }),\n});\n\nexport const Employee = StructType({\n id: StringType,\n name: OptionType(StringType),\n home_team: OptionType(StringType),\n active: BooleanType,\n skills: ArrayType(Holding),\n preferences: ArrayType(PreferenceSnapshot),\n});\n\nexport const Skill = StructType({ team: OptionType(StringType) });\n\nexport const Team = StructType({ name: StringType });\n\nexport const recordPeople = e3.record(\"record_people\", DictType(StringType, Employee), {\n initial: new Map([\n [\"P-0401\", { id: \"P-0401\", name: some(\"A. Morgan\"), home_team: some(\"T-IN\"), active: true,\n skills: [\n // Competent since March, signed off; competent until it lapsed on 30 September; a licence held until next May.\n { skill: \"Counting\", holding: variant(\"level\", variant(\"competent\", null)), since: new Date(\"2026-03-02T00:00:00Z\"), expires: none,\n signed_off_by: some(\"M. Hale\"), signed_off_at: some(new Date(\"2026-03-02T00:00:00Z\")) },\n { skill: \"Receiving\", holding: variant(\"level\", variant(\"competent\", null)), since: new Date(\"2026-03-02T00:00:00Z\"),\n expires: some(new Date(\"2026-09-30T00:00:00Z\")), signed_off_by: none, signed_off_at: none },\n { skill: \"Forklift\", holding: variant(\"licence\", true), since: new Date(\"2026-05-01T00:00:00Z\"),\n expires: some(new Date(\"2027-05-01T00:00:00Z\")), signed_off_by: none, signed_off_at: none },\n ],\n preferences: [\n { since: new Date(\"2026-10-01T00:00:00Z\"), basis: variant(\"stated\", null),\n standard: { day: variant(\"prefer\", null), afternoon: variant(\"can\", null), night: variant(\"cant\", null),\n saturday: variant(\"can\", null), sunday: variant(\"can\", null), sunday_night: variant(\"cant\", null) },\n peak: { day: variant(\"can\", null), night: variant(\"can\", null), saturday: variant(\"prefer\", null), sunday: variant(\"can\", null),\n four_days: variant(\"prefer\", null), five_days: variant(\"can\", null), six_days: variant(\"cant\", null) } },\n ] }],\n [\"P-0408\", { id: \"P-0408\", name: some(\"B. Ellis\"), home_team: some(\"T-OUT\"), active: true,\n skills: [\n // A trainee this month, signed off; no forklift licence.\n { skill: \"Dispatch\", holding: variant(\"level\", variant(\"trainee\", null)), since: new Date(\"2026-11-02T00:00:00Z\"), expires: none,\n signed_off_by: some(\"S. Park\"), signed_off_at: some(new Date(\"2026-11-02T00:00:00Z\")) },\n { skill: \"Forklift\", holding: variant(\"licence\", false), since: new Date(\"2026-05-01T00:00:00Z\"), expires: none,\n signed_off_by: none, signed_off_at: none },\n ],\n preferences: [\n { since: new Date(\"2026-02-01T00:00:00Z\"), basis: variant(\"guessed\", null),\n standard: { day: variant(\"can\", null), afternoon: variant(\"prefer\", null), night: variant(\"can\", null),\n saturday: variant(\"cant\", null), sunday: variant(\"cant\", null), sunday_night: variant(\"cant\", null) },\n peak: { day: variant(\"can\", null), night: variant(\"can\", null), saturday: variant(\"can\", null), sunday: variant(\"can\", null),\n four_days: variant(\"can\", null), five_days: variant(\"can\", null), six_days: variant(\"can\", null) } },\n ] }],\n // No name yet, no skill held and no preference stated.\n [\"P-0415\", { id: \"P-0415\", name: none, home_team: none, active: true, skills: [], preferences: [] }],\n ]),\n mutations: (mutation) => ({\n // Every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\nexport const recordSkillList = e3.record(\"record_skill_list\", DictType(StringType, Skill), {\n initial: new Map([\n [\"Counting\", { team: some(\"T-IN\") }],\n [\"Dispatch\", { team: some(\"T-OUT\") }],\n [\"First aid\", { team: none }],\n [\"Forklift\", { team: some(\"T-YARD\") }],\n [\"Receiving\", { team: some(\"T-IN\") }],\n ]),\n});\n\nexport const recordTeams = e3.record(\"record_teams\", DictType(StringType, Team), {\n initial: new Map([[\"T-IN\", { name: \"Inbound\" }], [\"T-OUT\", { name: \"Outbound\" }], [\"T-YARD\", { name: \"Yard\" }]]),\n});\n\n/** The holding of a skill in force on a day: the latest dated on or before it, the later of two dated the same. */\nexport const holdingOn = East.function([ArrayType(Holding), StringType, DateTimeType], OptionType(Holding), ($, holdings, skill, day) => {\n const found = $.let(none, OptionType(Holding));\n $.for(holdings, ($2, holding) => {\n const later = $2.const(found.match({ none: () => true, some: (_$3, held) => East.lessEqual(held.since, holding.since) }));\n $2.if(holding.skill.equal(skill).and(() => East.lessEqual(holding.since, day)).and(() => later), ($3) => {\n $3.assign(found, some(holding));\n });\n });\n return found;\n});\n\n/** A skill's level on a day, as every reader plans with it: none once its holding has expired, a licence held competent. */\nexport const levelOn = East.function([ArrayType(Holding), StringType, DateTimeType], OptionType(Level), ($, holdings, skill, day) => {\n const notHeld = $.const(none, OptionType(Level));\n const competent = $.const(some(variant(\"competent\", null)), OptionType(Level));\n const find = $.const(holdingOn);\n const inForce = $.const(find(holdings, skill, day));\n return inForce.match({\n none: () => notHeld,\n some: ($2, holding) => {\n const expired = $2.const(holding.expires.match({ none: () => false, some: (_$3, end) => East.lessEqual(end, day) }));\n return expired.ifElse(() => notHeld, () => holding.holding.match({\n level: (_$3, level) => some(level),\n licence: (_$3, held) => held.ifElse(() => competent, () => notHeld),\n }));\n },\n });\n});\n\n/** A cell's mark: a licence row in force locks it, held or not; an expired level says what lapsed. */\nexport const markOn = East.function([ArrayType(Holding), StringType, DateTimeType], OptionType(Record.Types.Mark), ($, holdings, skill, day) => {\n const noMark = $.const(none, OptionType(Record.Types.Mark));\n const find = $.const(holdingOn);\n const inForce = $.const(find(holdings, skill, day));\n return inForce.match({\n none: () => noMark,\n some: ($2, holding) => {\n const expired = $2.const(holding.expires.match({ none: () => false, some: (_$3, end) => East.lessEqual(end, day) }));\n return holding.holding.match({\n licence: (_$3, held) => held.ifElse(\n () => expired.ifElse(() => some(variant(\"lock\", \"licence: expired\")), () => some(variant(\"lock\", \"licence\"))),\n () => some(variant(\"lock\", \"no licence\"))),\n level: ($3, level) => {\n const name = $3.const(level.match({ not_trained: () => \"not trained\", trainee: () => \"trainee\", competent: () => \"competent\" }));\n return expired.ifElse(() => some(variant(\"note\", East.str`expired: ${name}`)), () => noMark);\n },\n });\n },\n });\n});\n\n/**\n * The holdings with a skill set to a level today. Today's last row of the skill is replaced when the grid could have\n * written it — a level, with no expiry and no sign-off — and otherwise a row is appended. A level the holdings already\n * read without the grid's row writes nothing, and drops that row: an edit that ends where it started saves none. No\n * earlier row changes.\n */\nexport const withLevel = East.function([ArrayType(Holding), StringType, Level, DateTimeType], ArrayType(Holding), ($, holdings, skill, level, today) => {\n const read = $.const(levelOn);\n const day = $.const(East.DateTime.roundDownDay(today, 1n));\n const written = $.const({ skill, holding: variant(\"level\", level), since: today, expires: none, signed_off_by: none, signed_off_at: none }, Holding);\n const last = $.let(none, OptionType(IntegerType));\n $.for(holdings, ($2, holding, index) => {\n $2.if(holding.skill.equal(skill).and(() => East.equal(East.DateTime.roundDownDay(holding.since, 1n), day)), ($3) => { $3.assign(last, some(index)); });\n });\n // Today's last row of the skill, when the grid could have written it.\n const mine = $.const(last.match({\n none: () => none,\n some: (_$2, at) => holdings.get(at).holding.hasTag(\"level\").and(() => holdings.get(at).expires.hasTag(\"none\")).and(() => holdings.get(at).signed_off_by.hasTag(\"none\"))\n .ifElse(() => some(at), () => none),\n }), OptionType(IntegerType));\n const without = $.const(mine.match({\n none: () => holdings,\n some: (_$2, at) => holdings.slice(0n, at).concat(holdings.slice(at.add(1n), holdings.size())),\n }));\n return East.equal(read(without, skill, today), some(level)).ifElse(\n () => without,\n () => mine.match({\n none: () => holdings.concat([written]),\n some: (_$2, at) => holdings.map((_$3, holding, index) => index.equal(at).ifElse(() => written, () => holding)),\n }));\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const staff = $.let(Record.bind(recordPeople));\n const teamRows = $.let(Data.bind(recordTeams));\n const skillRows = $.let(Data.bind(recordSkillList));\n return (\n <Box height=\"440px\">\n <Record\n record={staff}\n title=\"Skills\"\n noun={{ singular: \"person\", plural: \"people\" }}\n // The people come from the staff list: this page edits them, and adds none.\n edits={{ insertRows: false }}\n registers={{\n teams: Record.register.members(teamRows.read(), { kind: \"team\", key: (_t, code) => code, label: (t) => t.name }),\n skills: Record.register.members(skillRows.read(), {\n kind: \"skill\", key: (_s, name) => name, label: (_s, name) => name, parent: (s) => s.team,\n }),\n }}\n columns={{\n name: Record.column.title(Employee, { header: \"Name\", width: \"112px\",\n value: (p) => p.name.match({ some: (_$, name) => name, none: () => p.id }) }),\n // The skills field: a column for each skill, under its team — wide enough for a level and its\n // licence's lock, and a skill named in two words.\n skills: Record.column.cycle(Employee, Level, {\n each: \"skills\", groups: \"teams\",\n width: \"104px\", scale: true,\n steps: [\n { case: \"not_trained\", label: \"0\", meta: \"Not trained\" },\n { case: \"trainee\", label: \"1\", meta: \"Trainee\" },\n { case: \"competent\", label: \"2\", meta: \"Competent\" },\n ],\n read: levelOn,\n mark: markOn,\n write: withLevel,\n }),\n }}\n // The preferences are the preferences page's: held as dated snapshots, they would show here as raw data.\n fields={{ preferences: Record.field.hidden() }}\n inspector\n name=\"skillHistory\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
44760
+ },
44761
+ {
44762
+ "id": "e3-ui:record.examples.tsx:recordPreferenceSnapshots",
44763
+ "skill": "e3-ui",
44764
+ "package": "e3-ui",
44765
+ "file": "east-ui/packages/e3-ui/test/record/record.examples.tsx",
44766
+ "suite": "",
44767
+ "test": "The worked case's preferences page: each person's shift preferences held as dated snapshots, with two families of columns over one field, the standard choices and the peak ones. Each family reads the snapshot in force at the Record's day and writes a new stated one, through the solution's functions. The name notes a person whose choices are guessed or not stated yet, the page adds no one, and its side panel leaves out the skills, which the skills page edits",
44768
+ "keywords": [
44769
+ "Record",
44770
+ "columns from data",
44771
+ "worked case",
44772
+ "dated snapshots",
44773
+ "each",
44774
+ "field",
44775
+ "read",
44776
+ "write",
44777
+ "mark",
44778
+ "Record.Types.Mark",
44779
+ "note",
44780
+ "Record.column.cycle",
44781
+ "steps",
44782
+ "columnGroups",
44783
+ "Record.column.title",
44784
+ "value",
44785
+ "Record.field.hidden",
44786
+ "hidden"
44787
+ ],
44788
+ "imports": [
44789
+ "import {",
44790
+ "import { Box, Button, Configurator, HStack, Reactive, SegmentGroup, Slice, State, StatusValueType, Style, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
44791
+ "import { Data, Record } from \"@elaraai/e3-ui\";",
44792
+ "import e3 from \"@elaraai/e3\";",
44793
+ "import { IndexedWork, indexedWorkOrders } from \"../sheet/sheet-records.examples.js\";"
44794
+ ],
44795
+ "languages": [
44796
+ "tsx"
44797
+ ],
44798
+ "source": "// The worked case's preferences page: each person's shift preferences held as dated snapshots, with two families of columns over one field, the standard choices and the peak ones. Each family reads the snapshot in force at the Record's day and writes a new stated one, through the solution's functions. The name notes a person whose choices are guessed or not stated yet, the page adds no one, and its side panel leaves out the skills, which the skills page edits\n// inputs: []\nexport const Level = VariantType({ not_trained: NullType, trainee: NullType, competent: NullType });\n\nexport const Holding = StructType({\n skill: StringType,\n holding: VariantType({ level: Level, licence: BooleanType }),\n since: DateTimeType,\n expires: OptionType(DateTimeType),\n signed_off_by: OptionType(StringType),\n signed_off_at: OptionType(DateTimeType),\n});\n\nexport const Choice = VariantType({ cant: NullType, can: NullType, prefer: NullType });\n\nexport const PreferenceSnapshot = StructType({\n since: DateTimeType,\n basis: VariantType({ guessed: NullType, stated: NullType }),\n standard: StructType({ day: Choice, afternoon: Choice, night: Choice, saturday: Choice, sunday: Choice, sunday_night: Choice }),\n peak: StructType({ day: Choice, night: Choice, saturday: Choice, sunday: Choice, four_days: Choice, five_days: Choice, six_days: Choice }),\n});\n\nexport const Employee = StructType({\n id: StringType,\n name: OptionType(StringType),\n home_team: OptionType(StringType),\n active: BooleanType,\n skills: ArrayType(Holding),\n preferences: ArrayType(PreferenceSnapshot),\n});\n\nexport const recordPeople = e3.record(\"record_people\", DictType(StringType, Employee), {\n initial: new Map([\n [\"P-0401\", { id: \"P-0401\", name: some(\"A. Morgan\"), home_team: some(\"T-IN\"), active: true,\n skills: [\n // Competent since March, signed off; competent until it lapsed on 30 September; a licence held until next May.\n { skill: \"Counting\", holding: variant(\"level\", variant(\"competent\", null)), since: new Date(\"2026-03-02T00:00:00Z\"), expires: none,\n signed_off_by: some(\"M. Hale\"), signed_off_at: some(new Date(\"2026-03-02T00:00:00Z\")) },\n { skill: \"Receiving\", holding: variant(\"level\", variant(\"competent\", null)), since: new Date(\"2026-03-02T00:00:00Z\"),\n expires: some(new Date(\"2026-09-30T00:00:00Z\")), signed_off_by: none, signed_off_at: none },\n { skill: \"Forklift\", holding: variant(\"licence\", true), since: new Date(\"2026-05-01T00:00:00Z\"),\n expires: some(new Date(\"2027-05-01T00:00:00Z\")), signed_off_by: none, signed_off_at: none },\n ],\n preferences: [\n { since: new Date(\"2026-10-01T00:00:00Z\"), basis: variant(\"stated\", null),\n standard: { day: variant(\"prefer\", null), afternoon: variant(\"can\", null), night: variant(\"cant\", null),\n saturday: variant(\"can\", null), sunday: variant(\"can\", null), sunday_night: variant(\"cant\", null) },\n peak: { day: variant(\"can\", null), night: variant(\"can\", null), saturday: variant(\"prefer\", null), sunday: variant(\"can\", null),\n four_days: variant(\"prefer\", null), five_days: variant(\"can\", null), six_days: variant(\"cant\", null) } },\n ] }],\n [\"P-0408\", { id: \"P-0408\", name: some(\"B. Ellis\"), home_team: some(\"T-OUT\"), active: true,\n skills: [\n // A trainee this month, signed off; no forklift licence.\n { skill: \"Dispatch\", holding: variant(\"level\", variant(\"trainee\", null)), since: new Date(\"2026-11-02T00:00:00Z\"), expires: none,\n signed_off_by: some(\"S. Park\"), signed_off_at: some(new Date(\"2026-11-02T00:00:00Z\")) },\n { skill: \"Forklift\", holding: variant(\"licence\", false), since: new Date(\"2026-05-01T00:00:00Z\"), expires: none,\n signed_off_by: none, signed_off_at: none },\n ],\n preferences: [\n { since: new Date(\"2026-02-01T00:00:00Z\"), basis: variant(\"guessed\", null),\n standard: { day: variant(\"can\", null), afternoon: variant(\"prefer\", null), night: variant(\"can\", null),\n saturday: variant(\"cant\", null), sunday: variant(\"cant\", null), sunday_night: variant(\"cant\", null) },\n peak: { day: variant(\"can\", null), night: variant(\"can\", null), saturday: variant(\"can\", null), sunday: variant(\"can\", null),\n four_days: variant(\"can\", null), five_days: variant(\"can\", null), six_days: variant(\"can\", null) } },\n ] }],\n // No name yet, no skill held and no preference stated.\n [\"P-0415\", { id: \"P-0415\", name: none, home_team: none, active: true, skills: [], preferences: [] }],\n ]),\n mutations: (mutation) => ({\n // Every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\n/** The preferences in force on a day: the latest snapshot dated on or before it, the later of two dated the same. */\nexport const preferencesOn = East.function([ArrayType(PreferenceSnapshot), DateTimeType], OptionType(PreferenceSnapshot), ($, snapshots, day) => {\n const found = $.let(none, OptionType(PreferenceSnapshot));\n $.for(snapshots, ($2, snapshot) => {\n const later = $2.const(found.match({ none: () => true, some: (_$3, held) => East.lessEqual(held.since, snapshot.since) }));\n $2.if(East.lessEqual(snapshot.since, day).and(() => later), ($3) => { $3.assign(found, some(snapshot)); });\n });\n return found;\n});\n\n/** The standard marks in force on a day; before any snapshot, \"can\" for each. */\nexport const standardOn = East.function([ArrayType(PreferenceSnapshot), DateTimeType], PreferenceSnapshot.fields.standard, ($, snapshots, day) => {\n const unstated = $.const({ day: variant(\"can\", null), afternoon: variant(\"can\", null), night: variant(\"can\", null),\n saturday: variant(\"can\", null), sunday: variant(\"can\", null), sunday_night: variant(\"can\", null) }, PreferenceSnapshot.fields.standard);\n const find = $.const(preferencesOn);\n return find(snapshots, day).match({ none: () => unstated, some: (_$2, snapshot) => snapshot.standard });\n});\n\n/** The peak marks in force on a day; before any snapshot, \"can\" for each. */\nexport const peakOn = East.function([ArrayType(PreferenceSnapshot), DateTimeType], PreferenceSnapshot.fields.peak, ($, snapshots, day) => {\n const unstated = $.const({ day: variant(\"can\", null), night: variant(\"can\", null), saturday: variant(\"can\", null), sunday: variant(\"can\", null),\n four_days: variant(\"can\", null), five_days: variant(\"can\", null), six_days: variant(\"can\", null) }, PreferenceSnapshot.fields.peak);\n const find = $.const(preferencesOn);\n return find(snapshots, day).match({ none: () => unstated, some: (_$2, snapshot) => snapshot.peak });\n});\n\n/** A person's note, on the name: \"none stated\" before any snapshot of their preferences, \"guessed\" while the one in force is a guess. */\nexport const statedOn = East.function([Employee, DateTimeType], OptionType(Record.Types.Mark), ($, person, day) => {\n const noMark = $.const(none, OptionType(Record.Types.Mark));\n const find = $.const(preferencesOn);\n return find(person.preferences, day).match({\n none: () => some(variant(\"note\", \"none stated\")),\n some: (_$2, snapshot) => snapshot.basis.hasTag(\"guessed\").ifElse(() => some(variant(\"note\", \"guessed\")), () => noMark),\n });\n});\n\n/**\n * The snapshots with a new one dated today: today's last replaced when it is stated, which the grid could have written,\n * and otherwise the new one appended. Choices the snapshots already read without that stated one write nothing, and drop\n * it: an edit that ends where it started saves none. No earlier one changes.\n */\nexport const withSnapshot = East.function([ArrayType(PreferenceSnapshot), PreferenceSnapshot], ArrayType(PreferenceSnapshot), ($, snapshots, next) => {\n const standardIn = $.const(standardOn);\n const peakIn = $.const(peakOn);\n const day = $.const(East.DateTime.roundDownDay(next.since, 1n));\n const last = $.let(none, OptionType(IntegerType));\n $.for(snapshots, ($2, snapshot, index) => {\n $2.if(East.equal(East.DateTime.roundDownDay(snapshot.since, 1n), day), ($3) => { $3.assign(last, some(index)); });\n });\n // Today's last snapshot, when it is stated.\n const mine = $.const(last.match({\n none: () => none,\n some: (_$2, at) => snapshots.get(at).basis.hasTag(\"stated\").ifElse(() => some(at), () => none),\n }), OptionType(IntegerType));\n const without = $.const(mine.match({\n none: () => snapshots,\n some: (_$2, at) => snapshots.slice(0n, at).concat(snapshots.slice(at.add(1n), snapshots.size())),\n }));\n const unchanged = $.const(East.equal(standardIn(without, next.since), next.standard).and(() => East.equal(peakIn(without, next.since), next.peak)));\n return unchanged.ifElse(\n () => without,\n () => mine.match({\n none: () => snapshots.concat([next]),\n some: (_$2, at) => snapshots.map((_$3, snapshot, index) => index.equal(at).ifElse(() => next, () => snapshot)),\n }));\n});\n\n/** The snapshots with the standard marks set today, the peak marks in force copied: a write the person stated. */\nexport const withStandard = East.function([ArrayType(PreferenceSnapshot), PreferenceSnapshot.fields.standard, DateTimeType], ArrayType(PreferenceSnapshot), ($, snapshots, standard, day) => {\n const peak = $.const(peakOn);\n const write = $.const(withSnapshot);\n const next = $.const({ since: day, basis: variant(\"stated\", null), standard, peak: peak(snapshots, day) }, PreferenceSnapshot);\n return write(snapshots, next);\n});\n\n/** The snapshots with the peak marks set today, the standard marks in force copied: a write the person stated. */\nexport const withPeak = East.function([ArrayType(PreferenceSnapshot), PreferenceSnapshot.fields.peak, DateTimeType], ArrayType(PreferenceSnapshot), ($, snapshots, peak, day) => {\n const standard = $.const(standardOn);\n const write = $.const(withSnapshot);\n const next = $.const({ since: day, basis: variant(\"stated\", null), standard: standard(snapshots, day), peak }, PreferenceSnapshot);\n return write(snapshots, next);\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const staff = $.let(Record.bind(recordPeople));\n return (\n <Box height=\"440px\">\n <Record\n record={staff}\n title=\"Shift preferences\"\n noun={{ singular: \"person\", plural: \"people\" }}\n // The people come from the staff list: this page edits them, and adds none.\n edits={{ insertRows: false }}\n columns={{\n // The name, noting once a row whether the person's choices are guessed or not stated yet.\n name: Record.column.title(Employee, { header: \"Name\", width: \"176px\",\n value: (p) => p.name.match({ some: (_$, name) => name, none: () => p.id }), mark: statedOn }),\n // The preferences field: a column for each standard choice, then one for each peak choice.\n standard: Record.column.cycle(Employee, Choice, {\n field: \"preferences\",\n each: { day: \"Day\", afternoon: \"Afternoon\", night: \"Night\", saturday: \"Sat\", sunday: \"Sun\", sunday_night: \"Sun night\" },\n width: \"80px\",\n steps: [\n { case: \"can\", label: \"can\", meta: \"Can work\", tone: \"neutral\" },\n { case: \"prefer\", label: \"prefer\", meta: \"Prefers\", tone: \"success\" },\n { case: \"cant\", label: \"can't\", meta: \"Can't work\", tone: \"danger\" },\n ],\n read: standardOn,\n write: withStandard,\n }),\n peak: Record.column.cycle(Employee, Choice, {\n field: \"preferences\",\n each: { day: \"Day\", night: \"Night\", saturday: \"Sat\", sunday: \"Sun\", four_days: \"4 days\", five_days: \"5 days\", six_days: \"6 days\" },\n width: \"80px\",\n steps: [\n { case: \"can\", label: \"can\", meta: \"Can work\", tone: \"neutral\" },\n { case: \"prefer\", label: \"prefer\", meta: \"Prefers\", tone: \"success\" },\n { case: \"cant\", label: \"can't\", meta: \"Can't work\", tone: \"danger\" },\n ],\n read: peakOn,\n write: withPeak,\n }),\n }}\n columnGroups={[\n { label: \"Standard\", columnKeys: [\"standard\"] },\n { label: \"Peak\", columnKeys: [\"peak\"] },\n ]}\n // The skills are the skills page's: held as a dated history, they would show here as raw data.\n fields={{ skills: Record.field.hidden() }}\n inspector\n name=\"preferenceSnapshots\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
44799
+ },
44800
+ {
44801
+ "id": "e3-ui:record.examples.tsx:recordIndexedWorkOrders",
44802
+ "skill": "e3-ui",
44803
+ "package": "e3-ui",
44804
+ "file": "east-ui/packages/e3-ui/test/record/record.examples.tsx",
44805
+ "suite": "",
44806
+ "test": "50,000 work orders as a Record, the record sheetRecordIndexes edits: the rail's rows source narrows them through the record's maintained indexes — Status, a Due range, a Job search, Quantity, Urgent and Tag, opening on Ready, with Ready and Urgent presets — and the Record reads only the rows near the view. Each order's reference is its title, its status a chip a click steps through Ready, Scheduled and Done, and its urgency a toggle; Save commits by key through the record's patch door, and the page adds no orders",
44807
+ "keywords": [
44808
+ "Record",
44809
+ "Slice.bindRecords",
44810
+ "rows",
44811
+ "Data.bindPaged",
44812
+ "Record.onApply",
44813
+ "indexes",
44814
+ "paging",
44815
+ "large record",
44816
+ "filter",
44817
+ "range",
44818
+ "search",
44819
+ "presets",
44820
+ "lens",
44821
+ "Record.column.cycle",
44822
+ "tone",
44823
+ "Record.column.toggle"
44824
+ ],
44825
+ "imports": [
44826
+ "import {",
44827
+ "import { Box, Button, Configurator, HStack, Reactive, SegmentGroup, Slice, State, StatusValueType, Style, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
44828
+ "import { Data, Record } from \"@elaraai/e3-ui\";",
44829
+ "import e3 from \"@elaraai/e3\";",
44830
+ "import { IndexedWork, indexedWorkOrders } from \"../sheet/sheet-records.examples.js\";"
44831
+ ],
44832
+ "languages": [
44833
+ "tsx"
44834
+ ],
44835
+ "source": "// 50,000 work orders as a Record, the record sheetRecordIndexes edits: the rail's rows source narrows them through the record's maintained indexes — Status, a Due range, a Job search, Quantity, Urgent and Tag, opening on Ready, with Ready and Urgent presets — and the Record reads only the rows near the view. Each order's reference is its title, its status a chip a click steps through Ready, Scheduled and Done, and its urgency a toggle; Save commits by key through the record's patch door, and the page adds no orders\n// inputs: []\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const orders = $.let(Record.bind(indexedWorkOrders));\n // One rail over the work orders: its `rows` source narrows them through the record's indexes, and the Record pages the narrowing.\n const slice = $.let(Slice.bindRecords(\"record.indexedWorkOrders\", {\n rows: {\n source: Data.bindPaged(indexedWorkOrders, { indexes: [\"by_status_due\", \"by_due\", \"by_job\", \"by_quantity\", \"by_urgent\", \"by_tag\"] }),\n label: \"Work orders\",\n fields: { status: { label: \"Status\", hints: [\"Ready\", \"Scheduled\", \"Done\"] }, due: { label: \"Due\" }, job: { label: \"Job\" }, quantity: { label: \"Quantity\" }, urgent: { label: \"Urgent\" }, tags: { label: \"Tag\", hints: [\"Production\", \"Dispatch\"] } },\n range: \"due\", search: [\"job\"], initial: { status: [\"Ready\"] },\n },\n }, { presets: [{ id: \"ready\", name: \"Ready\", where: { rows: { status: [\"Ready\"] } } }, { id: \"urgent\", name: \"Urgent\", where: { rows: { urgent: [true] } } }] }));\n const StatusType = StructType({ key: StringType, tone: StatusValueType });\n const statuses = $.let([\n { key: \"Ready\", tone: variant(\"neutral\", null) },\n { key: \"Scheduled\", tone: variant(\"info\", null) },\n { key: \"Done\", tone: variant(\"success\", null) },\n ], ArrayType(StatusType));\n return (\n <Box height=\"760px\">\n <Record\n slice={{ slice }}\n title=\"Work orders\"\n noun={{ singular: \"work order\", plural: \"work orders\" }}\n // Work orders are raised where they are planned: this page edits them, and adds none.\n edits={{ insertRows: false }}\n registers={{ statuses: Record.register.members(statuses, { kind: \"status\", key: s => s.key, label: s => s.key, tone: s => some(s.tone) }) }}\n columns={{\n reference: Record.column.title(IndexedWork, { header: \"Reference\", width: \"136px\" }),\n job: Record.column.text(IndexedWork, { header: \"Job\", width: \"180px\" }),\n status: Record.column.cycle(IndexedWork, \"statuses\", { header: \"Status\", width: \"112px\" }),\n due: Record.column.date(IndexedWork, { header: \"Due\", width: \"144px\" }),\n quantity: Record.column.integer(IndexedWork, { header: \"Quantity\", width: \"112px\" }),\n urgent: Record.column.toggle(IndexedWork, { header: \"Urgent\", width: \"88px\", on: \"yes\", off: \"no\" }),\n }}\n inspector\n onApply={Record.onApply(orders, { keyed: true })}\n name=\"indexedWorkOrders\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
44836
+ },
44837
+ {
44838
+ "id": "e3-ui:record.examples.tsx:recordIndexedWorkOrdersMobile",
44839
+ "skill": "e3-ui",
44840
+ "package": "e3-ui",
44841
+ "file": "east-ui/packages/e3-ui/test/record/record.examples.tsx",
44842
+ "suite": "",
44843
+ "test": "The same 50,000 indexed work orders as a Record in a phone-width frame: the reference pinned at the left as the pager steps through the other columns, the rail's filters on the toolbar's responsive ladder, a press on a job, a date or a quantity editing it below, and the status and the urgency stepping where they are pressed",
44844
+ "keywords": [
44845
+ "Record",
44846
+ "Slice.bindRecords",
44847
+ "rows",
44848
+ "mobile",
44849
+ "phone",
44850
+ "indexes",
44851
+ "paging",
44852
+ "filters",
44853
+ "presets",
44854
+ "pinned title"
44855
+ ],
44856
+ "imports": [
44857
+ "import {",
44858
+ "import { Box, Button, Configurator, HStack, Reactive, SegmentGroup, Slice, State, StatusValueType, Style, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
44859
+ "import { Data, Record } from \"@elaraai/e3-ui\";",
44860
+ "import e3 from \"@elaraai/e3\";",
44861
+ "import { IndexedWork, indexedWorkOrders } from \"../sheet/sheet-records.examples.js\";"
44862
+ ],
44863
+ "languages": [
44864
+ "tsx"
44865
+ ],
44866
+ "source": "// The same 50,000 indexed work orders as a Record in a phone-width frame: the reference pinned at the left as the pager steps through the other columns, the rail's filters on the toolbar's responsive ladder, a press on a job, a date or a quantity editing it below, and the status and the urgency stepping where they are pressed\n// inputs: []\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const orders = $.let(Record.bind(indexedWorkOrders));\n // One rail over the work orders: its `rows` source narrows them through the record's indexes, and the Record pages the narrowing.\n const slice = $.let(Slice.bindRecords(\"record.indexedWorkOrders.mobile\", {\n rows: {\n source: Data.bindPaged(indexedWorkOrders, { indexes: [\"by_status_due\", \"by_due\", \"by_job\", \"by_quantity\", \"by_urgent\", \"by_tag\"] }),\n label: \"Work orders\",\n fields: { status: { label: \"Status\", hints: [\"Ready\", \"Scheduled\", \"Done\"] }, due: { label: \"Due\" }, job: { label: \"Job\" }, quantity: { label: \"Quantity\" }, urgent: { label: \"Urgent\" }, tags: { label: \"Tag\", hints: [\"Production\", \"Dispatch\"] } },\n range: \"due\", search: [\"job\"], initial: { status: [\"Ready\"] },\n },\n }, { presets: [{ id: \"ready\", name: \"Ready\", where: { rows: { status: [\"Ready\"] } } }, { id: \"urgent\", name: \"Urgent\", where: { rows: { urgent: [true] } } }] }));\n const StatusType = StructType({ key: StringType, tone: StatusValueType });\n const statuses = $.let([\n { key: \"Ready\", tone: variant(\"neutral\", null) },\n { key: \"Scheduled\", tone: variant(\"info\", null) },\n { key: \"Done\", tone: variant(\"success\", null) },\n ], ArrayType(StatusType));\n return (\n <Box width=\"390px\" maxWidth=\"100%\" height=\"760px\">\n <Record\n slice={{ slice }}\n title=\"Work orders\"\n noun={{ singular: \"work order\", plural: \"work orders\" }}\n // Work orders are raised where they are planned: this page edits them, and adds none.\n edits={{ insertRows: false }}\n registers={{ statuses: Record.register.members(statuses, { kind: \"status\", key: s => s.key, label: s => s.key, tone: s => some(s.tone) }) }}\n columns={{\n reference: Record.column.title(IndexedWork, { header: \"Reference\", width: \"136px\" }),\n job: Record.column.text(IndexedWork, { header: \"Job\", width: \"180px\" }),\n status: Record.column.cycle(IndexedWork, \"statuses\", { header: \"Status\", width: \"112px\" }),\n due: Record.column.date(IndexedWork, { header: \"Due\", width: \"144px\" }),\n quantity: Record.column.integer(IndexedWork, { header: \"Quantity\", width: \"112px\" }),\n urgent: Record.column.toggle(IndexedWork, { header: \"Urgent\", width: \"88px\", on: \"yes\", off: \"no\" }),\n }}\n inspector\n onApply={Record.onApply(orders, { keyed: true })}\n name=\"indexedWorkOrdersMobile\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
44867
+ },
44868
+ {
44869
+ "id": "e3-ui:record.examples.tsx:recordConflicts",
44870
+ "skill": "e3-ui",
44871
+ "package": "e3-ui",
44872
+ "file": "east-ui/packages/e3-ui/test/record/record.examples.tsx",
44873
+ "suite": "",
44874
+ "test": "Your edits meeting someone else's save, in one window — step a forklift level, then press Someone else saves, which saves another person's change to the same crew (every level a step down), so yours conflicts and waits to be chosen; an induction you toggle combines with theirs. Someone else removes A. Morgan removes that member — changed by you, a conflict of the whole row to choose, deleted by you too, nothing to choose — and Someone else adds a member adds one under the next key, which the Record's newKey gives a member of yours too: one you added meanwhile takes the key after it, and both are kept; a member you add joins not yet inducted and not trained (newRow), their name left to type",
44875
+ "keywords": [
44876
+ "Record",
44877
+ "conflict",
44878
+ "conflicts",
44879
+ "combine",
44880
+ "someone else",
44881
+ "carry over",
44882
+ "Choose",
44883
+ "removed",
44884
+ "added",
44885
+ "Delete",
44886
+ "Add",
44887
+ "key taken",
44888
+ "newKey",
44889
+ "newRow",
44890
+ "Record.patch",
44891
+ "renumbered",
44892
+ "Record.bind",
44893
+ "mutate",
44894
+ "Button",
44895
+ "patch"
44896
+ ],
44897
+ "imports": [
44898
+ "import {",
44899
+ "import { Box, Button, Configurator, HStack, Reactive, SegmentGroup, Slice, State, StatusValueType, Style, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
44900
+ "import { Data, Record } from \"@elaraai/e3-ui\";",
44901
+ "import e3 from \"@elaraai/e3\";",
44902
+ "import { IndexedWork, indexedWorkOrders } from \"../sheet/sheet-records.examples.js\";"
44903
+ ],
44904
+ "languages": [
44905
+ "tsx"
44906
+ ],
44907
+ "source": "// Your edits meeting someone else's save, in one window — step a forklift level, then press Someone else saves, which saves another person's change to the same crew (every level a step down), so yours conflicts and waits to be chosen; an induction you toggle combines with theirs. Someone else removes A. Morgan removes that member — changed by you, a conflict of the whole row to choose, deleted by you too, nothing to choose — and Someone else adds a member adds one under the next key, which the Record's newKey gives a member of yours too: one you added meanwhile takes the key after it, and both are kept; a member you add joins not yet inducted and not trained (newRow), their name left to type\n// inputs: []\nexport const Crew = StructType({ name: StringType, inducted: BooleanType, forklift: StringType });\n\n/** The crew the conflicts example edits, in a record of their own, so no other example's edits meet them. */\nexport const recordConflictCrew = e3.record(\"record_conflict_crew\", DictType(StringType, Crew), {\n initial: new Map([\n [\"C-001\", { name: \"A. Morgan\", inducted: true, forklift: \"2\" }],\n [\"C-002\", { name: \"B. Ellis\", inducted: false, forklift: \"0\" }],\n [\"C-003\", { name: \"C. Patel\", inducted: true, forklift: \"1\" }],\n ]),\n mutations: (mutation) => ({\n // The crew's patch door — every Save commits through it.\n patch: mutation.patch(),\n // Someone else's save: every member's forklift level a step down — Competent to Supervised, Supervised to Not\n // trained, Not trained to Competent — their name and induction as they were.\n elsewhere: mutation.reduce(East.function([DictType(StringType, Crew)], DictType(StringType, Crew), (_$, crew) =>\n crew.map((_$2, member) => ({\n name: member.name,\n inducted: member.inducted,\n forklift: member.forklift.equal(\"2\").ifElse((_$3) => \"1\", (_$3) => member.forklift.equal(\"1\").ifElse((_$4) => \"0\", (_$4) => \"2\")),\n })))),\n // Someone else's save: A. Morgan, C-001, removed — where the record still holds them.\n removes: mutation.reduce(East.function([DictType(StringType, Crew)], DictType(StringType, Crew), ($, crew) => {\n const next = $.let(crew.copy());\n $(next.tryDelete(\"C-001\"));\n return next;\n })),\n // Someone else's save: a member added under the next key, C-004 — where the record holds none there.\n adds: mutation.reduce(East.function([DictType(StringType, Crew)], DictType(StringType, Crew), ($, crew) => {\n const next = $.let(crew.copy());\n $.if(next.has(\"C-004\").not(), ($2) => {\n const joiner = $2.const({ name: \"D. Reyes\", inducted: false, forklift: \"0\" }, Crew);\n $2(next.insert(\"C-004\", joiner));\n });\n return next;\n })),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const members = $.let(Record.bind(recordConflictCrew, [\"patch\"]));\n const others = $.let(Record.bind(recordConflictCrew, [\"elsewhere\", \"removes\", \"adds\"]));\n const theirs = $.const(East.function([], NullType, ($) => { $(others.mutate.elsewhere()); }));\n const theirRemoval = $.const(East.function([], NullType, ($) => { $(others.mutate.removes()); }));\n const theirAddition = $.const(East.function([], NullType, ($) => { $(others.mutate.adds()); }));\n const LevelType = StructType({ key: StringType, name: StringType });\n const levels = $.let([\n { key: \"0\", name: \"Not trained\" },\n { key: \"1\", name: \"Supervised\" },\n { key: \"2\", name: \"Competent\" },\n ], ArrayType(LevelType));\n // A new member's key in the crew's own scheme: given every key taken, the first C-00N none of them is.\n const newKey = $.const(East.function([SetType(StringType)], StringType, ($, taken) => {\n const n = $.let(taken.size().add(1n));\n $.while(taken.has(East.str`C-00${n}`), ($2) => {\n $2.assign(n, n.add(1n));\n });\n return East.str`C-00${n}`;\n }));\n // A new member as they join: not yet inducted, not trained — their name left to type.\n const newRow = $.const(East.function([Record.Types.NewRow], Record.Types.Patch(Crew), (_$) => Record.patch(Crew, { inducted: false, forklift: \"0\" })));\n return (\n <VStack gap=\"3\" align=\"stretch\">\n <HStack gap=\"3\" wrap=\"wrap\">\n <Button variant=\"outline\" onClick={theirs} loading={others.mutate.pending()}>Someone else saves</Button>\n <Button variant=\"outline\" onClick={theirRemoval} loading={others.mutate.pending()}>Someone else removes A. Morgan</Button>\n <Button variant=\"outline\" onClick={theirAddition} loading={others.mutate.pending()}>Someone else adds a member</Button>\n </HStack>\n <Text color=\"fg.muted\">Someone else saves: every forklift level a step down. Their removal: C-001, A. Morgan. Their addition: C-004, D. Reyes.</Text>\n <Box height=\"360px\">\n <Record\n record={members}\n title=\"Crew\"\n noun={{ singular: \"crew member\", plural: \"crew members\" }}\n registers={{ levels: Record.register.members(levels, { kind: \"level\", key: l => l.key, label: l => l.key, meta: l => some(l.name) }) }}\n columns={{\n name: Record.column.title(Crew, { header: \"Name\", width: \"160px\" }),\n inducted: Record.column.toggle(Crew, { header: \"Inducted\", width: \"80px\", on: \"yes\", off: \"no\" }),\n forklift: Record.column.cycle(Crew, \"levels\", { header: \"Forklift\", width: \"72px\", scale: true }),\n }}\n newKey={newKey}\n newRow={newRow}\n name=\"recordConflicts\"\n />\n </Box>\n </VStack>\n );\n }}</Reactive>\n ))"
44908
+ },
44111
44909
  {
44112
44910
  "id": "e3-ui:domain.examples.ts:rosterCoverage",
44113
44911
  "skill": "e3-ui",
@@ -44131,7 +44929,7 @@
44131
44929
  "languages": [
44132
44930
  "typescript"
44133
44931
  ],
44134
- "source": "// Coverage over the app's own duties: named staff, requested positions, nominal skill capacity, each duty's own hours, and the slot's cost, the app's pay summed\n// inputs: [week, context, pay] returns: { positions: 4n, filled: 3n, open: 1n, people: 2n,\n hours: { permanent: 10, agency: 8, requested: 8, needed: 30, rostered: 26 },\n lines: [{ skill: \"reach\", needed: 24, holders: some(1n), capacity: some(8), gap: 16, assigned: 10 },\n { skill: \"general\", needed: 6, holders: none, capacity: none, gap: 0, assigned: 8 }],\n cost: 1278, lead: true, trainer: true }\n/** A duty of the app's own: who — one of its staff, or an agency asked to send someone — its own times, and a note the Roster carries but never reads. */\nexport const DomainDuty = StructType({\n who: VariantType({ staff: StringType, agency: StringType }), start: DateTimeType, end: DateTimeType, note: StringType,\n});\n\n/** A week of the app's duties, as the Roster reads it. */\nexport const DomainWeek = Roster.Types.Week(DomainDuty);\n\n/** Small staffing fixture with independently calculable hours and cost. */\nexport const context: ValueTypeOf<typeof Roster.Types.Context> = {\n people: new Map([\n [\"lead\", { key: \"lead\", name: \"Lead\", group: \"goods\", position: \"lead\", skills: new Set([\"reach\"]), contract: 40, agency: false, trainer: true, trainee: false, usual: some(\"early\") }],\n [\"agency\", { key: \"agency\", name: \"Agency\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 0, agency: true, trainer: false, trainee: false, usual: none }],\n [\"off\", { key: \"off\", name: \"Off\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 40, agency: false, trainer: false, trainee: false, usual: none }],\n ]),\n groups: [{ key: \"goods\", label: \"Goods\" }],\n // Goods' one skill, and the duty every group shares.\n activities: [{ key: \"reach\", label: \"Reach truck\", code: \"RT\", group: some(\"goods\") }, { key: \"general\", label: \"General duties\", code: \"GD\", group: none }],\n shifts: [\n { key: \"early\", label: \"Early\", code: \"E\", start: { hour: 6n, minute: 0n }, hours: 8, color: none },\n { key: \"late\", label: \"Late\", code: \"L\", start: { hour: 14n, minute: 0n }, hours: 8, color: none },\n { key: \"night\", label: \"Night\", code: \"N\", start: { hour: 22n, minute: 0n }, hours: 8, color: none },\n ],\n positions: [{ key: \"crew\", label: \"Crew\", code: \"\", lead: false }, { key: \"lead\", label: \"Lead\", code: \"SV\", lead: true }],\n agencies: [{ key: \"agency\", name: \"Staffing agency\" }],\n rules: { rest: 10, lead: true, skill: true, trainer: true },\n};\n\nexport const slot = { day: 0n, group: \"goods\", shift: \"early\" };\n\n/** Sunday's early shift: the lead in an hour late and on to 17:00, an agency's worker, and a request to the agency. */\nexport const week: ValueTypeOf<typeof DomainWeek> = {\n status: variant(\"draft\", null), dismissed: new Set<string>(),\n assignments: new Map([\n [\"a\", { slot, who: variant(\"person\", \"lead\"), position: \"lead\", activity: some(\"reach\"),\n start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), hours: 10,\n row: { who: variant(\"staff\", \"lead\"), start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), note: \"in late, stays on\" } }],\n [\"b\", { slot, who: variant(\"person\", \"agency\"), position: \"crew\", activity: some(\"general\"),\n start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), hours: 8,\n row: { who: variant(\"staff\", \"agency\"), start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), note: \"\" } }],\n [\"c\", { slot, who: variant(\"request\", \"agency\"), position: \"crew\", activity: none,\n start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), hours: 8,\n row: { who: variant(\"agency\", \"agency\"), start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), note: \"\" } }],\n ]),\n requirements: new SortedMap([[slot, { positions: 4n, hours: new Map([[\"reach\", 24], [\"general\", 6]]) }]], compareFor(Roster.Types.Slot)),\n};\n\n/** The app's pay for the week, by its own codes: the lead's eight ordinary hours and two of overtime, and the agency's sixteen. */\nexport const pay: ValueTypeOf<typeof Roster.Types.Pay> = new Map([\n [\"a\", new Map([[\"ORD\", 336], [\"OT1\", 126]])], [\"b\", new Map([[\"AGENCY\", 408]])], [\"c\", new Map([[\"AGENCY\", 408]])],\n]);\n\nEast.function([DomainWeek, Roster.Types.Context, Roster.Types.Pay], Roster.Types.Coverage, ($, week, context, pay) => {\n const coverage = $.const(Roster.coverage(DomainDuty));\n return coverage(week, context, pay).get(slot);\n })"
44932
+ "source": "// Coverage over the app's own duties: named staff, requested positions, nominal skill capacity, each duty's own hours, and the slot's cost, the app's pay summed\n// inputs: [week, context, pay] returns: { positions: 4n, filled: 3n, open: 1n, people: 2n,\n hours: { permanent: 10, agency: 8, requested: 8, needed: 30, rostered: 26 },\n lines: [{ skill: \"reach\", needed: 24, holders: some(1n), capacity: some(8), gap: 16, assigned: 10 },\n { skill: \"general\", needed: 6, holders: none, capacity: none, gap: 0, assigned: 8 }],\n cost: 1278, lead: true, trainer: true }\n/** A duty of the app's own: who — one of its staff, or an agency asked to send someone — its own times, and a note the Roster carries but never reads. */\nexport const DomainDuty = StructType({\n who: VariantType({ staff: StringType, agency: StringType }), start: DateTimeType, end: DateTimeType, note: StringType,\n});\n\n/** A week of the app's duties, as the Roster reads it. */\nexport const DomainWeek = Roster.Types.Week(DomainDuty);\n\n/** Small staffing fixture with independently calculable hours and cost. */\nexport const context: ValueTypeOf<typeof Roster.Types.Context> = {\n people: new Map([\n [\"lead\", { key: \"lead\", name: \"Lead\", group: \"goods\", position: \"lead\", skills: new Set([\"reach\"]), contract: 40, agency: false, trainer: true, trainee: false, usual: some(\"early\") }],\n [\"agency\", { key: \"agency\", name: \"Agency\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 0, agency: true, trainer: false, trainee: false, usual: none }],\n [\"off\", { key: \"off\", name: \"Off\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 40, agency: false, trainer: false, trainee: false, usual: none }],\n ]),\n groups: [{ key: \"goods\", label: \"Goods\" }],\n // Goods' one skill, and the duty every group shares.\n activities: [{ key: \"reach\", label: \"Reach truck\", code: \"RT\", group: some(\"goods\") }, { key: \"general\", label: \"General duties\", code: \"GD\", group: none }],\n shifts: [\n { key: \"early\", label: \"Early\", code: \"E\", start: { hour: 6n, minute: 0n }, hours: 8, color: none },\n { key: \"late\", label: \"Late\", code: \"L\", start: { hour: 14n, minute: 0n }, hours: 8, color: none },\n { key: \"night\", label: \"Night\", code: \"N\", start: { hour: 22n, minute: 0n }, hours: 8, color: none },\n ],\n positions: [{ key: \"crew\", label: \"Crew\", code: \"\", lead: false }, { key: \"lead\", label: \"Lead\", code: \"SV\", lead: true }],\n agencies: [{ key: \"agency\", name: \"Staffing agency\" }],\n rules: { rest: 10, lead: true, skill: true, trainer: true },\n};\n\nexport const slot = { day: 0n, group: \"goods\", shift: \"early\" };\n\n/** Where the slot's duties stand: Goods' Sunday early. */\nexport const place = { day: 0n, group: some(\"goods\"), shift: \"early\" };\n\n/** Sunday's early shift: the lead in an hour late and on to 17:00, an agency's worker, and a request to the agency. */\nexport const week: ValueTypeOf<typeof DomainWeek> = {\n status: variant(\"draft\", null), dismissed: new Set<string>(),\n assignments: new Map([\n [\"a\", { place, who: variant(\"person\", \"lead\"), position: \"lead\", activity: some(\"reach\"),\n start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), hours: 10,\n row: { who: variant(\"staff\", \"lead\"), start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), note: \"in late, stays on\" } }],\n [\"b\", { place, who: variant(\"person\", \"agency\"), position: \"crew\", activity: some(\"general\"),\n start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), hours: 8,\n row: { who: variant(\"staff\", \"agency\"), start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), note: \"\" } }],\n [\"c\", { place, who: variant(\"request\", \"agency\"), position: \"crew\", activity: none,\n start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), hours: 8,\n row: { who: variant(\"agency\", \"agency\"), start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), note: \"\" } }],\n ]),\n requirements: new SortedMap([[slot, { positions: 4n, hours: new Map([[\"reach\", 24], [\"general\", 6]]) }]], compareFor(Roster.Types.Slot)),\n};\n\n/** The app's pay for the week, by its own codes: the lead's eight ordinary hours and two of overtime, and the agency's sixteen. */\nexport const pay: ValueTypeOf<typeof Roster.Types.Pay> = new Map([\n [\"a\", new Map([[\"ORD\", 336], [\"OT1\", 126]])], [\"b\", new Map([[\"AGENCY\", 408]])], [\"c\", new Map([[\"AGENCY\", 408]])],\n]);\n\nEast.function([DomainWeek, Roster.Types.Context, Roster.Types.Pay], Roster.Types.Coverage, ($, week, context, pay) => {\n const coverage = $.const(Roster.coverage(DomainDuty));\n return coverage(week, context, pay).get(slot);\n })"
44135
44933
  },
44136
44934
  {
44137
44935
  "id": "e3-ui:domain.examples.ts:rosterChecks",
@@ -44153,7 +44951,7 @@
44153
44951
  "languages": [
44154
44952
  "typescript"
44155
44953
  ],
44156
- "source": "// Built-in checks report an open position and a skill-capacity gap; a lead holds the slot, and the duties' own times ask for no agreement\n// inputs: [week, context] returns: 2n\n/** A duty of the app's own: who — one of its staff, or an agency asked to send someone — its own times, and a note the Roster carries but never reads. */\nexport const DomainDuty = StructType({\n who: VariantType({ staff: StringType, agency: StringType }), start: DateTimeType, end: DateTimeType, note: StringType,\n});\n\n/** A week of the app's duties, as the Roster reads it. */\nexport const DomainWeek = Roster.Types.Week(DomainDuty);\n\n/** Small staffing fixture with independently calculable hours and cost. */\nexport const context: ValueTypeOf<typeof Roster.Types.Context> = {\n people: new Map([\n [\"lead\", { key: \"lead\", name: \"Lead\", group: \"goods\", position: \"lead\", skills: new Set([\"reach\"]), contract: 40, agency: false, trainer: true, trainee: false, usual: some(\"early\") }],\n [\"agency\", { key: \"agency\", name: \"Agency\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 0, agency: true, trainer: false, trainee: false, usual: none }],\n [\"off\", { key: \"off\", name: \"Off\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 40, agency: false, trainer: false, trainee: false, usual: none }],\n ]),\n groups: [{ key: \"goods\", label: \"Goods\" }],\n // Goods' one skill, and the duty every group shares.\n activities: [{ key: \"reach\", label: \"Reach truck\", code: \"RT\", group: some(\"goods\") }, { key: \"general\", label: \"General duties\", code: \"GD\", group: none }],\n shifts: [\n { key: \"early\", label: \"Early\", code: \"E\", start: { hour: 6n, minute: 0n }, hours: 8, color: none },\n { key: \"late\", label: \"Late\", code: \"L\", start: { hour: 14n, minute: 0n }, hours: 8, color: none },\n { key: \"night\", label: \"Night\", code: \"N\", start: { hour: 22n, minute: 0n }, hours: 8, color: none },\n ],\n positions: [{ key: \"crew\", label: \"Crew\", code: \"\", lead: false }, { key: \"lead\", label: \"Lead\", code: \"SV\", lead: true }],\n agencies: [{ key: \"agency\", name: \"Staffing agency\" }],\n rules: { rest: 10, lead: true, skill: true, trainer: true },\n};\n\nexport const slot = { day: 0n, group: \"goods\", shift: \"early\" };\n\n/** Sunday's early shift: the lead in an hour late and on to 17:00, an agency's worker, and a request to the agency. */\nexport const week: ValueTypeOf<typeof DomainWeek> = {\n status: variant(\"draft\", null), dismissed: new Set<string>(),\n assignments: new Map([\n [\"a\", { slot, who: variant(\"person\", \"lead\"), position: \"lead\", activity: some(\"reach\"),\n start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), hours: 10,\n row: { who: variant(\"staff\", \"lead\"), start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), note: \"in late, stays on\" } }],\n [\"b\", { slot, who: variant(\"person\", \"agency\"), position: \"crew\", activity: some(\"general\"),\n start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), hours: 8,\n row: { who: variant(\"staff\", \"agency\"), start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), note: \"\" } }],\n [\"c\", { slot, who: variant(\"request\", \"agency\"), position: \"crew\", activity: none,\n start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), hours: 8,\n row: { who: variant(\"agency\", \"agency\"), start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), note: \"\" } }],\n ]),\n requirements: new SortedMap([[slot, { positions: 4n, hours: new Map([[\"reach\", 24], [\"general\", 6]]) }]], compareFor(Roster.Types.Slot)),\n};\n\nEast.function([DomainWeek, Roster.Types.Context], IntegerType, ($, week, context) => {\n const check = $.const(Roster.check(DomainDuty));\n return check(week, context).size();\n })"
44954
+ "source": "// Built-in checks report an open position and a skill-capacity gap; a lead holds the slot, and the duties' own times ask for no agreement\n// inputs: [week, context] returns: 2n\n/** A duty of the app's own: who — one of its staff, or an agency asked to send someone — its own times, and a note the Roster carries but never reads. */\nexport const DomainDuty = StructType({\n who: VariantType({ staff: StringType, agency: StringType }), start: DateTimeType, end: DateTimeType, note: StringType,\n});\n\n/** A week of the app's duties, as the Roster reads it. */\nexport const DomainWeek = Roster.Types.Week(DomainDuty);\n\n/** Small staffing fixture with independently calculable hours and cost. */\nexport const context: ValueTypeOf<typeof Roster.Types.Context> = {\n people: new Map([\n [\"lead\", { key: \"lead\", name: \"Lead\", group: \"goods\", position: \"lead\", skills: new Set([\"reach\"]), contract: 40, agency: false, trainer: true, trainee: false, usual: some(\"early\") }],\n [\"agency\", { key: \"agency\", name: \"Agency\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 0, agency: true, trainer: false, trainee: false, usual: none }],\n [\"off\", { key: \"off\", name: \"Off\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 40, agency: false, trainer: false, trainee: false, usual: none }],\n ]),\n groups: [{ key: \"goods\", label: \"Goods\" }],\n // Goods' one skill, and the duty every group shares.\n activities: [{ key: \"reach\", label: \"Reach truck\", code: \"RT\", group: some(\"goods\") }, { key: \"general\", label: \"General duties\", code: \"GD\", group: none }],\n shifts: [\n { key: \"early\", label: \"Early\", code: \"E\", start: { hour: 6n, minute: 0n }, hours: 8, color: none },\n { key: \"late\", label: \"Late\", code: \"L\", start: { hour: 14n, minute: 0n }, hours: 8, color: none },\n { key: \"night\", label: \"Night\", code: \"N\", start: { hour: 22n, minute: 0n }, hours: 8, color: none },\n ],\n positions: [{ key: \"crew\", label: \"Crew\", code: \"\", lead: false }, { key: \"lead\", label: \"Lead\", code: \"SV\", lead: true }],\n agencies: [{ key: \"agency\", name: \"Staffing agency\" }],\n rules: { rest: 10, lead: true, skill: true, trainer: true },\n};\n\nexport const slot = { day: 0n, group: \"goods\", shift: \"early\" };\n\n/** Where the slot's duties stand: Goods' Sunday early. */\nexport const place = { day: 0n, group: some(\"goods\"), shift: \"early\" };\n\n/** Sunday's early shift: the lead in an hour late and on to 17:00, an agency's worker, and a request to the agency. */\nexport const week: ValueTypeOf<typeof DomainWeek> = {\n status: variant(\"draft\", null), dismissed: new Set<string>(),\n assignments: new Map([\n [\"a\", { place, who: variant(\"person\", \"lead\"), position: \"lead\", activity: some(\"reach\"),\n start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), hours: 10,\n row: { who: variant(\"staff\", \"lead\"), start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), note: \"in late, stays on\" } }],\n [\"b\", { place, who: variant(\"person\", \"agency\"), position: \"crew\", activity: some(\"general\"),\n start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), hours: 8,\n row: { who: variant(\"staff\", \"agency\"), start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), note: \"\" } }],\n [\"c\", { place, who: variant(\"request\", \"agency\"), position: \"crew\", activity: none,\n start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), hours: 8,\n row: { who: variant(\"agency\", \"agency\"), start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), note: \"\" } }],\n ]),\n requirements: new SortedMap([[slot, { positions: 4n, hours: new Map([[\"reach\", 24], [\"general\", 6]]) }]], compareFor(Roster.Types.Slot)),\n};\n\nEast.function([DomainWeek, Roster.Types.Context], IntegerType, ($, week, context) => {\n const check = $.const(Roster.check(DomainDuty));\n return check(week, context).size();\n })"
44157
44955
  },
44158
44956
  {
44159
44957
  "id": "e3-ui:domain.examples.ts:rosterWeeklyHours",
@@ -44174,7 +44972,7 @@
44174
44972
  "languages": [
44175
44973
  "typescript"
44176
44974
  ],
44177
- "source": "// A person's week counts each duty's own hours: the lead's 07:00–17:00 counts ten\n// inputs: [week, context] returns: 10\n/** A duty of the app's own: who — one of its staff, or an agency asked to send someone — its own times, and a note the Roster carries but never reads. */\nexport const DomainDuty = StructType({\n who: VariantType({ staff: StringType, agency: StringType }), start: DateTimeType, end: DateTimeType, note: StringType,\n});\n\n/** A week of the app's duties, as the Roster reads it. */\nexport const DomainWeek = Roster.Types.Week(DomainDuty);\n\n/** Small staffing fixture with independently calculable hours and cost. */\nexport const context: ValueTypeOf<typeof Roster.Types.Context> = {\n people: new Map([\n [\"lead\", { key: \"lead\", name: \"Lead\", group: \"goods\", position: \"lead\", skills: new Set([\"reach\"]), contract: 40, agency: false, trainer: true, trainee: false, usual: some(\"early\") }],\n [\"agency\", { key: \"agency\", name: \"Agency\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 0, agency: true, trainer: false, trainee: false, usual: none }],\n [\"off\", { key: \"off\", name: \"Off\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 40, agency: false, trainer: false, trainee: false, usual: none }],\n ]),\n groups: [{ key: \"goods\", label: \"Goods\" }],\n // Goods' one skill, and the duty every group shares.\n activities: [{ key: \"reach\", label: \"Reach truck\", code: \"RT\", group: some(\"goods\") }, { key: \"general\", label: \"General duties\", code: \"GD\", group: none }],\n shifts: [\n { key: \"early\", label: \"Early\", code: \"E\", start: { hour: 6n, minute: 0n }, hours: 8, color: none },\n { key: \"late\", label: \"Late\", code: \"L\", start: { hour: 14n, minute: 0n }, hours: 8, color: none },\n { key: \"night\", label: \"Night\", code: \"N\", start: { hour: 22n, minute: 0n }, hours: 8, color: none },\n ],\n positions: [{ key: \"crew\", label: \"Crew\", code: \"\", lead: false }, { key: \"lead\", label: \"Lead\", code: \"SV\", lead: true }],\n agencies: [{ key: \"agency\", name: \"Staffing agency\" }],\n rules: { rest: 10, lead: true, skill: true, trainer: true },\n};\n\nexport const slot = { day: 0n, group: \"goods\", shift: \"early\" };\n\n/** Sunday's early shift: the lead in an hour late and on to 17:00, an agency's worker, and a request to the agency. */\nexport const week: ValueTypeOf<typeof DomainWeek> = {\n status: variant(\"draft\", null), dismissed: new Set<string>(),\n assignments: new Map([\n [\"a\", { slot, who: variant(\"person\", \"lead\"), position: \"lead\", activity: some(\"reach\"),\n start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), hours: 10,\n row: { who: variant(\"staff\", \"lead\"), start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), note: \"in late, stays on\" } }],\n [\"b\", { slot, who: variant(\"person\", \"agency\"), position: \"crew\", activity: some(\"general\"),\n start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), hours: 8,\n row: { who: variant(\"staff\", \"agency\"), start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), note: \"\" } }],\n [\"c\", { slot, who: variant(\"request\", \"agency\"), position: \"crew\", activity: none,\n start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), hours: 8,\n row: { who: variant(\"agency\", \"agency\"), start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), note: \"\" } }],\n ]),\n requirements: new SortedMap([[slot, { positions: 4n, hours: new Map([[\"reach\", 24], [\"general\", 6]]) }]], compareFor(Roster.Types.Slot)),\n};\n\nEast.function([DomainWeek, Roster.Types.Context], FloatType, ($, week, context) => {\n const hours = $.const(Roster.weekHours(DomainDuty));\n return hours(week, context).get(\"lead\");\n })"
44975
+ "source": "// A person's week counts each duty's own hours: the lead's 07:00–17:00 counts ten\n// inputs: [week, context] returns: 10\n/** A duty of the app's own: who — one of its staff, or an agency asked to send someone — its own times, and a note the Roster carries but never reads. */\nexport const DomainDuty = StructType({\n who: VariantType({ staff: StringType, agency: StringType }), start: DateTimeType, end: DateTimeType, note: StringType,\n});\n\n/** A week of the app's duties, as the Roster reads it. */\nexport const DomainWeek = Roster.Types.Week(DomainDuty);\n\n/** Small staffing fixture with independently calculable hours and cost. */\nexport const context: ValueTypeOf<typeof Roster.Types.Context> = {\n people: new Map([\n [\"lead\", { key: \"lead\", name: \"Lead\", group: \"goods\", position: \"lead\", skills: new Set([\"reach\"]), contract: 40, agency: false, trainer: true, trainee: false, usual: some(\"early\") }],\n [\"agency\", { key: \"agency\", name: \"Agency\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 0, agency: true, trainer: false, trainee: false, usual: none }],\n [\"off\", { key: \"off\", name: \"Off\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 40, agency: false, trainer: false, trainee: false, usual: none }],\n ]),\n groups: [{ key: \"goods\", label: \"Goods\" }],\n // Goods' one skill, and the duty every group shares.\n activities: [{ key: \"reach\", label: \"Reach truck\", code: \"RT\", group: some(\"goods\") }, { key: \"general\", label: \"General duties\", code: \"GD\", group: none }],\n shifts: [\n { key: \"early\", label: \"Early\", code: \"E\", start: { hour: 6n, minute: 0n }, hours: 8, color: none },\n { key: \"late\", label: \"Late\", code: \"L\", start: { hour: 14n, minute: 0n }, hours: 8, color: none },\n { key: \"night\", label: \"Night\", code: \"N\", start: { hour: 22n, minute: 0n }, hours: 8, color: none },\n ],\n positions: [{ key: \"crew\", label: \"Crew\", code: \"\", lead: false }, { key: \"lead\", label: \"Lead\", code: \"SV\", lead: true }],\n agencies: [{ key: \"agency\", name: \"Staffing agency\" }],\n rules: { rest: 10, lead: true, skill: true, trainer: true },\n};\n\nexport const slot = { day: 0n, group: \"goods\", shift: \"early\" };\n\n/** Where the slot's duties stand: Goods' Sunday early. */\nexport const place = { day: 0n, group: some(\"goods\"), shift: \"early\" };\n\n/** Sunday's early shift: the lead in an hour late and on to 17:00, an agency's worker, and a request to the agency. */\nexport const week: ValueTypeOf<typeof DomainWeek> = {\n status: variant(\"draft\", null), dismissed: new Set<string>(),\n assignments: new Map([\n [\"a\", { place, who: variant(\"person\", \"lead\"), position: \"lead\", activity: some(\"reach\"),\n start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), hours: 10,\n row: { who: variant(\"staff\", \"lead\"), start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), note: \"in late, stays on\" } }],\n [\"b\", { place, who: variant(\"person\", \"agency\"), position: \"crew\", activity: some(\"general\"),\n start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), hours: 8,\n row: { who: variant(\"staff\", \"agency\"), start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), note: \"\" } }],\n [\"c\", { place, who: variant(\"request\", \"agency\"), position: \"crew\", activity: none,\n start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), hours: 8,\n row: { who: variant(\"agency\", \"agency\"), start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), note: \"\" } }],\n ]),\n requirements: new SortedMap([[slot, { positions: 4n, hours: new Map([[\"reach\", 24], [\"general\", 6]]) }]], compareFor(Roster.Types.Slot)),\n};\n\nEast.function([DomainWeek, Roster.Types.Context], FloatType, ($, week, context) => {\n const hours = $.const(Roster.weekHours(DomainDuty));\n return hours(week, context).get(\"lead\");\n })"
44178
44976
  },
44179
44977
  {
44180
44978
  "id": "e3-ui:domain.examples.ts:rosterRest",
@@ -44196,7 +44994,7 @@
44196
44994
  "languages": [
44197
44995
  "typescript"
44198
44996
  ],
44199
- "source": "// A night duty that runs on to 08:00 leaves only six hours before the next day's late shift\n// inputs: [context] returns: 6\n/** A duty of the app's own: who — one of its staff, or an agency asked to send someone — its own times, and a note the Roster carries but never reads. */\nexport const DomainDuty = StructType({\n who: VariantType({ staff: StringType, agency: StringType }), start: DateTimeType, end: DateTimeType, note: StringType,\n});\n\n/** A week of the app's duties, as the Roster reads it. */\nexport const DomainWeek = Roster.Types.Week(DomainDuty);\n\n/** Small staffing fixture with independently calculable hours and cost. */\nexport const context: ValueTypeOf<typeof Roster.Types.Context> = {\n people: new Map([\n [\"lead\", { key: \"lead\", name: \"Lead\", group: \"goods\", position: \"lead\", skills: new Set([\"reach\"]), contract: 40, agency: false, trainer: true, trainee: false, usual: some(\"early\") }],\n [\"agency\", { key: \"agency\", name: \"Agency\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 0, agency: true, trainer: false, trainee: false, usual: none }],\n [\"off\", { key: \"off\", name: \"Off\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 40, agency: false, trainer: false, trainee: false, usual: none }],\n ]),\n groups: [{ key: \"goods\", label: \"Goods\" }],\n // Goods' one skill, and the duty every group shares.\n activities: [{ key: \"reach\", label: \"Reach truck\", code: \"RT\", group: some(\"goods\") }, { key: \"general\", label: \"General duties\", code: \"GD\", group: none }],\n shifts: [\n { key: \"early\", label: \"Early\", code: \"E\", start: { hour: 6n, minute: 0n }, hours: 8, color: none },\n { key: \"late\", label: \"Late\", code: \"L\", start: { hour: 14n, minute: 0n }, hours: 8, color: none },\n { key: \"night\", label: \"Night\", code: \"N\", start: { hour: 22n, minute: 0n }, hours: 8, color: none },\n ],\n positions: [{ key: \"crew\", label: \"Crew\", code: \"\", lead: false }, { key: \"lead\", label: \"Lead\", code: \"SV\", lead: true }],\n agencies: [{ key: \"agency\", name: \"Staffing agency\" }],\n rules: { rest: 10, lead: true, skill: true, trainer: true },\n};\n\nEast.function([Roster.Types.Context], FloatType, ($, context) => {\n const rest = $.const(Roster.rest(DomainDuty));\n const night = $.const({ who: variant(\"staff\", \"lead\"), start: new Date(\"2028-03-05T22:00:00Z\"), end: new Date(\"2028-03-06T08:00:00Z\"), note: \"\" }, DomainDuty);\n const prior = $.const({ status: variant(\"draft\", null), dismissed: new Set<string>(), requirements: new Map(), assignments: new Map([\n [\"night\", { slot: { day: 0n, group: \"goods\", shift: \"night\" }, who: variant(\"person\", \"lead\"), position: \"lead\", activity: none,\n start: new Date(\"2028-03-05T22:00:00Z\"), end: new Date(\"2028-03-06T08:00:00Z\"), hours: 10, row: night }],\n ]) }, DomainWeek);\n const late = $.const({ who: variant(\"staff\", \"lead\"), start: new Date(\"2028-03-06T14:00:00Z\"), end: new Date(\"2028-03-06T22:00:00Z\"), note: \"\" }, DomainDuty);\n const next = $.const({ slot: { day: 1n, group: \"goods\", shift: \"late\" }, who: variant(\"person\", \"lead\"), position: \"lead\", activity: none,\n start: new Date(\"2028-03-06T14:00:00Z\"), end: new Date(\"2028-03-06T22:00:00Z\"), hours: 8, row: late }, Roster.Types.Assignment(DomainDuty));\n return rest(next, \"next\", prior, context).before;\n })"
44997
+ "source": "// A night duty that runs on to 08:00 leaves only six hours before the next day's late shift\n// inputs: [context] returns: 6\n/** A duty of the app's own: who — one of its staff, or an agency asked to send someone — its own times, and a note the Roster carries but never reads. */\nexport const DomainDuty = StructType({\n who: VariantType({ staff: StringType, agency: StringType }), start: DateTimeType, end: DateTimeType, note: StringType,\n});\n\n/** A week of the app's duties, as the Roster reads it. */\nexport const DomainWeek = Roster.Types.Week(DomainDuty);\n\n/** Small staffing fixture with independently calculable hours and cost. */\nexport const context: ValueTypeOf<typeof Roster.Types.Context> = {\n people: new Map([\n [\"lead\", { key: \"lead\", name: \"Lead\", group: \"goods\", position: \"lead\", skills: new Set([\"reach\"]), contract: 40, agency: false, trainer: true, trainee: false, usual: some(\"early\") }],\n [\"agency\", { key: \"agency\", name: \"Agency\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 0, agency: true, trainer: false, trainee: false, usual: none }],\n [\"off\", { key: \"off\", name: \"Off\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 40, agency: false, trainer: false, trainee: false, usual: none }],\n ]),\n groups: [{ key: \"goods\", label: \"Goods\" }],\n // Goods' one skill, and the duty every group shares.\n activities: [{ key: \"reach\", label: \"Reach truck\", code: \"RT\", group: some(\"goods\") }, { key: \"general\", label: \"General duties\", code: \"GD\", group: none }],\n shifts: [\n { key: \"early\", label: \"Early\", code: \"E\", start: { hour: 6n, minute: 0n }, hours: 8, color: none },\n { key: \"late\", label: \"Late\", code: \"L\", start: { hour: 14n, minute: 0n }, hours: 8, color: none },\n { key: \"night\", label: \"Night\", code: \"N\", start: { hour: 22n, minute: 0n }, hours: 8, color: none },\n ],\n positions: [{ key: \"crew\", label: \"Crew\", code: \"\", lead: false }, { key: \"lead\", label: \"Lead\", code: \"SV\", lead: true }],\n agencies: [{ key: \"agency\", name: \"Staffing agency\" }],\n rules: { rest: 10, lead: true, skill: true, trainer: true },\n};\n\nEast.function([Roster.Types.Context], FloatType, ($, context) => {\n const rest = $.const(Roster.rest(DomainDuty));\n const night = $.const({ who: variant(\"staff\", \"lead\"), start: new Date(\"2028-03-05T22:00:00Z\"), end: new Date(\"2028-03-06T08:00:00Z\"), note: \"\" }, DomainDuty);\n const prior = $.const({ status: variant(\"draft\", null), dismissed: new Set<string>(), requirements: new Map(), assignments: new Map([\n [\"night\", { place: { day: 0n, group: some(\"goods\"), shift: \"night\" }, who: variant(\"person\", \"lead\"), position: \"lead\", activity: none,\n start: new Date(\"2028-03-05T22:00:00Z\"), end: new Date(\"2028-03-06T08:00:00Z\"), hours: 10, row: night }],\n ]) }, DomainWeek);\n const late = $.const({ who: variant(\"staff\", \"lead\"), start: new Date(\"2028-03-06T14:00:00Z\"), end: new Date(\"2028-03-06T22:00:00Z\"), note: \"\" }, DomainDuty);\n const next = $.const({ place: { day: 1n, group: some(\"goods\"), shift: \"late\" }, who: variant(\"person\", \"lead\"), position: \"lead\", activity: none,\n start: new Date(\"2028-03-06T14:00:00Z\"), end: new Date(\"2028-03-06T22:00:00Z\"), hours: 8, row: late }, Roster.Types.Assignment(DomainDuty));\n return rest(next, \"next\", prior, context).before;\n })"
44200
44998
  },
44201
44999
  {
44202
45000
  "id": "e3-ui:domain.examples.ts:rosterFitTrainer",
@@ -44221,7 +45019,56 @@
44221
45019
  "languages": [
44222
45020
  "typescript"
44223
45021
  ],
44224
- "source": "// The ready-made fit: a trainer off that day whose rest is kept fits Goods' early shift, scored by spare contract hours and a week's more in the slot's group\n// inputs: [week, context] returns: variant(\"fits\", { score: 198, why: \"Goods · 30 h spare\", warn: none })\n/** A duty of the app's own: who — one of its staff, or an agency asked to send someone — its own times, and a note the Roster carries but never reads. */\nexport const DomainDuty = StructType({\n who: VariantType({ staff: StringType, agency: StringType }), start: DateTimeType, end: DateTimeType, note: StringType,\n});\n\n/** A week of the app's duties, as the Roster reads it. */\nexport const DomainWeek = Roster.Types.Week(DomainDuty);\n\n/** Small staffing fixture with independently calculable hours and cost. */\nexport const context: ValueTypeOf<typeof Roster.Types.Context> = {\n people: new Map([\n [\"lead\", { key: \"lead\", name: \"Lead\", group: \"goods\", position: \"lead\", skills: new Set([\"reach\"]), contract: 40, agency: false, trainer: true, trainee: false, usual: some(\"early\") }],\n [\"agency\", { key: \"agency\", name: \"Agency\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 0, agency: true, trainer: false, trainee: false, usual: none }],\n [\"off\", { key: \"off\", name: \"Off\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 40, agency: false, trainer: false, trainee: false, usual: none }],\n ]),\n groups: [{ key: \"goods\", label: \"Goods\" }],\n // Goods' one skill, and the duty every group shares.\n activities: [{ key: \"reach\", label: \"Reach truck\", code: \"RT\", group: some(\"goods\") }, { key: \"general\", label: \"General duties\", code: \"GD\", group: none }],\n shifts: [\n { key: \"early\", label: \"Early\", code: \"E\", start: { hour: 6n, minute: 0n }, hours: 8, color: none },\n { key: \"late\", label: \"Late\", code: \"L\", start: { hour: 14n, minute: 0n }, hours: 8, color: none },\n { key: \"night\", label: \"Night\", code: \"N\", start: { hour: 22n, minute: 0n }, hours: 8, color: none },\n ],\n positions: [{ key: \"crew\", label: \"Crew\", code: \"\", lead: false }, { key: \"lead\", label: \"Lead\", code: \"SV\", lead: true }],\n agencies: [{ key: \"agency\", name: \"Staffing agency\" }],\n rules: { rest: 10, lead: true, skill: true, trainer: true },\n};\n\nexport const slot = { day: 0n, group: \"goods\", shift: \"early\" };\n\n/** Sunday's early shift: the lead in an hour late and on to 17:00, an agency's worker, and a request to the agency. */\nexport const week: ValueTypeOf<typeof DomainWeek> = {\n status: variant(\"draft\", null), dismissed: new Set<string>(),\n assignments: new Map([\n [\"a\", { slot, who: variant(\"person\", \"lead\"), position: \"lead\", activity: some(\"reach\"),\n start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), hours: 10,\n row: { who: variant(\"staff\", \"lead\"), start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), note: \"in late, stays on\" } }],\n [\"b\", { slot, who: variant(\"person\", \"agency\"), position: \"crew\", activity: some(\"general\"),\n start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), hours: 8,\n row: { who: variant(\"staff\", \"agency\"), start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), note: \"\" } }],\n [\"c\", { slot, who: variant(\"request\", \"agency\"), position: \"crew\", activity: none,\n start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), hours: 8,\n row: { who: variant(\"agency\", \"agency\"), start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), note: \"\" } }],\n ]),\n requirements: new SortedMap([[slot, { positions: 4n, hours: new Map([[\"reach\", 24], [\"general\", 6]]) }]], compareFor(Roster.Types.Slot)),\n};\n\nEast.function([DomainWeek, Roster.Types.Context], Roster.Types.Fit, ($, week, context) => {\n const coverage = $.const(Roster.coverage(DomainDuty));\n const fit = $.const(Roster.fit(DomainDuty));\n const noPay = $.const(new Map(), Roster.Types.Pay);\n // Monday's early shift: the lead's Sunday duty ends at 17:00, so 13 hours' rest is kept; 10 of their 40 contract hours are rostered.\n const request = $.const({ need: variant(\"trainers\", null), slot: { day: 1n, group: \"goods\", shift: \"early\" }, start: new Date(\"2028-03-05T00:00:00Z\"),\n week, context, coverage: coverage(week, context, noPay) }, Roster.Types.FitRequest(DomainDuty));\n return fit(request, context.people.get(\"lead\"));\n })"
45022
+ "source": "// The ready-made fit: a trainer off that day whose rest is kept fits Goods' early shift, scored by spare contract hours and a week's more in the slot's group\n// inputs: [week, context] returns: variant(\"fits\", { score: 198, why: \"Goods · 30 h spare\", warn: none })\n/** A duty of the app's own: who — one of its staff, or an agency asked to send someone — its own times, and a note the Roster carries but never reads. */\nexport const DomainDuty = StructType({\n who: VariantType({ staff: StringType, agency: StringType }), start: DateTimeType, end: DateTimeType, note: StringType,\n});\n\n/** A week of the app's duties, as the Roster reads it. */\nexport const DomainWeek = Roster.Types.Week(DomainDuty);\n\n/** Small staffing fixture with independently calculable hours and cost. */\nexport const context: ValueTypeOf<typeof Roster.Types.Context> = {\n people: new Map([\n [\"lead\", { key: \"lead\", name: \"Lead\", group: \"goods\", position: \"lead\", skills: new Set([\"reach\"]), contract: 40, agency: false, trainer: true, trainee: false, usual: some(\"early\") }],\n [\"agency\", { key: \"agency\", name: \"Agency\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 0, agency: true, trainer: false, trainee: false, usual: none }],\n [\"off\", { key: \"off\", name: \"Off\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 40, agency: false, trainer: false, trainee: false, usual: none }],\n ]),\n groups: [{ key: \"goods\", label: \"Goods\" }],\n // Goods' one skill, and the duty every group shares.\n activities: [{ key: \"reach\", label: \"Reach truck\", code: \"RT\", group: some(\"goods\") }, { key: \"general\", label: \"General duties\", code: \"GD\", group: none }],\n shifts: [\n { key: \"early\", label: \"Early\", code: \"E\", start: { hour: 6n, minute: 0n }, hours: 8, color: none },\n { key: \"late\", label: \"Late\", code: \"L\", start: { hour: 14n, minute: 0n }, hours: 8, color: none },\n { key: \"night\", label: \"Night\", code: \"N\", start: { hour: 22n, minute: 0n }, hours: 8, color: none },\n ],\n positions: [{ key: \"crew\", label: \"Crew\", code: \"\", lead: false }, { key: \"lead\", label: \"Lead\", code: \"SV\", lead: true }],\n agencies: [{ key: \"agency\", name: \"Staffing agency\" }],\n rules: { rest: 10, lead: true, skill: true, trainer: true },\n};\n\nexport const slot = { day: 0n, group: \"goods\", shift: \"early\" };\n\n/** Where the slot's duties stand: Goods' Sunday early. */\nexport const place = { day: 0n, group: some(\"goods\"), shift: \"early\" };\n\n/** Sunday's early shift: the lead in an hour late and on to 17:00, an agency's worker, and a request to the agency. */\nexport const week: ValueTypeOf<typeof DomainWeek> = {\n status: variant(\"draft\", null), dismissed: new Set<string>(),\n assignments: new Map([\n [\"a\", { place, who: variant(\"person\", \"lead\"), position: \"lead\", activity: some(\"reach\"),\n start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), hours: 10,\n row: { who: variant(\"staff\", \"lead\"), start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), note: \"in late, stays on\" } }],\n [\"b\", { place, who: variant(\"person\", \"agency\"), position: \"crew\", activity: some(\"general\"),\n start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), hours: 8,\n row: { who: variant(\"staff\", \"agency\"), start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), note: \"\" } }],\n [\"c\", { place, who: variant(\"request\", \"agency\"), position: \"crew\", activity: none,\n start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), hours: 8,\n row: { who: variant(\"agency\", \"agency\"), start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), note: \"\" } }],\n ]),\n requirements: new SortedMap([[slot, { positions: 4n, hours: new Map([[\"reach\", 24], [\"general\", 6]]) }]], compareFor(Roster.Types.Slot)),\n};\n\nEast.function([DomainWeek, Roster.Types.Context], Roster.Types.Fit, ($, week, context) => {\n const coverage = $.const(Roster.coverage(DomainDuty));\n const fit = $.const(Roster.fit(DomainDuty));\n const noPay = $.const(new Map(), Roster.Types.Pay);\n // Monday's early shift: the lead's Sunday duty ends at 17:00, so 13 hours' rest is kept; 10 of their 40 contract hours are rostered.\n const request = $.const({ need: variant(\"trainers\", null), slot: { day: 1n, group: \"goods\", shift: \"early\" }, start: new Date(\"2028-03-05T00:00:00Z\"),\n week, context, coverage: coverage(week, context, noPay) }, Roster.Types.FitRequest(DomainDuty));\n return fit(request, context.people.get(\"lead\"));\n })"
45023
+ },
45024
+ {
45025
+ "id": "e3-ui:domain.examples.ts:rosterNoGroupHours",
45026
+ "skill": "e3-ui",
45027
+ "package": "e3-ui",
45028
+ "file": "east-ui/packages/e3-ui/test/roster/domain.examples.ts",
45029
+ "suite": "",
45030
+ "test": "A duty in no group yet counts in its person's week and in no group's coverage: the lead's night in none adds eight hours to their week and nothing to Goods' night",
45031
+ "keywords": [
45032
+ "Roster",
45033
+ "Roster.weekHours",
45034
+ "Roster.coverage",
45035
+ "no group",
45036
+ "Option group",
45037
+ "two-step roster"
45038
+ ],
45039
+ "imports": [
45040
+ "import {",
45041
+ "import { Roster } from \"@elaraai/e3-ui\";"
45042
+ ],
45043
+ "languages": [
45044
+ "typescript"
45045
+ ],
45046
+ "source": "// A duty in no group yet counts in its person's week and in no group's coverage: the lead's night in none adds eight hours to their week and nothing to Goods' night\n// inputs: [noGroupWeek, context] returns: { lead: 18, early: 26, night: 0n }\n/** A duty of the app's own: who — one of its staff, or an agency asked to send someone — its own times, and a note the Roster carries but never reads. */\nexport const DomainDuty = StructType({\n who: VariantType({ staff: StringType, agency: StringType }), start: DateTimeType, end: DateTimeType, note: StringType,\n});\n\n/** A week of the app's duties, as the Roster reads it. */\nexport const DomainWeek = Roster.Types.Week(DomainDuty);\n\n/** Small staffing fixture with independently calculable hours and cost. */\nexport const context: ValueTypeOf<typeof Roster.Types.Context> = {\n people: new Map([\n [\"lead\", { key: \"lead\", name: \"Lead\", group: \"goods\", position: \"lead\", skills: new Set([\"reach\"]), contract: 40, agency: false, trainer: true, trainee: false, usual: some(\"early\") }],\n [\"agency\", { key: \"agency\", name: \"Agency\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 0, agency: true, trainer: false, trainee: false, usual: none }],\n [\"off\", { key: \"off\", name: \"Off\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 40, agency: false, trainer: false, trainee: false, usual: none }],\n ]),\n groups: [{ key: \"goods\", label: \"Goods\" }],\n // Goods' one skill, and the duty every group shares.\n activities: [{ key: \"reach\", label: \"Reach truck\", code: \"RT\", group: some(\"goods\") }, { key: \"general\", label: \"General duties\", code: \"GD\", group: none }],\n shifts: [\n { key: \"early\", label: \"Early\", code: \"E\", start: { hour: 6n, minute: 0n }, hours: 8, color: none },\n { key: \"late\", label: \"Late\", code: \"L\", start: { hour: 14n, minute: 0n }, hours: 8, color: none },\n { key: \"night\", label: \"Night\", code: \"N\", start: { hour: 22n, minute: 0n }, hours: 8, color: none },\n ],\n positions: [{ key: \"crew\", label: \"Crew\", code: \"\", lead: false }, { key: \"lead\", label: \"Lead\", code: \"SV\", lead: true }],\n agencies: [{ key: \"agency\", name: \"Staffing agency\" }],\n rules: { rest: 10, lead: true, skill: true, trainer: true },\n};\n\nexport const slot = { day: 0n, group: \"goods\", shift: \"early\" };\n\n/** Where the slot's duties stand: Goods' Sunday early. */\nexport const place = { day: 0n, group: some(\"goods\"), shift: \"early\" };\n\n/** Sunday's early shift: the lead in an hour late and on to 17:00, an agency's worker, and a request to the agency. */\nexport const week: ValueTypeOf<typeof DomainWeek> = {\n status: variant(\"draft\", null), dismissed: new Set<string>(),\n assignments: new Map([\n [\"a\", { place, who: variant(\"person\", \"lead\"), position: \"lead\", activity: some(\"reach\"),\n start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), hours: 10,\n row: { who: variant(\"staff\", \"lead\"), start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), note: \"in late, stays on\" } }],\n [\"b\", { place, who: variant(\"person\", \"agency\"), position: \"crew\", activity: some(\"general\"),\n start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), hours: 8,\n row: { who: variant(\"staff\", \"agency\"), start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), note: \"\" } }],\n [\"c\", { place, who: variant(\"request\", \"agency\"), position: \"crew\", activity: none,\n start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), hours: 8,\n row: { who: variant(\"agency\", \"agency\"), start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), note: \"\" } }],\n ]),\n requirements: new SortedMap([[slot, { positions: 4n, hours: new Map([[\"reach\", 24], [\"general\", 6]]) }]], compareFor(Roster.Types.Slot)),\n};\n\nEast.function([DomainWeek, Roster.Types.Context], StructType({ lead: FloatType, early: FloatType, night: IntegerType }), ($, week, context) => {\n const hours = $.const(Roster.weekHours(DomainDuty));\n const coverage = $.const(Roster.coverage(DomainDuty));\n const noPay = $.const(new Map(), Roster.Types.Pay);\n const slots = $.const(coverage(week, context, noPay));\n const night = $.const({ day: 0n, group: \"goods\", shift: \"night\" }, Roster.Types.Slot);\n return { lead: hours(week, context).get(\"lead\"), early: slots.get(slot).hours.rostered, night: slots.get(night).filled };\n })"
45047
+ },
45048
+ {
45049
+ "id": "e3-ui:domain.examples.ts:rosterSlotOfPlaces",
45050
+ "skill": "e3-ui",
45051
+ "package": "e3-ui",
45052
+ "file": "east-ui/packages/e3-ui/test/roster/domain.examples.ts",
45053
+ "suite": "",
45054
+ "test": "Roster.slotOf: a duty in Goods stands in Goods' slot of its shift on its day, and one in no group yet in none — what an app's check names an issue's slot by",
45055
+ "keywords": [
45056
+ "Roster",
45057
+ "Roster.slotOf",
45058
+ "place",
45059
+ "slot",
45060
+ "no group",
45061
+ "check",
45062
+ "issue"
45063
+ ],
45064
+ "imports": [
45065
+ "import {",
45066
+ "import { Roster } from \"@elaraai/e3-ui\";"
45067
+ ],
45068
+ "languages": [
45069
+ "typescript"
45070
+ ],
45071
+ "source": "// Roster.slotOf: a duty in Goods stands in Goods' slot of its shift on its day, and one in no group yet in none — what an app's check names an issue's slot by\n// inputs: [] returns: [some({ day: 0n, group: \"goods\", shift: \"early\" }), none]\nEast.function([], ArrayType(OptionType(Roster.Types.Slot)), ($) => {\n const slotOf = $.const(Roster.slotOf);\n const inGoods = $.const({ day: 0n, group: some(\"goods\"), shift: \"early\" }, Roster.Types.Place);\n const inNone = $.const({ day: 0n, group: none, shift: \"night\" }, Roster.Types.Place);\n return [slotOf(inGoods), slotOf(inNone)];\n })"
44225
45072
  },
44226
45073
  {
44227
45074
  "id": "e3-ui:domain.examples.ts:rosterAnswerLeads",
@@ -44246,7 +45093,7 @@
44246
45093
  "languages": [
44247
45094
  "typescript"
44248
45095
  ],
44249
- "source": "// Roster.answer maps a rule over every person, echoing the need and the slot: the lead fits, and the two associates are refused as not leads\n// inputs: [week, context] returns: {\n need: variant(\"leads\", null), slot: { day: 1n, group: \"goods\", shift: \"early\" },\n people: new Map<string, ValueTypeOf<typeof Roster.Types.Fit>>([\n [\"agency\", variant(\"refused\", { group: \"Not a lead\", reason: \"Crew · not a lead\", measure: variant(\"none\", null) })],\n [\"lead\", variant(\"fits\", { score: 198, why: \"Goods · 30 h spare\", warn: none })],\n [\"off\", variant(\"refused\", { group: \"Not a lead\", reason: \"Crew · not a lead\", measure: variant(\"none\", null) })],\n ]),\n }\n/** A duty of the app's own: who — one of its staff, or an agency asked to send someone — its own times, and a note the Roster carries but never reads. */\nexport const DomainDuty = StructType({\n who: VariantType({ staff: StringType, agency: StringType }), start: DateTimeType, end: DateTimeType, note: StringType,\n});\n\n/** A week of the app's duties, as the Roster reads it. */\nexport const DomainWeek = Roster.Types.Week(DomainDuty);\n\n/** Small staffing fixture with independently calculable hours and cost. */\nexport const context: ValueTypeOf<typeof Roster.Types.Context> = {\n people: new Map([\n [\"lead\", { key: \"lead\", name: \"Lead\", group: \"goods\", position: \"lead\", skills: new Set([\"reach\"]), contract: 40, agency: false, trainer: true, trainee: false, usual: some(\"early\") }],\n [\"agency\", { key: \"agency\", name: \"Agency\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 0, agency: true, trainer: false, trainee: false, usual: none }],\n [\"off\", { key: \"off\", name: \"Off\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 40, agency: false, trainer: false, trainee: false, usual: none }],\n ]),\n groups: [{ key: \"goods\", label: \"Goods\" }],\n // Goods' one skill, and the duty every group shares.\n activities: [{ key: \"reach\", label: \"Reach truck\", code: \"RT\", group: some(\"goods\") }, { key: \"general\", label: \"General duties\", code: \"GD\", group: none }],\n shifts: [\n { key: \"early\", label: \"Early\", code: \"E\", start: { hour: 6n, minute: 0n }, hours: 8, color: none },\n { key: \"late\", label: \"Late\", code: \"L\", start: { hour: 14n, minute: 0n }, hours: 8, color: none },\n { key: \"night\", label: \"Night\", code: \"N\", start: { hour: 22n, minute: 0n }, hours: 8, color: none },\n ],\n positions: [{ key: \"crew\", label: \"Crew\", code: \"\", lead: false }, { key: \"lead\", label: \"Lead\", code: \"SV\", lead: true }],\n agencies: [{ key: \"agency\", name: \"Staffing agency\" }],\n rules: { rest: 10, lead: true, skill: true, trainer: true },\n};\n\nexport const slot = { day: 0n, group: \"goods\", shift: \"early\" };\n\n/** Sunday's early shift: the lead in an hour late and on to 17:00, an agency's worker, and a request to the agency. */\nexport const week: ValueTypeOf<typeof DomainWeek> = {\n status: variant(\"draft\", null), dismissed: new Set<string>(),\n assignments: new Map([\n [\"a\", { slot, who: variant(\"person\", \"lead\"), position: \"lead\", activity: some(\"reach\"),\n start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), hours: 10,\n row: { who: variant(\"staff\", \"lead\"), start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), note: \"in late, stays on\" } }],\n [\"b\", { slot, who: variant(\"person\", \"agency\"), position: \"crew\", activity: some(\"general\"),\n start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), hours: 8,\n row: { who: variant(\"staff\", \"agency\"), start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), note: \"\" } }],\n [\"c\", { slot, who: variant(\"request\", \"agency\"), position: \"crew\", activity: none,\n start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), hours: 8,\n row: { who: variant(\"agency\", \"agency\"), start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), note: \"\" } }],\n ]),\n requirements: new SortedMap([[slot, { positions: 4n, hours: new Map([[\"reach\", 24], [\"general\", 6]]) }]], compareFor(Roster.Types.Slot)),\n};\n\nEast.function([DomainWeek, Roster.Types.Context], Roster.Types.FitResult, ($, week, context) => {\n const coverage = $.const(Roster.coverage(DomainDuty));\n const answer = $.const(Roster.answer(DomainDuty));\n const fit = $.const(Roster.fit(DomainDuty));\n const noPay = $.const(new Map(), Roster.Types.Pay);\n const request = $.const({ need: variant(\"leads\", null), slot: { day: 1n, group: \"goods\", shift: \"early\" }, start: new Date(\"2028-03-05T00:00:00Z\"),\n week, context, coverage: coverage(week, context, noPay) }, Roster.Types.FitRequest(DomainDuty));\n return answer(request, fit);\n })"
45096
+ "source": "// Roster.answer maps a rule over every person, echoing the need and the slot: the lead fits, and the two associates are refused as not leads\n// inputs: [week, context] returns: {\n need: variant(\"leads\", null), slot: { day: 1n, group: \"goods\", shift: \"early\" },\n people: new Map<string, ValueTypeOf<typeof Roster.Types.Fit>>([\n [\"agency\", variant(\"refused\", { group: \"Not a lead\", reason: \"Crew · not a lead\", measure: variant(\"none\", null) })],\n [\"lead\", variant(\"fits\", { score: 198, why: \"Goods · 30 h spare\", warn: none })],\n [\"off\", variant(\"refused\", { group: \"Not a lead\", reason: \"Crew · not a lead\", measure: variant(\"none\", null) })],\n ]),\n }\n/** A duty of the app's own: who — one of its staff, or an agency asked to send someone — its own times, and a note the Roster carries but never reads. */\nexport const DomainDuty = StructType({\n who: VariantType({ staff: StringType, agency: StringType }), start: DateTimeType, end: DateTimeType, note: StringType,\n});\n\n/** A week of the app's duties, as the Roster reads it. */\nexport const DomainWeek = Roster.Types.Week(DomainDuty);\n\n/** Small staffing fixture with independently calculable hours and cost. */\nexport const context: ValueTypeOf<typeof Roster.Types.Context> = {\n people: new Map([\n [\"lead\", { key: \"lead\", name: \"Lead\", group: \"goods\", position: \"lead\", skills: new Set([\"reach\"]), contract: 40, agency: false, trainer: true, trainee: false, usual: some(\"early\") }],\n [\"agency\", { key: \"agency\", name: \"Agency\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 0, agency: true, trainer: false, trainee: false, usual: none }],\n [\"off\", { key: \"off\", name: \"Off\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 40, agency: false, trainer: false, trainee: false, usual: none }],\n ]),\n groups: [{ key: \"goods\", label: \"Goods\" }],\n // Goods' one skill, and the duty every group shares.\n activities: [{ key: \"reach\", label: \"Reach truck\", code: \"RT\", group: some(\"goods\") }, { key: \"general\", label: \"General duties\", code: \"GD\", group: none }],\n shifts: [\n { key: \"early\", label: \"Early\", code: \"E\", start: { hour: 6n, minute: 0n }, hours: 8, color: none },\n { key: \"late\", label: \"Late\", code: \"L\", start: { hour: 14n, minute: 0n }, hours: 8, color: none },\n { key: \"night\", label: \"Night\", code: \"N\", start: { hour: 22n, minute: 0n }, hours: 8, color: none },\n ],\n positions: [{ key: \"crew\", label: \"Crew\", code: \"\", lead: false }, { key: \"lead\", label: \"Lead\", code: \"SV\", lead: true }],\n agencies: [{ key: \"agency\", name: \"Staffing agency\" }],\n rules: { rest: 10, lead: true, skill: true, trainer: true },\n};\n\nexport const slot = { day: 0n, group: \"goods\", shift: \"early\" };\n\n/** Where the slot's duties stand: Goods' Sunday early. */\nexport const place = { day: 0n, group: some(\"goods\"), shift: \"early\" };\n\n/** Sunday's early shift: the lead in an hour late and on to 17:00, an agency's worker, and a request to the agency. */\nexport const week: ValueTypeOf<typeof DomainWeek> = {\n status: variant(\"draft\", null), dismissed: new Set<string>(),\n assignments: new Map([\n [\"a\", { place, who: variant(\"person\", \"lead\"), position: \"lead\", activity: some(\"reach\"),\n start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), hours: 10,\n row: { who: variant(\"staff\", \"lead\"), start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), note: \"in late, stays on\" } }],\n [\"b\", { place, who: variant(\"person\", \"agency\"), position: \"crew\", activity: some(\"general\"),\n start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), hours: 8,\n row: { who: variant(\"staff\", \"agency\"), start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), note: \"\" } }],\n [\"c\", { place, who: variant(\"request\", \"agency\"), position: \"crew\", activity: none,\n start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), hours: 8,\n row: { who: variant(\"agency\", \"agency\"), start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), note: \"\" } }],\n ]),\n requirements: new SortedMap([[slot, { positions: 4n, hours: new Map([[\"reach\", 24], [\"general\", 6]]) }]], compareFor(Roster.Types.Slot)),\n};\n\nEast.function([DomainWeek, Roster.Types.Context], Roster.Types.FitResult, ($, week, context) => {\n const coverage = $.const(Roster.coverage(DomainDuty));\n const answer = $.const(Roster.answer(DomainDuty));\n const fit = $.const(Roster.fit(DomainDuty));\n const noPay = $.const(new Map(), Roster.Types.Pay);\n const request = $.const({ need: variant(\"leads\", null), slot: { day: 1n, group: \"goods\", shift: \"early\" }, start: new Date(\"2028-03-05T00:00:00Z\"),\n week, context, coverage: coverage(week, context, noPay) }, Roster.Types.FitRequest(DomainDuty));\n return answer(request, fit);\n })"
44250
45097
  },
44251
45098
  {
44252
45099
  "id": "e3-ui:optimise.examples.tsx:rosterOptimise",
@@ -44276,18 +45123,59 @@
44276
45123
  "fit"
44277
45124
  ],
44278
45125
  "imports": [
44279
- "import { ArrayType, DateTimeType, DictType, East, FloatType, IntegerType, SetType, StringType, StructType, example, none, variant, type BlockBuilder, type ExprType } from \"@elaraai/east\";",
45126
+ "import {",
44280
45127
  "import e3 from \"@elaraai/e3\";",
44281
45128
  "import { Box, Reactive, Slice, UIComponentType } from \"@elaraai/east-ui\";",
44282
45129
  "import { Data, Func, Record, Roster, Schedule } from \"@elaraai/e3-ui\";",
44283
45130
  "import { WarehouseDuty } from \"./warehouse.js\";",
44284
- "import { rosterActivities, rosterAgencies, rosterCover, rosterDuties, rosterPatterns, rosterPositions, rosterShiftTimes, rosterStaff, rosterStaffFit, rosterSuggestions, rosterTeams, rosterWeeks } from \"./roster.examples.js\";"
45131
+ "import {"
44285
45132
  ],
44286
45133
  "languages": [
44287
45134
  "tsx"
44288
45135
  ],
44289
45136
  "source": "// The warehouse roster with the Elara eye (#1409): `optimise` is Func.bind of the warehouse's optimiser on e3 — Roster.Types.OptimiseRequest(WarehouseDuty) in, the week in view, the run number, the week's duties as drafted, its targets by slot and the Roster's context; Roster.Types.OptimiseResult(WarehouseDuty) out, the duties complete: every slot short of its heads filled from the people of its group, then everyone to their contract from their usual shift — on any week, an empty one too — within their contract and ten hours clear of their other duties. A click on the eye runs it once over the week; the result lands in the session as one edit, which one Undo reverts and Save commits with everything else.\n// inputs: []\n/** One person on one day of the week: who is booked when, so a run never books the same person twice on a day. */\nconst Booked = StructType({ day: IntegerType, person: StringType });\n\n/** A person's duty's times: what a new duty of theirs keeps ten hours clear of — the warehouse's rest rule. */\nconst Span = StructType({ person: StringType, start: DateTimeType, end: DateTimeType });\n\nconst Request = Roster.Types.OptimiseRequest(WarehouseDuty), Result = Roster.Types.OptimiseResult(WarehouseDuty);\n\ntype Block = BlockBuilder<typeof Result>;\n\ntype PersonExpr = ExprType<typeof Roster.Types.Person>;\n\ntype ShiftExpr = ExprType<typeof Roster.Types.Shift>;\n\n/**\n * The warehouse's optimiser's body, in two passes over the week as drafted, every duty it held kept as it was. First the\n * targets: every slot short of its heads is filled from the people of its group who can take it, those with the fewest\n * hours this week first. Then everyone to their contract, whatever the week's targets — so an empty week fills, this one\n * or any other: on each of their days off, their usual shift in their own group. A person takes a shift only off that\n * day, within their contract's hours and ten hours clear of every other duty of theirs (the warehouse's rest rule); the\n * agency's workers are left out. A new duty runs the shift's hours on its day, booked to the team's cost centre, under a\n * key of the run's own.\n */\nexport const rosterOptimiseBody = East.function([Request], Result, ($, req) => {\n const planned = $.let(new Map(), DictType(StringType, WarehouseDuty));\n // Who is booked on each day, each person's hours this week and each team's cost centre, from the week as drafted.\n const booked = $.let(new Set<{ day: bigint; person: string }>(), SetType(Booked));\n const spans = $.let(new Set<{ person: string; start: Date; end: Date }>(), SetType(Span));\n const hours = $.let(new Map(), DictType(StringType, FloatType));\n const centres = $.let(new Map(), DictType(StringType, StringType));\n $.for(req.duties, ($2, duty, key) => {\n $2(planned.insert(key, duty));\n $2(centres.insertOrUpdate(duty.team, duty.costCentre, (_$3, held, _given) => held));\n $2.match(duty.who, { staff: ($3, person) => {\n const day = $3.const(req.from.durationMilliseconds(duty.start).divide(86_400_000n));\n // A person drafted twice on a day is booked once.\n $3.if(booked.has({ day, person }).not(), ($4) => { $4(booked.insert({ day, person })); });\n $3(spans.insert({ person, start: duty.start, end: duty.end }));\n $3(hours.insertOrUpdate(person, duty.start.durationHours(duty.end), (_$4, held, more) => held.add(more)));\n } });\n });\n const shifts = $.const(req.context.shifts.toDict(($2, shift) => shift.key, ($2, shift) => shift));\n const people = $.const(req.context.people.toArray(($2, person) => person));\n const days = $.let([0n, 1n, 2n, 3n, 4n, 5n, 6n], ArrayType(IntegerType));\n const added = $.let(0n, IntegerType);\n /** A shift's start on a day of the week, and its end for its hours — fractional hours as whole minutes. */\n const timesOf = (day: ExprType<IntegerType>, shift: ShiftExpr) => {\n const start = req.from.addDays(day).addHours(shift.start.hour).addMinutes(shift.start.minute);\n return { start, end: start.addMinutes(East.Float.roundHalf(shift.hours.multiply(60.0))) };\n };\n /** Whether a person can take a shift on a day: off that day, within their contract, and ten hours clear of every other duty of theirs. */\n const takes = (person: PersonExpr, day: ExprType<IntegerType>, shift: ShiftExpr, start: ExprType<DateTimeType>, end: ExprType<DateTimeType>) =>\n booked.has({ day, person: person.key }).not()\n .and(() => hours.get(person.key, () => 0.0).add(shift.hours).lessEqual(person.contract))\n .and(() => spans.filter(($2, span) => span.person.equal(person.key).and(() => span.end.durationHours(start).less(10.0)).and(() => end.durationHours(span.start).less(10.0))).size().equal(0n));\n /** A new duty: the person on the shift that day in the group, at the shift's times, booked to the group's cost centre, under a key of the run's own. */\n const place = ($2: Block, person: PersonExpr, day: ExprType<IntegerType>, shift: ShiftExpr, group: ExprType<StringType>, start: ExprType<DateTimeType>, end: ExprType<DateTimeType>) => {\n $2.assign(added, added.add(1n));\n $2(planned.insert(East.str`elara-${req.run}-${added}`, {\n who: variant(\"staff\", person.key), start, end, shift: shift.key, team: group, role: person.position, task: none,\n unpaidBreak: 0.0, agreed: none, costCentre: centres.get(group, () => \"\"), note: \"\",\n }));\n $2(booked.insert({ day, person: person.key }));\n $2(spans.insert({ person: person.key, start, end }));\n $2(hours.insertOrUpdate(person.key, shift.hours, (_$3, held, more) => held.add(more)));\n };\n // First the targets: every slot short of its heads, from the group's own people who can take it, the fewest hours first.\n $.for(req.requirements, ($2, need, slot) => {\n // The slot's heads, less the duties already on it.\n const filled = $2.const(planned.filter(($3, duty) => duty.team.equal(slot.group).and(() => duty.shift.equal(slot.shift))\n .and(() => req.from.durationMilliseconds(duty.start).divide(86_400_000n).equal(slot.day))).size());\n const open = $2.const(need.positions.subtract(filled));\n $2.if(open.greater(0n).and(() => shifts.has(slot.shift)), ($3) => {\n const shift = $3.const(shifts.get(slot.shift));\n const times = timesOf(slot.day, shift);\n const start = $3.const(times.start), end = $3.const(times.end);\n const free = $3.const(people\n .filter(($4, person) => person.group.equal(slot.group).and(() => person.agency.not()).and(() => takes(person, slot.day, shift, start, end)))\n .sort(($4, person) => hours.get(person.key, () => 0.0)));\n $3.for(free, ($4, person, i) => {\n $4.if(i.less(open), ($5) => { place($5, person, slot.day, shift, slot.group, start, end); });\n });\n });\n });\n // Then everyone to their contract, whatever the week's targets: on each of their days off, their usual shift in their own\n // group, while another fits within their contract and keeps ten hours clear of their other duties.\n $.for(people, ($2, person) => {\n $2.match(person.usual, { some: ($3, usual) => {\n $3.if(person.agency.not().and(() => shifts.has(usual)), ($4) => {\n const shift = $4.const(shifts.get(usual));\n $4.for(days, ($5, day) => {\n const times = timesOf(day, shift);\n const start = $5.const(times.start), end = $5.const(times.end);\n $5.if(takes(person, day, shift, start, end), ($6) => { place($6, person, day, shift, person.group, start, end); });\n });\n });\n } });\n });\n return { duties: planned };\n});\n\n/** The warehouse's optimiser, on e3: the week's duties in, the week's duties out — its targets met, then everyone to their contract, whatever the week. */\nexport const rotaOptimise = e3.function(\"rota_optimise\", rosterOptimiseBody);\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const rota = $.let(Record.bind(rosterDuties));\n const entries = $.let(Data.bindPaged(rosterDuties));\n const byTime = $.let(Data.bindPaged(rosterDuties, { indexes: [\"roster_duties_by_time\"] }));\n const weeks = $.let(Record.bind(rosterWeeks));\n const cover = $.let(Record.bind(rosterCover));\n // Every person and activity is the calculation scope — and the optimiser's: the narrowing only chooses which show (#1342).\n const people = $.let(Data.bind(rosterStaff));\n const acts = $.let(Data.bind(rosterActivities));\n const staffIndex = $.let(Data.bindPaged(rosterStaff, { indexes: [\"roster_staff_by_team_name\", \"roster_staff_by_position\", \"roster_staff_by_trainer\", \"roster_staff_by_agency\", \"roster_staff_by_skill\", \"roster_staff_by_name\"] }));\n const actIndex = $.let(Data.bindPaged(rosterActivities, { indexes: [\"roster_activities_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.rosterOptimise\", {\n duty: { source: byTime, range: \"start\" },\n people: { source: staffIndex, icon: { prefix: \"fas\", name: \"user\" }, search: [\"name\", \"skills\"],\n fields: { team: { label: \"Group\", hints: [\"inbound\", \"picking\", \"dispatch\"] }, position: { label: \"Position\", hints: [\"lead\", \"deputy\", \"acting\", \"crew\"] },\n trainer: { label: \"Trainer\" }, agency: { label: \"Agency\" }, skills: { label: \"Skill\" }, name: { label: \"Name\" } } },\n activities: { source: actIndex, icon: { prefix: \"fas\", name: \"list-check\" }, fields: { group: { label: \"Group\", hints: [\"inbound\", \"picking\", \"dispatch\", null] } } },\n }, { presets: [{ id: \"leads\", name: \"Leads\", where: { people: { position: [\"lead\", \"deputy\", \"acting\"] } } }] }));\n const firms = $.let(Data.bind(rosterAgencies));\n const times = $.let(Data.bind(rosterShiftTimes));\n const teams = $.let(Data.bind(rosterTeams));\n const roles = $.let(Data.bind(rosterPositions));\n const ideas = $.let(Data.bind(rosterSuggestions));\n const weekPatterns = $.let(Data.bind(rosterPatterns));\n const fit = $.let(Func.bind(rosterStaffFit));\n // The app's optimiser: the eye calls it once per run over the week in view, and its answer is one edit.\n const optimise = $.let(Func.bind(rotaOptimise));\n return <Box width=\"100%\" height=\"760px\"><Roster id=\"rosterOptimise\" week={{ start: \"sunday\" }} slice={{ slice }} inspector fit={fit} optimise={optimise}\n view={{ layout: \"people\", period: \"week\", date: new Date(\"2028-03-09T00:00:00Z\") }}\n tileTimes=\"different\"\n events={{ duty: Schedule.events(rota, {\n name: \"Duty\", icon: \"user-clock\", entries,\n start: \"start\", end: \"end\", resource: { field: \"who\", of: { staff: \"people\", agency: \"agencies\" } },\n shift: \"shift\", group: \"team\", position: \"role\", activity: \"task\",\n hours: d => d.start.durationMinutes(d.end).subtract(d.unpaidBreak).divide(60.0),\n }) }}\n resources={{\n people: Schedule.resources(people.read(), { name: \"People\", icon: \"user\", label: p => p.name, group: p => p.team,\n position: p => p.position, skills: p => p.skills, contract: p => p.contract, agency: p => p.agency,\n trainer: p => p.trainer, trainee: p => p.trainee, usual: p => p.usual }),\n agencies: Schedule.resources(firms.read(), { name: \"Agencies\", icon: \"building\", label: a => a.name }),\n }}\n periods={Schedule.periods(weeks, { every: \"week\", status: { field: \"state\", draft: \"open\", published: \"issued\" }, dismissed: \"dismissed\" })}\n targets={Roster.targets(cover, { day: \"day\", group: \"team\", shift: \"shift\", positions: \"heads\", hours: \"hours\" })}\n shifts={Roster.shifts(times.read(), { label: s => s.label, code: s => s.code, start: s => s.start, hours: s => s.hours, order: s => s.order, color: s => s.colour })}\n groups={Roster.groups(teams.read(), { label: t => t.label, order: t => t.order })}\n positions={Roster.positions(roles.read(), { label: p => p.label, code: p => p.code, lead: p => p.lead, order: p => p.order })}\n activities={Roster.activities(acts.read(), { label: a => a.label, code: a => a.code, group: a => a.group, order: a => a.order })}\n proposals={Roster.proposals(ideas.read(), { person: s => s.person, day: s => s.day, group: s => s.team, shift: s => s.shift, reason: s => s.why })}\n patterns={Roster.patterns(weekPatterns.read(), { name: \"Patterns\", icon: \"calendar-week\", label: w => w.label, days: w => w.days, order: w => w.order })}\n rules={{ rest: 10.0 }}\n library={[Roster.library.people(), Roster.library.patterns(), Roster.library.activities()]} />\n </Box>;\n }}</Reactive>)"
44290
45137
  },
45138
+ {
45139
+ "id": "e3-ui:optimise.examples.tsx:rosterOptimiseEdges",
45140
+ "skill": "e3-ui",
45141
+ "package": "e3-ui",
45142
+ "file": "east-ui/packages/e3-ui/test/roster/optimise.examples.tsx",
45143
+ "suite": "",
45144
+ "test": "A warehouse whose week runs by when its shifts end (#1553), as its payroll's does: its Roster's week starts on Monday, so the night from Sunday 22:00 is drawn on the Sunday of the week before, though it is the business week's first shift, and the week's own last night ends in the next week. `optimise` is Func.bind of an e3.function from Roster.Types.OptimiseRequest(NightsShift, { edges: true }) to Roster.Types.OptimiseResult(NightsShift, { edges: true }): the run sees the week's duties and, in `edges`, every duty the window holds that the Roster places in another week, as the session holds them, unsaved drafts in place — `fixed` naming those of a published week. Its answer's `edges` are the edge duties as it leaves them: here the night before the week is kept, its times changed to the shift's own, and taken away from a person off nights; the week's last night is left to the next week, and Mia's Monday early is added — one edit, which one Undo reverts and Save writes through the patch door. Publish the week before first and its duties are fixed: the run leaves them as they are.",
45145
+ "keywords": [
45146
+ "Roster",
45147
+ "optimise",
45148
+ "Optimise",
45149
+ "Elara",
45150
+ "OptimiseRequest",
45151
+ "OptimiseResult",
45152
+ "edges",
45153
+ "fixed",
45154
+ "night shift",
45155
+ "overnight",
45156
+ "week start",
45157
+ "monday",
45158
+ "payroll week",
45159
+ "Func.bind",
45160
+ "e3.function",
45161
+ "Schedule.periods",
45162
+ "published",
45163
+ "one edit",
45164
+ "Undo"
45165
+ ],
45166
+ "imports": [
45167
+ "import {",
45168
+ "import e3 from \"@elaraai/e3\";",
45169
+ "import { Box, Reactive, Slice, UIComponentType } from \"@elaraai/east-ui\";",
45170
+ "import { Data, Func, Record, Roster, Schedule } from \"@elaraai/e3-ui\";",
45171
+ "import { WarehouseDuty } from \"./warehouse.js\";",
45172
+ "import {"
45173
+ ],
45174
+ "languages": [
45175
+ "tsx"
45176
+ ],
45177
+ "source": "// A warehouse whose week runs by when its shifts end (#1553), as its payroll's does: its Roster's week starts on Monday, so the night from Sunday 22:00 is drawn on the Sunday of the week before, though it is the business week's first shift, and the week's own last night ends in the next week. `optimise` is Func.bind of an e3.function from Roster.Types.OptimiseRequest(NightsShift, { edges: true }) to Roster.Types.OptimiseResult(NightsShift, { edges: true }): the run sees the week's duties and, in `edges`, every duty the window holds that the Roster places in another week, as the session holds them, unsaved drafts in place — `fixed` naming those of a published week. Its answer's `edges` are the edge duties as it leaves them: here the night before the week is kept, its times changed to the shift's own, and taken away from a person off nights; the week's last night is left to the next week, and Mia's Monday early is added — one edit, which one Undo reverts and Save writes through the patch door. Publish the week before first and its duties are fixed: the run leaves them as they are.\n// inputs: []\n/** A shift of the night warehouse: who works it, which shift, in which team, and when. */\nexport const NightsShift = StructType({ who: StringType, shift: StringType, team: StringType, start: DateTimeType, end: DateTimeType });\n\n/** One of its staff: a name, a team, and the shift they work the week being planned. */\nexport const NightsWorker = StructType({ name: StringType, team: StringType, usual: OptionType(StringType) });\n\n/** A week of its rota, its first day a Monday: open, or issued and when. */\nexport const NightsWeek = StructType({ state: VariantType({ open: NullType, issued: StructType({ at: DateTimeType }) }) });\n\n/**\n * The shifts, by key: the week planned (Monday 6 March 2028) and its edges. Ada works earlies and Tom nights, his night\n * before the week rostered from 21:00 and his last one ending in the next week; Mia, off nights this week, keeps the night\n * before it from her old plan, and her Monday is not rostered yet.\n */\nexport const nightsShiftRows: Map<string, ValueTypeOf<typeof NightsShift>> = new Map([\n [\"ada-mon\", { who: \"w-01\", shift: \"early\", team: \"inbound\", start: new Date(\"2028-03-06T06:00:00Z\"), end: new Date(\"2028-03-06T14:00:00Z\") }],\n [\"ada-tue\", { who: \"w-01\", shift: \"early\", team: \"inbound\", start: new Date(\"2028-03-07T06:00:00Z\"), end: new Date(\"2028-03-07T14:00:00Z\") }],\n [\"ada-wed\", { who: \"w-01\", shift: \"early\", team: \"inbound\", start: new Date(\"2028-03-08T06:00:00Z\"), end: new Date(\"2028-03-08T14:00:00Z\") }],\n [\"ada-thu\", { who: \"w-01\", shift: \"early\", team: \"inbound\", start: new Date(\"2028-03-09T06:00:00Z\"), end: new Date(\"2028-03-09T14:00:00Z\") }],\n [\"ada-fri\", { who: \"w-01\", shift: \"early\", team: \"inbound\", start: new Date(\"2028-03-10T06:00:00Z\"), end: new Date(\"2028-03-10T14:00:00Z\") }],\n [\"ada-next-mon\", { who: \"w-01\", shift: \"early\", team: \"inbound\", start: new Date(\"2028-03-13T06:00:00Z\"), end: new Date(\"2028-03-13T14:00:00Z\") }],\n [\"tom-sun-before\", { who: \"w-02\", shift: \"night\", team: \"dispatch\", start: new Date(\"2028-03-05T21:00:00Z\"), end: new Date(\"2028-03-06T05:00:00Z\") }],\n [\"tom-mon\", { who: \"w-02\", shift: \"night\", team: \"dispatch\", start: new Date(\"2028-03-06T22:00:00Z\"), end: new Date(\"2028-03-07T06:00:00Z\") }],\n [\"tom-tue\", { who: \"w-02\", shift: \"night\", team: \"dispatch\", start: new Date(\"2028-03-07T22:00:00Z\"), end: new Date(\"2028-03-08T06:00:00Z\") }],\n [\"tom-wed\", { who: \"w-02\", shift: \"night\", team: \"dispatch\", start: new Date(\"2028-03-08T22:00:00Z\"), end: new Date(\"2028-03-09T06:00:00Z\") }],\n [\"tom-thu\", { who: \"w-02\", shift: \"night\", team: \"dispatch\", start: new Date(\"2028-03-09T22:00:00Z\"), end: new Date(\"2028-03-10T06:00:00Z\") }],\n [\"tom-sun\", { who: \"w-02\", shift: \"night\", team: \"dispatch\", start: new Date(\"2028-03-12T22:00:00Z\"), end: new Date(\"2028-03-13T06:00:00Z\") }],\n [\"mia-sun-before\", { who: \"w-03\", shift: \"night\", team: \"inbound\", start: new Date(\"2028-03-05T22:00:00Z\"), end: new Date(\"2028-03-06T06:00:00Z\") }],\n [\"mia-tue\", { who: \"w-03\", shift: \"early\", team: \"inbound\", start: new Date(\"2028-03-07T06:00:00Z\"), end: new Date(\"2028-03-07T14:00:00Z\") }],\n [\"mia-wed\", { who: \"w-03\", shift: \"early\", team: \"inbound\", start: new Date(\"2028-03-08T06:00:00Z\"), end: new Date(\"2028-03-08T14:00:00Z\") }],\n [\"mia-thu\", { who: \"w-03\", shift: \"early\", team: \"inbound\", start: new Date(\"2028-03-09T06:00:00Z\"), end: new Date(\"2028-03-09T14:00:00Z\") }],\n [\"mia-fri\", { who: \"w-03\", shift: \"early\", team: \"inbound\", start: new Date(\"2028-03-10T06:00:00Z\"), end: new Date(\"2028-03-10T14:00:00Z\") }],\n]);\n\n/** The shifts, which the Roster writes through the patch door. */\nexport const nightsShifts = e3.record(\"rota_nights_shifts\", DictType(StringType, NightsShift), {\n initial: nightsShiftRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The staff as rows, by key: each with the shift they work the week being planned. */\nexport const nightsWorkerRows: Map<string, ValueTypeOf<typeof NightsWorker>> = new Map([\n [\"w-01\", { name: \"Ada Brook\", team: \"inbound\", usual: some(\"early\") }],\n [\"w-02\", { name: \"Tom Vale\", team: \"dispatch\", usual: some(\"night\") }],\n [\"w-03\", { name: \"Mia Hart\", team: \"inbound\", usual: some(\"early\") }],\n]);\n\nexport const nightsWorkers = e3.record(\"rota_nights_staff\", DictType(StringType, NightsWorker), { initial: nightsWorkerRows });\n\n/** Its shift times as rows, by key: an early from 6:00, a late from 14:00 and a night from 22:00, eight hours each. */\nexport const nightsShiftTimeRows: Map<string, ValueTypeOf<typeof MinimalShiftTime>> = new Map([\n [\"early\", { name: \"Early\", code: \"E\", starts: { hour: 6n, minute: 0n }, hours: 8.0, order: 1n }],\n [\"late\", { name: \"Late\", code: \"L\", starts: { hour: 14n, minute: 0n }, hours: 8.0, order: 2n }],\n [\"night\", { name: \"Night\", code: \"N\", starts: { hour: 22n, minute: 0n }, hours: 8.0, order: 3n }],\n]);\n\nexport const nightsShiftTimes = e3.record(\"rota_nights_shift_times\", DictType(StringType, MinimalShiftTime), { initial: nightsShiftTimeRows });\n\n/** The weeks of its rota as rows, each keyed by its Monday: the week before and the week planned, both open. */\nexport const nightsWeekRows: SortedMap<Date, ValueTypeOf<typeof NightsWeek>> = new SortedMap<Date, ValueTypeOf<typeof NightsWeek>>([\n [new Date(\"2028-02-28T00:00:00Z\"), { state: variant(\"open\", null) }],\n [new Date(\"2028-03-06T00:00:00Z\"), { state: variant(\"open\", null) }],\n], compareFor(DateTimeType));\n\n/** The weeks of its rota, which Publish writes through the patch door. */\nexport const nightsWeeks = e3.record(\"rota_nights_weeks\", DictType(DateTimeType, NightsWeek), {\n initial: nightsWeekRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nconst NightsRequest = Roster.Types.OptimiseRequest(NightsShift, { edges: true }), NightsResult = Roster.Types.OptimiseResult(NightsShift, { edges: true });\n\n/** A person's day of the business week, Monday 0: one the plan already holds. */\nconst NightsHeld = StructType({ person: StringType, day: IntegerType });\n\n/**\n * The night warehouse's optimiser (#1553): the business week — every shift ending from the week's Monday to the next —\n * planned by when each shift ends, each person on their usual shift Monday to Friday, in their own team. It sees the\n * week's duties and the duties at its edges together. A duty of a published week, among `fixed`, stands as it is and\n * holds its person's day. Every other duty ending in the business week — the night before the week among them — is\n * kept at its shift's own times, where it is its person's usual shift on a weekday not held yet, and taken away\n * otherwise; one ending outside it stands as it is: the week's last night is the next week's plan's. Each weekday left is\n * planned under a key of the run's own, a night before the week too: a new duty starting outside the week goes back among\n * the edges.\n */\nexport const rosterPlanNightsBody = East.function([NightsRequest], NightsResult, ($, req) => {\n const shifts = $.const(req.context.shifts.toDict(($2, shift) => shift.key, ($2, shift) => shift));\n // A person's usual shift on a day of the business week: a shift past midnight — the night — starts the day before the\n // day it ends on.\n const planned = $.const(East.function([Roster.Types.Person, Roster.Types.Shift, IntegerType], NightsShift, ($2, person, shift, day) => {\n const from = $2.const(shift.start.hour.multiply(60n).add(shift.start.minute));\n const length = $2.const(East.Float.roundHalf(shift.hours.multiply(60.0)));\n const before = $2.const(from.add(length).subtract(1n).divide(1440n));\n const start = $2.const(req.from.addDays(day.subtract(before)).addMinutes(from));\n return { who: person.key, shift: shift.key, team: person.group, start, end: start.addMinutes(length) };\n }));\n // The day of the business week a shift ending then belongs to, Monday 0; -1 for an end outside it.\n const dayOf = $.const(East.function([DateTimeType], IntegerType, ($2, end) => {\n const since = $2.const(req.from.durationMilliseconds(end));\n return East.greater(since, 0n).and(() => East.lessEqual(since, 604_800_000n)).ifElse(() => since.subtract(1n).divide(86_400_000n), () => -1n);\n }));\n // The week's duties and its edges together, by key: the request holds them apart.\n const seen = $.let(req.duties.map(($2, duty) => duty));\n $.for(req.edges, ($2, duty, key) => { $2(seen.insert(key, duty)); });\n const kept = $.let(new Map(), DictType(StringType, NightsShift));\n const held = $.let(new Set<{ person: string; day: bigint }>(), SetType(NightsHeld));\n // A published week's duties stand as they are, and hold their person's day.\n $.for(seen, ($2, duty, key) => {\n $2.if(req.fixed.has(key), ($3) => {\n $3(kept.insert(key, duty));\n const day = $3.const(dayOf(duty.end));\n $3.if(East.greaterEqual(day, 0n).and(() => held.has({ person: duty.who, day }).not()), ($4) => { $4(held.insert({ person: duty.who, day })); });\n });\n });\n // Every other duty: one ending outside the business week stands as it is; one ending on a weekday is kept where it is\n // its person's usual shift on a day not held yet, at the shift's own times; any other is taken away.\n $.for(seen, ($2, duty, key) => {\n $2.if(req.fixed.has(key).not(), ($3) => {\n const day = $3.const(dayOf(duty.end));\n $3.if(East.less(day, 0n), ($4) => { $4(kept.insert(key, duty)); }).else(($4) => {\n $4.if(East.less(day, 5n).and(() => req.context.people.has(duty.who)), ($5) => {\n const person = $5.const(req.context.people.get(duty.who));\n $5.match(person.usual, { some: ($6, usual) => {\n $6.if(usual.equal(duty.shift).and(() => shifts.has(usual)).and(() => held.has({ person: duty.who, day }).not()), ($7) => {\n $7(kept.insert(key, planned(person, shifts.get(usual), day)));\n $7(held.insert({ person: duty.who, day }));\n });\n } });\n });\n });\n });\n });\n // Each weekday left, planned on its person's usual shift under a key of the run's own.\n const weekdays = $.const([0n, 1n, 2n, 3n, 4n], ArrayType(IntegerType));\n const added = $.let(0n, IntegerType);\n $.for(req.context.people, ($2, person) => {\n $2.match(person.usual, { some: ($3, usual) => {\n $3.if(shifts.has(usual), ($4) => {\n const shift = $4.const(shifts.get(usual));\n $4.for(weekdays, ($5, day) => {\n $5.if(held.has({ person: person.key, day }).not(), ($6) => {\n $6.assign(added, added.add(1n));\n $6(kept.insert(East.str`elara-${req.run}-${added}`, planned(person, shift, day)));\n });\n });\n });\n } });\n });\n // Apart again: a duty the request held among the edges goes back among them, and a new one starting outside the week.\n const week = $.const(req.from.durationMilliseconds(req.to));\n const inWeek = $.const(East.function([DateTimeType], BooleanType, ($2, at) => {\n const since = $2.const(req.from.durationMilliseconds(at));\n return East.greaterEqual(since, 0n).and(() => East.less(since, week));\n }));\n return {\n duties: kept.filter(($2, duty, key) => req.duties.has(key).or(() => req.edges.has(key).not().and(() => inWeek(duty.start)))),\n edges: kept.filter(($2, duty, key) => req.edges.has(key).or(() => req.duties.has(key).not().and(() => inWeek(duty.start).not()))),\n };\n});\n\n/** The night warehouse's optimiser, on e3: the week's duties and the duties at its edges in, both out, planned by when each shift ends. */\nexport const rotaPlanNights = e3.function(\"rota_plan_nights\", rosterPlanNightsBody);\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const rota = $.let(Record.bind(nightsShifts));\n const weeks = $.let(Record.bind(nightsWeeks));\n const staff = $.let(Data.bind(nightsWorkers));\n const times = $.let(Data.bind(nightsShiftTimes));\n const teams = $.let(Data.bind(minimalTeams));\n // The plan by when shifts end: its function takes the edges, so the eye's run sees and plans the night before the week.\n const optimise = $.let(Func.bind(rotaPlanNights));\n return <Box width=\"100%\" height=\"760px\"><Roster id=\"rosterOptimiseEdges\" week={{ start: \"monday\" }} inspector optimise={optimise}\n view={{ layout: \"people\", period: \"week\", date: new Date(\"2028-03-06T00:00:00Z\") }}\n events={{ duty: Schedule.events(rota, {\n name: \"Shift\", icon: \"user-clock\",\n start: \"start\", end: \"end\", resource: { field: \"who\", of: \"people\" },\n shift: \"shift\", group: \"team\",\n }) }}\n resources={{ people: Schedule.resources(staff.read(), { name: \"People\", icon: \"user\", label: w => w.name, group: w => w.team, usual: w => w.usual }) }}\n periods={Schedule.periods(weeks, { every: \"week\", status: { field: \"state\", draft: \"open\", published: \"issued\" } })}\n shifts={Roster.shifts(times.read(), { label: s => s.name, code: s => s.code, start: s => s.starts, hours: s => s.hours, order: s => s.order })}\n groups={Roster.groups(teams.read(), { label: t => t.name })} />\n </Box>;\n }}</Reactive>)"
45178
+ },
44291
45179
  {
44292
45180
  "id": "e3-ui:roster-records.examples.tsx:rosterRecordIndexes",
44293
45181
  "skill": "e3-ui",
@@ -44363,7 +45251,7 @@
44363
45251
  "package": "e3-ui",
44364
45252
  "file": "east-ui/packages/e3-ui/test/roster/roster.examples.tsx",
44365
45253
  "suite": "",
44366
- "test": "The mock warehouse roster over its own records: its duties, the weeks of its rota, its cover targets and suggestions, 69 staff and an agency, its shift times, teams, positions and activities. One Slice.bindRecords rail over the week's duties, the staff and the activities; the warehouse's pay in its own codes and its check over the pay; Publish; a Positions tab; the inspector; and the warehouse's greedy fit on e3, which a Find fix asks who fits.",
45254
+ "test": "The mock warehouse roster over its own records: its duties, the weeks of its rota, its cover targets and suggestions, 69 staff and an agency, its shift times, teams, positions and activities. One Slice.bindRecords rail over the week's duties, the staff and the activities; the warehouse's pay in its own codes and its check over the pay; a new duty's own fields, a new target's basis and a new week's approver from the app's `values`; Publish; a Positions tab; the inspector; and the warehouse's greedy fit on e3, which a Find fix asks who fits.",
44367
45255
  "keywords": [
44368
45256
  "Roster",
44369
45257
  "Schedule.events",
@@ -44377,6 +45265,10 @@
44377
45265
  "Roster.proposals",
44378
45266
  "pay",
44379
45267
  "check",
45268
+ "values",
45269
+ "new row",
45270
+ "Roster.Types.NewDuty",
45271
+ "Roster.Types.NewTarget",
44380
45272
  "Slice",
44381
45273
  "Slice.bindRecords",
44382
45274
  "Data.bindPaged",
@@ -44399,7 +45291,7 @@
44399
45291
  "languages": [
44400
45292
  "tsx"
44401
45293
  ],
44402
- "source": "// The mock warehouse roster over its own records: its duties, the weeks of its rota, its cover targets and suggestions, 69 staff and an agency, its shift times, teams, positions and activities. One Slice.bindRecords rail over the week's duties, the staff and the activities; the warehouse's pay in its own codes and its check over the pay; Publish; a Positions tab; the inspector; and the warehouse's greedy fit on e3, which a Find fix asks who fits.\n// inputs: []\n/** The duties, both weeks', each the warehouse's own row. */\nexport const rosterDuties = e3.record(\"roster_duties\", DictType(StringType, WarehouseDuty), {\n initial: warehouseDuties,\n indexes: (index) => ({\n // The duties by their times: what the Roster's slice reads a week of them through, its navigation writing the range.\n roster_duties_by_time: index.interval({ from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The weeks of the rota: the one before issued, this one open. */\nexport const rosterWeeks = e3.record(\"roster_rota_weeks\", DictType(DateTimeType, WarehouseWeek), {\n initial: warehouseWeeks,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The cover targets, a row per slot: the week before's, this week's and the forecast's for the week after. */\nexport const rosterCover = e3.record(\"roster_cover\", DictType(StringType, WarehouseCover), {\n initial: warehouseCover,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The suggestions: someone for a slot, and why. */\nexport const rosterSuggestions = e3.record(\"roster_suggestions\", DictType(StringType, WarehouseSuggestion), {\n initial: warehouseSuggestions,\n mutations: (mutation) => ({\n // The suggestions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\n/** The pay rates, an hour, by the warehouse's own pay codes. */\nexport const rosterPayRates = e3.record(\"roster_pay_rates\", DictType(StringType, FloatType), { initial: warehousePayRates });\n\nexport const rosterStaff = e3.record(\"roster_staff\", DictType(StringType, WarehousePerson), {\n initial: warehousePeople,\n indexes: (index) => ({\n // The rail's fields, each on an index of its own: the staff by group then name, position, trainer, agency, skill and name, the activities by group.\n roster_staff_by_team_name: index.on([\"team\", \"name\"]),\n roster_staff_by_position: index.on([\"position\"]),\n roster_staff_by_trainer: index.on([\"trainer\"]),\n roster_staff_by_agency: index.on([\"agency\"]),\n roster_staff_by_skill: index.on([\"skills\"]),\n roster_staff_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // What the renderer's tests on e3 write and ask beside the examples (#1376): another session's edits of the\n // reference data, a roster the warehouse has locked, and another app's fit over the same staff.\n // The staff's patch door: another session's edit of the staff.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterAgencies = e3.record(\"roster_agencies\", DictType(StringType, WarehouseAgency), { initial: warehouseAgencies });\n\nexport const rosterShiftTimes = e3.record(\"roster_shift_times\", DictType(StringType, WarehouseShift), {\n initial: warehouseShifts,\n mutations: (mutation) => ({\n // The shift times' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterTeams = e3.record(\"roster_teams\", DictType(StringType, WarehouseTeam), {\n initial: warehouseTeams,\n mutations: (mutation) => ({\n // The teams' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterPositions = e3.record(\"roster_positions\", DictType(StringType, WarehousePosition), {\n initial: warehousePositions,\n mutations: (mutation) => ({\n // The positions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\n/** Every activity by its key: each group's skills, and the duty of none (#1342). */\nexport const rosterActivities = e3.record(\"roster_activities\", DictType(StringType, WarehouseActivity), {\n initial: warehouseActivities,\n indexes: (index) => ({\n roster_activities_by_group: index.on([\"group\"]),\n }),\n});\n\n/** The warehouse's fit's body: the ready-made rule, then a greedy order — the people off that day with the most spare contract hours first, whatever their group. */\nexport const rosterStaffFitBody = East.function([Roster.Types.FitRequest(WarehouseDuty)], Roster.Types.FitResult, ($, req) => {\n const answer = $.const(Roster.answer(WarehouseDuty));\n const rule = $.const(Roster.fit(WarehouseDuty));\n const weekHours = $.const(Roster.weekHours(WarehouseDuty));\n // Every person's hours this week, once: what is left of each one's contract ranks them.\n const hours = $.const(weekHours(req.week, req.context));\n return answer(req, East.function([Roster.Types.FitRequest(WarehouseDuty), Roster.Types.Person], Roster.Types.Fit, ($2, request, person) => {\n const verdict = $2.const(rule(request, person));\n $2.match(verdict, { refused: ($3) => { $3.return(verdict); } });\n const fits = $2.const(verdict.unwrap(\"fits\"));\n return variant(\"fits\", { score: person.contract.subtract(hours.get(person.key, () => 0.0)), why: fits.why, warn: fits.warn });\n }));\n});\n\nexport const rosterStaffFit = e3.function(\"roster_staff_fit\", rosterStaffFitBody);\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n // What the Roster writes: the duties, the weeks of the rota and the cover targets, each through its patch door.\n const rota = $.let(Record.bind(rosterDuties));\n const entries = $.let(Data.bindPaged(rosterDuties));\n const byTime = $.let(Data.bindPaged(rosterDuties, { indexes: [\"roster_duties_by_time\"] }));\n const weeks = $.let(Record.bind(rosterWeeks));\n const cover = $.let(Record.bind(rosterCover));\n // Every person and activity is the calculation scope; the narrowing only chooses which show (#1342).\n const people = $.let(Data.bind(rosterStaff));\n const acts = $.let(Data.bind(rosterActivities));\n const staffIndex = $.let(Data.bindPaged(rosterStaff, { indexes: [\"roster_staff_by_team_name\", \"roster_staff_by_position\", \"roster_staff_by_trainer\", \"roster_staff_by_agency\", \"roster_staff_by_skill\", \"roster_staff_by_name\"] }));\n const actIndex = $.let(Data.bindPaged(rosterActivities, { indexes: [\"roster_activities_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.rosterWarehouse\", {\n // The week's duties: the Roster's navigation writes the range; no chip picks the week.\n duty: { source: byTime, range: \"start\" },\n people: { source: staffIndex, icon: { prefix: \"fas\", name: \"user\" }, search: [\"name\", \"skills\"],\n fields: { team: { label: \"Group\", hints: [{ value: \"inbound\", label: \"Inbound\" }, { value: \"picking\", label: \"Picking\" }, { value: \"dispatch\", label: \"Dispatch\" }] }, position: { label: \"Position\", hints: [{ value: \"lead\", label: \"Lead\" }, { value: \"deputy\", label: \"Deputy\" }, { value: \"acting\", label: \"Acting\" }, { value: \"crew\", label: \"Crew\" }] },\n trainer: { label: \"Trainer\" }, agency: { label: \"Agency\" }, skills: { label: \"Skill\" }, name: { label: \"Name\" } } },\n activities: { source: actIndex, icon: { prefix: \"fas\", name: \"list-check\" }, fields: { group: { label: \"Group\", hints: [{ value: \"inbound\", label: \"Inbound\" }, { value: \"picking\", label: \"Picking\" }, { value: \"dispatch\", label: \"Dispatch\" }, null] } } },\n }, { presets: [{ id: \"leads\", name: \"Leads\", where: { people: { position: [\"lead\", \"deputy\", \"acting\"] } } }] }));\n const firms = $.let(Data.bind(rosterAgencies));\n const times = $.let(Data.bind(rosterShiftTimes));\n const teams = $.let(Data.bind(rosterTeams));\n const roles = $.let(Data.bind(rosterPositions));\n const ideas = $.let(Data.bind(rosterSuggestions));\n const rateRows = $.let(Data.bind(rosterPayRates));\n const rates = $.const(rateRows.read());\n // The app's fit: a Find fix asks it who fits, over every person, and the People tab shows its answer.\n const fit = $.let(Func.bind(rosterStaffFit));\n // The warehouse's pay (§5.6), in its own codes. One person's duties for the week in, or one agency's requests;\n // each duty's cost by code out: ordinary time up to the person's contracted hours in the week, OT1 past them,\n // and an agency's hours — its named worker's, or its request's — at its own rate.\n const pay = $.const(East.function([Roster.Types.PayRequest(WarehouseDuty)], Roster.Types.Pay, ($2, req) => {\n const out = $2.let(new Map(), Roster.Types.Pay);\n const zero = $2.const(0.0, FloatType);\n const agency = $2.let(true, BooleanType);\n const contract = $2.let(0.0, FloatType);\n $2.match(req.who, { person: ($3, key) => {\n $3.if(req.context.people.has(key), ($4) => {\n const person = $4.const(req.context.people.get(key));\n $4.assign(agency, person.agency);\n $4.assign(contract, person.contract);\n });\n } });\n const worked = $2.let(0.0, FloatType);\n // The week's duties in time order, so the contract's hours run out where they do.\n const ordered = $2.const(req.duties.toArray(($3, duty, key) => ({ key, duty })).sort(($3, d) => d.duty.start));\n $2.for(ordered, ($3, d) => {\n const costs = $3.let(new Map(), DictType(StringType, FloatType));\n $3.if(agency, ($4) => {\n $4(costs.insert(\"AGENCY\", d.duty.hours.multiply(rates.get(\"AGENCY\", () => 0.0))));\n }).else(($4) => {\n const ordinary = $4.const(East.max(East.min(d.duty.hours, contract.subtract(worked)), zero));\n const over = $4.const(d.duty.hours.subtract(ordinary));\n $4(costs.insert(\"ORD\", ordinary.multiply(rates.get(\"ORD\", () => 0.0))));\n $4.if(East.greater(over, 0.0), ($5) => { $5(costs.insert(\"OT1\", over.multiply(rates.get(\"OT1\", () => 0.0)))); });\n });\n $3.assign(worked, worked.add(d.duty.hours));\n $3(out.insert(d.key, costs));\n });\n return out;\n }));\n // The warehouse's check sees the pay too (§5.8): overtime on a duty nobody has agreed.\n const check = $.const(East.function([Roster.Types.CheckContext(WarehouseDuty)], ArrayType(Roster.Types.Issue), ($2, cx) => {\n const issues = $2.let([], ArrayType(Roster.Types.Issue));\n $2.for(cx.week.assignments, ($3, a, id) => {\n const costs = $3.const(cx.pay.get(id, () => East.value(new Map(), DictType(StringType, FloatType))));\n $3.if(costs.has(\"OT1\").and(() => East.notEqual(a.row.agreed, some(true))), ($4) => {\n $4(issues.pushLast({ kind: variant(\"breach\", null), tone: variant(\"info\", null),\n title: \"Overtime not agreed\", detail: East.str`${a.row.team} · ${a.row.shift}`,\n slot: some(a.slot), assignment: some(id), flag: some(\"OT\"), fix: none }));\n });\n });\n return issues;\n }));\n return <Box width=\"100%\" height=\"760px\"><Roster id=\"rosterWarehouse\" week={{ start: \"sunday\" }} slice={{ slice }} fit={fit}\n pay={pay} currency=\"AUD\" check={check} inspector view={{ layout: \"shifts\", period: \"day\", date: new Date(\"2028-03-09T00:00:00Z\") }}\n events={{ duty: Schedule.events(rota, {\n name: \"Duty\", icon: \"user-clock\", entries,\n start: \"start\", end: \"end\", resource: { field: \"who\", of: { staff: \"people\", agency: \"agencies\" } },\n shift: \"shift\", group: \"team\", position: \"role\", activity: \"task\",\n // The hours a duty counts: its length less its unpaid break.\n hours: d => d.start.durationMinutes(d.end).subtract(d.unpaidBreak).divide(60.0),\n fields: { unpaidBreak: Schedule.field.number({ label: \"Unpaid break\", unit: \"min\", step: 15.0, min: 0.0 }),\n costCentre: Schedule.field.text({ label: \"Cost centre\" }), note: Schedule.field.text({ label: \"Note\" }) },\n // The app's check on a draft: Save waits until every duty has a cost centre.\n ready: d => East.equal(d.costCentre, \"\").ifElse(\n () => variant(\"invalid\", [{ field: \"costCentre\", message: \"Give the duty a cost centre\" }]),\n () => variant(\"ready\", null)),\n }) }}\n resources={{\n people: Schedule.resources(people.read(), { name: \"People\", icon: \"user\", label: p => p.name, group: p => p.team,\n position: p => p.position, skills: p => p.skills, contract: p => p.contract, agency: p => p.agency,\n trainer: p => p.trainer, trainee: p => p.trainee, usual: p => p.usual }),\n agencies: Schedule.resources(firms.read(), { name: \"Agencies\", icon: \"building\", label: a => a.name }),\n }}\n periods={Schedule.periods(weeks, { every: \"week\", status: { field: \"state\", draft: \"open\", published: \"issued\" }, dismissed: \"dismissed\" })}\n targets={Roster.targets(cover, { day: \"day\", group: \"team\", shift: \"shift\", positions: \"heads\", hours: \"hours\" })}\n shifts={Roster.shifts(times.read(), { label: s => s.label, code: s => s.code, start: s => s.start, hours: s => s.hours, order: s => s.order })}\n groups={Roster.groups(teams.read(), { label: t => t.label, order: t => t.order })}\n positions={Roster.positions(roles.read(), { label: p => p.label, code: p => p.code, lead: p => p.lead, order: p => p.order })}\n activities={Roster.activities(acts.read(), { label: a => a.label, code: a => a.code, group: a => a.group, order: a => a.order })}\n proposals={Roster.proposals(ideas.read(), { person: s => s.person, day: s => s.day, group: s => s.team, shift: s => s.shift, reason: s => s.why })}\n rules={{ rest: 10.0 }}\n library={[Roster.library.people(), Roster.library.activities(), Roster.library.tab(roles.read(), {\n name: \"Positions\", icon: \"id-badge\", label: p => p.label, meta: p => some(p.code),\n drop: (_p, key) => Schedule.patch(WarehouseDuty, { role: key }),\n })]} />\n </Box>;\n }}</Reactive>)"
45294
+ "source": "// The mock warehouse roster over its own records: its duties, the weeks of its rota, its cover targets and suggestions, 69 staff and an agency, its shift times, teams, positions and activities. One Slice.bindRecords rail over the week's duties, the staff and the activities; the warehouse's pay in its own codes and its check over the pay; a new duty's own fields, a new target's basis and a new week's approver from the app's `values`; Publish; a Positions tab; the inspector; and the warehouse's greedy fit on e3, which a Find fix asks who fits.\n// inputs: []\n/** The duties, both weeks', each the warehouse's own row. */\nexport const rosterDuties = e3.record(\"roster_duties\", DictType(StringType, WarehouseDuty), {\n initial: warehouseDuties,\n indexes: (index) => ({\n // The duties by their times: what the Roster's slice reads a week of them through, its navigation writing the range.\n roster_duties_by_time: index.interval({ from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The weeks of the rota: the one before issued, this one open. */\nexport const rosterWeeks = e3.record(\"roster_rota_weeks\", DictType(DateTimeType, WarehouseWeek), {\n initial: warehouseWeeks,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The cover targets, a row per slot: the week before's, this week's and the forecast's for the week after. */\nexport const rosterCover = e3.record(\"roster_cover\", DictType(StringType, WarehouseCover), {\n initial: warehouseCover,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The suggestions: someone for a slot, and why. */\nexport const rosterSuggestions = e3.record(\"roster_suggestions\", DictType(StringType, WarehouseSuggestion), {\n initial: warehouseSuggestions,\n mutations: (mutation) => ({\n // The suggestions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\n/** The pay rates, an hour, by the warehouse's own pay codes. */\nexport const rosterPayRates = e3.record(\"roster_pay_rates\", DictType(StringType, FloatType), { initial: warehousePayRates });\n\nexport const rosterStaff = e3.record(\"roster_staff\", DictType(StringType, WarehousePerson), {\n initial: warehousePeople,\n indexes: (index) => ({\n // The rail's fields, each on an index of its own: the staff by group then name, position, trainer, agency, skill and name, the activities by group.\n roster_staff_by_team_name: index.on([\"team\", \"name\"]),\n roster_staff_by_position: index.on([\"position\"]),\n roster_staff_by_trainer: index.on([\"trainer\"]),\n roster_staff_by_agency: index.on([\"agency\"]),\n roster_staff_by_skill: index.on([\"skills\"]),\n roster_staff_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // What the renderer's tests on e3 write and ask beside the examples (#1376): another session's edits of the\n // reference data, a roster the warehouse has locked, and another app's fit over the same staff.\n // The staff's patch door: another session's edit of the staff.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterAgencies = e3.record(\"roster_agencies\", DictType(StringType, WarehouseAgency), { initial: warehouseAgencies });\n\nexport const rosterShiftTimes = e3.record(\"roster_shift_times\", DictType(StringType, WarehouseShift), {\n initial: warehouseShifts,\n mutations: (mutation) => ({\n // The shift times' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterTeams = e3.record(\"roster_teams\", DictType(StringType, WarehouseTeam), {\n initial: warehouseTeams,\n mutations: (mutation) => ({\n // The teams' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterPositions = e3.record(\"roster_positions\", DictType(StringType, WarehousePosition), {\n initial: warehousePositions,\n mutations: (mutation) => ({\n // The positions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\n/** Every activity by its key: each group's skills, and the duty of none (#1342). */\nexport const rosterActivities = e3.record(\"roster_activities\", DictType(StringType, WarehouseActivity), {\n initial: warehouseActivities,\n indexes: (index) => ({\n roster_activities_by_group: index.on([\"group\"]),\n }),\n});\n\n/** The warehouse's fit's body: the ready-made rule, then a greedy order — the people off that day with the most spare contract hours first, whatever their group. */\nexport const rosterStaffFitBody = East.function([Roster.Types.FitRequest(WarehouseDuty)], Roster.Types.FitResult, ($, req) => {\n const answer = $.const(Roster.answer(WarehouseDuty));\n const rule = $.const(Roster.fit(WarehouseDuty));\n const weekHours = $.const(Roster.weekHours(WarehouseDuty));\n // Every person's hours this week, once: what is left of each one's contract ranks them.\n const hours = $.const(weekHours(req.week, req.context));\n return answer(req, East.function([Roster.Types.FitRequest(WarehouseDuty), Roster.Types.Person], Roster.Types.Fit, ($2, request, person) => {\n const verdict = $2.const(rule(request, person));\n $2.match(verdict, { refused: ($3) => { $3.return(verdict); } });\n const fits = $2.const(verdict.unwrap(\"fits\"));\n return variant(\"fits\", { score: person.contract.subtract(hours.get(person.key, () => 0.0)), why: fits.why, warn: fits.warn });\n }));\n});\n\nexport const rosterStaffFit = e3.function(\"roster_staff_fit\", rosterStaffFitBody);\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n // What the Roster writes: the duties, the weeks of the rota and the cover targets, each through its patch door.\n const rota = $.let(Record.bind(rosterDuties));\n const entries = $.let(Data.bindPaged(rosterDuties));\n const byTime = $.let(Data.bindPaged(rosterDuties, { indexes: [\"roster_duties_by_time\"] }));\n const weeks = $.let(Record.bind(rosterWeeks));\n const cover = $.let(Record.bind(rosterCover));\n // Every person and activity is the calculation scope; the narrowing only chooses which show (#1342).\n const people = $.let(Data.bind(rosterStaff));\n const acts = $.let(Data.bind(rosterActivities));\n const staffIndex = $.let(Data.bindPaged(rosterStaff, { indexes: [\"roster_staff_by_team_name\", \"roster_staff_by_position\", \"roster_staff_by_trainer\", \"roster_staff_by_agency\", \"roster_staff_by_skill\", \"roster_staff_by_name\"] }));\n const actIndex = $.let(Data.bindPaged(rosterActivities, { indexes: [\"roster_activities_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.rosterWarehouse\", {\n // The week's duties: the Roster's navigation writes the range; no chip picks the week.\n duty: { source: byTime, range: \"start\" },\n people: { source: staffIndex, icon: { prefix: \"fas\", name: \"user\" }, search: [\"name\", \"skills\"],\n fields: { team: { label: \"Group\", hints: [{ value: \"inbound\", label: \"Inbound\" }, { value: \"picking\", label: \"Picking\" }, { value: \"dispatch\", label: \"Dispatch\" }] }, position: { label: \"Position\", hints: [{ value: \"lead\", label: \"Lead\" }, { value: \"deputy\", label: \"Deputy\" }, { value: \"acting\", label: \"Acting\" }, { value: \"crew\", label: \"Crew\" }] },\n trainer: { label: \"Trainer\" }, agency: { label: \"Agency\" }, skills: { label: \"Skill\" }, name: { label: \"Name\" } } },\n activities: { source: actIndex, icon: { prefix: \"fas\", name: \"list-check\" }, fields: { group: { label: \"Group\", hints: [{ value: \"inbound\", label: \"Inbound\" }, { value: \"picking\", label: \"Picking\" }, { value: \"dispatch\", label: \"Dispatch\" }, null] } } },\n }, { presets: [{ id: \"leads\", name: \"Leads\", where: { people: { position: [\"lead\", \"deputy\", \"acting\"] } } }] }));\n const firms = $.let(Data.bind(rosterAgencies));\n const times = $.let(Data.bind(rosterShiftTimes));\n const teams = $.let(Data.bind(rosterTeams));\n // Each team's cost centre: what a new duty of the team is booked to.\n const centres = $.const(teams.read().map((_$2, team) => team.costCentre));\n const roles = $.let(Data.bind(rosterPositions));\n const ideas = $.let(Data.bind(rosterSuggestions));\n const rateRows = $.let(Data.bind(rosterPayRates));\n const rates = $.const(rateRows.read());\n // The app's fit: a Find fix asks it who fits, over every person, and the People tab shows its answer.\n const fit = $.let(Func.bind(rosterStaffFit));\n // The warehouse's pay (§5.6), in its own codes. One person's duties for the week in, or one agency's requests;\n // each duty's cost by code out: ordinary time up to the person's contracted hours in the week, OT1 past them,\n // and an agency's hours — its named worker's, or its request's — at its own rate.\n const pay = $.const(East.function([Roster.Types.PayRequest(WarehouseDuty)], Roster.Types.Pay, ($2, req) => {\n const out = $2.let(new Map(), Roster.Types.Pay);\n const zero = $2.const(0.0, FloatType);\n const agency = $2.let(true, BooleanType);\n const contract = $2.let(0.0, FloatType);\n $2.match(req.who, { person: ($3, key) => {\n $3.if(req.context.people.has(key), ($4) => {\n const person = $4.const(req.context.people.get(key));\n $4.assign(agency, person.agency);\n $4.assign(contract, person.contract);\n });\n } });\n const worked = $2.let(0.0, FloatType);\n // The week's duties in time order, so the contract's hours run out where they do.\n const ordered = $2.const(req.duties.toArray(($3, duty, key) => ({ key, duty })).sort(($3, d) => d.duty.start));\n $2.for(ordered, ($3, d) => {\n const costs = $3.let(new Map(), DictType(StringType, FloatType));\n $3.if(agency, ($4) => {\n $4(costs.insert(\"AGENCY\", d.duty.hours.multiply(rates.get(\"AGENCY\", () => 0.0))));\n }).else(($4) => {\n const ordinary = $4.const(East.max(East.min(d.duty.hours, contract.subtract(worked)), zero));\n const over = $4.const(d.duty.hours.subtract(ordinary));\n $4(costs.insert(\"ORD\", ordinary.multiply(rates.get(\"ORD\", () => 0.0))));\n $4.if(East.greater(over, 0.0), ($5) => { $5(costs.insert(\"OT1\", over.multiply(rates.get(\"OT1\", () => 0.0)))); });\n });\n $3.assign(worked, worked.add(d.duty.hours));\n $3(out.insert(d.key, costs));\n });\n return out;\n }));\n // The warehouse's check sees the pay too (§5.8): overtime on a duty nobody has agreed.\n const check = $.const(East.function([Roster.Types.CheckContext(WarehouseDuty)], ArrayType(Roster.Types.Issue), ($2, cx) => {\n const issues = $2.let([], ArrayType(Roster.Types.Issue));\n const slotOf = $2.const(Roster.slotOf);\n $2.for(cx.week.assignments, ($3, a, id) => {\n const costs = $3.const(cx.pay.get(id, () => East.value(new Map(), DictType(StringType, FloatType))));\n $3.if(costs.has(\"OT1\").and(() => East.notEqual(a.row.agreed, some(true))), ($4) => {\n $4(issues.pushLast({ kind: variant(\"breach\", null), tone: variant(\"info\", null),\n title: \"Overtime not agreed\", detail: East.str`${a.row.team} · ${a.row.shift}`,\n slot: slotOf(a.place), assignment: some(id), flag: some(\"OT\"), fix: none }));\n });\n });\n return issues;\n }));\n return <Box width=\"100%\" height=\"760px\"><Roster id=\"rosterWarehouse\" week={{ start: \"sunday\" }} slice={{ slice }} fit={fit}\n pay={pay} currency=\"AUD\" check={check} inspector view={{ layout: \"shifts\", period: \"day\", date: new Date(\"2028-03-09T00:00:00Z\") }}\n events={{ duty: Schedule.events(rota, {\n name: \"Duty\", icon: \"user-clock\", entries,\n start: \"start\", end: \"end\", resource: { field: \"who\", of: { staff: \"people\", agency: \"agencies\" } },\n shift: \"shift\", group: \"team\", position: \"role\", activity: \"task\",\n // The hours a duty counts: its length less its unpaid break.\n hours: d => d.start.durationMinutes(d.end).subtract(d.unpaidBreak).divide(60.0),\n fields: { unpaidBreak: Schedule.field.number({ label: \"Unpaid break\", unit: \"min\", step: 15.0, min: 0.0 }),\n costCentre: Schedule.field.text({ label: \"Cost centre\" }), note: Schedule.field.text({ label: \"Note\" }) },\n // A new duty's own fields, the app's: half an hour's break on a shift over six hours, and its team's cost centre.\n values: d => ({\n unpaidBreak: d.hours.greaterThan(6.0).ifElse(() => 30.0, () => 0.0),\n agreed: none,\n costCentre: d.group.match({ some: (_$2, team) => centres.get(team, () => \"\"), none: () => \"\" }),\n note: \"\",\n }),\n // The app's check on a draft: Save waits while a duty has no cost centre — one a person cleared, or a team's with none.\n ready: d => East.equal(d.costCentre, \"\").ifElse(\n () => variant(\"invalid\", [{ field: \"costCentre\", message: \"Give the duty a cost centre\" }]),\n () => variant(\"ready\", null)),\n }) }}\n resources={{\n people: Schedule.resources(people.read(), { name: \"People\", icon: \"user\", label: p => p.name, group: p => p.team,\n position: p => p.position, skills: p => p.skills, contract: p => p.contract, agency: p => p.agency,\n trainer: p => p.trainer, trainee: p => p.trainee, usual: p => p.usual }),\n agencies: Schedule.resources(firms.read(), { name: \"Agencies\", icon: \"building\", label: a => a.name }),\n }}\n // A week's row the Roster makes, at its first Save or its Publish: Ops approves the warehouse's weeks.\n periods={Schedule.periods(weeks, { every: \"week\", status: { field: \"state\", draft: \"open\", published: \"issued\" }, dismissed: \"dismissed\",\n values: _week => ({ approver: some(\"Ops\") }) })}\n // A target added here is the planner's own, where the forecast's rest on its run.\n targets={Roster.targets(cover, { day: \"day\", group: \"team\", shift: \"shift\", positions: \"heads\", hours: \"hours\", values: _t => ({ basis: \"planner\" }) })}\n shifts={Roster.shifts(times.read(), { label: s => s.label, code: s => s.code, start: s => s.start, hours: s => s.hours, order: s => s.order })}\n groups={Roster.groups(teams.read(), { label: t => t.label, order: t => t.order })}\n positions={Roster.positions(roles.read(), { label: p => p.label, code: p => p.code, lead: p => p.lead, order: p => p.order })}\n activities={Roster.activities(acts.read(), { label: a => a.label, code: a => a.code, group: a => a.group, order: a => a.order })}\n proposals={Roster.proposals(ideas.read(), { person: s => s.person, day: s => s.day, group: s => s.team, shift: s => s.shift, reason: s => s.why })}\n rules={{ rest: 10.0 }}\n library={[Roster.library.people(), Roster.library.activities(), Roster.library.tab(roles.read(), {\n name: \"Positions\", icon: \"id-badge\", label: p => p.label, meta: p => some(p.code),\n drop: (_p, key) => Schedule.patch(WarehouseDuty, { role: key }),\n })]} />\n </Box>;\n }}</Reactive>)"
44403
45295
  },
44404
45296
  {
44405
45297
  "id": "e3-ui:roster.examples.tsx:rosterMobile",
@@ -44441,7 +45333,7 @@
44441
45333
  "package": "e3-ui",
44442
45334
  "file": "east-ui/packages/e3-ui/test/roster/roster.examples.tsx",
44443
45335
  "suite": "",
44444
- "test": "The app's own words for who is on the Roster (#1516): `vocabulary` replaces Permanent, Agency staff, Leads, Associates, Trainers and Off Mon · available wherever the Roster draws them, its coverage detail's short forms too, and the People tab keeps its groups' order whatever they are called.",
45336
+ "test": "The app's own words for who is on the Roster (#1516): `vocabulary` replaces Permanent, Agency staff, Leads, Associates, Trainers and Off Mon · available wherever the Roster draws them, its coverage detail's short forms too, and the People tab keeps its groups' order whatever they are called; the badge beside an agency person's name — in the People layout, and on a Shifts chip, a request's too — is its `agencyShort`, each group's row of agency requests its `requests` (#1566), and the People layout's work requirement heading its `demand` (#1568).",
44445
45337
  "keywords": [
44446
45338
  "Roster",
44447
45339
  "vocabulary",
@@ -44464,7 +45356,7 @@
44464
45356
  "languages": [
44465
45357
  "tsx"
44466
45358
  ],
44467
- "source": "// The app's own words for who is on the Roster (#1516): `vocabulary` replaces Permanent, Agency staff, Leads, Associates, Trainers and Off Mon · available wherever the Roster draws them, its coverage detail's short forms too, and the People tab keeps its groups' order whatever they are called.\n// inputs: []\n/** The duties, both weeks', each the warehouse's own row. */\nexport const rosterDuties = e3.record(\"roster_duties\", DictType(StringType, WarehouseDuty), {\n initial: warehouseDuties,\n indexes: (index) => ({\n // The duties by their times: what the Roster's slice reads a week of them through, its navigation writing the range.\n roster_duties_by_time: index.interval({ from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The weeks of the rota: the one before issued, this one open. */\nexport const rosterWeeks = e3.record(\"roster_rota_weeks\", DictType(DateTimeType, WarehouseWeek), {\n initial: warehouseWeeks,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The cover targets, a row per slot: the week before's, this week's and the forecast's for the week after. */\nexport const rosterCover = e3.record(\"roster_cover\", DictType(StringType, WarehouseCover), {\n initial: warehouseCover,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The suggestions: someone for a slot, and why. */\nexport const rosterSuggestions = e3.record(\"roster_suggestions\", DictType(StringType, WarehouseSuggestion), {\n initial: warehouseSuggestions,\n mutations: (mutation) => ({\n // The suggestions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterStaff = e3.record(\"roster_staff\", DictType(StringType, WarehousePerson), {\n initial: warehousePeople,\n indexes: (index) => ({\n // The rail's fields, each on an index of its own: the staff by group then name, position, trainer, agency, skill and name, the activities by group.\n roster_staff_by_team_name: index.on([\"team\", \"name\"]),\n roster_staff_by_position: index.on([\"position\"]),\n roster_staff_by_trainer: index.on([\"trainer\"]),\n roster_staff_by_agency: index.on([\"agency\"]),\n roster_staff_by_skill: index.on([\"skills\"]),\n roster_staff_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // What the renderer's tests on e3 write and ask beside the examples (#1376): another session's edits of the\n // reference data, a roster the warehouse has locked, and another app's fit over the same staff.\n // The staff's patch door: another session's edit of the staff.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterAgencies = e3.record(\"roster_agencies\", DictType(StringType, WarehouseAgency), { initial: warehouseAgencies });\n\nexport const rosterShiftTimes = e3.record(\"roster_shift_times\", DictType(StringType, WarehouseShift), {\n initial: warehouseShifts,\n mutations: (mutation) => ({\n // The shift times' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterTeams = e3.record(\"roster_teams\", DictType(StringType, WarehouseTeam), {\n initial: warehouseTeams,\n mutations: (mutation) => ({\n // The teams' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterPositions = e3.record(\"roster_positions\", DictType(StringType, WarehousePosition), {\n initial: warehousePositions,\n mutations: (mutation) => ({\n // The positions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\n/** Every activity by its key: each group's skills, and the duty of none (#1342). */\nexport const rosterActivities = e3.record(\"roster_activities\", DictType(StringType, WarehouseActivity), {\n initial: warehouseActivities,\n indexes: (index) => ({\n roster_activities_by_group: index.on([\"group\"]),\n }),\n});\n\n/** The warehouse's fit's body: the ready-made rule, then a greedy order — the people off that day with the most spare contract hours first, whatever their group. */\nexport const rosterStaffFitBody = East.function([Roster.Types.FitRequest(WarehouseDuty)], Roster.Types.FitResult, ($, req) => {\n const answer = $.const(Roster.answer(WarehouseDuty));\n const rule = $.const(Roster.fit(WarehouseDuty));\n const weekHours = $.const(Roster.weekHours(WarehouseDuty));\n // Every person's hours this week, once: what is left of each one's contract ranks them.\n const hours = $.const(weekHours(req.week, req.context));\n return answer(req, East.function([Roster.Types.FitRequest(WarehouseDuty), Roster.Types.Person], Roster.Types.Fit, ($2, request, person) => {\n const verdict = $2.const(rule(request, person));\n $2.match(verdict, { refused: ($3) => { $3.return(verdict); } });\n const fits = $2.const(verdict.unwrap(\"fits\"));\n return variant(\"fits\", { score: person.contract.subtract(hours.get(person.key, () => 0.0)), why: fits.why, warn: fits.warn });\n }));\n});\n\nexport const rosterStaffFit = e3.function(\"roster_staff_fit\", rosterStaffFitBody);\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const rota = $.let(Record.bind(rosterDuties));\n const entries = $.let(Data.bindPaged(rosterDuties));\n const byTime = $.let(Data.bindPaged(rosterDuties, { indexes: [\"roster_duties_by_time\"] }));\n const weeks = $.let(Record.bind(rosterWeeks));\n const cover = $.let(Record.bind(rosterCover));\n const people = $.let(Data.bind(rosterStaff));\n const acts = $.let(Data.bind(rosterActivities));\n const slice = $.let(Slice.bindRecords(\"ex.rosterVocabulary\", { duty: { source: byTime, range: \"start\" } }));\n const firms = $.let(Data.bind(rosterAgencies));\n const times = $.let(Data.bind(rosterShiftTimes));\n const teams = $.let(Data.bind(rosterTeams));\n const roles = $.let(Data.bind(rosterPositions));\n const ideas = $.let(Data.bind(rosterSuggestions));\n const fit = $.let(Func.bind(rosterStaffFit));\n return <Box width=\"100%\" height=\"760px\"><Roster id=\"rosterVocabulary\" week={{ start: \"sunday\" }} slice={{ slice }} inspector fit={fit}\n vocabulary={{\n permanent: \"Employees\", permanentShort: \"empl\", agency: \"Contractors\", agencyShort: \"contr\", leads: \"Supervisors\", others: \"Colleagues\", trainers: \"Mentors\",\n available: East.function([StringType], StringType, (_$2, weekday) => East.str`Not rostered ${weekday}`),\n }}\n view={{ layout: \"shifts\", period: \"day\", date: new Date(\"2028-03-09T00:00:00Z\") }}\n events={{ duty: Schedule.events(rota, {\n name: \"Duty\", icon: \"user-clock\", entries,\n start: \"start\", end: \"end\", resource: { field: \"who\", of: { staff: \"people\", agency: \"agencies\" } },\n shift: \"shift\", group: \"team\", position: \"role\", activity: \"task\",\n hours: d => d.start.durationMinutes(d.end).subtract(d.unpaidBreak).divide(60.0),\n }) }}\n resources={{\n people: Schedule.resources(people.read(), { name: \"People\", icon: \"user\", label: p => p.name, group: p => p.team,\n position: p => p.position, skills: p => p.skills, contract: p => p.contract, agency: p => p.agency,\n trainer: p => p.trainer, trainee: p => p.trainee, usual: p => p.usual }),\n agencies: Schedule.resources(firms.read(), { name: \"Agencies\", icon: \"building\", label: a => a.name }),\n }}\n periods={Schedule.periods(weeks, { every: \"week\", status: { field: \"state\", draft: \"open\", published: \"issued\" }, dismissed: \"dismissed\" })}\n targets={Roster.targets(cover, { day: \"day\", group: \"team\", shift: \"shift\", positions: \"heads\", hours: \"hours\" })}\n shifts={Roster.shifts(times.read(), { label: s => s.label, code: s => s.code, start: s => s.start, hours: s => s.hours, order: s => s.order })}\n groups={Roster.groups(teams.read(), { label: t => t.label, order: t => t.order })}\n positions={Roster.positions(roles.read(), { label: p => p.label, code: p => p.code, lead: p => p.lead, order: p => p.order })}\n activities={Roster.activities(acts.read(), { label: a => a.label, code: a => a.code, group: a => a.group, order: a => a.order })}\n proposals={Roster.proposals(ideas.read(), { person: s => s.person, day: s => s.day, group: s => s.team, shift: s => s.shift, reason: s => s.why })}\n rules={{ rest: 10.0 }}\n library={[Roster.library.people(), Roster.library.activities()]} />\n </Box>;\n }}</Reactive>)"
45359
+ "source": "// The app's own words for who is on the Roster (#1516): `vocabulary` replaces Permanent, Agency staff, Leads, Associates, Trainers and Off Mon · available wherever the Roster draws them, its coverage detail's short forms too, and the People tab keeps its groups' order whatever they are called; the badge beside an agency person's name — in the People layout, and on a Shifts chip, a request's too — is its `agencyShort`, each group's row of agency requests its `requests` (#1566), and the People layout's work requirement heading its `demand` (#1568).\n// inputs: []\n/** The duties, both weeks', each the warehouse's own row. */\nexport const rosterDuties = e3.record(\"roster_duties\", DictType(StringType, WarehouseDuty), {\n initial: warehouseDuties,\n indexes: (index) => ({\n // The duties by their times: what the Roster's slice reads a week of them through, its navigation writing the range.\n roster_duties_by_time: index.interval({ from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The weeks of the rota: the one before issued, this one open. */\nexport const rosterWeeks = e3.record(\"roster_rota_weeks\", DictType(DateTimeType, WarehouseWeek), {\n initial: warehouseWeeks,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The cover targets, a row per slot: the week before's, this week's and the forecast's for the week after. */\nexport const rosterCover = e3.record(\"roster_cover\", DictType(StringType, WarehouseCover), {\n initial: warehouseCover,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The suggestions: someone for a slot, and why. */\nexport const rosterSuggestions = e3.record(\"roster_suggestions\", DictType(StringType, WarehouseSuggestion), {\n initial: warehouseSuggestions,\n mutations: (mutation) => ({\n // The suggestions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterStaff = e3.record(\"roster_staff\", DictType(StringType, WarehousePerson), {\n initial: warehousePeople,\n indexes: (index) => ({\n // The rail's fields, each on an index of its own: the staff by group then name, position, trainer, agency, skill and name, the activities by group.\n roster_staff_by_team_name: index.on([\"team\", \"name\"]),\n roster_staff_by_position: index.on([\"position\"]),\n roster_staff_by_trainer: index.on([\"trainer\"]),\n roster_staff_by_agency: index.on([\"agency\"]),\n roster_staff_by_skill: index.on([\"skills\"]),\n roster_staff_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // What the renderer's tests on e3 write and ask beside the examples (#1376): another session's edits of the\n // reference data, a roster the warehouse has locked, and another app's fit over the same staff.\n // The staff's patch door: another session's edit of the staff.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterAgencies = e3.record(\"roster_agencies\", DictType(StringType, WarehouseAgency), { initial: warehouseAgencies });\n\nexport const rosterShiftTimes = e3.record(\"roster_shift_times\", DictType(StringType, WarehouseShift), {\n initial: warehouseShifts,\n mutations: (mutation) => ({\n // The shift times' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterTeams = e3.record(\"roster_teams\", DictType(StringType, WarehouseTeam), {\n initial: warehouseTeams,\n mutations: (mutation) => ({\n // The teams' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterPositions = e3.record(\"roster_positions\", DictType(StringType, WarehousePosition), {\n initial: warehousePositions,\n mutations: (mutation) => ({\n // The positions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\n/** Every activity by its key: each group's skills, and the duty of none (#1342). */\nexport const rosterActivities = e3.record(\"roster_activities\", DictType(StringType, WarehouseActivity), {\n initial: warehouseActivities,\n indexes: (index) => ({\n roster_activities_by_group: index.on([\"group\"]),\n }),\n});\n\n/** The warehouse's fit's body: the ready-made rule, then a greedy order — the people off that day with the most spare contract hours first, whatever their group. */\nexport const rosterStaffFitBody = East.function([Roster.Types.FitRequest(WarehouseDuty)], Roster.Types.FitResult, ($, req) => {\n const answer = $.const(Roster.answer(WarehouseDuty));\n const rule = $.const(Roster.fit(WarehouseDuty));\n const weekHours = $.const(Roster.weekHours(WarehouseDuty));\n // Every person's hours this week, once: what is left of each one's contract ranks them.\n const hours = $.const(weekHours(req.week, req.context));\n return answer(req, East.function([Roster.Types.FitRequest(WarehouseDuty), Roster.Types.Person], Roster.Types.Fit, ($2, request, person) => {\n const verdict = $2.const(rule(request, person));\n $2.match(verdict, { refused: ($3) => { $3.return(verdict); } });\n const fits = $2.const(verdict.unwrap(\"fits\"));\n return variant(\"fits\", { score: person.contract.subtract(hours.get(person.key, () => 0.0)), why: fits.why, warn: fits.warn });\n }));\n});\n\nexport const rosterStaffFit = e3.function(\"roster_staff_fit\", rosterStaffFitBody);\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const rota = $.let(Record.bind(rosterDuties));\n const entries = $.let(Data.bindPaged(rosterDuties));\n const byTime = $.let(Data.bindPaged(rosterDuties, { indexes: [\"roster_duties_by_time\"] }));\n const weeks = $.let(Record.bind(rosterWeeks));\n const cover = $.let(Record.bind(rosterCover));\n const people = $.let(Data.bind(rosterStaff));\n const acts = $.let(Data.bind(rosterActivities));\n const slice = $.let(Slice.bindRecords(\"ex.rosterVocabulary\", { duty: { source: byTime, range: \"start\" } }));\n const firms = $.let(Data.bind(rosterAgencies));\n const times = $.let(Data.bind(rosterShiftTimes));\n const teams = $.let(Data.bind(rosterTeams));\n const roles = $.let(Data.bind(rosterPositions));\n const ideas = $.let(Data.bind(rosterSuggestions));\n const fit = $.let(Func.bind(rosterStaffFit));\n return <Box width=\"100%\" height=\"760px\"><Roster id=\"rosterVocabulary\" week={{ start: \"sunday\" }} slice={{ slice }} inspector fit={fit}\n vocabulary={{\n permanent: \"Employees\", permanentShort: \"empl\", agency: \"Contractors\", agencyShort: \"contr\", leads: \"Supervisors\", others: \"Colleagues\", trainers: \"Mentors\",\n available: East.function([StringType], StringType, (_$2, weekday) => East.str`Not rostered ${weekday}`), requests: \"Contractor requests\",\n demand: \"Hours needed\",\n }}\n view={{ layout: \"shifts\", period: \"day\", date: new Date(\"2028-03-09T00:00:00Z\") }}\n events={{ duty: Schedule.events(rota, {\n name: \"Duty\", icon: \"user-clock\", entries,\n start: \"start\", end: \"end\", resource: { field: \"who\", of: { staff: \"people\", agency: \"agencies\" } },\n shift: \"shift\", group: \"team\", position: \"role\", activity: \"task\",\n hours: d => d.start.durationMinutes(d.end).subtract(d.unpaidBreak).divide(60.0),\n }) }}\n resources={{\n people: Schedule.resources(people.read(), { name: \"People\", icon: \"user\", label: p => p.name, group: p => p.team,\n position: p => p.position, skills: p => p.skills, contract: p => p.contract, agency: p => p.agency,\n trainer: p => p.trainer, trainee: p => p.trainee, usual: p => p.usual }),\n agencies: Schedule.resources(firms.read(), { name: \"Agencies\", icon: \"building\", label: a => a.name }),\n }}\n periods={Schedule.periods(weeks, { every: \"week\", status: { field: \"state\", draft: \"open\", published: \"issued\" }, dismissed: \"dismissed\" })}\n targets={Roster.targets(cover, { day: \"day\", group: \"team\", shift: \"shift\", positions: \"heads\", hours: \"hours\" })}\n shifts={Roster.shifts(times.read(), { label: s => s.label, code: s => s.code, start: s => s.start, hours: s => s.hours, order: s => s.order })}\n groups={Roster.groups(teams.read(), { label: t => t.label, order: t => t.order })}\n positions={Roster.positions(roles.read(), { label: p => p.label, code: p => p.code, lead: p => p.lead, order: p => p.order })}\n activities={Roster.activities(acts.read(), { label: a => a.label, code: a => a.code, group: a => a.group, order: a => a.order })}\n proposals={Roster.proposals(ideas.read(), { person: s => s.person, day: s => s.day, group: s => s.team, shift: s => s.shift, reason: s => s.why })}\n rules={{ rest: 10.0 }}\n library={[Roster.library.people(), Roster.library.activities()]} />\n </Box>;\n }}</Reactive>)"
44468
45360
  },
44469
45361
  {
44470
45362
  "id": "e3-ui:roster.examples.tsx:rosterPeople",
@@ -44472,7 +45364,7 @@
44472
45364
  "package": "e3-ui",
44473
45365
  "file": "east-ui/packages/e3-ui/test/roster/roster.examples.tsx",
44474
45366
  "suite": "",
44475
- "test": "The People layout by week over the same records (#1406): a row per person under their group's band, a tile per duty in each day cell in the shift's colour token — its hours only where a duty's own times differ (tileTimes=\"different\") — the week's hours and a meter in the name cell, `+ Assign` on an off day opening a menu of the home group's shifts, and the warehouse's week patterns in a Patterns tab, each dropped on a person's week as one undo step; the agency's requests their own row.",
45367
+ "test": "The People layout by week over the same records (#1406): a row per person under their group's band, a tile per duty in each day cell in the shift's colour token — its hours only where a duty's own times differ (tileTimes=\"different\") — the week's hours and a meter in the name cell, `+ Assign` on an off day opening a menu of the home group's shifts, and the warehouse's week patterns in a Patterns tab, each dropped on a person's week as one undo step, a day it makes a duty of taking the app's `values` — the pattern named in its note; the agency's requests their own row.",
44476
45368
  "keywords": [
44477
45369
  "Roster",
44478
45370
  "Schedule.events",
@@ -44485,6 +45377,9 @@
44485
45377
  "Roster.patterns",
44486
45378
  "Roster.library.patterns",
44487
45379
  "tileTimes",
45380
+ "values",
45381
+ "Roster.Types.NewDuty",
45382
+ "pattern",
44488
45383
  "Slice",
44489
45384
  "Slice.bindRecords",
44490
45385
  "Data.bindPaged",
@@ -44505,7 +45400,7 @@
44505
45400
  "languages": [
44506
45401
  "tsx"
44507
45402
  ],
44508
- "source": "// The People layout by week over the same records (#1406): a row per person under their group's band, a tile per duty in each day cell in the shift's colour token — its hours only where a duty's own times differ (tileTimes=\"different\") — the week's hours and a meter in the name cell, `+ Assign` on an off day opening a menu of the home group's shifts, and the warehouse's week patterns in a Patterns tab, each dropped on a person's week as one undo step; the agency's requests their own row.\n// inputs: []\n/** The duties, both weeks', each the warehouse's own row. */\nexport const rosterDuties = e3.record(\"roster_duties\", DictType(StringType, WarehouseDuty), {\n initial: warehouseDuties,\n indexes: (index) => ({\n // The duties by their times: what the Roster's slice reads a week of them through, its navigation writing the range.\n roster_duties_by_time: index.interval({ from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The weeks of the rota: the one before issued, this one open. */\nexport const rosterWeeks = e3.record(\"roster_rota_weeks\", DictType(DateTimeType, WarehouseWeek), {\n initial: warehouseWeeks,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The cover targets, a row per slot: the week before's, this week's and the forecast's for the week after. */\nexport const rosterCover = e3.record(\"roster_cover\", DictType(StringType, WarehouseCover), {\n initial: warehouseCover,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The suggestions: someone for a slot, and why. */\nexport const rosterSuggestions = e3.record(\"roster_suggestions\", DictType(StringType, WarehouseSuggestion), {\n initial: warehouseSuggestions,\n mutations: (mutation) => ({\n // The suggestions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterStaff = e3.record(\"roster_staff\", DictType(StringType, WarehousePerson), {\n initial: warehousePeople,\n indexes: (index) => ({\n // The rail's fields, each on an index of its own: the staff by group then name, position, trainer, agency, skill and name, the activities by group.\n roster_staff_by_team_name: index.on([\"team\", \"name\"]),\n roster_staff_by_position: index.on([\"position\"]),\n roster_staff_by_trainer: index.on([\"trainer\"]),\n roster_staff_by_agency: index.on([\"agency\"]),\n roster_staff_by_skill: index.on([\"skills\"]),\n roster_staff_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // What the renderer's tests on e3 write and ask beside the examples (#1376): another session's edits of the\n // reference data, a roster the warehouse has locked, and another app's fit over the same staff.\n // The staff's patch door: another session's edit of the staff.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterAgencies = e3.record(\"roster_agencies\", DictType(StringType, WarehouseAgency), { initial: warehouseAgencies });\n\nexport const rosterShiftTimes = e3.record(\"roster_shift_times\", DictType(StringType, WarehouseShift), {\n initial: warehouseShifts,\n mutations: (mutation) => ({\n // The shift times' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterTeams = e3.record(\"roster_teams\", DictType(StringType, WarehouseTeam), {\n initial: warehouseTeams,\n mutations: (mutation) => ({\n // The teams' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterPositions = e3.record(\"roster_positions\", DictType(StringType, WarehousePosition), {\n initial: warehousePositions,\n mutations: (mutation) => ({\n // The positions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\n/** Every activity by its key: each group's skills, and the duty of none (#1342). */\nexport const rosterActivities = e3.record(\"roster_activities\", DictType(StringType, WarehouseActivity), {\n initial: warehouseActivities,\n indexes: (index) => ({\n roster_activities_by_group: index.on([\"group\"]),\n }),\n});\n\n/** The week patterns (#1406): the thirteen a planner drops on a person's week, the warehouse's own record. */\nexport const rosterPatterns = e3.record(\"roster_week_patterns\", DictType(StringType, WarehousePattern), {\n initial: warehousePatterns,\n mutations: (mutation) => ({\n // The week patterns' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const rota = $.let(Record.bind(rosterDuties));\n const entries = $.let(Data.bindPaged(rosterDuties));\n const byTime = $.let(Data.bindPaged(rosterDuties, { indexes: [\"roster_duties_by_time\"] }));\n const weeks = $.let(Record.bind(rosterWeeks));\n const cover = $.let(Record.bind(rosterCover));\n // Every person and activity is the calculation scope; the narrowing only chooses which show (#1342).\n const people = $.let(Data.bind(rosterStaff));\n const acts = $.let(Data.bind(rosterActivities));\n const staffIndex = $.let(Data.bindPaged(rosterStaff, { indexes: [\"roster_staff_by_team_name\", \"roster_staff_by_position\", \"roster_staff_by_trainer\", \"roster_staff_by_agency\", \"roster_staff_by_skill\", \"roster_staff_by_name\"] }));\n const actIndex = $.let(Data.bindPaged(rosterActivities, { indexes: [\"roster_activities_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.rosterPeople\", {\n duty: { source: byTime, range: \"start\" },\n people: { source: staffIndex, icon: { prefix: \"fas\", name: \"user\" }, search: [\"name\", \"skills\"],\n fields: { team: { label: \"Group\", hints: [{ value: \"inbound\", label: \"Inbound\" }, { value: \"picking\", label: \"Picking\" }, { value: \"dispatch\", label: \"Dispatch\" }] }, position: { label: \"Position\", hints: [{ value: \"lead\", label: \"Lead\" }, { value: \"deputy\", label: \"Deputy\" }, { value: \"acting\", label: \"Acting\" }, { value: \"crew\", label: \"Crew\" }] },\n trainer: { label: \"Trainer\" }, agency: { label: \"Agency\" }, skills: { label: \"Skill\" }, name: { label: \"Name\" } } },\n activities: { source: actIndex, icon: { prefix: \"fas\", name: \"list-check\" }, fields: { group: { label: \"Group\", hints: [{ value: \"inbound\", label: \"Inbound\" }, { value: \"picking\", label: \"Picking\" }, { value: \"dispatch\", label: \"Dispatch\" }, null] } } },\n }, { presets: [{ id: \"leads\", name: \"Leads\", where: { people: { position: [\"lead\", \"deputy\", \"acting\"] } } }] }));\n const firms = $.let(Data.bind(rosterAgencies));\n const times = $.let(Data.bind(rosterShiftTimes));\n const teams = $.let(Data.bind(rosterTeams));\n const roles = $.let(Data.bind(rosterPositions));\n const ideas = $.let(Data.bind(rosterSuggestions));\n // The warehouse's week patterns: the cards of the Patterns tab, each dropped on a person's week.\n const weekPatterns = $.let(Data.bind(rosterPatterns));\n return <Box width=\"100%\" height=\"760px\"><Roster id=\"rosterPeople\" week={{ start: \"sunday\" }} slice={{ slice }} inspector\n view={{ layout: \"people\", period: \"week\", date: new Date(\"2028-03-09T00:00:00Z\") }}\n tileTimes=\"different\"\n events={{ duty: Schedule.events(rota, {\n name: \"Duty\", icon: \"user-clock\", entries,\n start: \"start\", end: \"end\", resource: { field: \"who\", of: { staff: \"people\", agency: \"agencies\" } },\n shift: \"shift\", group: \"team\", position: \"role\", activity: \"task\",\n hours: d => d.start.durationMinutes(d.end).subtract(d.unpaidBreak).divide(60.0),\n }) }}\n resources={{\n people: Schedule.resources(people.read(), { name: \"People\", icon: \"user\", label: p => p.name, group: p => p.team,\n position: p => p.position, skills: p => p.skills, contract: p => p.contract, agency: p => p.agency,\n trainer: p => p.trainer, trainee: p => p.trainee, usual: p => p.usual }),\n agencies: Schedule.resources(firms.read(), { name: \"Agencies\", icon: \"building\", label: a => a.name }),\n }}\n periods={Schedule.periods(weeks, { every: \"week\", status: { field: \"state\", draft: \"open\", published: \"issued\" }, dismissed: \"dismissed\" })}\n targets={Roster.targets(cover, { day: \"day\", group: \"team\", shift: \"shift\", positions: \"heads\", hours: \"hours\" })}\n // Each shift's colour token, the warehouse's own: the tiles' and the marks' fill.\n shifts={Roster.shifts(times.read(), { label: s => s.label, code: s => s.code, start: s => s.start, hours: s => s.hours, order: s => s.order, color: s => s.colour })}\n groups={Roster.groups(teams.read(), { label: t => t.label, order: t => t.order })}\n positions={Roster.positions(roles.read(), { label: p => p.label, code: p => p.code, lead: p => p.lead, order: p => p.order })}\n activities={Roster.activities(acts.read(), { label: a => a.label, code: a => a.code, group: a => a.group, order: a => a.order })}\n proposals={Roster.proposals(ideas.read(), { person: s => s.person, day: s => s.day, group: s => s.team, shift: s => s.shift, reason: s => s.why })}\n patterns={Roster.patterns(weekPatterns.read(), { name: \"Patterns\", icon: \"calendar-week\", label: w => w.label, days: w => w.days, order: w => w.order })}\n rules={{ rest: 10.0 }}\n library={[Roster.library.people(), Roster.library.patterns(), Roster.library.activities(), Roster.library.tab(roles.read(), {\n name: \"Positions\", icon: \"id-badge\", label: p => p.label, meta: p => some(p.code),\n drop: (_p, key) => Schedule.patch(WarehouseDuty, { role: key }),\n })]} />\n </Box>;\n }}</Reactive>)"
45403
+ "source": "// The People layout by week over the same records (#1406): a row per person under their group's band, a tile per duty in each day cell in the shift's colour token — its hours only where a duty's own times differ (tileTimes=\"different\") — the week's hours and a meter in the name cell, `+ Assign` on an off day opening a menu of the home group's shifts, and the warehouse's week patterns in a Patterns tab, each dropped on a person's week as one undo step, a day it makes a duty of taking the app's `values` — the pattern named in its note; the agency's requests their own row.\n// inputs: []\n/** The duties, both weeks', each the warehouse's own row. */\nexport const rosterDuties = e3.record(\"roster_duties\", DictType(StringType, WarehouseDuty), {\n initial: warehouseDuties,\n indexes: (index) => ({\n // The duties by their times: what the Roster's slice reads a week of them through, its navigation writing the range.\n roster_duties_by_time: index.interval({ from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The weeks of the rota: the one before issued, this one open. */\nexport const rosterWeeks = e3.record(\"roster_rota_weeks\", DictType(DateTimeType, WarehouseWeek), {\n initial: warehouseWeeks,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The cover targets, a row per slot: the week before's, this week's and the forecast's for the week after. */\nexport const rosterCover = e3.record(\"roster_cover\", DictType(StringType, WarehouseCover), {\n initial: warehouseCover,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The suggestions: someone for a slot, and why. */\nexport const rosterSuggestions = e3.record(\"roster_suggestions\", DictType(StringType, WarehouseSuggestion), {\n initial: warehouseSuggestions,\n mutations: (mutation) => ({\n // The suggestions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterStaff = e3.record(\"roster_staff\", DictType(StringType, WarehousePerson), {\n initial: warehousePeople,\n indexes: (index) => ({\n // The rail's fields, each on an index of its own: the staff by group then name, position, trainer, agency, skill and name, the activities by group.\n roster_staff_by_team_name: index.on([\"team\", \"name\"]),\n roster_staff_by_position: index.on([\"position\"]),\n roster_staff_by_trainer: index.on([\"trainer\"]),\n roster_staff_by_agency: index.on([\"agency\"]),\n roster_staff_by_skill: index.on([\"skills\"]),\n roster_staff_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // What the renderer's tests on e3 write and ask beside the examples (#1376): another session's edits of the\n // reference data, a roster the warehouse has locked, and another app's fit over the same staff.\n // The staff's patch door: another session's edit of the staff.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterAgencies = e3.record(\"roster_agencies\", DictType(StringType, WarehouseAgency), { initial: warehouseAgencies });\n\nexport const rosterShiftTimes = e3.record(\"roster_shift_times\", DictType(StringType, WarehouseShift), {\n initial: warehouseShifts,\n mutations: (mutation) => ({\n // The shift times' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterTeams = e3.record(\"roster_teams\", DictType(StringType, WarehouseTeam), {\n initial: warehouseTeams,\n mutations: (mutation) => ({\n // The teams' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterPositions = e3.record(\"roster_positions\", DictType(StringType, WarehousePosition), {\n initial: warehousePositions,\n mutations: (mutation) => ({\n // The positions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\n/** Every activity by its key: each group's skills, and the duty of none (#1342). */\nexport const rosterActivities = e3.record(\"roster_activities\", DictType(StringType, WarehouseActivity), {\n initial: warehouseActivities,\n indexes: (index) => ({\n roster_activities_by_group: index.on([\"group\"]),\n }),\n});\n\n/** The week patterns (#1406): the thirteen a planner drops on a person's week, the warehouse's own record. */\nexport const rosterPatterns = e3.record(\"roster_week_patterns\", DictType(StringType, WarehousePattern), {\n initial: warehousePatterns,\n mutations: (mutation) => ({\n // The week patterns' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const rota = $.let(Record.bind(rosterDuties));\n const entries = $.let(Data.bindPaged(rosterDuties));\n const byTime = $.let(Data.bindPaged(rosterDuties, { indexes: [\"roster_duties_by_time\"] }));\n const weeks = $.let(Record.bind(rosterWeeks));\n const cover = $.let(Record.bind(rosterCover));\n // Every person and activity is the calculation scope; the narrowing only chooses which show (#1342).\n const people = $.let(Data.bind(rosterStaff));\n const acts = $.let(Data.bind(rosterActivities));\n const staffIndex = $.let(Data.bindPaged(rosterStaff, { indexes: [\"roster_staff_by_team_name\", \"roster_staff_by_position\", \"roster_staff_by_trainer\", \"roster_staff_by_agency\", \"roster_staff_by_skill\", \"roster_staff_by_name\"] }));\n const actIndex = $.let(Data.bindPaged(rosterActivities, { indexes: [\"roster_activities_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.rosterPeople\", {\n duty: { source: byTime, range: \"start\" },\n people: { source: staffIndex, icon: { prefix: \"fas\", name: \"user\" }, search: [\"name\", \"skills\"],\n fields: { team: { label: \"Group\", hints: [{ value: \"inbound\", label: \"Inbound\" }, { value: \"picking\", label: \"Picking\" }, { value: \"dispatch\", label: \"Dispatch\" }] }, position: { label: \"Position\", hints: [{ value: \"lead\", label: \"Lead\" }, { value: \"deputy\", label: \"Deputy\" }, { value: \"acting\", label: \"Acting\" }, { value: \"crew\", label: \"Crew\" }] },\n trainer: { label: \"Trainer\" }, agency: { label: \"Agency\" }, skills: { label: \"Skill\" }, name: { label: \"Name\" } } },\n activities: { source: actIndex, icon: { prefix: \"fas\", name: \"list-check\" }, fields: { group: { label: \"Group\", hints: [{ value: \"inbound\", label: \"Inbound\" }, { value: \"picking\", label: \"Picking\" }, { value: \"dispatch\", label: \"Dispatch\" }, null] } } },\n }, { presets: [{ id: \"leads\", name: \"Leads\", where: { people: { position: [\"lead\", \"deputy\", \"acting\"] } } }] }));\n const firms = $.let(Data.bind(rosterAgencies));\n const times = $.let(Data.bind(rosterShiftTimes));\n const teams = $.let(Data.bind(rosterTeams));\n // Each team's cost centre: what a new duty of the team is booked to.\n const centres = $.const(teams.read().map((_$2, team) => team.costCentre));\n const roles = $.let(Data.bind(rosterPositions));\n const ideas = $.let(Data.bind(rosterSuggestions));\n // The warehouse's week patterns: the cards of the Patterns tab, each dropped on a person's week.\n const weekPatterns = $.let(Data.bind(rosterPatterns));\n // The patterns by key: what a duty a pattern made is noted with.\n const named = $.const(weekPatterns.read());\n return <Box width=\"100%\" height=\"760px\"><Roster id=\"rosterPeople\" week={{ start: \"sunday\" }} slice={{ slice }} inspector\n view={{ layout: \"people\", period: \"week\", date: new Date(\"2028-03-09T00:00:00Z\") }}\n tileTimes=\"different\"\n events={{ duty: Schedule.events(rota, {\n name: \"Duty\", icon: \"user-clock\", entries,\n start: \"start\", end: \"end\", resource: { field: \"who\", of: { staff: \"people\", agency: \"agencies\" } },\n shift: \"shift\", group: \"team\", position: \"role\", activity: \"task\",\n hours: d => d.start.durationMinutes(d.end).subtract(d.unpaidBreak).divide(60.0),\n // A new duty's own fields, the app's: half an hour's break on a shift over six hours, its team's cost centre, and\n // the name of the pattern that made it, where one did.\n values: d => ({\n unpaidBreak: d.hours.greaterThan(6.0).ifElse(() => 30.0, () => 0.0),\n agreed: none,\n costCentre: d.group.match({ some: (_$2, team) => centres.get(team, () => \"\"), none: () => \"\" }),\n note: d.pattern.match({ some: (_$2, key) => named.get(key).label, none: () => \"\" }),\n }),\n }) }}\n resources={{\n people: Schedule.resources(people.read(), { name: \"People\", icon: \"user\", label: p => p.name, group: p => p.team,\n position: p => p.position, skills: p => p.skills, contract: p => p.contract, agency: p => p.agency,\n trainer: p => p.trainer, trainee: p => p.trainee, usual: p => p.usual }),\n agencies: Schedule.resources(firms.read(), { name: \"Agencies\", icon: \"building\", label: a => a.name }),\n }}\n periods={Schedule.periods(weeks, { every: \"week\", status: { field: \"state\", draft: \"open\", published: \"issued\" }, dismissed: \"dismissed\" })}\n targets={Roster.targets(cover, { day: \"day\", group: \"team\", shift: \"shift\", positions: \"heads\", hours: \"hours\" })}\n // Each shift's colour token, the warehouse's own: the tiles' and the marks' fill.\n shifts={Roster.shifts(times.read(), { label: s => s.label, code: s => s.code, start: s => s.start, hours: s => s.hours, order: s => s.order, color: s => s.colour })}\n groups={Roster.groups(teams.read(), { label: t => t.label, order: t => t.order })}\n positions={Roster.positions(roles.read(), { label: p => p.label, code: p => p.code, lead: p => p.lead, order: p => p.order })}\n activities={Roster.activities(acts.read(), { label: a => a.label, code: a => a.code, group: a => a.group, order: a => a.order })}\n proposals={Roster.proposals(ideas.read(), { person: s => s.person, day: s => s.day, group: s => s.team, shift: s => s.shift, reason: s => s.why })}\n patterns={Roster.patterns(weekPatterns.read(), { name: \"Patterns\", icon: \"calendar-week\", label: w => w.label, days: w => w.days, order: w => w.order })}\n rules={{ rest: 10.0 }}\n library={[Roster.library.people(), Roster.library.patterns(), Roster.library.activities(), Roster.library.tab(roles.read(), {\n name: \"Positions\", icon: \"id-badge\", label: p => p.label, meta: p => some(p.code),\n drop: (_p, key) => Schedule.patch(WarehouseDuty, { role: key }),\n })]} />\n </Box>;\n }}</Reactive>)"
44509
45404
  },
44510
45405
  {
44511
45406
  "id": "e3-ui:roster.examples.tsx:rosterPeopleMonth",
@@ -44546,6 +45441,91 @@
44546
45441
  ],
44547
45442
  "source": "// The People layout by month (#1406): a column per week touching the month, four to six, each cell seven marks in the shifts' colours lettered where a day is wide enough; a column's header opens its week, a cell's click selects the person-week the inspector's Details then read, and a pattern dropped on a cell replaces that week as one undo step. Week · Month in the Period segment; ‹ › step a month.\n// inputs: []\n/** The duties, both weeks', each the warehouse's own row. */\nexport const rosterDuties = e3.record(\"roster_duties\", DictType(StringType, WarehouseDuty), {\n initial: warehouseDuties,\n indexes: (index) => ({\n // The duties by their times: what the Roster's slice reads a week of them through, its navigation writing the range.\n roster_duties_by_time: index.interval({ from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The weeks of the rota: the one before issued, this one open. */\nexport const rosterWeeks = e3.record(\"roster_rota_weeks\", DictType(DateTimeType, WarehouseWeek), {\n initial: warehouseWeeks,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The cover targets, a row per slot: the week before's, this week's and the forecast's for the week after. */\nexport const rosterCover = e3.record(\"roster_cover\", DictType(StringType, WarehouseCover), {\n initial: warehouseCover,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The suggestions: someone for a slot, and why. */\nexport const rosterSuggestions = e3.record(\"roster_suggestions\", DictType(StringType, WarehouseSuggestion), {\n initial: warehouseSuggestions,\n mutations: (mutation) => ({\n // The suggestions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterStaff = e3.record(\"roster_staff\", DictType(StringType, WarehousePerson), {\n initial: warehousePeople,\n indexes: (index) => ({\n // The rail's fields, each on an index of its own: the staff by group then name, position, trainer, agency, skill and name, the activities by group.\n roster_staff_by_team_name: index.on([\"team\", \"name\"]),\n roster_staff_by_position: index.on([\"position\"]),\n roster_staff_by_trainer: index.on([\"trainer\"]),\n roster_staff_by_agency: index.on([\"agency\"]),\n roster_staff_by_skill: index.on([\"skills\"]),\n roster_staff_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // What the renderer's tests on e3 write and ask beside the examples (#1376): another session's edits of the\n // reference data, a roster the warehouse has locked, and another app's fit over the same staff.\n // The staff's patch door: another session's edit of the staff.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterAgencies = e3.record(\"roster_agencies\", DictType(StringType, WarehouseAgency), { initial: warehouseAgencies });\n\nexport const rosterShiftTimes = e3.record(\"roster_shift_times\", DictType(StringType, WarehouseShift), {\n initial: warehouseShifts,\n mutations: (mutation) => ({\n // The shift times' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterTeams = e3.record(\"roster_teams\", DictType(StringType, WarehouseTeam), {\n initial: warehouseTeams,\n mutations: (mutation) => ({\n // The teams' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterPositions = e3.record(\"roster_positions\", DictType(StringType, WarehousePosition), {\n initial: warehousePositions,\n mutations: (mutation) => ({\n // The positions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\n/** Every activity by its key: each group's skills, and the duty of none (#1342). */\nexport const rosterActivities = e3.record(\"roster_activities\", DictType(StringType, WarehouseActivity), {\n initial: warehouseActivities,\n indexes: (index) => ({\n roster_activities_by_group: index.on([\"group\"]),\n }),\n});\n\n/** The week patterns (#1406): the thirteen a planner drops on a person's week, the warehouse's own record. */\nexport const rosterPatterns = e3.record(\"roster_week_patterns\", DictType(StringType, WarehousePattern), {\n initial: warehousePatterns,\n mutations: (mutation) => ({\n // The week patterns' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const rota = $.let(Record.bind(rosterDuties));\n const entries = $.let(Data.bindPaged(rosterDuties));\n const byTime = $.let(Data.bindPaged(rosterDuties, { indexes: [\"roster_duties_by_time\"] }));\n const weeks = $.let(Record.bind(rosterWeeks));\n const cover = $.let(Record.bind(rosterCover));\n const people = $.let(Data.bind(rosterStaff));\n const acts = $.let(Data.bind(rosterActivities));\n const staffIndex = $.let(Data.bindPaged(rosterStaff, { indexes: [\"roster_staff_by_team_name\", \"roster_staff_by_position\", \"roster_staff_by_trainer\", \"roster_staff_by_agency\", \"roster_staff_by_skill\", \"roster_staff_by_name\"] }));\n const actIndex = $.let(Data.bindPaged(rosterActivities, { indexes: [\"roster_activities_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.rosterPeopleMonth\", {\n duty: { source: byTime, range: \"start\" },\n people: { source: staffIndex, icon: { prefix: \"fas\", name: \"user\" }, search: [\"name\", \"skills\"],\n fields: { team: { label: \"Group\", hints: [{ value: \"inbound\", label: \"Inbound\" }, { value: \"picking\", label: \"Picking\" }, { value: \"dispatch\", label: \"Dispatch\" }] }, position: { label: \"Position\", hints: [{ value: \"lead\", label: \"Lead\" }, { value: \"deputy\", label: \"Deputy\" }, { value: \"acting\", label: \"Acting\" }, { value: \"crew\", label: \"Crew\" }] },\n trainer: { label: \"Trainer\" }, agency: { label: \"Agency\" }, skills: { label: \"Skill\" }, name: { label: \"Name\" } } },\n activities: { source: actIndex, icon: { prefix: \"fas\", name: \"list-check\" }, fields: { group: { label: \"Group\", hints: [{ value: \"inbound\", label: \"Inbound\" }, { value: \"picking\", label: \"Picking\" }, { value: \"dispatch\", label: \"Dispatch\" }, null] } } },\n }, { presets: [{ id: \"leads\", name: \"Leads\", where: { people: { position: [\"lead\", \"deputy\", \"acting\"] } } }] }));\n const firms = $.let(Data.bind(rosterAgencies));\n const times = $.let(Data.bind(rosterShiftTimes));\n const teams = $.let(Data.bind(rosterTeams));\n const roles = $.let(Data.bind(rosterPositions));\n const ideas = $.let(Data.bind(rosterSuggestions));\n const weekPatterns = $.let(Data.bind(rosterPatterns));\n return <Box width=\"100%\" height=\"760px\"><Roster id=\"rosterPeopleMonth\" week={{ start: \"sunday\" }} slice={{ slice }} inspector\n view={{ layout: \"people\", period: \"month\", date: new Date(\"2028-03-09T00:00:00Z\") }}\n letters\n events={{ duty: Schedule.events(rota, {\n name: \"Duty\", icon: \"user-clock\", entries,\n start: \"start\", end: \"end\", resource: { field: \"who\", of: { staff: \"people\", agency: \"agencies\" } },\n shift: \"shift\", group: \"team\", position: \"role\", activity: \"task\",\n hours: d => d.start.durationMinutes(d.end).subtract(d.unpaidBreak).divide(60.0),\n }) }}\n resources={{\n people: Schedule.resources(people.read(), { name: \"People\", icon: \"user\", label: p => p.name, group: p => p.team,\n position: p => p.position, skills: p => p.skills, contract: p => p.contract, agency: p => p.agency,\n trainer: p => p.trainer, trainee: p => p.trainee, usual: p => p.usual }),\n agencies: Schedule.resources(firms.read(), { name: \"Agencies\", icon: \"building\", label: a => a.name }),\n }}\n periods={Schedule.periods(weeks, { every: \"week\", status: { field: \"state\", draft: \"open\", published: \"issued\" }, dismissed: \"dismissed\" })}\n targets={Roster.targets(cover, { day: \"day\", group: \"team\", shift: \"shift\", positions: \"heads\", hours: \"hours\" })}\n shifts={Roster.shifts(times.read(), { label: s => s.label, code: s => s.code, start: s => s.start, hours: s => s.hours, order: s => s.order, color: s => s.colour })}\n groups={Roster.groups(teams.read(), { label: t => t.label, order: t => t.order })}\n positions={Roster.positions(roles.read(), { label: p => p.label, code: p => p.code, lead: p => p.lead, order: p => p.order })}\n activities={Roster.activities(acts.read(), { label: a => a.label, code: a => a.code, group: a => a.group, order: a => a.order })}\n proposals={Roster.proposals(ideas.read(), { person: s => s.person, day: s => s.day, group: s => s.team, shift: s => s.shift, reason: s => s.why })}\n patterns={Roster.patterns(weekPatterns.read(), { name: \"Patterns\", icon: \"calendar-week\", label: w => w.label, days: w => w.days, order: w => w.order })}\n rules={{ rest: 10.0 }}\n library={[Roster.library.people(), Roster.library.patterns(), Roster.library.activities()]} />\n </Box>;\n }}</Reactive>)"
44548
45443
  },
45444
+ {
45445
+ "id": "e3-ui:roster.examples.tsx:rosterPeopleNoBands",
45446
+ "skill": "e3-ui",
45447
+ "package": "e3-ui",
45448
+ "file": "east-ui/packages/e3-ui/test/roster/roster.examples.tsx",
45449
+ "suite": "",
45450
+ "test": "The People layout by week without its groups' bands (peopleBands={false}, #1567): every person the rail shows in one list — the leads, then the rest, then agency staff — with no band to fold, and every group's agency requests in one row at its foot, each request naming its group. A person keeps their home group: `+ Assign` offers its shifts, and a Find's needs, the fit and the optimiser read it. Shifts keeps its bands, which are its slots.",
45451
+ "keywords": [
45452
+ "Roster",
45453
+ "peopleBands",
45454
+ "people",
45455
+ "week",
45456
+ "list",
45457
+ "bands",
45458
+ "Schedule.events",
45459
+ "Schedule.resources",
45460
+ "Schedule.periods",
45461
+ "Roster.targets",
45462
+ "Roster.shifts",
45463
+ "Slice",
45464
+ "Slice.bindRecords",
45465
+ "Data.bindPaged",
45466
+ "BuilderFrame",
45467
+ "Save",
45468
+ "Publish"
45469
+ ],
45470
+ "imports": [
45471
+ "import {",
45472
+ "import e3 from \"@elaraai/e3\";",
45473
+ "import { Box, Button, Field, HStack, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
45474
+ "import { Data, Func, Record, Roster, Schedule } from \"@elaraai/e3-ui\";",
45475
+ "import {"
45476
+ ],
45477
+ "languages": [
45478
+ "tsx"
45479
+ ],
45480
+ "source": "// The People layout by week without its groups' bands (peopleBands={false}, #1567): every person the rail shows in one list — the leads, then the rest, then agency staff — with no band to fold, and every group's agency requests in one row at its foot, each request naming its group. A person keeps their home group: `+ Assign` offers its shifts, and a Find's needs, the fit and the optimiser read it. Shifts keeps its bands, which are its slots.\n// inputs: []\n/** The duties, both weeks', each the warehouse's own row. */\nexport const rosterDuties = e3.record(\"roster_duties\", DictType(StringType, WarehouseDuty), {\n initial: warehouseDuties,\n indexes: (index) => ({\n // The duties by their times: what the Roster's slice reads a week of them through, its navigation writing the range.\n roster_duties_by_time: index.interval({ from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The weeks of the rota: the one before issued, this one open. */\nexport const rosterWeeks = e3.record(\"roster_rota_weeks\", DictType(DateTimeType, WarehouseWeek), {\n initial: warehouseWeeks,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The cover targets, a row per slot: the week before's, this week's and the forecast's for the week after. */\nexport const rosterCover = e3.record(\"roster_cover\", DictType(StringType, WarehouseCover), {\n initial: warehouseCover,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The suggestions: someone for a slot, and why. */\nexport const rosterSuggestions = e3.record(\"roster_suggestions\", DictType(StringType, WarehouseSuggestion), {\n initial: warehouseSuggestions,\n mutations: (mutation) => ({\n // The suggestions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterStaff = e3.record(\"roster_staff\", DictType(StringType, WarehousePerson), {\n initial: warehousePeople,\n indexes: (index) => ({\n // The rail's fields, each on an index of its own: the staff by group then name, position, trainer, agency, skill and name, the activities by group.\n roster_staff_by_team_name: index.on([\"team\", \"name\"]),\n roster_staff_by_position: index.on([\"position\"]),\n roster_staff_by_trainer: index.on([\"trainer\"]),\n roster_staff_by_agency: index.on([\"agency\"]),\n roster_staff_by_skill: index.on([\"skills\"]),\n roster_staff_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // What the renderer's tests on e3 write and ask beside the examples (#1376): another session's edits of the\n // reference data, a roster the warehouse has locked, and another app's fit over the same staff.\n // The staff's patch door: another session's edit of the staff.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterAgencies = e3.record(\"roster_agencies\", DictType(StringType, WarehouseAgency), { initial: warehouseAgencies });\n\nexport const rosterShiftTimes = e3.record(\"roster_shift_times\", DictType(StringType, WarehouseShift), {\n initial: warehouseShifts,\n mutations: (mutation) => ({\n // The shift times' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterTeams = e3.record(\"roster_teams\", DictType(StringType, WarehouseTeam), {\n initial: warehouseTeams,\n mutations: (mutation) => ({\n // The teams' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterPositions = e3.record(\"roster_positions\", DictType(StringType, WarehousePosition), {\n initial: warehousePositions,\n mutations: (mutation) => ({\n // The positions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\n/** Every activity by its key: each group's skills, and the duty of none (#1342). */\nexport const rosterActivities = e3.record(\"roster_activities\", DictType(StringType, WarehouseActivity), {\n initial: warehouseActivities,\n indexes: (index) => ({\n roster_activities_by_group: index.on([\"group\"]),\n }),\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const rota = $.let(Record.bind(rosterDuties));\n const entries = $.let(Data.bindPaged(rosterDuties));\n const byTime = $.let(Data.bindPaged(rosterDuties, { indexes: [\"roster_duties_by_time\"] }));\n const weeks = $.let(Record.bind(rosterWeeks));\n const cover = $.let(Record.bind(rosterCover));\n // Every person and activity is the calculation scope; the narrowing only chooses which show (#1342).\n const people = $.let(Data.bind(rosterStaff));\n const acts = $.let(Data.bind(rosterActivities));\n const staffIndex = $.let(Data.bindPaged(rosterStaff, { indexes: [\"roster_staff_by_team_name\", \"roster_staff_by_position\", \"roster_staff_by_trainer\", \"roster_staff_by_agency\", \"roster_staff_by_skill\", \"roster_staff_by_name\"] }));\n const actIndex = $.let(Data.bindPaged(rosterActivities, { indexes: [\"roster_activities_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.rosterPeopleNoBands\", {\n duty: { source: byTime, range: \"start\" },\n people: { source: staffIndex, icon: { prefix: \"fas\", name: \"user\" }, search: [\"name\", \"skills\"],\n fields: { team: { label: \"Group\", hints: [{ value: \"inbound\", label: \"Inbound\" }, { value: \"picking\", label: \"Picking\" }, { value: \"dispatch\", label: \"Dispatch\" }] }, position: { label: \"Position\", hints: [{ value: \"lead\", label: \"Lead\" }, { value: \"deputy\", label: \"Deputy\" }, { value: \"acting\", label: \"Acting\" }, { value: \"crew\", label: \"Crew\" }] },\n trainer: { label: \"Trainer\" }, agency: { label: \"Agency\" }, skills: { label: \"Skill\" }, name: { label: \"Name\" } } },\n activities: { source: actIndex, icon: { prefix: \"fas\", name: \"list-check\" }, fields: { group: { label: \"Group\", hints: [{ value: \"inbound\", label: \"Inbound\" }, { value: \"picking\", label: \"Picking\" }, { value: \"dispatch\", label: \"Dispatch\" }, null] } } },\n }, { presets: [{ id: \"leads\", name: \"Leads\", where: { people: { position: [\"lead\", \"deputy\", \"acting\"] } } }] }));\n const firms = $.let(Data.bind(rosterAgencies));\n const times = $.let(Data.bind(rosterShiftTimes));\n const teams = $.let(Data.bind(rosterTeams));\n const roles = $.let(Data.bind(rosterPositions));\n const ideas = $.let(Data.bind(rosterSuggestions));\n return <Box width=\"100%\" height=\"760px\"><Roster id=\"rosterPeopleNoBands\" week={{ start: \"sunday\" }} slice={{ slice }} inspector\n view={{ layout: \"people\", period: \"week\", date: new Date(\"2028-03-09T00:00:00Z\") }}\n // Everyone in one list: no group's band over its people.\n peopleBands={false}\n events={{ duty: Schedule.events(rota, {\n name: \"Duty\", icon: \"user-clock\", entries,\n start: \"start\", end: \"end\", resource: { field: \"who\", of: { staff: \"people\", agency: \"agencies\" } },\n shift: \"shift\", group: \"team\", position: \"role\", activity: \"task\",\n hours: d => d.start.durationMinutes(d.end).subtract(d.unpaidBreak).divide(60.0),\n }) }}\n resources={{\n people: Schedule.resources(people.read(), { name: \"People\", icon: \"user\", label: p => p.name, group: p => p.team,\n position: p => p.position, skills: p => p.skills, contract: p => p.contract, agency: p => p.agency,\n trainer: p => p.trainer, trainee: p => p.trainee, usual: p => p.usual }),\n agencies: Schedule.resources(firms.read(), { name: \"Agencies\", icon: \"building\", label: a => a.name }),\n }}\n periods={Schedule.periods(weeks, { every: \"week\", status: { field: \"state\", draft: \"open\", published: \"issued\" }, dismissed: \"dismissed\" })}\n targets={Roster.targets(cover, { day: \"day\", group: \"team\", shift: \"shift\", positions: \"heads\", hours: \"hours\" })}\n shifts={Roster.shifts(times.read(), { label: s => s.label, code: s => s.code, start: s => s.start, hours: s => s.hours, order: s => s.order, color: s => s.colour })}\n groups={Roster.groups(teams.read(), { label: t => t.label, order: t => t.order })}\n positions={Roster.positions(roles.read(), { label: p => p.label, code: p => p.code, lead: p => p.lead, order: p => p.order })}\n activities={Roster.activities(acts.read(), { label: a => a.label, code: a => a.code, group: a => a.group, order: a => a.order })}\n proposals={Roster.proposals(ideas.read(), { person: s => s.person, day: s => s.day, group: s => s.team, shift: s => s.shift, reason: s => s.why })}\n rules={{ rest: 10.0 }}\n library={[Roster.library.people(), Roster.library.activities()]} />\n </Box>;\n }}</Reactive>)"
45481
+ },
45482
+ {
45483
+ "id": "e3-ui:roster.examples.tsx:rosterWorkRequirement",
45484
+ "skill": "e3-ui",
45485
+ "package": "e3-ui",
45486
+ "file": "east-ui/packages/e3-ui/test/roster/roster.examples.tsx",
45487
+ "suite": "",
45488
+ "test": "The People layout by week with the warehouse's cover targets (#1568): under each group's band, its work requirement — a lane a shift with a target, its week's hours rostered against those needed, and each day's figures over a bar in the coverage marks, `no target` where none of the day's slots has one — each lane opening to its skill rows, then its people. Deep in a group's people, its band and its work requirement stay under the header until the next group's band pushes them out, an open lane's skill rows scrolling with the people once the block passes half the view. A lane's day opens its slot in the inspector. By month (the Period's Month), the eyebrow says each week's hours and a lane's day is a cup on the person marks' columns, filled to its hours rostered of needed in its bar's colours — the requests on top, what a short day lacks dashed above them, empty with no target — a cup opening its slot in its week. On a phone, before each group's people's cards, a card a day holds each shift's hours rostered of needed over its bar, a line opening its slot. Rostered counts every duty, agency requests included; the band sums its group's week, or the month's weeks. The heading is `vocabulary.demand`; `requirements={false}` draws the People layout without it.",
45489
+ "keywords": [
45490
+ "Roster",
45491
+ "requirements",
45492
+ "work requirement",
45493
+ "demand",
45494
+ "targets",
45495
+ "cover",
45496
+ "lanes",
45497
+ "skills",
45498
+ "hours",
45499
+ "people",
45500
+ "week",
45501
+ "month",
45502
+ "marks",
45503
+ "phone",
45504
+ "cards",
45505
+ "Roster.targets",
45506
+ "Schedule.events",
45507
+ "Schedule.resources",
45508
+ "Schedule.periods",
45509
+ "Roster.shifts",
45510
+ "Slice",
45511
+ "Slice.bindRecords",
45512
+ "Data.bindPaged",
45513
+ "BuilderFrame",
45514
+ "Save",
45515
+ "Publish"
45516
+ ],
45517
+ "imports": [
45518
+ "import {",
45519
+ "import e3 from \"@elaraai/e3\";",
45520
+ "import { Box, Button, Field, HStack, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
45521
+ "import { Data, Func, Record, Roster, Schedule } from \"@elaraai/e3-ui\";",
45522
+ "import {"
45523
+ ],
45524
+ "languages": [
45525
+ "tsx"
45526
+ ],
45527
+ "source": "// The People layout by week with the warehouse's cover targets (#1568): under each group's band, its work requirement — a lane a shift with a target, its week's hours rostered against those needed, and each day's figures over a bar in the coverage marks, `no target` where none of the day's slots has one — each lane opening to its skill rows, then its people. Deep in a group's people, its band and its work requirement stay under the header until the next group's band pushes them out, an open lane's skill rows scrolling with the people once the block passes half the view. A lane's day opens its slot in the inspector. By month (the Period's Month), the eyebrow says each week's hours and a lane's day is a cup on the person marks' columns, filled to its hours rostered of needed in its bar's colours — the requests on top, what a short day lacks dashed above them, empty with no target — a cup opening its slot in its week. On a phone, before each group's people's cards, a card a day holds each shift's hours rostered of needed over its bar, a line opening its slot. Rostered counts every duty, agency requests included; the band sums its group's week, or the month's weeks. The heading is `vocabulary.demand`; `requirements={false}` draws the People layout without it.\n// inputs: []\n/** The duties, both weeks', each the warehouse's own row. */\nexport const rosterDuties = e3.record(\"roster_duties\", DictType(StringType, WarehouseDuty), {\n initial: warehouseDuties,\n indexes: (index) => ({\n // The duties by their times: what the Roster's slice reads a week of them through, its navigation writing the range.\n roster_duties_by_time: index.interval({ from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The weeks of the rota: the one before issued, this one open. */\nexport const rosterWeeks = e3.record(\"roster_rota_weeks\", DictType(DateTimeType, WarehouseWeek), {\n initial: warehouseWeeks,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The cover targets, a row per slot: the week before's, this week's and the forecast's for the week after. */\nexport const rosterCover = e3.record(\"roster_cover\", DictType(StringType, WarehouseCover), {\n initial: warehouseCover,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterStaff = e3.record(\"roster_staff\", DictType(StringType, WarehousePerson), {\n initial: warehousePeople,\n indexes: (index) => ({\n // The rail's fields, each on an index of its own: the staff by group then name, position, trainer, agency, skill and name, the activities by group.\n roster_staff_by_team_name: index.on([\"team\", \"name\"]),\n roster_staff_by_position: index.on([\"position\"]),\n roster_staff_by_trainer: index.on([\"trainer\"]),\n roster_staff_by_agency: index.on([\"agency\"]),\n roster_staff_by_skill: index.on([\"skills\"]),\n roster_staff_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // What the renderer's tests on e3 write and ask beside the examples (#1376): another session's edits of the\n // reference data, a roster the warehouse has locked, and another app's fit over the same staff.\n // The staff's patch door: another session's edit of the staff.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterAgencies = e3.record(\"roster_agencies\", DictType(StringType, WarehouseAgency), { initial: warehouseAgencies });\n\nexport const rosterShiftTimes = e3.record(\"roster_shift_times\", DictType(StringType, WarehouseShift), {\n initial: warehouseShifts,\n mutations: (mutation) => ({\n // The shift times' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterTeams = e3.record(\"roster_teams\", DictType(StringType, WarehouseTeam), {\n initial: warehouseTeams,\n mutations: (mutation) => ({\n // The teams' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterPositions = e3.record(\"roster_positions\", DictType(StringType, WarehousePosition), {\n initial: warehousePositions,\n mutations: (mutation) => ({\n // The positions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\n/** Every activity by its key: each group's skills, and the duty of none (#1342). */\nexport const rosterActivities = e3.record(\"roster_activities\", DictType(StringType, WarehouseActivity), {\n initial: warehouseActivities,\n indexes: (index) => ({\n roster_activities_by_group: index.on([\"group\"]),\n }),\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const rota = $.let(Record.bind(rosterDuties));\n const entries = $.let(Data.bindPaged(rosterDuties));\n const byTime = $.let(Data.bindPaged(rosterDuties, { indexes: [\"roster_duties_by_time\"] }));\n const weeks = $.let(Record.bind(rosterWeeks));\n // The warehouse's cover targets: what each lane's hours needed, and its skill rows, are summed from.\n const cover = $.let(Record.bind(rosterCover));\n // Every person and activity is the calculation scope; the narrowing only chooses which show (#1342).\n const people = $.let(Data.bind(rosterStaff));\n const acts = $.let(Data.bind(rosterActivities));\n const staffIndex = $.let(Data.bindPaged(rosterStaff, { indexes: [\"roster_staff_by_team_name\", \"roster_staff_by_position\", \"roster_staff_by_trainer\", \"roster_staff_by_agency\", \"roster_staff_by_skill\", \"roster_staff_by_name\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.rosterWorkRequirement\", {\n duty: { source: byTime, range: \"start\" },\n people: { source: staffIndex, icon: { prefix: \"fas\", name: \"user\" }, search: [\"name\", \"skills\"],\n fields: { team: { label: \"Group\", hints: [{ value: \"inbound\", label: \"Inbound\" }, { value: \"picking\", label: \"Picking\" }, { value: \"dispatch\", label: \"Dispatch\" }] }, position: { label: \"Position\", hints: [{ value: \"lead\", label: \"Lead\" }, { value: \"deputy\", label: \"Deputy\" }, { value: \"acting\", label: \"Acting\" }, { value: \"crew\", label: \"Crew\" }] },\n trainer: { label: \"Trainer\" }, agency: { label: \"Agency\" }, skills: { label: \"Skill\" }, name: { label: \"Name\" } } },\n }));\n const firms = $.let(Data.bind(rosterAgencies));\n const times = $.let(Data.bind(rosterShiftTimes));\n const teams = $.let(Data.bind(rosterTeams));\n const roles = $.let(Data.bind(rosterPositions));\n return <Box width=\"100%\" height=\"760px\"><Roster id=\"rosterWorkRequirement\" week={{ start: \"sunday\" }} slice={{ slice }} inspector\n view={{ layout: \"people\", period: \"week\", date: new Date(\"2028-03-09T00:00:00Z\") }}\n // The targets against what is rostered: on by default, said here as the layout's work requirement.\n requirements\n events={{ duty: Schedule.events(rota, {\n name: \"Duty\", icon: \"user-clock\", entries,\n start: \"start\", end: \"end\", resource: { field: \"who\", of: { staff: \"people\", agency: \"agencies\" } },\n shift: \"shift\", group: \"team\", position: \"role\", activity: \"task\",\n hours: d => d.start.durationMinutes(d.end).subtract(d.unpaidBreak).divide(60.0),\n }) }}\n resources={{\n people: Schedule.resources(people.read(), { name: \"People\", icon: \"user\", label: p => p.name, group: p => p.team,\n position: p => p.position, skills: p => p.skills, contract: p => p.contract, agency: p => p.agency,\n trainer: p => p.trainer, trainee: p => p.trainee, usual: p => p.usual }),\n agencies: Schedule.resources(firms.read(), { name: \"Agencies\", icon: \"building\", label: a => a.name }),\n }}\n periods={Schedule.periods(weeks, { every: \"week\", status: { field: \"state\", draft: \"open\", published: \"issued\" }, dismissed: \"dismissed\" })}\n targets={Roster.targets(cover, { day: \"day\", group: \"team\", shift: \"shift\", positions: \"heads\", hours: \"hours\" })}\n shifts={Roster.shifts(times.read(), { label: s => s.label, code: s => s.code, start: s => s.start, hours: s => s.hours, order: s => s.order, color: s => s.colour })}\n groups={Roster.groups(teams.read(), { label: t => t.label, order: t => t.order })}\n positions={Roster.positions(roles.read(), { label: p => p.label, code: p => p.code, lead: p => p.lead, order: p => p.order })}\n activities={Roster.activities(acts.read(), { label: a => a.label, code: a => a.code, group: a => a.group, order: a => a.order })}\n rules={{ rest: 10.0 }}\n library={[Roster.library.people(), Roster.library.activities()]} />\n </Box>;\n }}</Reactive>)"
45528
+ },
44549
45529
  {
44550
45530
  "id": "e3-ui:roster.examples.tsx:rosterWeek",
44551
45531
  "skill": "e3-ui",
@@ -44678,6 +45658,43 @@
44678
45658
  ],
44679
45659
  "source": "// Which layouts an instance offers, chosen as the page runs: a multi-select wired into `views`, an expression of an array of Roster.Types.Layout. Choose People alone and Shifts is gone, its button and all; with one layout left no switch shows, and with none chosen, both. `views={[\"people\"]}` writes the same choice in the code. A second multi-select does the same for the periods through `viewPeriods`, each layout keeping its own where the list leaves it none.\n// inputs: []\n/** A duty of the smallest roster: who, as a staff key; when, as worked; its shift and its team. */\nexport const MinimalDuty = StructType({ person: StringType, start: DateTimeType, end: DateTimeType, shift: StringType, team: StringType });\n\n/** One of its staff: a name and a team. */\nexport const MinimalWorker = StructType({ name: StringType, team: StringType });\n\n/** One of its shifts: a name, a code, when it starts, its hours and where it shows. */\nexport const MinimalShiftTime = StructType({ name: StringType, code: StringType, starts: Schedule.Types.Clock, hours: FloatType, order: IntegerType });\n\n/** One of its teams: a name. */\nexport const MinimalTeam = StructType({ name: StringType });\n\nexport const minimalDuties = e3.record(\"rota_minimal_duties\", DictType(StringType, MinimalDuty), {\n initial: new Map([\n [\"d-1\", { person: \"w-01\", start: new Date(\"2028-03-06T06:00:00Z\"), end: new Date(\"2028-03-06T14:00:00Z\"), shift: \"early\", team: \"inbound\" }],\n [\"d-2\", { person: \"w-02\", start: new Date(\"2028-03-06T14:00:00Z\"), end: new Date(\"2028-03-06T22:00:00Z\"), shift: \"late\", team: \"dispatch\" }],\n [\"d-3\", { person: \"w-01\", start: new Date(\"2028-03-07T05:30:00Z\"), end: new Date(\"2028-03-07T14:00:00Z\"), shift: \"early\", team: \"inbound\" }],\n ]),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const minimalWorkers = e3.record(\"rota_minimal_workers\", DictType(StringType, MinimalWorker), {\n initial: new Map([\n [\"w-01\", { name: \"Ada Brook\", team: \"inbound\" }],\n [\"w-02\", { name: \"Tom Vale\", team: \"dispatch\" }],\n ]),\n});\n\nexport const minimalShiftTimes = e3.record(\"rota_minimal_shift_times\", DictType(StringType, MinimalShiftTime), {\n initial: new Map([\n [\"early\", { name: \"Early\", code: \"E\", starts: { hour: 6n, minute: 0n }, hours: 8.0, order: 1n }],\n [\"late\", { name: \"Late\", code: \"L\", starts: { hour: 14n, minute: 0n }, hours: 8.0, order: 2n }],\n ]),\n});\n\nexport const minimalTeams = e3.record(\"rota_minimal_teams\", DictType(StringType, MinimalTeam), {\n initial: new Map([\n [\"inbound\", { name: \"Inbound\" }], [\"dispatch\", { name: \"Dispatch\" }],\n ]),\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const rota = $.let(Record.bind(minimalDuties));\n const staff = $.let(Data.bind(minimalWorkers));\n const times = $.let(Data.bind(minimalShiftTimes));\n const groups = $.let(Data.bind(minimalTeams));\n // The tags the multi-select holds, and the layouts they name.\n const chosen = $.let(State.bind([ArrayType(StringType)], \"ex.rosterViews.views\", []));\n const tags = $.let(chosen.read());\n const onViews = $.const(East.function([ArrayType(StringType)], NullType, ($, next) => { $(chosen.write(next)); }));\n const every = $.const([variant(\"shifts\", null), variant(\"people\", null)], ArrayType(Roster.Types.Layout));\n const views = $.let(every.filter(($, view) => tags.toSet().has(view.getTag())));\n // And the periods.\n const chosenPeriods = $.let(State.bind([ArrayType(StringType)], \"ex.rosterViews.periods\", []));\n const periodTags = $.let(chosenPeriods.read());\n const onPeriods = $.const(East.function([ArrayType(StringType)], NullType, ($, next) => { $(chosenPeriods.write(next)); }));\n const everyPeriod = $.const([variant(\"day\", null), variant(\"week\", null), variant(\"month\", null)], ArrayType(Roster.Types.Period));\n const viewPeriods = $.let(everyPeriod.filter(($, period) => periodTags.toSet().has(period.getTag())));\n return <VStack gap=\"3\" align=\"stretch\" width=\"100%\">\n <HStack gap=\"2\" align=\"center\"><Text>Views</Text><Select value=\"\" placeholder=\"Every view\" multiple={true} onChangeMultiple={onViews}\n items={[Select.Item(\"shifts\", \"Shifts\"), Select.Item(\"people\", \"People\")]} /></HStack>\n <HStack gap=\"2\" align=\"center\"><Text>Periods</Text><Select value=\"\" placeholder=\"Every period\" multiple={true} onChangeMultiple={onPeriods}\n items={[Select.Item(\"day\", \"Day\"), Select.Item(\"week\", \"Week\"), Select.Item(\"month\", \"Month\")]} /></HStack>\n <Box width=\"100%\" height=\"700px\"><Roster id=\"rosterViews\" inspector views={views} viewPeriods={viewPeriods} view={{ date: new Date(\"2028-03-06T00:00:00Z\") }}\n events={{ duty: Schedule.events(rota, {\n name: \"Duty\", icon: \"user-clock\",\n start: \"start\", end: \"end\", resource: { field: \"person\", of: \"people\" },\n shift: \"shift\", group: \"team\",\n }) }}\n resources={{ people: Schedule.resources(staff.read(), { name: \"People\", icon: \"user\", label: w => w.name, group: w => w.team }) }}\n shifts={Roster.shifts(times.read(), { label: s => s.name, code: s => s.code, start: s => s.starts, hours: s => s.hours, order: s => s.order })}\n groups={Roster.groups(groups.read(), { label: t => t.name })} />\n </Box>\n </VStack>;\n }}</Reactive>)"
44680
45660
  },
45661
+ {
45662
+ "id": "e3-ui:roster.examples.tsx:rosterNoGroup",
45663
+ "skill": "e3-ui",
45664
+ "package": "e3-ui",
45665
+ "file": "east-ui/packages/e3-ui/test/roster/roster.examples.tsx",
45666
+ "suite": "",
45667
+ "test": "A roster made in two steps (#1548): the duty's team is an Option<String> field, `none` while it is in no group yet. The first step's week stands in no group — each person's shifts, Monday to Friday — listed under each shift in the No group band after the groups in Shifts, and on its person's row in People, its tile and the inspector saying No group; it counts in its person's hours, contract and rest, and in no group's targets. A drag from the band into a group's slot writes `some(team)`, and one back into the band `none`, each one edit. The Elara eye runs the second step, `optimise` over Roster.Types.OptimiseRequest(NoGroupDuty): each duty in no group to its person's own team where its target has a head open that day and shift, then the rest to any team with one, a duty no team needs left in none — one edit, which one Undo reverts and Save writes through the duties' patch door.",
45668
+ "keywords": [
45669
+ "Roster",
45670
+ "No group",
45671
+ "no group",
45672
+ "two steps",
45673
+ "Option",
45674
+ "OptionType",
45675
+ "group",
45676
+ "Schedule.events",
45677
+ "optimise",
45678
+ "OptimiseRequest",
45679
+ "OptimiseResult",
45680
+ "Func.bind",
45681
+ "e3.function",
45682
+ "Roster.targets",
45683
+ "place",
45684
+ "unplaced"
45685
+ ],
45686
+ "imports": [
45687
+ "import {",
45688
+ "import e3 from \"@elaraai/e3\";",
45689
+ "import { Box, Button, Field, HStack, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
45690
+ "import { Data, Func, Record, Roster, Schedule } from \"@elaraai/e3-ui\";",
45691
+ "import {"
45692
+ ],
45693
+ "languages": [
45694
+ "tsx"
45695
+ ],
45696
+ "source": "// A roster made in two steps (#1548): the duty's team is an Option<String> field, `none` while it is in no group yet. The first step's week stands in no group — each person's shifts, Monday to Friday — listed under each shift in the No group band after the groups in Shifts, and on its person's row in People, its tile and the inspector saying No group; it counts in its person's hours, contract and rest, and in no group's targets. A drag from the band into a group's slot writes `some(team)`, and one back into the band `none`, each one edit. The Elara eye runs the second step, `optimise` over Roster.Types.OptimiseRequest(NoGroupDuty): each duty in no group to its person's own team where its target has a head open that day and shift, then the rest to any team with one, a duty no team needs left in none — one edit, which one Undo reverts and Save writes through the duties' patch door.\n// inputs: []\n/** One of its shifts: a name, a code, when it starts, its hours and where it shows. */\nexport const MinimalShiftTime = StructType({ name: StringType, code: StringType, starts: Schedule.Types.Clock, hours: FloatType, order: IntegerType });\n\n/** One of its teams: a name. */\nexport const MinimalTeam = StructType({ name: StringType });\n\nexport const minimalShiftTimes = e3.record(\"rota_minimal_shift_times\", DictType(StringType, MinimalShiftTime), {\n initial: new Map([\n [\"early\", { name: \"Early\", code: \"E\", starts: { hour: 6n, minute: 0n }, hours: 8.0, order: 1n }],\n [\"late\", { name: \"Late\", code: \"L\", starts: { hour: 14n, minute: 0n }, hours: 8.0, order: 2n }],\n ]),\n});\n\nexport const minimalTeams = e3.record(\"rota_minimal_teams\", DictType(StringType, MinimalTeam), {\n initial: new Map([\n [\"inbound\", { name: \"Inbound\" }], [\"dispatch\", { name: \"Dispatch\" }],\n ]),\n});\n\n/** A duty of a roster made in two steps: who, when and on which shift — and its team, none until it is placed in one. */\nexport const NoGroupDuty = StructType({ person: StringType, start: DateTimeType, end: DateTimeType, shift: StringType, team: OptionType(StringType) });\n\n/** One of its staff: a name, their own team and their contracted hours a week. */\nexport const NoGroupWorker = StructType({ name: StringType, team: StringType, contract: FloatType });\n\n/** One of its targets: a team's heads on a shift of a day, and the hours each activity needs. */\nexport const NoGroupCover = StructType({ day: DateTimeType, team: StringType, shift: StringType, heads: IntegerType, hours: DictType(StringType, FloatType) });\n\nconst NO_GROUP_MONDAY = new Date(\"2028-03-06T00:00:00Z\").getTime();\n\nconst NO_GROUP_HOUR = 3_600_000;\n\nconst NO_GROUP_DAYS = [\"mon\", \"tue\", \"wed\", \"thu\", \"fri\"];\n\n/** The first step's week as rows, by key: the day and the person, every one in no team. */\nexport const noGroupShifts: Map<string, ValueTypeOf<typeof NoGroupDuty>> = new Map();\n\n/** The duties, every one in no team yet: the first step's week. */\nexport const noGroupDuties = e3.record(\"rota_no_group_duties\", DictType(StringType, NoGroupDuty), {\n initial: noGroupShifts,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The staff as rows, by key: three of Inbound's and three of Dispatch's. */\nexport const noGroupStaffRows: Map<string, ValueTypeOf<typeof NoGroupWorker>> = new Map([\n [\"w-01\", { name: \"Ada Brook\", team: \"inbound\", contract: 40.0 }], [\"w-02\", { name: \"Tom Vale\", team: \"dispatch\", contract: 40.0 }],\n [\"w-03\", { name: \"Mia Hart\", team: \"inbound\", contract: 40.0 }], [\"w-04\", { name: \"Sam Reed\", team: \"dispatch\", contract: 40.0 }],\n [\"w-05\", { name: \"Lea Fox\", team: \"inbound\", contract: 40.0 }], [\"w-06\", { name: \"Ben Moss\", team: \"dispatch\", contract: 40.0 }],\n]);\n\nexport const noGroupWorkers = e3.record(\"rota_no_group_staff\", DictType(StringType, NoGroupWorker), { initial: noGroupStaffRows });\n\n/** Each weekday's targets: Inbound two on the early and one on the late, Dispatch one on the early and two on the late. */\nconst noGroupTargets = [[\"inbound\", \"early\", 2n], [\"inbound\", \"late\", 1n], [\"dispatch\", \"early\", 1n], [\"dispatch\", \"late\", 2n]] as const;\n\n/** The targets as rows, by key: the day, the team and the shift. */\nexport const noGroupCoverRows: Map<string, ValueTypeOf<typeof NoGroupCover>> = new Map(NO_GROUP_DAYS.flatMap((name, day) => noGroupTargets.map(([team, shift, heads]) => [\n `${name}-${team}-${shift}`, { day: new Date(NO_GROUP_MONDAY + day * 24 * NO_GROUP_HOUR), team, shift, heads, hours: new Map<string, number>() },\n] as const)));\n\nexport const noGroupCover = e3.record(\"rota_no_group_cover\", DictType(StringType, NoGroupCover), {\n initial: noGroupCoverRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nconst NoGroupRequest = Roster.Types.OptimiseRequest(NoGroupDuty), NoGroupResult = Roster.Types.OptimiseResult(NoGroupDuty);\n\n/**\n * The second step's optimiser: each duty in no team placed in one, against the targets, in two passes over the week as\n * drafted. First each goes to its person's own team, where that team's target has a head open on its day and shift; then\n * each still in none to the first team, in the teams' order, with one open. A duty no team needs stays in none, and every\n * duty already in a team stays where it is.\n */\nexport const rosterPlaceShiftsBody = East.function([NoGroupRequest], NoGroupResult, ($, req) => {\n // Each slot's open heads: its target, less the duties in its team already.\n const open = $.let(req.requirements.map(($2, need) => need.positions));\n $.for(req.duties, ($2, duty) => {\n $2.match(duty.team, { some: ($3, team) => {\n const slot = $3.const({ day: req.from.durationMilliseconds(duty.start).divide(86_400_000n), group: team, shift: duty.shift });\n $3.if(open.has(slot), ($4) => { $4(open.update(slot, open.get(slot).subtract(1n))); });\n } });\n });\n const placed = $.let(req.duties.map(($2, duty) => duty));\n const home = $.const(req.context.people.map(($2, person) => person.group));\n const teams = $.const(req.context.groups.map(($2, group) => group.key));\n // The passes: a person's own team first, then any team.\n const ownTeamFirst = $.const([true, false], ArrayType(BooleanType));\n $.for(ownTeamFirst, ($2, own) => {\n $2.for(req.duties, ($3, duty, key) => {\n $3.match(placed.get(key).team, { none: ($4) => {\n const day = $4.const(req.from.durationMilliseconds(duty.start).divide(86_400_000n));\n const mine = $4.const(home.get(duty.person, () => \"\"));\n const choices = $4.const(teams.filter(($5, team) => own.not().or(() => team.equal(mine))\n .and(() => open.get({ day, group: team, shift: duty.shift }, () => 0n).greater(0n))));\n $4.if(choices.size().greater(0n), ($5) => {\n const slot = $5.const({ day, group: choices.get(0n), shift: duty.shift });\n $5(open.update(slot, open.get(slot).subtract(1n)));\n $5(placed.update(key, { person: duty.person, start: duty.start, end: duty.end, shift: duty.shift, team: some(slot.group) }));\n });\n } });\n });\n });\n return { duties: placed };\n});\n\n/** The second step on e3: the week's duties in, each in no team placed in one against the targets. */\nexport const rotaPlaceShifts = e3.function(\"rota_place_shifts\", rosterPlaceShiftsBody);\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const rota = $.let(Record.bind(noGroupDuties));\n const cover = $.let(Record.bind(noGroupCover));\n const staff = $.let(Data.bind(noGroupWorkers));\n const times = $.let(Data.bind(minimalShiftTimes));\n const groups = $.let(Data.bind(minimalTeams));\n // The second step: the eye places each duty in no group in a team, against the targets.\n const optimise = $.let(Func.bind(rotaPlaceShifts));\n return <Box width=\"100%\" height=\"760px\"><Roster id=\"rosterNoGroup\" inspector optimise={optimise}\n view={{ layout: \"shifts\", period: \"week\", date: new Date(\"2028-03-06T00:00:00Z\") }}\n events={{ duty: Schedule.events(rota, {\n name: \"Duty\", icon: \"user-clock\",\n start: \"start\", end: \"end\", resource: { field: \"person\", of: \"people\" },\n // An Option<String> field: `none`, a duty in no group yet.\n shift: \"shift\", group: \"team\",\n }) }}\n resources={{ people: Schedule.resources(staff.read(), { name: \"People\", icon: \"user\", label: w => w.name, group: w => w.team, contract: w => w.contract }) }}\n targets={Roster.targets(cover, { day: \"day\", group: \"team\", shift: \"shift\", positions: \"heads\", hours: \"hours\" })}\n shifts={Roster.shifts(times.read(), { label: s => s.name, code: s => s.code, start: s => s.starts, hours: s => s.hours, order: s => s.order })}\n groups={Roster.groups(groups.read(), { label: t => t.name })} />\n </Box>;\n }}</Reactive>)"
45697
+ },
44681
45698
  {
44682
45699
  "id": "e3-ui:roster.examples.tsx:rosterPublished",
44683
45700
  "skill": "e3-ui",
@@ -44711,6 +45728,79 @@
44711
45728
  ],
44712
45729
  "source": "// The week before, published, is read-only: navigation, staff filtering, coverage and inspection remain available.\n// inputs: []\n/** The duties, both weeks', each the warehouse's own row. */\nexport const rosterDuties = e3.record(\"roster_duties\", DictType(StringType, WarehouseDuty), {\n initial: warehouseDuties,\n indexes: (index) => ({\n // The duties by their times: what the Roster's slice reads a week of them through, its navigation writing the range.\n roster_duties_by_time: index.interval({ from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The weeks of the rota: the one before issued, this one open. */\nexport const rosterWeeks = e3.record(\"roster_rota_weeks\", DictType(DateTimeType, WarehouseWeek), {\n initial: warehouseWeeks,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The cover targets, a row per slot: the week before's, this week's and the forecast's for the week after. */\nexport const rosterCover = e3.record(\"roster_cover\", DictType(StringType, WarehouseCover), {\n initial: warehouseCover,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The suggestions: someone for a slot, and why. */\nexport const rosterSuggestions = e3.record(\"roster_suggestions\", DictType(StringType, WarehouseSuggestion), {\n initial: warehouseSuggestions,\n mutations: (mutation) => ({\n // The suggestions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterStaff = e3.record(\"roster_staff\", DictType(StringType, WarehousePerson), {\n initial: warehousePeople,\n indexes: (index) => ({\n // The rail's fields, each on an index of its own: the staff by group then name, position, trainer, agency, skill and name, the activities by group.\n roster_staff_by_team_name: index.on([\"team\", \"name\"]),\n roster_staff_by_position: index.on([\"position\"]),\n roster_staff_by_trainer: index.on([\"trainer\"]),\n roster_staff_by_agency: index.on([\"agency\"]),\n roster_staff_by_skill: index.on([\"skills\"]),\n roster_staff_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // What the renderer's tests on e3 write and ask beside the examples (#1376): another session's edits of the\n // reference data, a roster the warehouse has locked, and another app's fit over the same staff.\n // The staff's patch door: another session's edit of the staff.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterAgencies = e3.record(\"roster_agencies\", DictType(StringType, WarehouseAgency), { initial: warehouseAgencies });\n\nexport const rosterShiftTimes = e3.record(\"roster_shift_times\", DictType(StringType, WarehouseShift), {\n initial: warehouseShifts,\n mutations: (mutation) => ({\n // The shift times' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterTeams = e3.record(\"roster_teams\", DictType(StringType, WarehouseTeam), {\n initial: warehouseTeams,\n mutations: (mutation) => ({\n // The teams' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterPositions = e3.record(\"roster_positions\", DictType(StringType, WarehousePosition), {\n initial: warehousePositions,\n mutations: (mutation) => ({\n // The positions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\n/** Every activity by its key: each group's skills, and the duty of none (#1342). */\nexport const rosterActivities = e3.record(\"roster_activities\", DictType(StringType, WarehouseActivity), {\n initial: warehouseActivities,\n indexes: (index) => ({\n roster_activities_by_group: index.on([\"group\"]),\n }),\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const rota = $.let(Record.bind(rosterDuties));\n const entries = $.let(Data.bindPaged(rosterDuties));\n const byTime = $.let(Data.bindPaged(rosterDuties, { indexes: [\"roster_duties_by_time\"] }));\n const weeks = $.let(Record.bind(rosterWeeks));\n const cover = $.let(Record.bind(rosterCover));\n // Every person and activity is the calculation scope; the narrowing only chooses which show (#1342).\n const people = $.let(Data.bind(rosterStaff));\n const acts = $.let(Data.bind(rosterActivities));\n const staffIndex = $.let(Data.bindPaged(rosterStaff, { indexes: [\"roster_staff_by_team_name\", \"roster_staff_by_position\", \"roster_staff_by_trainer\", \"roster_staff_by_agency\", \"roster_staff_by_skill\", \"roster_staff_by_name\"] }));\n const actIndex = $.let(Data.bindPaged(rosterActivities, { indexes: [\"roster_activities_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.rosterPublished\", {\n duty: { source: byTime, range: \"start\" },\n people: { source: staffIndex, icon: { prefix: \"fas\", name: \"user\" }, search: [\"name\", \"skills\"],\n fields: { team: { label: \"Group\", hints: [{ value: \"inbound\", label: \"Inbound\" }, { value: \"picking\", label: \"Picking\" }, { value: \"dispatch\", label: \"Dispatch\" }] }, position: { label: \"Position\", hints: [{ value: \"lead\", label: \"Lead\" }, { value: \"deputy\", label: \"Deputy\" }, { value: \"acting\", label: \"Acting\" }, { value: \"crew\", label: \"Crew\" }] },\n trainer: { label: \"Trainer\" }, agency: { label: \"Agency\" }, skills: { label: \"Skill\" }, name: { label: \"Name\" } } },\n activities: { source: actIndex, icon: { prefix: \"fas\", name: \"list-check\" }, fields: { group: { label: \"Group\", hints: [{ value: \"inbound\", label: \"Inbound\" }, { value: \"picking\", label: \"Picking\" }, { value: \"dispatch\", label: \"Dispatch\" }, null] } } },\n }, { presets: [{ id: \"leads\", name: \"Leads\", where: { people: { position: [\"lead\", \"deputy\", \"acting\"] } } }] }));\n const firms = $.let(Data.bind(rosterAgencies));\n const times = $.let(Data.bind(rosterShiftTimes));\n const teams = $.let(Data.bind(rosterTeams));\n const roles = $.let(Data.bind(rosterPositions));\n const ideas = $.let(Data.bind(rosterSuggestions));\n return <Box width=\"100%\" height=\"760px\"><Roster id=\"rosterPublished\" week={{ start: \"sunday\" }} slice={{ slice }} inspector\n view={{ layout: \"shifts\", period: \"day\", date: new Date(\"2028-03-02T00:00:00Z\") }}\n events={{ duty: Schedule.events(rota, {\n name: \"Duty\", icon: \"user-clock\", entries,\n start: \"start\", end: \"end\", resource: { field: \"who\", of: { staff: \"people\", agency: \"agencies\" } },\n shift: \"shift\", group: \"team\", position: \"role\", activity: \"task\",\n hours: d => d.start.durationMinutes(d.end).subtract(d.unpaidBreak).divide(60.0),\n }) }}\n resources={{\n people: Schedule.resources(people.read(), { name: \"People\", icon: \"user\", label: p => p.name, group: p => p.team,\n position: p => p.position, skills: p => p.skills, contract: p => p.contract, agency: p => p.agency,\n trainer: p => p.trainer, trainee: p => p.trainee, usual: p => p.usual }),\n agencies: Schedule.resources(firms.read(), { name: \"Agencies\", icon: \"building\", label: a => a.name }),\n }}\n periods={Schedule.periods(weeks, { every: \"week\", status: { field: \"state\", draft: \"open\", published: \"issued\" }, dismissed: \"dismissed\" })}\n targets={Roster.targets(cover, { day: \"day\", group: \"team\", shift: \"shift\", positions: \"heads\", hours: \"hours\" })}\n shifts={Roster.shifts(times.read(), { label: s => s.label, code: s => s.code, start: s => s.start, hours: s => s.hours, order: s => s.order })}\n groups={Roster.groups(teams.read(), { label: t => t.label, order: t => t.order })}\n positions={Roster.positions(roles.read(), { label: p => p.label, code: p => p.code, lead: p => p.lead, order: p => p.order })}\n activities={Roster.activities(acts.read(), { label: a => a.label, code: a => a.code, group: a => a.group, order: a => a.order })}\n proposals={Roster.proposals(ideas.read(), { person: s => s.person, day: s => s.day, group: s => s.team, shift: s => s.shift, reason: s => s.why })}\n rules={{ rest: 10.0 }}\n library={[Roster.library.people(), Roster.library.activities(), Roster.library.tab(roles.read(), {\n name: \"Positions\", icon: \"id-badge\", label: p => p.label, meta: p => some(p.code),\n drop: (_p, key) => Schedule.patch(WarehouseDuty, { role: key }),\n })]} />\n </Box>;\n }}</Reactive>)"
44713
45730
  },
45731
+ {
45732
+ "id": "e3-ui:roster.examples.tsx:rosterDaily",
45733
+ "skill": "e3-ui",
45734
+ "package": "e3-ui",
45735
+ "file": "east-ui/packages/e3-ui/test/roster/roster.examples.tsx",
45736
+ "suite": "",
45737
+ "test": "A roster published a day at a time (#1550) — the second step of one made in two (#1548), where each duty works, firming up a day at a time: `periods` are the rota's days, `Schedule.periods(days, { every: \"day\", status, dismissed, entries })`, each row keyed by its UTC day and read by key through `entries`. In Shifts' Day, Publish saves the day's drafts, then writes the day's row, under Publish day; in Week, it writes each day of the week that takes edits as one request, under Publish week. A published day is read-only in every layout and period, under its banner, while the other days of its week take edits: issued Wednesday refuses a drop that Thursday takes. A proposal rejected is kept on its day's row. The status chip says the day's status, or the week's — 4 of 7 published — and the picker marks each day. Sunday to Wednesday are issued, Thursday is open, and Friday and Saturday are not started.",
45738
+ "keywords": [
45739
+ "Roster",
45740
+ "Schedule.periods",
45741
+ "every",
45742
+ "day",
45743
+ "days",
45744
+ "Publish",
45745
+ "Publish day",
45746
+ "Publish week",
45747
+ "published",
45748
+ "read-only",
45749
+ "two steps",
45750
+ "entries",
45751
+ "Data.bindPaged",
45752
+ "Record.bind",
45753
+ "BuilderFrame"
45754
+ ],
45755
+ "imports": [
45756
+ "import {",
45757
+ "import e3 from \"@elaraai/e3\";",
45758
+ "import { Box, Button, Field, HStack, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
45759
+ "import { Data, Func, Record, Roster, Schedule } from \"@elaraai/e3-ui\";",
45760
+ "import {"
45761
+ ],
45762
+ "languages": [
45763
+ "tsx"
45764
+ ],
45765
+ "source": "// A roster published a day at a time (#1550) — the second step of one made in two (#1548), where each duty works, firming up a day at a time: `periods` are the rota's days, `Schedule.periods(days, { every: \"day\", status, dismissed, entries })`, each row keyed by its UTC day and read by key through `entries`. In Shifts' Day, Publish saves the day's drafts, then writes the day's row, under Publish day; in Week, it writes each day of the week that takes edits as one request, under Publish week. A published day is read-only in every layout and period, under its banner, while the other days of its week take edits: issued Wednesday refuses a drop that Thursday takes. A proposal rejected is kept on its day's row. The status chip says the day's status, or the week's — 4 of 7 published — and the picker marks each day. Sunday to Wednesday are issued, Thursday is open, and Friday and Saturday are not started.\n// inputs: []\n/** The duties, both weeks', each the warehouse's own row. */\nexport const rosterDuties = e3.record(\"roster_duties\", DictType(StringType, WarehouseDuty), {\n initial: warehouseDuties,\n indexes: (index) => ({\n // The duties by their times: what the Roster's slice reads a week of them through, its navigation writing the range.\n roster_duties_by_time: index.interval({ from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** A day of the rota, for a Roster publishing a day at a time (#1550): open, or issued and when; the suggestions it dismissed. */\nexport const WarehouseDay = StructType({\n state: VariantType({ open: NullType, issued: StructType({ at: DateTimeType }) }),\n dismissed: SetType(StringType),\n});\n\nconst ROTA_DAY = 86_400_000, ROTA_HOUR = 3_600_000;\n\nconst byName = compareFor(StringType);\n\n/**\n * The rota's days as rows, each keyed by its UTC day: every day of the week before and this week's Sunday to Wednesday\n * issued, each at 17:00 the evening before; Thursday open; Friday and Saturday not started, with no row.\n */\nexport const rosterDayRows: SortedMap<Date, ValueTypeOf<typeof WarehouseDay>> = new SortedMap<Date, ValueTypeOf<typeof WarehouseDay>>([\n ...Array.from({ length: 11 }, (_, day): [Date, ValueTypeOf<typeof WarehouseDay>] => {\n const start = new Date(warehousePreviousStart.getTime() + day * ROTA_DAY);\n return [start, { state: variant(\"issued\", { at: new Date(start.getTime() - 7 * ROTA_HOUR) }), dismissed: new SortedSet<string>([], byName) }];\n }),\n [new Date(warehouseStart.getTime() + 4 * ROTA_DAY), { state: variant(\"open\", null), dismissed: new SortedSet<string>([], byName) }],\n], compareFor(DateTimeType));\n\n/** The days of the rota, which a Roster publishing a day at a time writes (#1550): each day's status and its dismissals. */\nexport const rosterDays = e3.record(\"roster_rota_days\", DictType(DateTimeType, WarehouseDay), {\n initial: rosterDayRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The cover targets, a row per slot: the week before's, this week's and the forecast's for the week after. */\nexport const rosterCover = e3.record(\"roster_cover\", DictType(StringType, WarehouseCover), {\n initial: warehouseCover,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The suggestions: someone for a slot, and why. */\nexport const rosterSuggestions = e3.record(\"roster_suggestions\", DictType(StringType, WarehouseSuggestion), {\n initial: warehouseSuggestions,\n mutations: (mutation) => ({\n // The suggestions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterStaff = e3.record(\"roster_staff\", DictType(StringType, WarehousePerson), {\n initial: warehousePeople,\n indexes: (index) => ({\n // The rail's fields, each on an index of its own: the staff by group then name, position, trainer, agency, skill and name, the activities by group.\n roster_staff_by_team_name: index.on([\"team\", \"name\"]),\n roster_staff_by_position: index.on([\"position\"]),\n roster_staff_by_trainer: index.on([\"trainer\"]),\n roster_staff_by_agency: index.on([\"agency\"]),\n roster_staff_by_skill: index.on([\"skills\"]),\n roster_staff_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // What the renderer's tests on e3 write and ask beside the examples (#1376): another session's edits of the\n // reference data, a roster the warehouse has locked, and another app's fit over the same staff.\n // The staff's patch door: another session's edit of the staff.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterAgencies = e3.record(\"roster_agencies\", DictType(StringType, WarehouseAgency), { initial: warehouseAgencies });\n\nexport const rosterShiftTimes = e3.record(\"roster_shift_times\", DictType(StringType, WarehouseShift), {\n initial: warehouseShifts,\n mutations: (mutation) => ({\n // The shift times' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterTeams = e3.record(\"roster_teams\", DictType(StringType, WarehouseTeam), {\n initial: warehouseTeams,\n mutations: (mutation) => ({\n // The teams' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterPositions = e3.record(\"roster_positions\", DictType(StringType, WarehousePosition), {\n initial: warehousePositions,\n mutations: (mutation) => ({\n // The positions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\n/** Every activity by its key: each group's skills, and the duty of none (#1342). */\nexport const rosterActivities = e3.record(\"roster_activities\", DictType(StringType, WarehouseActivity), {\n initial: warehouseActivities,\n indexes: (index) => ({\n roster_activities_by_group: index.on([\"group\"]),\n }),\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const rota = $.let(Record.bind(rosterDuties));\n const entries = $.let(Data.bindPaged(rosterDuties));\n const byTime = $.let(Data.bindPaged(rosterDuties, { indexes: [\"roster_duties_by_time\"] }));\n // What the Roster publishes: the rota's days, through the record's patch door, each span of them read by key.\n const days = $.let(Record.bind(rosterDays));\n const dayEntries = $.let(Data.bindPaged(rosterDays));\n const cover = $.let(Record.bind(rosterCover));\n // Every person and activity is the calculation scope; the narrowing only chooses which show (#1342).\n const people = $.let(Data.bind(rosterStaff));\n const acts = $.let(Data.bind(rosterActivities));\n const staffIndex = $.let(Data.bindPaged(rosterStaff, { indexes: [\"roster_staff_by_team_name\", \"roster_staff_by_position\", \"roster_staff_by_trainer\", \"roster_staff_by_agency\", \"roster_staff_by_skill\", \"roster_staff_by_name\"] }));\n const actIndex = $.let(Data.bindPaged(rosterActivities, { indexes: [\"roster_activities_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.rosterDaily\", {\n duty: { source: byTime, range: \"start\" },\n people: { source: staffIndex, icon: { prefix: \"fas\", name: \"user\" }, search: [\"name\", \"skills\"],\n fields: { team: { label: \"Group\", hints: [{ value: \"inbound\", label: \"Inbound\" }, { value: \"picking\", label: \"Picking\" }, { value: \"dispatch\", label: \"Dispatch\" }] }, position: { label: \"Position\", hints: [{ value: \"lead\", label: \"Lead\" }, { value: \"deputy\", label: \"Deputy\" }, { value: \"acting\", label: \"Acting\" }, { value: \"crew\", label: \"Crew\" }] },\n trainer: { label: \"Trainer\" }, agency: { label: \"Agency\" }, skills: { label: \"Skill\" }, name: { label: \"Name\" } } },\n activities: { source: actIndex, icon: { prefix: \"fas\", name: \"list-check\" }, fields: { group: { label: \"Group\", hints: [{ value: \"inbound\", label: \"Inbound\" }, { value: \"picking\", label: \"Picking\" }, { value: \"dispatch\", label: \"Dispatch\" }, null] } } },\n }));\n const firms = $.let(Data.bind(rosterAgencies));\n const times = $.let(Data.bind(rosterShiftTimes));\n const teams = $.let(Data.bind(rosterTeams));\n const roles = $.let(Data.bind(rosterPositions));\n const ideas = $.let(Data.bind(rosterSuggestions));\n return <Box width=\"100%\" height=\"760px\"><Roster id=\"rosterDaily\" week={{ start: \"sunday\" }} slice={{ slice }} inspector\n view={{ layout: \"shifts\", period: \"day\", date: new Date(\"2028-03-09T00:00:00Z\") }}\n events={{ duty: Schedule.events(rota, {\n name: \"Duty\", icon: \"user-clock\", entries,\n start: \"start\", end: \"end\", resource: { field: \"who\", of: { staff: \"people\", agency: \"agencies\" } },\n shift: \"shift\", group: \"team\", position: \"role\", activity: \"task\",\n hours: d => d.start.durationMinutes(d.end).subtract(d.unpaidBreak).divide(60.0),\n }) }}\n resources={{\n people: Schedule.resources(people.read(), { name: \"People\", icon: \"user\", label: p => p.name, group: p => p.team,\n position: p => p.position, skills: p => p.skills, contract: p => p.contract, agency: p => p.agency,\n trainer: p => p.trainer, trainee: p => p.trainee, usual: p => p.usual }),\n agencies: Schedule.resources(firms.read(), { name: \"Agencies\", icon: \"building\", label: a => a.name }),\n }}\n // A day each, keyed by its UTC day: Publish writes the day in view's, or each day of the week that takes edits.\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"open\", published: \"issued\" }, dismissed: \"dismissed\", entries: dayEntries })}\n targets={Roster.targets(cover, { day: \"day\", group: \"team\", shift: \"shift\", positions: \"heads\", hours: \"hours\" })}\n shifts={Roster.shifts(times.read(), { label: s => s.label, code: s => s.code, start: s => s.start, hours: s => s.hours, order: s => s.order })}\n groups={Roster.groups(teams.read(), { label: t => t.label, order: t => t.order })}\n positions={Roster.positions(roles.read(), { label: p => p.label, code: p => p.code, lead: p => p.lead, order: p => p.order })}\n activities={Roster.activities(acts.read(), { label: a => a.label, code: a => a.code, group: a => a.group, order: a => a.order })}\n proposals={Roster.proposals(ideas.read(), { person: s => s.person, day: s => s.day, group: s => s.team, shift: s => s.shift, reason: s => s.why })}\n rules={{ rest: 10.0 }}\n library={[Roster.library.people(), Roster.library.activities()]} />\n </Box>;\n }}</Reactive>)"
45766
+ },
45767
+ {
45768
+ "id": "e3-ui:roster.examples.tsx:rosterRota",
45769
+ "skill": "e3-ui",
45770
+ "package": "e3-ui",
45771
+ "file": "east-ui/packages/e3-ui/test/roster/roster.examples.tsx",
45772
+ "suite": "",
45773
+ "test": "A board over its rota (#1551), the second step of a roster made in two: the rota — each person's shifts for the week, the first step's answer, in no team — is a record of its own, and each duty a rota line placed in a team, naming the line it carries out. The slice's `reference` source reads the rota through its interval index, the Roster writing its window into it as into the duties' — each week's lines and the twelve hours either side, never the rota whole — and the check, over Roster.Types.CheckContext(RotaDuty, RotaLine), reads that week's lines in `cx.reference` beside the duties: a duty whose line has changed, its fix the line's shift where only the shift moved; a duty whose line is gone; and a line of the week no duty carries out, on the slot its person's own team would carry it out in. Nothing draws the rota, and the rail offers none of its fields.",
45774
+ "keywords": [
45775
+ "Roster",
45776
+ "check",
45777
+ "reference",
45778
+ "Roster.Types.CheckContext",
45779
+ "Roster.Types.Issue",
45780
+ "Roster.Types.Fix",
45781
+ "rota",
45782
+ "two steps",
45783
+ "Slice.bindRecords",
45784
+ "Data.bindPaged",
45785
+ "interval",
45786
+ "indexes",
45787
+ "Schedule.events",
45788
+ "Roster.slotOf",
45789
+ "fix",
45790
+ "move"
45791
+ ],
45792
+ "imports": [
45793
+ "import {",
45794
+ "import e3 from \"@elaraai/e3\";",
45795
+ "import { Box, Button, Field, HStack, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
45796
+ "import { Data, Func, Record, Roster, Schedule } from \"@elaraai/e3-ui\";",
45797
+ "import {"
45798
+ ],
45799
+ "languages": [
45800
+ "tsx"
45801
+ ],
45802
+ "source": "// A board over its rota (#1551), the second step of a roster made in two: the rota — each person's shifts for the week, the first step's answer, in no team — is a record of its own, and each duty a rota line placed in a team, naming the line it carries out. The slice's `reference` source reads the rota through its interval index, the Roster writing its window into it as into the duties' — each week's lines and the twelve hours either side, never the rota whole — and the check, over Roster.Types.CheckContext(RotaDuty, RotaLine), reads that week's lines in `cx.reference` beside the duties: a duty whose line has changed, its fix the line's shift where only the shift moved; a duty whose line is gone; and a line of the week no duty carries out, on the slot its person's own team would carry it out in. Nothing draws the rota, and the rail offers none of its fields.\n// inputs: []\n/** One of its shifts: a name, a code, when it starts, its hours and where it shows. */\nexport const MinimalShiftTime = StructType({ name: StringType, code: StringType, starts: Schedule.Types.Clock, hours: FloatType, order: IntegerType });\n\n/** One of its teams: a name. */\nexport const MinimalTeam = StructType({ name: StringType });\n\nexport const minimalShiftTimes = e3.record(\"rota_minimal_shift_times\", DictType(StringType, MinimalShiftTime), {\n initial: new Map([\n [\"early\", { name: \"Early\", code: \"E\", starts: { hour: 6n, minute: 0n }, hours: 8.0, order: 1n }],\n [\"late\", { name: \"Late\", code: \"L\", starts: { hour: 14n, minute: 0n }, hours: 8.0, order: 2n }],\n ]),\n});\n\nexport const minimalTeams = e3.record(\"rota_minimal_teams\", DictType(StringType, MinimalTeam), {\n initial: new Map([\n [\"inbound\", { name: \"Inbound\" }], [\"dispatch\", { name: \"Dispatch\" }],\n ]),\n});\n\n/** A duty of a roster made in two steps: who, when and on which shift — and its team, none until it is placed in one. */\nexport const NoGroupDuty = StructType({ person: StringType, start: DateTimeType, end: DateTimeType, shift: StringType, team: OptionType(StringType) });\n\n/** One of its staff: a name, their own team and their contracted hours a week. */\nexport const NoGroupWorker = StructType({ name: StringType, team: StringType, contract: FloatType });\n\n/** The first step's week as rows, by key: the day and the person, every one in no team. */\nexport const noGroupShifts: Map<string, ValueTypeOf<typeof NoGroupDuty>> = new Map();\n\n/** The staff as rows, by key: three of Inbound's and three of Dispatch's. */\nexport const noGroupStaffRows: Map<string, ValueTypeOf<typeof NoGroupWorker>> = new Map([\n [\"w-01\", { name: \"Ada Brook\", team: \"inbound\", contract: 40.0 }], [\"w-02\", { name: \"Tom Vale\", team: \"dispatch\", contract: 40.0 }],\n [\"w-03\", { name: \"Mia Hart\", team: \"inbound\", contract: 40.0 }], [\"w-04\", { name: \"Sam Reed\", team: \"dispatch\", contract: 40.0 }],\n [\"w-05\", { name: \"Lea Fox\", team: \"inbound\", contract: 40.0 }], [\"w-06\", { name: \"Ben Moss\", team: \"dispatch\", contract: 40.0 }],\n]);\n\nexport const noGroupWorkers = e3.record(\"rota_no_group_staff\", DictType(StringType, NoGroupWorker), { initial: noGroupStaffRows });\n\n/** A line of the rota: who works which shift, and when — the first step's answer, in no team. */\nexport const RotaLine = StructType({ person: StringType, shift: StringType, start: DateTimeType, end: DateTimeType });\n\n/** A duty of the board over the rota: a rota line placed in a team, and the key of the line it carries out. */\nexport const RotaDuty = StructType({ person: StringType, start: DateTimeType, end: DateTimeType, shift: StringType, team: StringType, rota: OptionType(StringType) });\n\n/** The rota's lines as rows, by key, as the rota stands now: the first step's week. */\nexport const rotaLineRows: Map<string, ValueTypeOf<typeof RotaLine>> = new Map([...noGroupShifts].map(([key, duty]): [string, ValueTypeOf<typeof RotaLine>] =>\n [key, { person: duty.person, shift: duty.shift, start: duty.start, end: duty.end }]));\n\n/**\n * The board's duties as rows, by key: the rota as it stood when the board was made, each line placed in its person's own\n * team — since when the rota has moved Mia Hart's Wednesday to the late and taken her Friday off, and put Ben Moss on\n * Monday's late, which no duty carries out yet.\n */\nexport const rotaDutyRows: Map<string, ValueTypeOf<typeof RotaDuty>> = new Map();\n\n/** The rota, which the board reads and never writes: its lines, a week of them read through their interval index. */\nexport const rosterRotaLines = e3.record(\"roster_rota_lines\", DictType(StringType, RotaLine), {\n initial: rotaLineRows,\n indexes: (index) => ({\n // The lines by their times: what the board's reference source reads a week of them through.\n roster_rota_lines_by_time: index.interval({ from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n // The rota's patch door: the first step answering again, which the renderer's tests on e3 write beside the board.\n patch: mutation.patch(),\n }),\n});\n\n/** The board's duties, each a rota line placed in a team. */\nexport const rosterBoardDuties = e3.record(\"roster_board_duties\", DictType(StringType, RotaDuty), {\n initial: rotaDutyRows,\n indexes: (index) => ({\n roster_board_duties_by_time: index.interval({ from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const board = $.let(Record.bind(rosterBoardDuties));\n const entries = $.let(Data.bindPaged(rosterBoardDuties));\n const byTime = $.let(Data.bindPaged(rosterBoardDuties, { indexes: [\"roster_board_duties_by_time\"] }));\n // The rota, read only: a week of its lines at a time, through its interval index.\n const rota = $.let(Data.bindPaged(rosterRotaLines, { indexes: [\"roster_rota_lines_by_time\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.rosterRota\", {\n duty: { source: byTime, range: \"start\" },\n // The record the check reads beside the duties: the Roster writes its week into it, as into the duties'.\n reference: { source: rota, range: \"start\" },\n }));\n const staff = $.let(Data.bind(noGroupWorkers));\n const times = $.let(Data.bind(minimalShiftTimes));\n const groups = $.let(Data.bind(minimalTeams));\n // The board's check over the rota: where the week's duties and the rota's lines part.\n const check = $.const(East.function([Roster.Types.CheckContext(RotaDuty, RotaLine)], ArrayType(Roster.Types.Issue), ($2, cx) => {\n const issues = $2.let([], ArrayType(Roster.Types.Issue));\n const slotOf = $2.const(Roster.slotOf);\n const names = $2.const(cx.context.people.map((_$3, person) => person.name));\n const homes = $2.const(cx.context.people.map((_$3, person) => person.group));\n const shifts = $2.const(cx.context.shifts.toDict((_$3, shift) => shift.key, (_$3, shift) => shift.label));\n const weekdays = $2.const([\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\", \"Sun\"], ArrayType(StringType));\n // Each duty against the line it carries out, noting each line carried out.\n const carried = $2.let(new Set([]), SetType(StringType));\n $2.for(cx.week.assignments, ($3, a, id) => {\n $3.match(a.row.rota, { some: ($4, key) => {\n $4(carried.tryInsert(key));\n $4.if(cx.reference.has(key).not(), ($5) => {\n $5(issues.pushLast({ kind: variant(\"breach\", null), tone: variant(\"warning\", null),\n title: \"Rota line gone\", detail: East.str`The rota no longer has ${names.get(a.row.person, () => a.row.person)} on this shift`,\n slot: slotOf(a.place), assignment: some(id), flag: some(\"Rota\"), fix: none }));\n }).else(($5) => {\n const line = $5.const(cx.reference.get(key));\n $5.if(East.notEqual(line, { person: a.row.person, shift: a.row.shift, start: a.row.start, end: a.row.end }), ($6) => {\n // Where only the line's shift moved, the fix moves the duty to it.\n const fix = $6.let(none, OptionType(Roster.Types.Fix));\n $6.if(East.equal(line.person, a.row.person).and(() => East.notEqual(line.shift, a.row.shift)), ($7) => {\n $7.assign(fix, some(variant(\"move\", line.shift)));\n });\n $6(issues.pushLast({ kind: variant(\"breach\", null), tone: variant(\"warning\", null),\n title: \"Rota line changed\", detail: East.str`The rota has ${names.get(line.person, () => line.person)} on ${shifts.get(line.shift, () => line.shift)} now`,\n slot: slotOf(a.place), assignment: some(id), flag: some(\"Rota\"), fix }));\n });\n });\n } });\n });\n // Each line of the week no duty carries out: a line at the window's edges is the week before's or after's.\n const end = $2.const(cx.start.addDays(7n));\n $2.for(cx.reference, ($3, line, key) => {\n $3.if(carried.has(key).not().and(() => East.greaterEqual(line.start, cx.start)).and(() => East.less(line.start, end)), ($4) => {\n const day = $4.const(cx.start.durationMilliseconds(line.start).divide(86_400_000n));\n const slot = $4.const({ day, group: homes.get(line.person, () => \"\"), shift: line.shift });\n $4(issues.pushLast({ kind: variant(\"gap\", null), tone: variant(\"warning\", null),\n title: \"Rota line not on the board\", detail: East.str`${names.get(line.person, () => line.person)} · ${weekdays.get(day)} ${shifts.get(line.shift, () => line.shift)}`,\n slot: some(slot), assignment: none, flag: none, fix: none }));\n });\n });\n return issues;\n }));\n return <Box width=\"100%\" height=\"760px\"><Roster id=\"rosterRota\" slice={{ slice }} check={check} inspector\n view={{ layout: \"shifts\", period: \"week\", date: new Date(\"2028-03-06T00:00:00Z\") }}\n events={{ duty: Schedule.events(board, {\n name: \"Duty\", icon: \"user-clock\", entries,\n start: \"start\", end: \"end\", resource: { field: \"person\", of: \"people\" },\n shift: \"shift\", group: \"team\",\n }) }}\n resources={{ people: Schedule.resources(staff.read(), { name: \"People\", icon: \"user\", label: w => w.name, group: w => w.team, contract: w => w.contract }) }}\n shifts={Roster.shifts(times.read(), { label: s => s.name, code: s => s.code, start: s => s.starts, hours: s => s.hours, order: s => s.order })}\n groups={Roster.groups(groups.read(), { label: t => t.name })} />\n </Box>;\n }}</Reactive>)"
45803
+ },
44714
45804
  {
44715
45805
  "id": "e3-ui:roster.examples.tsx:rosterCustomInspector",
44716
45806
  "skill": "e3-ui",
@@ -44784,7 +45874,7 @@
44784
45874
  "package": "e3-ui",
44785
45875
  "file": "east-ui/packages/e3-ui/test/schematic/schematic-records.examples.tsx",
44786
45876
  "suite": "",
44787
- "test": "A floor of 20,000 racks in ten halls, read a window at a time: the racks bound with their patch door and read through their source of the slice, whose indexes include an area index at a 1 cm cell, so the canvas reads only the racks its view shows, from the index alone, and draws their density from the index's counts while the view holds more than 5,000; a choice of halls reads through the area index the hall leads, and a choice of models through the one led by nothing, asking which of the window's racks the choice holds; the Index in the library pane lists the halls, one open at a time — a hall's racks read by its box — and opens the hall the view is in as it pans and zooms; each rack's load read by the runs its window's cells are of the area index — e3 reads their keys from the index, so none is sent — every cell not yet read in one request, so a dot draws its rack's alarm as a card does; a rack moved is a draft that waits in its session wherever the window goes, and Save writes it through the door",
45877
+ "test": "A floor of 20,000 racks in ten halls, read a window at a time: the racks bound with their patch door and read through their source of the slice, whose indexes include an area index at a 1 cm cell, so the canvas reads only the racks its view shows, from the index alone, and draws their density from the index's counts while the view holds more than 5,000; a choice of halls reads through the area index the hall leads, and a choice of models through the one led by nothing, asking which of the window's racks the choice holds; the Index in the library pane lists the halls, one open at a time — a hall's racks read by its box — and opens the hall the view comes to rest in, never one a fly or a fast zoom passes, its row held at the list's top while its racks scroll; each rack's load read by the runs its window's cells are of the area index — e3 reads their keys from the index, so none is sent — every cell not yet read in one request, so a dot draws its rack's alarm as a card does; a rack moved is a draft that waits in its session wherever the window goes, and Save writes it through the door",
44788
45878
  "keywords": [
44789
45879
  "Schematic",
44790
45880
  "Schematic.items",
@@ -44816,7 +45906,7 @@
44816
45906
  "languages": [
44817
45907
  "tsx"
44818
45908
  ],
44819
- "source": "// A floor of 20,000 racks in ten halls, read a window at a time: the racks bound with their patch door and read through their source of the slice, whose indexes include an area index at a 1 cm cell, so the canvas reads only the racks its view shows, from the index alone, and draws their density from the index's counts while the view holds more than 5,000; a choice of halls reads through the area index the hall leads, and a choice of models through the one led by nothing, asking which of the window's racks the choice holds; the Index in the library pane lists the halls, one open at a time — a hall's racks read by its box — and opens the hall the view is in as it pans and zooms; each rack's load read by the runs its window's cells are of the area index — e3 reads their keys from the index, so none is sent — every cell not yet read in one request, so a dot draws its rack's alarm as a card does; a rack moved is a draft that waits in its session wherever the window goes, and Save writes it through the door\n// inputs: []\n/** A rack of the floor: its hall and model, placed by its centre, its box 0.6 m by 1.2 m. */\nexport const StressRack = StructType({ name: StringType, hall: StringType, model: StringType, x: FloatType, y: FloatType, w: FloatType, h: FloatType });\n\n/** How hot a rack runs. */\nexport const StressAlarm = VariantType({ ok: NullType, warm: NullType, hot: NullType });\n\n/** A rack's load: what its card's bar, figure and dot draw. */\nexport const StressLoad = StructType({ kw: FloatType, capacity: FloatType, alarm: StressAlarm });\n\n/** A hall of the floor: its box and its name. */\nexport const StressHall = StructType({ name: StringType, x: FloatType, y: FloatType, w: FloatType, h: FloatType });\n\nconst StressRacks = DictType(StringType, StressRack);\n\nconst StressLoads = DictType(StringType, StressLoad);\n\n/**\n * The floor's racks, a row of 100 in each of the ten halls in turn — five\n * halls to a row of the floor, each holding 50 rows, 0.7 m apart along a row\n * and 2.4 m from row to row — so any count fills every hall's rows from the\n * front: 20,000 racks fill each hall's first 20, and 50,000 the floor. The\n * budget run makes the floor's 50,000 with it, and patches in what the seed's\n * 20,000 lack.\n */\nexport const generateRacks = East.function([IntegerType], StressRacks, ($, count) => {\n const racks = $.let(new Map(), StressRacks);\n const models = $.const([\"42U · 8 kW\", \"48U · 12 kW\", \"24U · 4 kW\"], ArrayType(StringType));\n const i = $.let(0n);\n $.while(i.less(count), ($2) => {\n const hall = $2.const(i.divide(100n).remainder(10n));\n const row = $2.const(i.divide(1000n));\n const key = $2.const(East.str`R${i.add(100000n)}`);\n $2(racks.insert(key, {\n name: key,\n hall: East.str`Hall ${hall.add(1n)}`,\n model: models.get(i.remainder(3n)),\n x: hall.remainder(5n).toFloat().multiply(76.0).add(i.remainder(100n).toFloat().multiply(0.7)).add(3.3),\n y: hall.divide(5n).toFloat().multiply(126.0).add(row.toFloat().multiply(2.4)).add(3.6),\n w: 0.6,\n h: 1.2,\n }));\n $2.assign(i, i.add(1n));\n });\n return racks;\n});\n\n/** The racks' loads, keyed as the racks are: up to 12 kW of a 12 kW rack, warm past 9.6 and hot past 10.8. The budget run makes the floor's with it. */\nexport const generateLoads = East.function([IntegerType], StressLoads, ($, count) => {\n const loads = $.let(new Map(), StressLoads);\n const i = $.let(0n);\n $.while(i.less(count), ($2) => {\n const kw = $2.const(i.multiply(37n).remainder(120n).toFloat().divide(10.0));\n const alarm = $2.let(variant(\"ok\", null), StressAlarm);\n $2.if(kw.greater(9.6), ($3) => { $3.assign(alarm, variant(\"warm\", null)); });\n $2.if(kw.greater(10.8), ($3) => { $3.assign(alarm, variant(\"hot\", null)); });\n $2(loads.insert(East.str`R${i.add(100000n)}`, { kw, capacity: 12.0, alarm }));\n $2.assign(i, i.add(1n));\n });\n return loads;\n});\n\nexport const schematicStressRacks = e3.record(\"schematic_stress_racks\", StressRacks, {\n initial: () => East.compile(generateRacks, [])(20000n),\n indexes: (index) => ({\n // The window, whatever the rail chooses: every rack filed once by its box, at a 1 cm cell.\n schematic_stress_racks_by_area: index.area({\n x: \"x\", y: \"y\", width: \"w\", height: \"h\", at: \"centre\", cell: 0.01,\n }),\n // Beside it, a choice of halls and the window in one read.\n schematic_stress_racks_by_hall_area: index.area({\n on: [\"hall\"], x: \"x\", y: \"y\", width: \"w\", height: \"h\", at: \"centre\", cell: 0.01,\n }),\n // A choice no area index leads: a window under it asks which of its racks the choice holds.\n schematic_stress_racks_by_model: index.on([\"model\"]),\n }),\n mutations: (mutation) => ({\n // The racks' patch door: each Save of the floor writes through it, and the budget run fills the floor through it.\n patch: mutation.patch(),\n }),\n});\n\nexport const schematicStressRackLoads = e3.record(\"schematic_stress_rack_loads\", StressLoads, {\n initial: () => East.compile(generateLoads, [])(20000n),\n mutations: (mutation) => ({\n // The loads' patch door: the budget run fills them through it, keyed as the racks it fills.\n patch: mutation.patch(),\n }),\n});\n\nexport const schematicStressHalls = e3.record(\"schematic_stress_halls\", DictType(StringType, StressHall), {\n initial: new Map([\n [\"hall-1\", { name: \"Hall 1\", x: 2.0, y: 2.0, w: 72.0, h: 122.0 }],\n [\"hall-2\", { name: \"Hall 2\", x: 78.0, y: 2.0, w: 72.0, h: 122.0 }],\n [\"hall-3\", { name: \"Hall 3\", x: 154.0, y: 2.0, w: 72.0, h: 122.0 }],\n [\"hall-4\", { name: \"Hall 4\", x: 230.0, y: 2.0, w: 72.0, h: 122.0 }],\n [\"hall-5\", { name: \"Hall 5\", x: 306.0, y: 2.0, w: 72.0, h: 122.0 }],\n [\"hall-6\", { name: \"Hall 6\", x: 2.0, y: 128.0, w: 72.0, h: 122.0 }],\n [\"hall-7\", { name: \"Hall 7\", x: 78.0, y: 128.0, w: 72.0, h: 122.0 }],\n [\"hall-8\", { name: \"Hall 8\", x: 154.0, y: 128.0, w: 72.0, h: 122.0 }],\n [\"hall-9\", { name: \"Hall 9\", x: 230.0, y: 128.0, w: 72.0, h: 122.0 }],\n [\"hall-10\", { name: \"Hall 10\", x: 306.0, y: 128.0, w: 72.0, h: 122.0 }],\n ]),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n // The racks bound with their patch door, read by key through their own entries beside their source of the slice.\n const racks = $.let(Record.bind(schematicStressRacks));\n const rackEntries = $.let(Data.bindPaged(schematicStressRacks));\n const loads = $.let(Data.bindPaged(schematicStressRackLoads));\n const halls = $.let(Data.bind(schematicStressHalls));\n // One rail: the racks by hall, through the area index the hall leads, and by model, through the one led by nothing.\n const slice = $.let(Slice.bindRecords(\"ex.schematicRecordIndexes\", {\n racks: {\n source: Data.bindPaged(schematicStressRacks, { indexes: [\"schematic_stress_racks_by_area\", \"schematic_stress_racks_by_hall_area\", \"schematic_stress_racks_by_model\"] }),\n icon: { prefix: \"fas\", name: \"server\" },\n fields: {\n hall: { label: \"Hall\", hints: [\"Hall 1\", \"Hall 2\", \"Hall 3\", \"Hall 4\", \"Hall 5\", \"Hall 6\", \"Hall 7\", \"Hall 8\", \"Hall 9\", \"Hall 10\"] },\n model: { label: \"Model\", hints: [\"42U · 8 kW\", \"48U · 12 kW\", \"24U · 4 kW\"] },\n },\n },\n }));\n return (\n <Box height=\"640px\">\n <Schematic\n id=\"recordIndexes\"\n // The Index: the halls and their racks, one hall open at a time, following the hall the view is in.\n library={[Schematic.library.index()]}\n extent={{ width: 382, height: 254 }}\n scaleUnit=\"m\"\n slice={{ slice }}\n items={{\n racks: Schematic.items(racks, {\n name: \"Rack\", icon: \"server\", x: \"x\", y: \"y\", width: \"w\", height: \"h\", label: \"name\", entries: rackEntries,\n sublabel: (r) => r.model,\n details: Schematic.details(loads, {\n meter: (l) => ({ value: l.kw, max: l.capacity }),\n metric: (l) => some(East.str`${East.Float.printFixed(l.kw, 1n)} kW`),\n status: { field: \"alarm\", cases: {\n ok: { label: \"OK\", tone: variant(\"success\", null), ring: false },\n warm: { label: \"Warm\", tone: variant(\"warning\", null), ring: false },\n hot: { label: \"Hot\", tone: variant(\"danger\", null), ring: false },\n } },\n }),\n }),\n }}\n zones={{\n halls: Schematic.zones(halls, { name: \"Hall\", icon: \"warehouse\", x: \"x\", y: \"y\", width: \"w\", height: \"h\", label: \"name\" }),\n }}\n />\n </Box>\n );\n }}</Reactive>\n ))"
45909
+ "source": "// A floor of 20,000 racks in ten halls, read a window at a time: the racks bound with their patch door and read through their source of the slice, whose indexes include an area index at a 1 cm cell, so the canvas reads only the racks its view shows, from the index alone, and draws their density from the index's counts while the view holds more than 5,000; a choice of halls reads through the area index the hall leads, and a choice of models through the one led by nothing, asking which of the window's racks the choice holds; the Index in the library pane lists the halls, one open at a time — a hall's racks read by its box — and opens the hall the view comes to rest in, never one a fly or a fast zoom passes, its row held at the list's top while its racks scroll; each rack's load read by the runs its window's cells are of the area index — e3 reads their keys from the index, so none is sent — every cell not yet read in one request, so a dot draws its rack's alarm as a card does; a rack moved is a draft that waits in its session wherever the window goes, and Save writes it through the door\n// inputs: []\n/** A rack of the floor: its hall and model, placed by its centre, its box 0.6 m by 1.2 m. */\nexport const StressRack = StructType({ name: StringType, hall: StringType, model: StringType, x: FloatType, y: FloatType, w: FloatType, h: FloatType });\n\n/** How hot a rack runs. */\nexport const StressAlarm = VariantType({ ok: NullType, warm: NullType, hot: NullType });\n\n/** A rack's load: what its card's bar, figure and dot draw. */\nexport const StressLoad = StructType({ kw: FloatType, capacity: FloatType, alarm: StressAlarm });\n\n/** A hall of the floor: its box and its name. */\nexport const StressHall = StructType({ name: StringType, x: FloatType, y: FloatType, w: FloatType, h: FloatType });\n\nconst StressRacks = DictType(StringType, StressRack);\n\nconst StressLoads = DictType(StringType, StressLoad);\n\n/**\n * The floor's racks, a row of 100 in each of the ten halls in turn — five\n * halls to a row of the floor, each holding 50 rows, 0.7 m apart along a row\n * and 2.4 m from row to row — so any count fills every hall's rows from the\n * front: 20,000 racks fill each hall's first 20, and 50,000 the floor. The\n * budget run makes the floor's 50,000 with it, and patches in what the seed's\n * 20,000 lack.\n */\nexport const generateRacks = East.function([IntegerType], StressRacks, ($, count) => {\n const racks = $.let(new Map(), StressRacks);\n const models = $.const([\"42U · 8 kW\", \"48U · 12 kW\", \"24U · 4 kW\"], ArrayType(StringType));\n const i = $.let(0n);\n $.while(i.less(count), ($2) => {\n const hall = $2.const(i.divide(100n).remainder(10n));\n const row = $2.const(i.divide(1000n));\n const key = $2.const(East.str`R${i.add(100000n)}`);\n $2(racks.insert(key, {\n name: key,\n hall: East.str`Hall ${hall.add(1n)}`,\n model: models.get(i.remainder(3n)),\n x: hall.remainder(5n).toFloat().multiply(76.0).add(i.remainder(100n).toFloat().multiply(0.7)).add(3.3),\n y: hall.divide(5n).toFloat().multiply(126.0).add(row.toFloat().multiply(2.4)).add(3.6),\n w: 0.6,\n h: 1.2,\n }));\n $2.assign(i, i.add(1n));\n });\n return racks;\n});\n\n/** The racks' loads, keyed as the racks are: up to 12 kW of a 12 kW rack, warm past 9.6 and hot past 10.8. The budget run makes the floor's with it. */\nexport const generateLoads = East.function([IntegerType], StressLoads, ($, count) => {\n const loads = $.let(new Map(), StressLoads);\n const i = $.let(0n);\n $.while(i.less(count), ($2) => {\n const kw = $2.const(i.multiply(37n).remainder(120n).toFloat().divide(10.0));\n const alarm = $2.let(variant(\"ok\", null), StressAlarm);\n $2.if(kw.greater(9.6), ($3) => { $3.assign(alarm, variant(\"warm\", null)); });\n $2.if(kw.greater(10.8), ($3) => { $3.assign(alarm, variant(\"hot\", null)); });\n $2(loads.insert(East.str`R${i.add(100000n)}`, { kw, capacity: 12.0, alarm }));\n $2.assign(i, i.add(1n));\n });\n return loads;\n});\n\nexport const schematicStressRacks = e3.record(\"schematic_stress_racks\", StressRacks, {\n initial: () => East.compile(generateRacks, [])(20000n),\n indexes: (index) => ({\n // The window, whatever the rail chooses: every rack filed once by its box, at a 1 cm cell.\n schematic_stress_racks_by_area: index.area({\n x: \"x\", y: \"y\", width: \"w\", height: \"h\", at: \"centre\", cell: 0.01,\n }),\n // Beside it, a choice of halls and the window in one read.\n schematic_stress_racks_by_hall_area: index.area({\n on: [\"hall\"], x: \"x\", y: \"y\", width: \"w\", height: \"h\", at: \"centre\", cell: 0.01,\n }),\n // A choice no area index leads: a window under it asks which of its racks the choice holds.\n schematic_stress_racks_by_model: index.on([\"model\"]),\n }),\n mutations: (mutation) => ({\n // The racks' patch door: each Save of the floor writes through it, and the budget run fills the floor through it.\n patch: mutation.patch(),\n }),\n});\n\nexport const schematicStressRackLoads = e3.record(\"schematic_stress_rack_loads\", StressLoads, {\n initial: () => East.compile(generateLoads, [])(20000n),\n mutations: (mutation) => ({\n // The loads' patch door: the budget run fills them through it, keyed as the racks it fills.\n patch: mutation.patch(),\n }),\n});\n\nexport const schematicStressHalls = e3.record(\"schematic_stress_halls\", DictType(StringType, StressHall), {\n initial: new Map([\n [\"hall-1\", { name: \"Hall 1\", x: 2.0, y: 2.0, w: 72.0, h: 122.0 }],\n [\"hall-2\", { name: \"Hall 2\", x: 78.0, y: 2.0, w: 72.0, h: 122.0 }],\n [\"hall-3\", { name: \"Hall 3\", x: 154.0, y: 2.0, w: 72.0, h: 122.0 }],\n [\"hall-4\", { name: \"Hall 4\", x: 230.0, y: 2.0, w: 72.0, h: 122.0 }],\n [\"hall-5\", { name: \"Hall 5\", x: 306.0, y: 2.0, w: 72.0, h: 122.0 }],\n [\"hall-6\", { name: \"Hall 6\", x: 2.0, y: 128.0, w: 72.0, h: 122.0 }],\n [\"hall-7\", { name: \"Hall 7\", x: 78.0, y: 128.0, w: 72.0, h: 122.0 }],\n [\"hall-8\", { name: \"Hall 8\", x: 154.0, y: 128.0, w: 72.0, h: 122.0 }],\n [\"hall-9\", { name: \"Hall 9\", x: 230.0, y: 128.0, w: 72.0, h: 122.0 }],\n [\"hall-10\", { name: \"Hall 10\", x: 306.0, y: 128.0, w: 72.0, h: 122.0 }],\n ]),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n // The racks bound with their patch door, read by key through their own entries beside their source of the slice.\n const racks = $.let(Record.bind(schematicStressRacks));\n const rackEntries = $.let(Data.bindPaged(schematicStressRacks));\n const loads = $.let(Data.bindPaged(schematicStressRackLoads));\n const halls = $.let(Data.bind(schematicStressHalls));\n // One rail: the racks by hall, through the area index the hall leads, and by model, through the one led by nothing.\n const slice = $.let(Slice.bindRecords(\"ex.schematicRecordIndexes\", {\n racks: {\n source: Data.bindPaged(schematicStressRacks, { indexes: [\"schematic_stress_racks_by_area\", \"schematic_stress_racks_by_hall_area\", \"schematic_stress_racks_by_model\"] }),\n icon: { prefix: \"fas\", name: \"server\" },\n fields: {\n hall: { label: \"Hall\", hints: [\"Hall 1\", \"Hall 2\", \"Hall 3\", \"Hall 4\", \"Hall 5\", \"Hall 6\", \"Hall 7\", \"Hall 8\", \"Hall 9\", \"Hall 10\"] },\n model: { label: \"Model\", hints: [\"42U · 8 kW\", \"48U · 12 kW\", \"24U · 4 kW\"] },\n },\n },\n }));\n return (\n <Box height=\"640px\">\n <Schematic\n id=\"recordIndexes\"\n // The Index: the halls and their racks, one hall open at a time, following the hall the view rests in.\n library={[Schematic.library.index()]}\n extent={{ width: 382, height: 254 }}\n scaleUnit=\"m\"\n slice={{ slice }}\n items={{\n racks: Schematic.items(racks, {\n name: \"Rack\", icon: \"server\", x: \"x\", y: \"y\", width: \"w\", height: \"h\", label: \"name\", entries: rackEntries,\n sublabel: (r) => r.model,\n details: Schematic.details(loads, {\n meter: (l) => ({ value: l.kw, max: l.capacity }),\n metric: (l) => some(East.str`${East.Float.printFixed(l.kw, 1n)} kW`),\n status: { field: \"alarm\", cases: {\n ok: { label: \"OK\", tone: variant(\"success\", null), ring: false },\n warm: { label: \"Warm\", tone: variant(\"warning\", null), ring: false },\n hot: { label: \"Hot\", tone: variant(\"danger\", null), ring: false },\n } },\n }),\n }),\n }}\n zones={{\n halls: Schematic.zones(halls, { name: \"Hall\", icon: \"warehouse\", x: \"x\", y: \"y\", width: \"w\", height: \"h\", label: \"name\" }),\n }}\n />\n </Box>\n );\n }}</Reactive>\n ))"
44820
45910
  },
44821
45911
  {
44822
45912
  "id": "e3-ui:schematic-records.examples.tsx:schematicRecordIndexesMobile",
@@ -44963,7 +46053,7 @@
44963
46053
  "package": "e3-ui",
44964
46054
  "file": "east-ui/packages/e3-ui/test/schematic/schematic.examples.tsx",
44965
46055
  "suite": "Shapes: footprints and zone geometry about their anchors, tones, layers",
44966
- "test": "A data centre floor over the app's records, each holding its own fields: racks read through their source of the slice, editable with their patch door, their loads as details on each card, editable in the inspector; network frames, round cooling units with their own Details and power distribution units; halls, cages and aisles, outlined or hatched by what they are; fibre runs between racks and frames, solid or dashed by their cable, a run between two frames refused in the veto's words; power feeds, and fibre trunks a Shift-connect gathers runs into, none onto the core; every gesture a step of one history, Save writing each record through its patch door; the inspector; the whole selection kept by the host; and in the library every kind's templates, dropped on the canvas or on a fibre run, the racks with no position, a drop placing one, the zones' index, the layers, a systems record, and the floor's owners, an owner's card dropped on a rack making it the rack's owner",
46056
+ "test": "A data centre floor over the app's records, each holding its own fields: racks read through their source of the slice, editable with their patch door, their loads as details on each card, editable in the inspector; network frames, round cooling units with their own Details and power distribution units; halls, cages and aisles, outlined or hatched by what they are; fibre runs between racks and frames, solid or dashed by their cable, a run between two frames refused in the veto's words; power feeds, and fibre trunks a Shift-connect gathers runs into, none onto the core; a run or a trunk drawn with no template selected on the network layer, its kind's `values`; every gesture a step of one history, Save writing each record through its patch door; the inspector; the whole selection kept by the host; and in the library every kind's templates, dropped on the canvas or on a fibre run, the racks with no position, a drop placing one, the zones' index, the layers, a systems record, and the floor's owners, an owner's card dropped on a rack making it the rack's owner",
44967
46057
  "keywords": [
44968
46058
  "Schematic",
44969
46059
  "Schematic.items",
@@ -45000,7 +46090,10 @@
45000
46090
  "Connect",
45001
46091
  "nets",
45002
46092
  "drag and drop",
45003
- "drop"
46093
+ "drop",
46094
+ "values",
46095
+ "Schematic.Types.Ends",
46096
+ "Schematic.Types.Sides"
45004
46097
  ],
45005
46098
  "imports": [
45006
46099
  "import {",
@@ -45011,7 +46104,7 @@
45011
46104
  "languages": [
45012
46105
  "tsx"
45013
46106
  ],
45014
- "source": "// A data centre floor over the app's records, each holding its own fields: racks read through their source of the slice, editable with their patch door, their loads as details on each card, editable in the inspector; network frames, round cooling units with their own Details and power distribution units; halls, cages and aisles, outlined or hatched by what they are; fibre runs between racks and frames, solid or dashed by their cable, a run between two frames refused in the veto's words; power feeds, and fibre trunks a Shift-connect gathers runs into, none onto the core; every gesture a step of one history, Save writing each record through its patch door; the inspector; the whole selection kept by the host; and in the library every kind's templates, dropped on the canvas or on a fibre run, the racks with no position, a drop placing one, the zones' index, the layers, a systems record, and the floor's owners, an owner's card dropped on a rack making it the rack's owner\n// inputs: []\n/** A system the floor's equipment and areas belong to: a layer of the drawing, its colour a theme token. */\nexport const DcSystem = StructType({ label: StringType, colour: StringType, order: IntegerType, fixed: BooleanType, dim: FloatType });\n\nexport const schematicSystems = e3.record(\"schematic_systems\", DictType(StringType, DcSystem), {\n initial: new Map([\n [\"structure\", { label: \"Structure\", colour: \"fg.muted\", order: 1n, fixed: true, dim: 0.6 }],\n [\"power\", { label: \"Power\", colour: \"status.warn\", order: 2n, fixed: false, dim: 1.0 }],\n [\"cooling\", { label: \"Cooling\", colour: \"brand.solid\", order: 3n, fixed: false, dim: 1.0 }],\n [\"network\", { label: \"Network\", colour: \"status.pos\", order: 4n, fixed: false, dim: 1.0 }],\n ]),\n mutations: (mutation) => ({\n // The systems' patch door: another session's change of a layer — its colour, say — which the floor redraws.\n patch: mutation.patch(),\n }),\n});\n\n/** A rack: placed by its centre, or unplaced until a drop places it. */\nexport const DcRack = StructType({\n name: StringType, x: OptionType(FloatType), y: OptionType(FloatType), w: FloatType, h: FloatType,\n model: StringType, hall: StringType, system: StringType, owner: StringType,\n});\n\n/** A rack's load: what its card's bar, figure and dot draw. */\nexport const DcLoad = StructType({ kw: FloatType, capacity: FloatType, alarm: VariantType({ ok: NullType, warm: NullType, hot: NullType }) });\n\n/** A network frame or a power distribution unit. */\nexport const DcUnit = StructType({ name: StringType, x: FloatType, y: FloatType, w: FloatType, h: FloatType, kind: StringType, system: StringType });\n\n/** A cooling unit: round, drawn by its radius. */\nexport const DcCooling = StructType({\n name: StringType, x: FloatType, y: FloatType, w: FloatType, h: FloatType, radius: FloatType, setpoint: FloatType, system: StringType,\n});\n\n/** What an area is: a room or a cage, outlined, or a cold or a hot aisle, hatched. */\nexport const DcAreaKind = VariantType({ room: NullType, cold: NullType, hot: NullType });\n\n/** A hall, a cage or an aisle. */\nexport const DcArea = StructType({ name: StringType, x: FloatType, y: FloatType, w: FloatType, h: FloatType, kind: DcAreaKind, system: StringType });\n\n/** A fibre run's end: a rack, or a network frame. */\nexport const DcEnd = VariantType({ rack: StringType, frame: StringType });\n\n/** A bend of a fibre run's path, in metres. */\nexport const DcPoint = StructType({ x: FloatType, y: FloatType });\n\n/** What a run carries: fibre, drawn solid, or a logical link — management, a cross-connect — drawn dashed. */\nexport const DcCable = VariantType({ fibre: NullType, logical: NullType });\n\n/** A fibre run between two ends. */\nexport const DcFibre = StructType({\n from: DcEnd, to: DcEnd, path: ArrayType(DcPoint), label: OptionType(StringType), speed: OptionType(StringType), cable: DcCable, system: StringType,\n});\n\n/** A power feed: power distribution units feeding racks. */\nexport const DcFeed = StructType({ supply: ArrayType(StringType), racks: ArrayType(StringType), label: StringType, load: StringType, system: StringType });\n\n/** A fibre trunk: one cable gathering several racks' runs into a frame. */\nexport const DcTrunk = StructType({ racks: ArrayType(StringType), frames: ArrayType(StringType), label: OptionType(StringType), system: StringType });\n\n/** What a rack template gives a new rack: every field of a rack but its centre, which the drop places. */\nexport const DcRackValues = StructType({ name: StringType, w: FloatType, h: FloatType, model: StringType, hall: StringType, system: StringType, owner: StringType });\n\n/** A rack template: its card's name and group, and the rack it creates. */\nexport const DcRackTemplate = StructType({ name: StringType, group: StringType, values: DcRackValues });\n\n/** What a fibre template gives a run: every field of a run but its ends. */\nexport const DcFibreValues = StructType({\n path: ArrayType(DcPoint), label: OptionType(StringType), speed: OptionType(StringType), cable: DcCable, system: StringType,\n});\n\n/** A fibre template: its card's name and system, and what it gives a run. */\nexport const DcFibreTemplate = StructType({ name: StringType, system: StringType, values: DcFibreValues });\n\n/** A tenant of the floor: the owner a rack is let to, and who looks after its racks. */\nexport const DcOwner = StructType({ name: StringType, contact: StringType });\n\nexport const schematicRacks = e3.record(\"schematic_racks\", DictType(StringType, DcRack), {\n initial: new Map([\n [\"A01\", { name: \"A01\", x: some(2.4), y: some(2.9), w: 3.2, h: 1.2, model: \"42U · 8 kW\", hall: \"Cage A\", system: \"power\", owner: \"Harbour Labs\" }],\n [\"A02\", { name: \"A02\", x: some(6.0), y: some(2.9), w: 3.2, h: 1.2, model: \"42U · 8 kW\", hall: \"Cage A\", system: \"power\", owner: \"Harbour Labs\" }],\n [\"A03\", { name: \"A03\", x: some(9.6), y: some(2.9), w: 3.2, h: 1.2, model: \"42U · 8 kW\", hall: \"Cage A\", system: \"power\", owner: \"Northwind Media\" }],\n [\"A04\", { name: \"A04\", x: some(13.2), y: some(2.9), w: 3.2, h: 1.2, model: \"48U · 12 kW\", hall: \"Cage A\", system: \"power\", owner: \"Northwind Media\" }],\n [\"A05\", { name: \"A05\", x: some(16.8), y: some(2.9), w: 3.2, h: 1.2, model: \"48U · 12 kW\", hall: \"Cage A\", system: \"power\", owner: \"Elmway College\" }],\n [\"A06\", { name: \"A06\", x: none, y: none, w: 3.2, h: 1.2, model: \"48U · 12 kW\", hall: \"Cage A\", system: \"power\", owner: \"Elmway College\" }],\n [\"A07\", { name: \"A07\", x: none, y: none, w: 3.2, h: 1.2, model: \"42U · 8 kW\", hall: \"Cage A\", system: \"power\", owner: \"\" }],\n ]),\n indexes: (index) => ({\n schematic_racks_by_name: index.on([\"name\"]),\n schematic_racks_by_hall: index.on([\"hall\"]),\n schematic_racks_by_owner: index.on([\"owner\"]),\n // The racks filed by their boxes at a 1 cm cell, for a floor read a window at a time (#1393): what a window reads whatever\n // the rail chooses, and the racks with no position, under its unplaced clause, which the Backlog pages.\n schematic_racks_by_area: index.area({\n x: \"x\", y: \"y\", width: \"w\", height: \"h\", at: \"centre\", cell: 0.01,\n }),\n // Beside it, a choice of owners and the window — or the racks with no position — in one read.\n schematic_racks_by_owner_area: index.area({\n on: [\"owner\"], x: \"x\", y: \"y\", width: \"w\", height: \"h\", at: \"centre\", cell: 0.01,\n }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const schematicRackLoads = e3.record(\"schematic_rack_loads\", DictType(StringType, DcLoad), {\n initial: new Map([\n [\"A01\", { kw: 5.2, capacity: 8.0, alarm: variant(\"ok\", null) }],\n [\"A02\", { kw: 7.4, capacity: 8.0, alarm: variant(\"warm\", null) }],\n [\"A03\", { kw: 3.9, capacity: 8.0, alarm: variant(\"ok\", null) }],\n [\"A04\", { kw: 11.6, capacity: 12.0, alarm: variant(\"hot\", null) }],\n [\"A05\", { kw: 0.0, capacity: 12.0, alarm: variant(\"ok\", null) }],\n ]),\n mutations: (mutation) => ({\n // The racks' loads' patch door: a rack's capacity edited in the inspector's details.\n patch: mutation.patch(),\n }),\n});\n\nexport const schematicFrames = e3.record(\"schematic_frames\", DictType(StringType, DcUnit), {\n initial: new Map([\n [\"MMR-1\", { name: \"MMR-1\", x: 24.2, y: 2.9, w: 4.0, h: 1.2, kind: \"demarc · 48 ports\", system: \"network\" }],\n [\"ODF-1\", { name: \"ODF-1\", x: 8.4, y: 9.6, w: 12.8, h: 1.0, kind: \"fibre frame · 288 F\", system: \"network\" }],\n [\"CORE-1\", { name: \"CORE-1\", x: 23.2, y: 9.7, w: 4.0, h: 1.2, kind: \"core · 64 ports\", system: \"network\" }],\n ]),\n});\n\nexport const schematicPdus = e3.record(\"schematic_pdus\", DictType(StringType, DcUnit), {\n initial: new Map([\n [\"PDU-A\", { name: \"PDU-A\", x: 1.6, y: 4.2, w: 1.2, h: 0.6, kind: \"PDU · 32 A\", system: \"power\" }],\n [\"PDU-B\", { name: \"PDU-B\", x: 18.6, y: 4.2, w: 1.2, h: 0.6, kind: \"PDU · 32 A\", system: \"power\" }],\n ]),\n});\n\nexport const schematicCooling = e3.record(\"schematic_cooling\", DictType(StringType, DcCooling), {\n initial: new Map([\n [\"CRAH-1\", { name: \"CRAH-1\", x: 3.0, y: 11.9, w: 1.4, h: 1.4, radius: 0.7, setpoint: 22.0, system: \"cooling\" }],\n [\"CRAH-2\", { name: \"CRAH-2\", x: 9.0, y: 11.9, w: 1.4, h: 1.4, radius: 0.7, setpoint: 22.0, system: \"cooling\" }],\n [\"CRAH-3\", { name: \"CRAH-3\", x: 15.0, y: 11.9, w: 1.4, h: 1.4, radius: 0.7, setpoint: 23.0, system: \"cooling\" }],\n ]),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const schematicAreas = e3.record(\"schematic_areas\", DictType(StringType, DcArea), {\n initial: new Map([\n [\"cage-a\", { name: \"Cage A\", x: 0.6, y: 0.6, w: 19.6, h: 4.6, kind: variant(\"room\", null), system: \"structure\" }],\n [\"mmr\", { name: \"Meet-me room\", x: 21.0, y: 0.6, w: 6.4, h: 4.6, kind: variant(\"room\", null), system: \"structure\" }],\n [\"cold-a\", { name: \"Cold aisle A · 1.2 m\", x: 0.6, y: 6.0, w: 26.8, h: 1.2, kind: variant(\"cold\", null), system: \"cooling\" }],\n [\"net-room\", { name: \"Network room\", x: 19.0, y: 7.8, w: 8.4, h: 3.8, kind: variant(\"room\", null), system: \"structure\" }],\n [\"hot-a\", { name: \"Hot aisle A · 1.0 m\", x: 0.6, y: 12.9, w: 18.0, h: 0.9, kind: variant(\"hot\", null), system: \"cooling\" }],\n ]),\n});\n\n/** The floor's fibre runs, as its record and the frozen floor's hold them. */\nconst dcFibreRuns = new Map([\n [\"u1\", { from: variant(\"rack\", \"A01\"), to: variant(\"frame\", \"ODF-1\"), path: [], label: some(\"uplink\"), speed: some(\"100G\"), cable: variant(\"fibre\", null), system: \"network\" }],\n [\"u2\", { from: variant(\"rack\", \"A02\"), to: variant(\"frame\", \"ODF-1\"), path: [], label: some(\"uplink\"), speed: some(\"100G\"), cable: variant(\"fibre\", null), system: \"network\" }],\n [\"u2m\", { from: variant(\"rack\", \"A02\"), to: variant(\"frame\", \"ODF-1\"), path: [], label: some(\"OOB mgmt\"), speed: none, cable: variant(\"logical\", null), system: \"network\" }],\n [\"u3\", { from: variant(\"rack\", \"A03\"), to: variant(\"frame\", \"ODF-1\"), path: [], label: none, speed: none, cable: variant(\"fibre\", null), system: \"network\" }],\n [\"u4\", { from: variant(\"rack\", \"A04\"), to: variant(\"frame\", \"ODF-1\"), path: [], label: none, speed: some(\"2 × 100G\"), cable: variant(\"fibre\", null), system: \"network\" }],\n [\"x1\", { from: variant(\"frame\", \"MMR-1\"), to: variant(\"frame\", \"CORE-1\"), path: [{ x: 26.0, y: 6.6 }], label: none, speed: some(\"2 × 10G\"), cable: variant(\"logical\", null), system: \"network\" }],\n]);\n\nexport const schematicFibre = e3.record(\"schematic_fibre\", DictType(StringType, DcFibre), {\n initial: dcFibreRuns,\n indexes: (index) => ({\n // The fibre runs by system, for a floor whose rail narrows its runs through a source of their own: a run read complete\n // through its narrowing, a run a draft changed that a choice leaves out waiting in its session (#1391).\n schematic_fibre_by_system: index.on([\"system\"]),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const schematicFeeds = e3.record(\"schematic_feeds\", DictType(StringType, DcFeed), {\n initial: new Map([\n [\"feed-a\", { supply: [\"PDU-A\"], racks: [\"A01\", \"A02\", \"A03\"], label: \"PDU-A · A side\", load: \"16.5 kW\", system: \"power\" }],\n [\"feed-b\", { supply: [\"PDU-B\"], racks: [\"A04\", \"A05\"], label: \"PDU-B · A side\", load: \"11.6 kW\", system: \"power\" }],\n ]),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The floor's fibre trunks: none yet — a Shift-connect from racks to a frame gathers their runs into one. */\nexport const schematicTrunks = e3.record(\"schematic_trunks\", DictType(StringType, DcTrunk), {\n initial: new Map(),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const schematicRackTemplates = e3.record(\"schematic_rack_templates\", DictType(StringType, DcRackTemplate), {\n initial: new Map([\n [\"r42\", { name: \"42U rack · 8 kW\", group: \"Racks\", values: { name: \"New 42U rack\", w: 3.2, h: 1.2, model: \"42U · 8 kW\", hall: \"Cage A\", system: \"power\", owner: \"\" } }],\n [\"r48\", { name: \"48U rack · 12 kW\", group: \"Racks\", values: { name: \"New 48U rack\", w: 3.2, h: 1.2, model: \"48U · 12 kW\", hall: \"Cage A\", system: \"power\", owner: \"\" } }],\n [\"half\", { name: \"Half rack · 4 kW\", group: \"Half racks\", values: { name: \"New half rack\", w: 1.6, h: 1.2, model: \"24U · 4 kW\", hall: \"Cage A\", system: \"power\", owner: \"\" } }],\n ]),\n indexes: (index) => ({\n schematic_rack_templates_by_group: index.on([\"group\"]),\n }),\n});\n\nexport const schematicFibreTemplates = e3.record(\"schematic_fibre_templates\", DictType(StringType, DcFibreTemplate), {\n initial: new Map([\n [\"uplink\", { name: \"Uplink · 100G\", system: \"network\",\n values: { path: [], label: some(\"uplink\"), speed: some(\"100G\"), cable: variant(\"fibre\", null), system: \"network\" } }],\n [\"oob\", { name: \"Out-of-band management\", system: \"network\",\n values: { path: [], label: some(\"OOB mgmt\"), speed: none, cable: variant(\"logical\", null), system: \"network\" } }],\n ]),\n indexes: (index) => ({\n schematic_fibre_templates_by_system: index.on([\"system\"]),\n }),\n});\n\nexport const schematicOwners = e3.record(\"schematic_owners\", DictType(StringType, DcOwner), {\n initial: new Map([\n [\"elmway\", { name: \"Elmway College\", contact: \"IT services\" }],\n [\"harbour\", { name: \"Harbour Labs\", contact: \"Network desk\" }],\n [\"northwind\", { name: \"Northwind Media\", contact: \"Facilities\" }],\n ]),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const racks = $.let(Record.bind(schematicRacks));\n const rackEntries = $.let(Data.bindPaged(schematicRacks));\n // The racks' loads, edited in the inspector: their patch door, read by key beside the racks' source.\n const loads = $.let(Record.bind(schematicRackLoads));\n const loadEntries = $.let(Data.bindPaged(schematicRackLoads));\n const frames = $.let(Data.bind(schematicFrames));\n const pdus = $.let(Data.bind(schematicPdus));\n const cooling = $.let(Record.bind(schematicCooling));\n const areas = $.let(Data.bind(schematicAreas));\n const fibre = $.let(Record.bind(schematicFibre));\n const feeds = $.let(Record.bind(schematicFeeds));\n const trunks = $.let(Record.bind(schematicTrunks));\n const systems = $.let(Data.bind(schematicSystems));\n const rackTemplates = $.let(Data.bind(schematicRackTemplates));\n const fibreTemplates = $.let(Data.bind(schematicFibreTemplates));\n const owners = $.let(Data.bind(schematicOwners));\n // A cooling unit's own Details: its setpoint, and a button that lowers it — the edited unit goes back through `update`.\n const coolingDetails = $.const(East.function([DcCooling, FunctionType([DcCooling], NullType)], UIComponentType, ($2, unit, update) => {\n const lower = $2.const(East.function([], NullType, ($3) => {\n // East has no struct spread: the unit, rebuilt with its new setpoint.\n const edited = $3.const({\n name: unit.name, x: unit.x, y: unit.y, w: unit.w, h: unit.h, radius: unit.radius, setpoint: unit.setpoint.subtract(1.0), system: unit.system,\n }, DcCooling);\n $3(update(edited));\n }));\n return (\n <VStack gap=\"2\" align=\"stretch\">\n <Text>{East.str`${unit.name} holds ${East.Float.printFixed(unit.setpoint, 1n)} °C`}</Text>\n <Button variant=\"outline\" onClick={lower}>Lower the setpoint by 1 °C</Button>\n </VStack>\n );\n }));\n // The whole selection, after each change — items, zones, links and nets alike, each by its kind's slot and\n // key — kept where the rest of the app reads it.\n const selected = $.let(State.bind([ArrayType(Schematic.Types.Ref)], \"ex.schematicDataCentre.selected\", []));\n const onSelect = $.const(East.function([ArrayType(Schematic.Types.Ref)], NullType, ($2, refs) => {\n $2(selected.write(refs));\n }));\n // Two frames are joined by a cross-connect, never a fibre run, and the racks' trunks land on a fibre frame,\n // never on the core: the veto's words refuse the pair — a drag's draft shows them, and the footer says them of\n // the inspector's ends, sides and Connect to….\n const canConnect = $.const(East.function([Schematic.Types.Candidate], OptionType(StringType), ($2, candidate) => {\n const reason = $2.let(none, OptionType(StringType));\n $2.if(candidate.from.kind.equal(\"network\").and(() => candidate.to.kind.equal(\"network\")), ($3) => {\n $3.assign(reason, some(\"Two frames are joined by a cross-connect\"));\n });\n $2.if(candidate.kind.equal(\"trunks\").and(() => candidate.to.key.equal(\"CORE-1\")), ($3) => {\n $3.assign(reason, some(\"A trunk lands on a fibre frame, never the core\"));\n });\n return reason;\n }));\n // One rail: the racks by name, hall and owner, and each templates list by its group or system.\n const slice = $.let(Slice.bindRecords(\"ex.schematicDataCentre\", {\n racks: { source: Data.bindPaged(schematicRacks, { indexes: [\"schematic_racks_by_name\", \"schematic_racks_by_hall\", \"schematic_racks_by_owner\"] }), icon: { prefix: \"fas\", name: \"server\" },\n search: [\"name\", \"owner\"], fields: {\n name: { label: \"Rack\" }, hall: { label: \"Hall\", hints: [\"Cage A\"] }, owner: { label: \"Owner\", hints: [\"Harbour Labs\", \"Northwind Media\", \"Elmway College\"] },\n } },\n rackTemplates: { source: Data.bindPaged(schematicRackTemplates, { indexes: [\"schematic_rack_templates_by_group\"] }), fields: { group: { label: \"Group\", hints: [\"Racks\", \"Half racks\"] } } },\n fibreTemplates: { source: Data.bindPaged(schematicFibreTemplates, { indexes: [\"schematic_fibre_templates_by_system\"] }), fields: { system: { label: \"System\", hints: [\"network\"] } } },\n }));\n return (\n <Box height=\"640px\">\n <Schematic\n id=\"dataCentre\"\n inspector\n extent={{ width: 28, height: 14 }}\n scaleUnit=\"m\"\n slice={{ slice }}\n narrowed=\"dim\"\n onSelect={onSelect}\n canConnect={canConnect}\n items={{\n racks: Schematic.items(racks, {\n name: \"Rack\", icon: \"server\", x: \"x\", y: \"y\", width: \"w\", height: \"h\", label: \"name\", layer: \"system\", entries: rackEntries,\n sublabel: (r) => r.model,\n details: Schematic.details(loads, {\n entries: loadEntries,\n meter: (l) => ({ value: l.kw, max: l.capacity }),\n metric: (l) => some(East.str`${East.Float.printFixed(l.kw, 1n)} kW`),\n status: { field: \"alarm\", cases: {\n ok: { label: \"OK\", tone: variant(\"success\", null), ring: false },\n warm: { label: \"Warm\", tone: variant(\"warning\", null), ring: false },\n hot: { label: \"Hot\", tone: variant(\"danger\", null), ring: false },\n } },\n }),\n templates: Schematic.templates(rackTemplates.read(), {\n name: (t) => t.name, group: (t) => some(t.group), values: (t) => t.values, source: \"rackTemplates\",\n }),\n }),\n network: Schematic.items(frames, {\n name: \"Network frame\", icon: \"network-wired\", x: \"x\", y: \"y\", width: \"w\", height: \"h\", label: \"name\", layer: \"system\",\n sublabel: (f) => f.kind,\n }),\n cooling: Schematic.items(cooling, {\n name: \"Cooling unit\", icon: \"fan\", x: \"x\", y: \"y\", width: \"w\", height: \"h\", label: \"name\", layer: \"system\",\n footprint: (c) => some(Schematic.circle(c.radius)),\n sublabel: (c) => East.str`set ${East.Float.printFixed(c.setpoint, 1n)} °C`,\n inspector: coolingDetails,\n }),\n pdus: Schematic.items(pdus, {\n name: \"Power distribution unit\", icon: \"plug\", x: \"x\", y: \"y\", width: \"w\", height: \"h\", label: \"name\", layer: \"system\",\n sublabel: (p) => p.kind,\n }),\n }}\n zones={{\n areas: Schematic.zones(areas, {\n name: \"Area\", icon: \"vector-square\", x: \"x\", y: \"y\", width: \"w\", height: \"h\", label: \"name\", layer: \"system\",\n pattern: (a) => a.kind.match({\n room: (_$2) => Schematic.outline(),\n cold: (_$2) => Schematic.hatch({ tone: \"brand\" }),\n hot: (_$2) => Schematic.hatch({ tone: \"warning\" }),\n }),\n }),\n }}\n links={{\n fibre: Schematic.links(fibre, {\n name: \"Fibre run\", icon: \"bolt\", layer: \"system\", via: \"path\",\n from: { field: \"from\", of: { rack: \"racks\", frame: \"network\" } },\n to: { field: \"to\", of: { rack: \"racks\", frame: \"network\" } },\n label: (f) => f.label, metric: (f) => f.speed,\n style: (f) => f.cable.match({ fibre: (_$2) => Schematic.solid(), logical: (_$2) => Schematic.dashed() }),\n templates: Schematic.templates(fibreTemplates.read(), {\n name: (t) => t.name, group: (t) => some(t.system), values: (t) => t.values, source: \"fibreTemplates\",\n }),\n }),\n }}\n nets={{\n feeds: Schematic.nets(feeds, {\n name: \"Power feed\", icon: \"plug-circle-bolt\", layer: \"system\",\n sources: { field: \"supply\", of: \"pdus\" }, destinations: { field: \"racks\", of: \"racks\" },\n label: (f) => some(f.label), metric: (f) => some(f.load),\n }),\n // A Shift-connect from racks to a frame grows its first run into a trunk of them.\n trunks: Schematic.nets(trunks, {\n name: \"Fibre trunk\", icon: \"diagram-project\", layer: \"system\",\n sources: { field: \"racks\", of: \"racks\" }, destinations: { field: \"frames\", of: \"network\" },\n label: (t) => t.label,\n }),\n }}\n layers={Schematic.layers(systems.read(), {\n label: (s) => s.label, color: (s) => some(s.colour), order: (s) => s.order, locked: (s) => s.fixed, opacity: (s) => s.dim,\n })}\n library={[\n Schematic.library.templates(),\n Schematic.library.backlog(),\n Schematic.library.index(),\n Schematic.library.layers(),\n // The floor's owners: a card dropped on a rack — its patch is over a rack's row — makes it the rack's owner.\n Schematic.library.tab(owners.read(), {\n name: \"Owners\", icon: \"building\", label: (o) => o.name, meta: (o) => some(o.contact),\n drop: (o) => Schematic.patch(DcRack, { owner: o.name }),\n }),\n ]}\n />\n </Box>\n );\n }}</Reactive>\n ))"
46107
+ "source": "// A data centre floor over the app's records, each holding its own fields: racks read through their source of the slice, editable with their patch door, their loads as details on each card, editable in the inspector; network frames, round cooling units with their own Details and power distribution units; halls, cages and aisles, outlined or hatched by what they are; fibre runs between racks and frames, solid or dashed by their cable, a run between two frames refused in the veto's words; power feeds, and fibre trunks a Shift-connect gathers runs into, none onto the core; a run or a trunk drawn with no template selected on the network layer, its kind's `values`; every gesture a step of one history, Save writing each record through its patch door; the inspector; the whole selection kept by the host; and in the library every kind's templates, dropped on the canvas or on a fibre run, the racks with no position, a drop placing one, the zones' index, the layers, a systems record, and the floor's owners, an owner's card dropped on a rack making it the rack's owner\n// inputs: []\n/** A system the floor's equipment and areas belong to: a layer of the drawing, its colour a theme token. */\nexport const DcSystem = StructType({ label: StringType, colour: StringType, order: IntegerType, fixed: BooleanType, dim: FloatType });\n\nexport const schematicSystems = e3.record(\"schematic_systems\", DictType(StringType, DcSystem), {\n initial: new Map([\n [\"structure\", { label: \"Structure\", colour: \"fg.muted\", order: 1n, fixed: true, dim: 0.6 }],\n [\"power\", { label: \"Power\", colour: \"status.warn\", order: 2n, fixed: false, dim: 1.0 }],\n [\"cooling\", { label: \"Cooling\", colour: \"brand.solid\", order: 3n, fixed: false, dim: 1.0 }],\n [\"network\", { label: \"Network\", colour: \"status.pos\", order: 4n, fixed: false, dim: 1.0 }],\n ]),\n mutations: (mutation) => ({\n // The systems' patch door: another session's change of a layer — its colour, say — which the floor redraws.\n patch: mutation.patch(),\n }),\n});\n\n/** A rack: placed by its centre, or unplaced until a drop places it. */\nexport const DcRack = StructType({\n name: StringType, x: OptionType(FloatType), y: OptionType(FloatType), w: FloatType, h: FloatType,\n model: StringType, hall: StringType, system: StringType, owner: StringType,\n});\n\n/** A rack's load: what its card's bar, figure and dot draw. */\nexport const DcLoad = StructType({ kw: FloatType, capacity: FloatType, alarm: VariantType({ ok: NullType, warm: NullType, hot: NullType }) });\n\n/** A network frame or a power distribution unit. */\nexport const DcUnit = StructType({ name: StringType, x: FloatType, y: FloatType, w: FloatType, h: FloatType, kind: StringType, system: StringType });\n\n/** A cooling unit: round, drawn by its radius. */\nexport const DcCooling = StructType({\n name: StringType, x: FloatType, y: FloatType, w: FloatType, h: FloatType, radius: FloatType, setpoint: FloatType, system: StringType,\n});\n\n/** What an area is: a room or a cage, outlined, or a cold or a hot aisle, hatched. */\nexport const DcAreaKind = VariantType({ room: NullType, cold: NullType, hot: NullType });\n\n/** A hall, a cage or an aisle. */\nexport const DcArea = StructType({ name: StringType, x: FloatType, y: FloatType, w: FloatType, h: FloatType, kind: DcAreaKind, system: StringType });\n\n/** A fibre run's end: a rack, or a network frame. */\nexport const DcEnd = VariantType({ rack: StringType, frame: StringType });\n\n/** A bend of a fibre run's path, in metres. */\nexport const DcPoint = StructType({ x: FloatType, y: FloatType });\n\n/** What a run carries: fibre, drawn solid, or a logical link — management, a cross-connect — drawn dashed. */\nexport const DcCable = VariantType({ fibre: NullType, logical: NullType });\n\n/** A fibre run between two ends. */\nexport const DcFibre = StructType({\n from: DcEnd, to: DcEnd, path: ArrayType(DcPoint), label: OptionType(StringType), speed: OptionType(StringType), cable: DcCable, system: StringType,\n});\n\n/** A power feed: power distribution units feeding racks. */\nexport const DcFeed = StructType({ supply: ArrayType(StringType), racks: ArrayType(StringType), label: StringType, load: StringType, system: StringType });\n\n/** A fibre trunk: one cable gathering several racks' runs into a frame. */\nexport const DcTrunk = StructType({ racks: ArrayType(StringType), frames: ArrayType(StringType), label: OptionType(StringType), system: StringType });\n\n/** What a rack template gives a new rack: every field of a rack but its centre, which the drop places. */\nexport const DcRackValues = StructType({ name: StringType, w: FloatType, h: FloatType, model: StringType, hall: StringType, system: StringType, owner: StringType });\n\n/** A rack template: its card's name and group, and the rack it creates. */\nexport const DcRackTemplate = StructType({ name: StringType, group: StringType, values: DcRackValues });\n\n/** What a fibre template gives a run: every field of a run but its ends. */\nexport const DcFibreValues = StructType({\n path: ArrayType(DcPoint), label: OptionType(StringType), speed: OptionType(StringType), cable: DcCable, system: StringType,\n});\n\n/** A fibre template: its card's name and system, and what it gives a run. */\nexport const DcFibreTemplate = StructType({ name: StringType, system: StringType, values: DcFibreValues });\n\n/** A tenant of the floor: the owner a rack is let to, and who looks after its racks. */\nexport const DcOwner = StructType({ name: StringType, contact: StringType });\n\nexport const schematicRacks = e3.record(\"schematic_racks\", DictType(StringType, DcRack), {\n initial: new Map([\n [\"A01\", { name: \"A01\", x: some(2.4), y: some(2.9), w: 3.2, h: 1.2, model: \"42U · 8 kW\", hall: \"Cage A\", system: \"power\", owner: \"Harbour Labs\" }],\n [\"A02\", { name: \"A02\", x: some(6.0), y: some(2.9), w: 3.2, h: 1.2, model: \"42U · 8 kW\", hall: \"Cage A\", system: \"power\", owner: \"Harbour Labs\" }],\n [\"A03\", { name: \"A03\", x: some(9.6), y: some(2.9), w: 3.2, h: 1.2, model: \"42U · 8 kW\", hall: \"Cage A\", system: \"power\", owner: \"Northwind Media\" }],\n [\"A04\", { name: \"A04\", x: some(13.2), y: some(2.9), w: 3.2, h: 1.2, model: \"48U · 12 kW\", hall: \"Cage A\", system: \"power\", owner: \"Northwind Media\" }],\n [\"A05\", { name: \"A05\", x: some(16.8), y: some(2.9), w: 3.2, h: 1.2, model: \"48U · 12 kW\", hall: \"Cage A\", system: \"power\", owner: \"Elmway College\" }],\n [\"A06\", { name: \"A06\", x: none, y: none, w: 3.2, h: 1.2, model: \"48U · 12 kW\", hall: \"Cage A\", system: \"power\", owner: \"Elmway College\" }],\n [\"A07\", { name: \"A07\", x: none, y: none, w: 3.2, h: 1.2, model: \"42U · 8 kW\", hall: \"Cage A\", system: \"power\", owner: \"\" }],\n ]),\n indexes: (index) => ({\n schematic_racks_by_name: index.on([\"name\"]),\n schematic_racks_by_hall: index.on([\"hall\"]),\n schematic_racks_by_owner: index.on([\"owner\"]),\n // The racks filed by their boxes at a 1 cm cell, for a floor read a window at a time (#1393): what a window reads whatever\n // the rail chooses, and the racks with no position, under its unplaced clause, which the Backlog pages.\n schematic_racks_by_area: index.area({\n x: \"x\", y: \"y\", width: \"w\", height: \"h\", at: \"centre\", cell: 0.01,\n }),\n // Beside it, a choice of owners and the window — or the racks with no position — in one read.\n schematic_racks_by_owner_area: index.area({\n on: [\"owner\"], x: \"x\", y: \"y\", width: \"w\", height: \"h\", at: \"centre\", cell: 0.01,\n }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const schematicRackLoads = e3.record(\"schematic_rack_loads\", DictType(StringType, DcLoad), {\n initial: new Map([\n [\"A01\", { kw: 5.2, capacity: 8.0, alarm: variant(\"ok\", null) }],\n [\"A02\", { kw: 7.4, capacity: 8.0, alarm: variant(\"warm\", null) }],\n [\"A03\", { kw: 3.9, capacity: 8.0, alarm: variant(\"ok\", null) }],\n [\"A04\", { kw: 11.6, capacity: 12.0, alarm: variant(\"hot\", null) }],\n [\"A05\", { kw: 0.0, capacity: 12.0, alarm: variant(\"ok\", null) }],\n ]),\n mutations: (mutation) => ({\n // The racks' loads' patch door: a rack's capacity edited in the inspector's details.\n patch: mutation.patch(),\n }),\n});\n\nexport const schematicFrames = e3.record(\"schematic_frames\", DictType(StringType, DcUnit), {\n initial: new Map([\n [\"MMR-1\", { name: \"MMR-1\", x: 24.2, y: 2.9, w: 4.0, h: 1.2, kind: \"demarc · 48 ports\", system: \"network\" }],\n [\"ODF-1\", { name: \"ODF-1\", x: 8.4, y: 9.6, w: 12.8, h: 1.0, kind: \"fibre frame · 288 F\", system: \"network\" }],\n [\"CORE-1\", { name: \"CORE-1\", x: 23.2, y: 9.7, w: 4.0, h: 1.2, kind: \"core · 64 ports\", system: \"network\" }],\n ]),\n});\n\nexport const schematicPdus = e3.record(\"schematic_pdus\", DictType(StringType, DcUnit), {\n initial: new Map([\n [\"PDU-A\", { name: \"PDU-A\", x: 1.6, y: 4.2, w: 1.2, h: 0.6, kind: \"PDU · 32 A\", system: \"power\" }],\n [\"PDU-B\", { name: \"PDU-B\", x: 18.6, y: 4.2, w: 1.2, h: 0.6, kind: \"PDU · 32 A\", system: \"power\" }],\n ]),\n});\n\nexport const schematicCooling = e3.record(\"schematic_cooling\", DictType(StringType, DcCooling), {\n initial: new Map([\n [\"CRAH-1\", { name: \"CRAH-1\", x: 3.0, y: 11.9, w: 1.4, h: 1.4, radius: 0.7, setpoint: 22.0, system: \"cooling\" }],\n [\"CRAH-2\", { name: \"CRAH-2\", x: 9.0, y: 11.9, w: 1.4, h: 1.4, radius: 0.7, setpoint: 22.0, system: \"cooling\" }],\n [\"CRAH-3\", { name: \"CRAH-3\", x: 15.0, y: 11.9, w: 1.4, h: 1.4, radius: 0.7, setpoint: 23.0, system: \"cooling\" }],\n ]),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const schematicAreas = e3.record(\"schematic_areas\", DictType(StringType, DcArea), {\n initial: new Map([\n [\"cage-a\", { name: \"Cage A\", x: 0.6, y: 0.6, w: 19.6, h: 4.6, kind: variant(\"room\", null), system: \"structure\" }],\n [\"mmr\", { name: \"Meet-me room\", x: 21.0, y: 0.6, w: 6.4, h: 4.6, kind: variant(\"room\", null), system: \"structure\" }],\n [\"cold-a\", { name: \"Cold aisle A · 1.2 m\", x: 0.6, y: 6.0, w: 26.8, h: 1.2, kind: variant(\"cold\", null), system: \"cooling\" }],\n [\"net-room\", { name: \"Network room\", x: 19.0, y: 7.8, w: 8.4, h: 3.8, kind: variant(\"room\", null), system: \"structure\" }],\n [\"hot-a\", { name: \"Hot aisle A · 1.0 m\", x: 0.6, y: 12.9, w: 18.0, h: 0.9, kind: variant(\"hot\", null), system: \"cooling\" }],\n ]),\n});\n\n/** The floor's fibre runs, as its record and the frozen floor's hold them. */\nconst dcFibreRuns = new Map([\n [\"u1\", { from: variant(\"rack\", \"A01\"), to: variant(\"frame\", \"ODF-1\"), path: [], label: some(\"uplink\"), speed: some(\"100G\"), cable: variant(\"fibre\", null), system: \"network\" }],\n [\"u2\", { from: variant(\"rack\", \"A02\"), to: variant(\"frame\", \"ODF-1\"), path: [], label: some(\"uplink\"), speed: some(\"100G\"), cable: variant(\"fibre\", null), system: \"network\" }],\n [\"u2m\", { from: variant(\"rack\", \"A02\"), to: variant(\"frame\", \"ODF-1\"), path: [], label: some(\"OOB mgmt\"), speed: none, cable: variant(\"logical\", null), system: \"network\" }],\n [\"u3\", { from: variant(\"rack\", \"A03\"), to: variant(\"frame\", \"ODF-1\"), path: [], label: none, speed: none, cable: variant(\"fibre\", null), system: \"network\" }],\n [\"u4\", { from: variant(\"rack\", \"A04\"), to: variant(\"frame\", \"ODF-1\"), path: [], label: none, speed: some(\"2 × 100G\"), cable: variant(\"fibre\", null), system: \"network\" }],\n [\"x1\", { from: variant(\"frame\", \"MMR-1\"), to: variant(\"frame\", \"CORE-1\"), path: [{ x: 26.0, y: 6.6 }], label: none, speed: some(\"2 × 10G\"), cable: variant(\"logical\", null), system: \"network\" }],\n]);\n\nexport const schematicFibre = e3.record(\"schematic_fibre\", DictType(StringType, DcFibre), {\n initial: dcFibreRuns,\n indexes: (index) => ({\n // The fibre runs by system, for a floor whose rail narrows its runs through a source of their own: a run read complete\n // through its narrowing, a run a draft changed that a choice leaves out waiting in its session (#1391).\n schematic_fibre_by_system: index.on([\"system\"]),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const schematicFeeds = e3.record(\"schematic_feeds\", DictType(StringType, DcFeed), {\n initial: new Map([\n [\"feed-a\", { supply: [\"PDU-A\"], racks: [\"A01\", \"A02\", \"A03\"], label: \"PDU-A · A side\", load: \"16.5 kW\", system: \"power\" }],\n [\"feed-b\", { supply: [\"PDU-B\"], racks: [\"A04\", \"A05\"], label: \"PDU-B · A side\", load: \"11.6 kW\", system: \"power\" }],\n ]),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The floor's fibre trunks: none yet — a Shift-connect from racks to a frame gathers their runs into one. */\nexport const schematicTrunks = e3.record(\"schematic_trunks\", DictType(StringType, DcTrunk), {\n initial: new Map(),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const schematicRackTemplates = e3.record(\"schematic_rack_templates\", DictType(StringType, DcRackTemplate), {\n initial: new Map([\n [\"r42\", { name: \"42U rack · 8 kW\", group: \"Racks\", values: { name: \"New 42U rack\", w: 3.2, h: 1.2, model: \"42U · 8 kW\", hall: \"Cage A\", system: \"power\", owner: \"\" } }],\n [\"r48\", { name: \"48U rack · 12 kW\", group: \"Racks\", values: { name: \"New 48U rack\", w: 3.2, h: 1.2, model: \"48U · 12 kW\", hall: \"Cage A\", system: \"power\", owner: \"\" } }],\n [\"half\", { name: \"Half rack · 4 kW\", group: \"Half racks\", values: { name: \"New half rack\", w: 1.6, h: 1.2, model: \"24U · 4 kW\", hall: \"Cage A\", system: \"power\", owner: \"\" } }],\n ]),\n indexes: (index) => ({\n schematic_rack_templates_by_group: index.on([\"group\"]),\n }),\n});\n\nexport const schematicFibreTemplates = e3.record(\"schematic_fibre_templates\", DictType(StringType, DcFibreTemplate), {\n initial: new Map([\n [\"uplink\", { name: \"Uplink · 100G\", system: \"network\",\n values: { path: [], label: some(\"uplink\"), speed: some(\"100G\"), cable: variant(\"fibre\", null), system: \"network\" } }],\n [\"oob\", { name: \"Out-of-band management\", system: \"network\",\n values: { path: [], label: some(\"OOB mgmt\"), speed: none, cable: variant(\"logical\", null), system: \"network\" } }],\n ]),\n indexes: (index) => ({\n schematic_fibre_templates_by_system: index.on([\"system\"]),\n }),\n});\n\nexport const schematicOwners = e3.record(\"schematic_owners\", DictType(StringType, DcOwner), {\n initial: new Map([\n [\"elmway\", { name: \"Elmway College\", contact: \"IT services\" }],\n [\"harbour\", { name: \"Harbour Labs\", contact: \"Network desk\" }],\n [\"northwind\", { name: \"Northwind Media\", contact: \"Facilities\" }],\n ]),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const racks = $.let(Record.bind(schematicRacks));\n const rackEntries = $.let(Data.bindPaged(schematicRacks));\n // The racks' loads, edited in the inspector: their patch door, read by key beside the racks' source.\n const loads = $.let(Record.bind(schematicRackLoads));\n const loadEntries = $.let(Data.bindPaged(schematicRackLoads));\n const frames = $.let(Data.bind(schematicFrames));\n const pdus = $.let(Data.bind(schematicPdus));\n const cooling = $.let(Record.bind(schematicCooling));\n const areas = $.let(Data.bind(schematicAreas));\n const fibre = $.let(Record.bind(schematicFibre));\n const feeds = $.let(Record.bind(schematicFeeds));\n const trunks = $.let(Record.bind(schematicTrunks));\n const systems = $.let(Data.bind(schematicSystems));\n const rackTemplates = $.let(Data.bind(schematicRackTemplates));\n const fibreTemplates = $.let(Data.bind(schematicFibreTemplates));\n const owners = $.let(Data.bind(schematicOwners));\n // A cooling unit's own Details: its setpoint, and a button that lowers it — the edited unit goes back through `update`.\n const coolingDetails = $.const(East.function([DcCooling, FunctionType([DcCooling], NullType)], UIComponentType, ($2, unit, update) => {\n const lower = $2.const(East.function([], NullType, ($3) => {\n // East has no struct spread: the unit, rebuilt with its new setpoint.\n const edited = $3.const({\n name: unit.name, x: unit.x, y: unit.y, w: unit.w, h: unit.h, radius: unit.radius, setpoint: unit.setpoint.subtract(1.0), system: unit.system,\n }, DcCooling);\n $3(update(edited));\n }));\n return (\n <VStack gap=\"2\" align=\"stretch\">\n <Text>{East.str`${unit.name} holds ${East.Float.printFixed(unit.setpoint, 1n)} °C`}</Text>\n <Button variant=\"outline\" onClick={lower}>Lower the setpoint by 1 °C</Button>\n </VStack>\n );\n }));\n // The whole selection, after each change — items, zones, links and nets alike, each by its kind's slot and\n // key — kept where the rest of the app reads it.\n const selected = $.let(State.bind([ArrayType(Schematic.Types.Ref)], \"ex.schematicDataCentre.selected\", []));\n const onSelect = $.const(East.function([ArrayType(Schematic.Types.Ref)], NullType, ($2, refs) => {\n $2(selected.write(refs));\n }));\n // Two frames are joined by a cross-connect, never a fibre run, and the racks' trunks land on a fibre frame,\n // never on the core: the veto's words refuse the pair — a drag's draft shows them, and the footer says them of\n // the inspector's ends, sides and Connect to….\n const canConnect = $.const(East.function([Schematic.Types.Candidate], OptionType(StringType), ($2, candidate) => {\n const reason = $2.let(none, OptionType(StringType));\n $2.if(candidate.from.kind.equal(\"network\").and(() => candidate.to.kind.equal(\"network\")), ($3) => {\n $3.assign(reason, some(\"Two frames are joined by a cross-connect\"));\n });\n $2.if(candidate.kind.equal(\"trunks\").and(() => candidate.to.key.equal(\"CORE-1\")), ($3) => {\n $3.assign(reason, some(\"A trunk lands on a fibre frame, never the core\"));\n });\n return reason;\n }));\n // One rail: the racks by name, hall and owner, and each templates list by its group or system.\n const slice = $.let(Slice.bindRecords(\"ex.schematicDataCentre\", {\n racks: { source: Data.bindPaged(schematicRacks, { indexes: [\"schematic_racks_by_name\", \"schematic_racks_by_hall\", \"schematic_racks_by_owner\"] }), icon: { prefix: \"fas\", name: \"server\" },\n search: [\"name\", \"owner\"], fields: {\n name: { label: \"Rack\" }, hall: { label: \"Hall\", hints: [\"Cage A\"] }, owner: { label: \"Owner\", hints: [\"Harbour Labs\", \"Northwind Media\", \"Elmway College\"] },\n } },\n rackTemplates: { source: Data.bindPaged(schematicRackTemplates, { indexes: [\"schematic_rack_templates_by_group\"] }), fields: { group: { label: \"Group\", hints: [\"Racks\", \"Half racks\"] } } },\n fibreTemplates: { source: Data.bindPaged(schematicFibreTemplates, { indexes: [\"schematic_fibre_templates_by_system\"] }), fields: { system: { label: \"System\", hints: [\"network\"] } } },\n }));\n return (\n <Box height=\"640px\">\n <Schematic\n id=\"dataCentre\"\n inspector\n extent={{ width: 28, height: 14 }}\n scaleUnit=\"m\"\n slice={{ slice }}\n narrowed=\"dim\"\n onSelect={onSelect}\n canConnect={canConnect}\n items={{\n racks: Schematic.items(racks, {\n name: \"Rack\", icon: \"server\", x: \"x\", y: \"y\", width: \"w\", height: \"h\", label: \"name\", layer: \"system\", entries: rackEntries,\n sublabel: (r) => r.model,\n details: Schematic.details(loads, {\n entries: loadEntries,\n meter: (l) => ({ value: l.kw, max: l.capacity }),\n metric: (l) => some(East.str`${East.Float.printFixed(l.kw, 1n)} kW`),\n status: { field: \"alarm\", cases: {\n ok: { label: \"OK\", tone: variant(\"success\", null), ring: false },\n warm: { label: \"Warm\", tone: variant(\"warning\", null), ring: false },\n hot: { label: \"Hot\", tone: variant(\"danger\", null), ring: false },\n } },\n }),\n templates: Schematic.templates(rackTemplates.read(), {\n name: (t) => t.name, group: (t) => some(t.group), values: (t) => t.values, source: \"rackTemplates\",\n }),\n }),\n network: Schematic.items(frames, {\n name: \"Network frame\", icon: \"network-wired\", x: \"x\", y: \"y\", width: \"w\", height: \"h\", label: \"name\", layer: \"system\",\n sublabel: (f) => f.kind,\n }),\n cooling: Schematic.items(cooling, {\n name: \"Cooling unit\", icon: \"fan\", x: \"x\", y: \"y\", width: \"w\", height: \"h\", label: \"name\", layer: \"system\",\n footprint: (c) => some(Schematic.circle(c.radius)),\n sublabel: (c) => East.str`set ${East.Float.printFixed(c.setpoint, 1n)} °C`,\n inspector: coolingDetails,\n }),\n pdus: Schematic.items(pdus, {\n name: \"Power distribution unit\", icon: \"plug\", x: \"x\", y: \"y\", width: \"w\", height: \"h\", label: \"name\", layer: \"system\",\n sublabel: (p) => p.kind,\n }),\n }}\n zones={{\n areas: Schematic.zones(areas, {\n name: \"Area\", icon: \"vector-square\", x: \"x\", y: \"y\", width: \"w\", height: \"h\", label: \"name\", layer: \"system\",\n pattern: (a) => a.kind.match({\n room: (_$2) => Schematic.outline(),\n cold: (_$2) => Schematic.hatch({ tone: \"brand\" }),\n hot: (_$2) => Schematic.hatch({ tone: \"warning\" }),\n }),\n }),\n }}\n links={{\n fibre: Schematic.links(fibre, {\n name: \"Fibre run\", icon: \"bolt\", layer: \"system\", via: \"path\",\n from: { field: \"from\", of: { rack: \"racks\", frame: \"network\" } },\n to: { field: \"to\", of: { rack: \"racks\", frame: \"network\" } },\n label: (f) => f.label, metric: (f) => f.speed,\n style: (f) => f.cable.match({ fibre: (_$2) => Schematic.solid(), logical: (_$2) => Schematic.dashed() }),\n // A run drawn with no template selected: a fibre run on the network layer, every field but its ends.\n values: (_ends) => ({ path: [], label: none, speed: none, cable: variant(\"fibre\", null), system: \"network\" }),\n templates: Schematic.templates(fibreTemplates.read(), {\n name: (t) => t.name, group: (t) => some(t.system), values: (t) => t.values, source: \"fibreTemplates\",\n }),\n }),\n }}\n nets={{\n feeds: Schematic.nets(feeds, {\n name: \"Power feed\", icon: \"plug-circle-bolt\", layer: \"system\",\n sources: { field: \"supply\", of: \"pdus\" }, destinations: { field: \"racks\", of: \"racks\" },\n label: (f) => some(f.label), metric: (f) => some(f.load),\n }),\n // A Shift-connect from racks to a frame grows its first run into a trunk of them.\n trunks: Schematic.nets(trunks, {\n name: \"Fibre trunk\", icon: \"diagram-project\", layer: \"system\",\n sources: { field: \"racks\", of: \"racks\" }, destinations: { field: \"frames\", of: \"network\" },\n label: (t) => t.label,\n // A trunk a Shift-connect grows: on the network layer, every field but its sides.\n values: (_sides) => ({ label: none, system: \"network\" }),\n }),\n }}\n layers={Schematic.layers(systems.read(), {\n label: (s) => s.label, color: (s) => some(s.colour), order: (s) => s.order, locked: (s) => s.fixed, opacity: (s) => s.dim,\n })}\n library={[\n Schematic.library.templates(),\n Schematic.library.backlog(),\n Schematic.library.index(),\n Schematic.library.layers(),\n // The floor's owners: a card dropped on a rack — its patch is over a rack's row — makes it the rack's owner.\n Schematic.library.tab(owners.read(), {\n name: \"Owners\", icon: \"building\", label: (o) => o.name, meta: (o) => some(o.contact),\n drop: (o) => Schematic.patch(DcRack, { owner: o.name }),\n }),\n ]}\n />\n </Box>\n );\n }}</Reactive>\n ))"
45015
46108
  },
45016
46109
  {
45017
46110
  "id": "e3-ui:schematic.examples.tsx:schematicWording",
@@ -45102,6 +46195,42 @@
45102
46195
  ],
45103
46196
  "source": "// Your edits meeting someone else's save, in one window — move a rack sideways, then press Someone else saves, which saves another person's change to the same racks (every rack half a metre to the right), so yours conflict and wait to be chosen; a rack moved only up or down, or a field changed in the panel, combines with theirs\n// inputs: []\nexport const FloorRack = StructType({ name: StringType, x: FloatType, y: FloatType, w: FloatType, h: FloatType, model: StringType, kw: FloatType, capacity: FloatType });\n\n/** The racks the conflicts example edits, in a record of their own, so no other example's edits meet them. */\nexport const schematicConflictRacks = e3.record(\"schematic_conflict_racks\", DictType(StringType, FloorRack), {\n initial: new Map([\n [\"A01\", { name: \"A01\", x: 2.4, y: 2.9, w: 3.2, h: 1.2, model: \"42U · 8 kW\", kw: 5.2, capacity: 8.0 }],\n [\"A02\", { name: \"A02\", x: 6.0, y: 2.9, w: 3.2, h: 1.2, model: \"42U · 8 kW\", kw: 7.4, capacity: 8.0 }],\n [\"A03\", { name: \"A03\", x: 9.6, y: 2.9, w: 3.2, h: 1.2, model: \"42U · 8 kW\", kw: 3.9, capacity: 8.0 }],\n [\"B01\", { name: \"B01\", x: 2.4, y: 8.6, w: 3.2, h: 1.2, model: \"42U · 8 kW\", kw: 6.1, capacity: 8.0 }],\n [\"B02\", { name: \"B02\", x: 6.0, y: 8.6, w: 3.2, h: 1.2, model: \"42U · 8 kW\", kw: 2.8, capacity: 8.0 }],\n ]),\n mutations: (mutation) => ({\n // The racks' patch door — every Save commits through it.\n patch: mutation.patch(),\n // Someone else's save: every rack half a metre to the right, its other fields as they were.\n elsewhere: mutation.reduce(East.function([DictType(StringType, FloorRack)], DictType(StringType, FloorRack), (_$, racks) =>\n racks.map((_$2, rack) => ({\n name: rack.name, x: rack.x.add(0.5), y: rack.y, w: rack.w, h: rack.h, model: rack.model, kw: rack.kw, capacity: rack.capacity,\n })))),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const racks = $.let(Record.bind(schematicConflictRacks, [\"patch\"]));\n const others = $.let(Record.bind(schematicConflictRacks, [\"elsewhere\"]));\n const theirs = $.const(East.function([], NullType, ($) => { $(others.mutate.elsewhere()); }));\n return (\n <VStack gap=\"3\" align=\"stretch\">\n <HStack gap=\"3\">\n <Button variant=\"outline\" onClick={theirs} loading={others.mutate.pending()}>Someone else saves</Button>\n <Text color=\"fg.muted\">Their change: every rack half a metre to the right</Text>\n </HStack>\n <Box height=\"440px\">\n <Schematic\n id=\"conflicts\"\n extent={{ width: 18, height: 12 }}\n scaleUnit=\"m\"\n items={{\n racks: Schematic.items(racks, {\n name: \"Rack\", icon: \"server\", x: \"x\", y: \"y\", width: \"w\", height: \"h\", label: \"name\",\n sublabel: (r) => r.model,\n meter: (r) => ({ value: r.kw, max: r.capacity }),\n }),\n }}\n inspector\n />\n </Box>\n </VStack>\n );\n }}</Reactive>\n ))"
45104
46197
  },
46198
+ {
46199
+ "id": "e3-ui:schematic.examples.tsx:schematicBakehouse",
46200
+ "skill": "e3-ui",
46201
+ "package": "e3-ui",
46202
+ "file": "east-ui/packages/e3-ui/test/schematic/schematic.examples.tsx",
46203
+ "suite": "The bakehouse: records keyed by number",
46204
+ "test": "A bakehouse's ovens and the ducts between them, each record keyed by number: a duct's ends hold its ovens' numbers, checked against the ovens' key type when the Schematic is built; an oven dropped from the library is numbered one past the largest, and a duct drawn with Connect is numbered the same way; the inspector names each by its number",
46205
+ "keywords": [
46206
+ "Schematic",
46207
+ "Schematic.items",
46208
+ "Schematic.links",
46209
+ "Schematic.templates",
46210
+ "Record.bind",
46211
+ "records",
46212
+ "IntegerType",
46213
+ "Integer key",
46214
+ "key type",
46215
+ "keyed by number",
46216
+ "new key",
46217
+ "one past the largest",
46218
+ "Connect",
46219
+ "drop",
46220
+ "templates",
46221
+ "inspector"
46222
+ ],
46223
+ "imports": [
46224
+ "import {",
46225
+ "import { Box, Button, HStack, Reactive, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
46226
+ "import { Data, Record, Schematic } from \"@elaraai/e3-ui\";",
46227
+ "import e3 from \"@elaraai/e3\";"
46228
+ ],
46229
+ "languages": [
46230
+ "tsx"
46231
+ ],
46232
+ "source": "// A bakehouse's ovens and the ducts between them, each record keyed by number: a duct's ends hold its ovens' numbers, checked against the ovens' key type when the Schematic is built; an oven dropped from the library is numbered one past the largest, and a duct drawn with Connect is numbered the same way; the inspector names each by its number\n// inputs: []\n/** An oven on the bakehouse floor, placed by its centre. */\nexport const BakeryOven = StructType({ name: StringType, x: FloatType, y: FloatType, w: FloatType, h: FloatType });\n\n/** A duct between two ovens: each end an oven's number. */\nexport const BakeryDuct = StructType({ from: IntegerType, to: IntegerType });\n\n/** What an oven template gives a new oven: every field of an oven but its centre, which the drop places. */\nexport const BakeryOvenValues = StructType({ name: StringType, w: FloatType, h: FloatType });\n\n/** An oven template: its card's name and group, and the oven it creates. */\nexport const BakeryOvenTemplate = StructType({ name: StringType, group: StringType, values: BakeryOvenValues });\n\nexport const schematicBakeryOvens = e3.record(\"schematic_bakery_ovens\", DictType(IntegerType, BakeryOven), {\n initial: new Map([\n [1n, { name: \"Deck oven\", x: 4, y: 3, w: 3, h: 2 }],\n [2n, { name: \"Convection oven\", x: 12, y: 3, w: 3, h: 2 }],\n ]),\n mutations: (mutation) => ({\n // The ovens' patch door: Save writes each oven through it, a new one under the number one past the largest.\n patch: mutation.patch(),\n }),\n});\n\nexport const schematicBakeryDucts = e3.record(\"schematic_bakery_ducts\", DictType(IntegerType, BakeryDuct), {\n initial: new Map([[1n, { from: 1n, to: 2n }]]),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const schematicBakeryOvenTemplates = e3.record(\"schematic_bakery_oven_templates\", DictType(StringType, BakeryOvenTemplate), {\n initial: new Map([\n [\"deck\", { name: \"Deck oven\", group: \"Ovens\", values: { name: \"Deck oven\", w: 3, h: 2 } }],\n [\"rack\", { name: \"Rack oven\", group: \"Ovens\", values: { name: \"Rack oven\", w: 2, h: 2 } }],\n ]),\n indexes: (index) => ({\n schematic_bakery_oven_templates_by_group: index.on([\"group\"]),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const ovens = $.let(Record.bind(schematicBakeryOvens));\n const ducts = $.let(Record.bind(schematicBakeryDucts));\n const templates = $.let(Data.bind(schematicBakeryOvenTemplates));\n // The oven templates by their group: the library's cards follow the rail.\n const slice = $.let(Slice.bindRecords(\"ex.schematicBakehouse\", {\n ovenTemplates: {\n source: Data.bindPaged(schematicBakeryOvenTemplates, { indexes: [\"schematic_bakery_oven_templates_by_group\"] }),\n fields: { group: { label: \"Group\", hints: [\"Ovens\"] } },\n },\n }));\n return (\n <Box height=\"440px\">\n <Schematic\n id=\"bakehouse\"\n inspector\n extent={{ width: 20, height: 12 }}\n scaleUnit=\"m\"\n slice={{ slice }}\n items={{\n ovens: Schematic.items(ovens, {\n name: \"Oven\", icon: \"fire-burner\", x: \"x\", y: \"y\", width: \"w\", height: \"h\", label: \"name\",\n templates: Schematic.templates(templates.read(), {\n name: (t) => t.name, group: (t) => some(t.group), values: (t) => t.values, source: \"ovenTemplates\",\n }),\n }),\n }}\n links={{\n // Each end an Integer field, holding an oven's number: the ovens' key type.\n ducts: Schematic.links(ducts, { name: \"Duct\", icon: \"wind\", from: { field: \"from\", of: \"ovens\" }, to: { field: \"to\", of: \"ovens\" } }),\n }}\n library={[Schematic.library.templates()]}\n />\n </Box>\n );\n }}</Reactive>\n ))"
46233
+ },
45105
46234
  {
45106
46235
  "id": "e3-ui:optimise.examples.tsx:sheetOptimise",
45107
46236
  "skill": "e3-ui",
@@ -45204,7 +46333,7 @@
45204
46333
  "languages": [
45205
46334
  "tsx"
45206
46335
  ],
45207
- "source": "// Work orders whose steps are a state machine: Start, Complete, Report… (a number form), Hold ▾ (a menu of reasons) and Alert… (a struct form), each state's `next` its way on; a step blocked until the one before it is finished; each case's `updates` writing Good and Done on the step and the order's status on its band — saved with the order — as one step of history\n// inputs: []\nexport const HoldReason = VariantType({ awaiting_parts: NullType, machine_down: NullType, quality_hold: NullType });\n\nexport const StepAlert = StructType({ changes: StringType, severity: VariantType({ low: NullType, high: NullType }) });\n\nexport const StepAction = VariantType({\n started: NullType,\n completed: NullType,\n reported: IntegerType, // the good parts counted so far\n held: HoldReason,\n alerted: StepAlert,\n verified: NullType, // written upstream by QA; never offered here\n});\n\nexport const Step = StructType({\n op: StringType, step: StringType, plan: IntegerType,\n good: OptionType(IntegerType), done: OptionType(DateTimeType),\n action: OptionType(StepAction),\n});\n\nexport const WorkOrder = StructType({ id: StringType, name: StringType, status: StringType, steps: ArrayType(Step) });\n\nexport const WorkStatus = StructType({ word: StringType, label: StringType, tone: StatusValueType });\n\nexport const sheetWorkOrders = e3.record(\"sheet_work_orders\", DictType(StringType, WorkOrder), {\n initial: new Map([\n [\"WO-1042\", { id: \"WO-1042\", name: \"Frame assembly\", status: \"in_progress\", steps: [\n { op: \"10\", step: \"Cut tube stock\", plan: 24n, good: some(24n), done: some(new Date(\"2026-11-02T08:42:00Z\")), action: some(variant(\"completed\", null)) },\n { op: \"20\", step: \"Weld frame\", plan: 24n, good: none, done: none, action: some(variant(\"started\", null)) },\n { op: \"30\", step: \"Grind welds\", plan: 24n, good: none, done: none, action: none },\n ] }],\n [\"WO-1043\", { id: \"WO-1043\", name: \"Bracket kit\", status: \"on_hold\", steps: [\n { op: \"10\", step: \"Laser cut\", plan: 120n, good: none, done: none, action: some(variant(\"held\", variant(\"machine_down\", null))) },\n { op: \"20\", step: \"Bend\", plan: 120n, good: none, done: none, action: none },\n ] }],\n [\"WO-1044\", { id: \"WO-1044\", name: \"Pump housing\", status: \"on_hold\", steps: [\n { op: \"10\", step: \"Turn blank\", plan: 8n, good: some(8n), done: some(new Date(\"2026-11-02T11:05:00Z\")), action: some(variant(\"verified\", null)) },\n { op: \"20\", step: \"Mill bore\", plan: 8n, good: none, done: none,\n action: some(variant(\"alerted\", { changes: \"Bore gauge reads 0.04 mm over\", severity: variant(\"high\", null) })) },\n ] }],\n ]),\n indexes: (index) => ({\n // The orders by status: what the rail narrows them by.\n sheet_work_orders_by_status: index.on([\"status\"]),\n }),\n mutations: (mutation) => ({\n // The orders' patch door — every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const orders = $.let(Record.bind(sheetWorkOrders));\n // One rail over the orders: its `rows` source narrows them.\n const slice = $.let(Slice.bindRecords(\"sheet.work.sheetActionsWorkOrders\", {\n rows: {\n source: Data.bindPaged(sheetWorkOrders, { indexes: [\"sheet_work_orders_by_status\"] }),\n label: \"Orders\",\n fields: { status: { label: \"Status\", hints: [{ value: \"in_progress\", label: \"In progress\" }, { value: \"on_hold\", label: \"On hold\" }, { value: \"done\", label: \"Done\" }] } },\n },\n }));\n const statuses = $.let([\n { word: \"in_progress\", label: \"In progress\", tone: variant(\"info\", null) },\n { word: \"on_hold\", label: \"On hold\", tone: variant(\"warning\", null) },\n { word: \"done\", label: \"Done\", tone: variant(\"success\", null) },\n ], ArrayType(WorkStatus));\n // A step is finished once completed or verified.\n const finished = $.const(East.function([Step], BooleanType, (_$2, step) =>\n step.action.match({ some: (_$3, a) => a.hasTag(\"completed\").or(() => a.hasTag(\"verified\")) }, () => false)));\n return (\n <Box width=\"100%\" height=\"560px\">\n <Sheet\n slice={{ slice }}\n name=\"sheetActionsWorkOrders\"\n group={Sheet.group(WorkOrder, \"steps\", {\n title: \"name\", sub: o => o.id, noun: { singular: \"order\", plural: \"orders\" },\n // The order's status on its band, under the Action column; the actions write it.\n cells: { action: Sheet.group.cell.enum(WorkOrder, \"statuses\", \"status\", { editable: false }) },\n })}\n registers={{\n statuses: Sheet.register.members(statuses, { kind: \"status\", key: s => s.word, label: s => s.label, tone: s => some(s.tone) }),\n }}\n columns={{\n step: Sheet.column.text(Step, { header: \"Step\", width: \"158px\", editable: false }),\n good: Sheet.column.integer(Step, { header: \"Good\", width: \"56px\" }),\n action: Sheet.column.action(Step, StepAction, {\n header: \"Action\", width: \"304px\",\n name: s => East.str`step ${s.op}`,\n title: s => s.step,\n start: [\"started\"],\n // A step waits until the step before it is finished.\n blocked: (ctx) => ctx.index.equal(0n).ifElse(() => East.value(none, OptionType(StringType)), () =>\n ctx.rows.get(ctx.index.subtract(1n)).match({\n some: (_$2, before) => finished(before).ifElse(() => East.value(none, OptionType(StringType)), () => East.value(some(East.str`waits for ${before.op}`), OptionType(StringType))),\n }, () => East.value(some(\"waits for the step before\"), OptionType(StringType)))),\n cases: {\n started: {\n label: \"Start\", state: \"Started\", tone: \"info\", icon: \"play\",\n next: [\"completed\", \"reported\", \"held\", \"alerted\"],\n updates: () => ({ group: Sheet.patch(WorkOrder, { status: \"in_progress\" }) }),\n },\n completed: {\n label: \"Complete\", state: \"Completed\", tone: \"success\", icon: \"check\",\n summary: (_v, s) => s.good.match({ some: (_$2, g) => East.str`${g} good` }, () => \"\"),\n updates: (_v, ctx, at) => ({\n row: Sheet.patch(Step, { good: some(ctx.row.good.match({ some: (_$2, g) => g }, () => ctx.row.plan)), done: some(at) }),\n // The last step to finish finishes the order.\n group: Sheet.patch(WorkOrder, { status: ctx.rows.every((_$2, r, i) =>\n i.equal(ctx.index).or(() => r.match({ some: (_$3, s) => finished(s) }, () => false)))\n .ifElse(() => \"done\", () => \"in_progress\") }),\n }),\n },\n reported: {\n label: \"Report\", state: \"Reported\", tone: \"info\", icon: \"hashtag\",\n next: [\"completed\", \"reported\", \"held\", \"alerted\"],\n take: Sheet.action.form({\n fields: Sheet.field.number({ label: \"Good parts\", unit: \"pcs\", min: 0n }),\n initial: (ctx) => ctx.row.good.match({ some: (_$2, g) => g }, () => 0n),\n }),\n summary: (count) => East.str`${count} good`,\n updates: (count) => ({ row: Sheet.patch(Step, { good: some(count) }) }),\n },\n held: {\n label: \"Hold\", state: \"Held\", tone: \"warning\", icon: \"pause\",\n next: [\"started\"],\n take: Sheet.action.menu({ labels: { awaiting_parts: \"Awaiting parts\", machine_down: \"Machine down\", quality_hold: \"Quality hold\" } }),\n summary: (reason) => reason.match({ awaiting_parts: () => \"Awaiting parts\", machine_down: () => \"Machine down\", quality_hold: () => \"Quality hold\" }),\n updates: () => ({ group: Sheet.patch(WorkOrder, { status: \"on_hold\" }) }),\n },\n alerted: {\n label: \"Alert\", state: \"Alerted\", tone: \"danger\", icon: \"flag\",\n next: [\"started\", \"completed\"],\n take: Sheet.action.form({ fields: {\n changes: Sheet.field.text({ label: \"What changed\", help: \"What the operator saw\", placeholder: \"What the operator saw\" }),\n severity: Sheet.field.select({ help: \"High puts the order on hold\" }),\n } }),\n summary: (alert) => alert.changes,\n updates: (alert) => ({ group: Sheet.patch(WorkOrder, {\n status: alert.severity.hasTag(\"high\").ifElse(() => \"on_hold\", () => \"in_progress\"),\n }) }),\n },\n verified: {\n label: \"Verify\", state: \"Verified\", tone: \"success\",\n summary: () => \"by QA\",\n },\n },\n }),\n done: Sheet.column.date(Step, { header: \"Done\", width: \"64px\", level: () => \"time\", format: \"HH:mm\" }),\n }}\n inspector\n onApply={Record.onApply(orders, { keyed: true })}\n applyMode=\"batch\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
46336
+ "source": "// Work orders whose steps are a state machine: Start, Complete, Report… (a number form), Hold ▾ (a menu of reasons) and Alert… (a struct form), each state's `next` its way on; a step blocked until the one before it is finished; each case's `updates` writing Good and Done on the step and the order's status on its band — saved with the order — as one step of history\n// inputs: []\nexport const HoldReason = VariantType({ awaiting_parts: NullType, machine_down: NullType, quality_hold: NullType });\n\nexport const StepAlert = StructType({ changes: StringType, severity: VariantType({ low: NullType, high: NullType }) });\n\nexport const StepAction = VariantType({\n started: NullType,\n completed: NullType,\n reported: IntegerType, // the good parts counted so far\n held: HoldReason,\n alerted: StepAlert,\n verified: NullType, // written upstream by QA; never offered here\n});\n\nexport const Step = StructType({\n op: StringType, step: StringType, plan: IntegerType,\n good: OptionType(IntegerType), done: OptionType(DateTimeType),\n action: OptionType(StepAction),\n});\n\nexport const WorkOrder = StructType({ id: StringType, name: StringType, status: StringType, steps: ArrayType(Step) });\n\nexport const WorkStatus = StructType({ word: StringType, label: StringType, tone: StatusValueType });\n\nexport const sheetWorkOrders = e3.record(\"sheet_work_orders\", DictType(StringType, WorkOrder), {\n initial: new Map([\n [\"WO-1042\", { id: \"WO-1042\", name: \"Frame assembly\", status: \"in_progress\", steps: [\n { op: \"10\", step: \"Cut tube stock\", plan: 24n, good: some(24n), done: some(new Date(\"2026-11-02T08:42:00Z\")), action: some(variant(\"completed\", null)) },\n { op: \"20\", step: \"Weld frame\", plan: 24n, good: none, done: none, action: some(variant(\"started\", null)) },\n { op: \"30\", step: \"Grind welds\", plan: 24n, good: none, done: none, action: none },\n ] }],\n [\"WO-1043\", { id: \"WO-1043\", name: \"Bracket kit\", status: \"on_hold\", steps: [\n { op: \"10\", step: \"Laser cut\", plan: 120n, good: none, done: none, action: some(variant(\"held\", variant(\"machine_down\", null))) },\n { op: \"20\", step: \"Bend\", plan: 120n, good: none, done: none, action: none },\n ] }],\n [\"WO-1044\", { id: \"WO-1044\", name: \"Pump housing\", status: \"on_hold\", steps: [\n { op: \"10\", step: \"Turn blank\", plan: 8n, good: some(8n), done: some(new Date(\"2026-11-02T11:05:00Z\")), action: some(variant(\"verified\", null)) },\n { op: \"20\", step: \"Mill bore\", plan: 8n, good: none, done: none,\n action: some(variant(\"alerted\", { changes: \"Bore gauge reads 0.04 mm over\", severity: variant(\"high\", null) })) },\n ] }],\n ]),\n indexes: (index) => ({\n // The orders by status: what the rail narrows them by.\n sheet_work_orders_by_status: index.on([\"status\"]),\n }),\n mutations: (mutation) => ({\n // The orders' patch door — every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const orders = $.let(Record.bind(sheetWorkOrders));\n // One rail over the orders: its `rows` source narrows them.\n const slice = $.let(Slice.bindRecords(\"sheet.work.sheetActionsWorkOrders\", {\n rows: {\n source: Data.bindPaged(sheetWorkOrders, { indexes: [\"sheet_work_orders_by_status\"] }),\n label: \"Orders\",\n fields: { status: { label: \"Status\", hints: [{ value: \"in_progress\", label: \"In progress\" }, { value: \"on_hold\", label: \"On hold\" }, { value: \"done\", label: \"Done\" }] } },\n },\n }));\n const statuses = $.let([\n { word: \"in_progress\", label: \"In progress\", tone: variant(\"info\", null) },\n { word: \"on_hold\", label: \"On hold\", tone: variant(\"warning\", null) },\n { word: \"done\", label: \"Done\", tone: variant(\"success\", null) },\n ], ArrayType(WorkStatus));\n // A step is finished once completed or verified.\n const finished = $.const(East.function([Step], BooleanType, (_$2, step) =>\n step.action.match({ some: (_$3, a) => a.hasTag(\"completed\").or(() => a.hasTag(\"verified\")) }, () => false)));\n return (\n <Box width=\"100%\" height=\"560px\">\n <Sheet\n slice={{ slice }}\n name=\"sheetActionsWorkOrders\"\n // The orders and their steps come from planning: this sheet takes their actions, and adds neither.\n edits={{ insertRows: false, insertGroups: false }}\n group={Sheet.group(WorkOrder, \"steps\", {\n title: \"name\", sub: o => o.id, noun: { singular: \"order\", plural: \"orders\" },\n // The order's status on its band, under the Action column; the actions write it.\n cells: { action: Sheet.group.cell.enum(WorkOrder, \"statuses\", \"status\", { editable: false }) },\n })}\n registers={{\n statuses: Sheet.register.members(statuses, { kind: \"status\", key: s => s.word, label: s => s.label, tone: s => some(s.tone) }),\n }}\n columns={{\n step: Sheet.column.text(Step, { header: \"Step\", width: \"158px\", editable: false }),\n good: Sheet.column.integer(Step, { header: \"Good\", width: \"56px\" }),\n action: Sheet.column.action(Step, StepAction, {\n header: \"Action\", width: \"304px\",\n name: s => East.str`step ${s.op}`,\n title: s => s.step,\n start: [\"started\"],\n // A step waits until the step before it is finished.\n blocked: (ctx) => ctx.index.equal(0n).ifElse(() => East.value(none, OptionType(StringType)), () =>\n ctx.rows.get(ctx.index.subtract(1n)).match({\n some: (_$2, before) => finished(before).ifElse(() => East.value(none, OptionType(StringType)), () => East.value(some(East.str`waits for ${before.op}`), OptionType(StringType))),\n }, () => East.value(some(\"waits for the step before\"), OptionType(StringType)))),\n cases: {\n started: {\n label: \"Start\", state: \"Started\", tone: \"info\", icon: \"play\",\n next: [\"completed\", \"reported\", \"held\", \"alerted\"],\n updates: () => ({ group: Sheet.patch(WorkOrder, { status: \"in_progress\" }) }),\n },\n completed: {\n label: \"Complete\", state: \"Completed\", tone: \"success\", icon: \"check\",\n summary: (_v, s) => s.good.match({ some: (_$2, g) => East.str`${g} good` }, () => \"\"),\n updates: (_v, ctx, at) => ({\n row: Sheet.patch(Step, { good: some(ctx.row.good.match({ some: (_$2, g) => g }, () => ctx.row.plan)), done: some(at) }),\n // The last step to finish finishes the order.\n group: Sheet.patch(WorkOrder, { status: ctx.rows.every((_$2, r, i) =>\n i.equal(ctx.index).or(() => r.match({ some: (_$3, s) => finished(s) }, () => false)))\n .ifElse(() => \"done\", () => \"in_progress\") }),\n }),\n },\n reported: {\n label: \"Report\", state: \"Reported\", tone: \"info\", icon: \"hashtag\",\n next: [\"completed\", \"reported\", \"held\", \"alerted\"],\n take: Sheet.action.form({\n fields: Sheet.field.number({ label: \"Good parts\", unit: \"pcs\", min: 0n }),\n initial: (ctx) => ctx.row.good.match({ some: (_$2, g) => g }, () => 0n),\n }),\n summary: (count) => East.str`${count} good`,\n updates: (count) => ({ row: Sheet.patch(Step, { good: some(count) }) }),\n },\n held: {\n label: \"Hold\", state: \"Held\", tone: \"warning\", icon: \"pause\",\n next: [\"started\"],\n take: Sheet.action.menu({ labels: { awaiting_parts: \"Awaiting parts\", machine_down: \"Machine down\", quality_hold: \"Quality hold\" } }),\n summary: (reason) => reason.match({ awaiting_parts: () => \"Awaiting parts\", machine_down: () => \"Machine down\", quality_hold: () => \"Quality hold\" }),\n updates: () => ({ group: Sheet.patch(WorkOrder, { status: \"on_hold\" }) }),\n },\n alerted: {\n label: \"Alert\", state: \"Alerted\", tone: \"danger\", icon: \"flag\",\n next: [\"started\", \"completed\"],\n take: Sheet.action.form({ fields: {\n changes: Sheet.field.text({ label: \"What changed\", help: \"What the operator saw\", placeholder: \"What the operator saw\" }),\n severity: Sheet.field.select({ help: \"High puts the order on hold\" }),\n } }),\n summary: (alert) => alert.changes,\n updates: (alert) => ({ group: Sheet.patch(WorkOrder, {\n status: alert.severity.hasTag(\"high\").ifElse(() => \"on_hold\", () => \"in_progress\"),\n }) }),\n },\n verified: {\n label: \"Verify\", state: \"Verified\", tone: \"success\",\n summary: () => \"by QA\",\n },\n },\n }),\n done: Sheet.column.date(Step, { header: \"Done\", width: \"64px\", level: () => \"time\", format: \"HH:mm\" }),\n }}\n inspector\n onApply={Record.onApply(orders, { keyed: true })}\n />\n </Box>\n );\n }}</Reactive>\n ))"
45208
46337
  },
45209
46338
  {
45210
46339
  "id": "e3-ui:sheet-actions.examples.tsx:sheetActionsTickets",
@@ -45212,7 +46341,7 @@
45212
46341
  "package": "e3-ui",
45213
46342
  "file": "east-ui/packages/e3-ui/test/sheet/sheet-actions.examples.tsx",
45214
46343
  "suite": "",
45215
- "test": "Maintenance tickets on a flat sheet: Acknowledge, Defer… (a form of one date field, opening on tomorrow, that moves the ticket's due date), Hand over ▾ (a menu of the crews register, that moves its crew) and Close, a final state — each action saved as it is taken",
46344
+ "test": "Maintenance tickets on a flat sheet: Acknowledge, Defer… (a form of one date field, opening on tomorrow, that moves the ticket's due date), Hand over ▾ (a menu of the crews register, that moves its crew) and Close, a final state",
45216
46345
  "keywords": [
45217
46346
  "Sheet",
45218
46347
  "Sheet.column.action",
@@ -45225,9 +46354,7 @@
45225
46354
  "register",
45226
46355
  "Sheet.action.menu",
45227
46356
  "of",
45228
- "updates",
45229
- "applyMode",
45230
- "auto"
46357
+ "updates"
45231
46358
  ],
45232
46359
  "imports": [
45233
46360
  "import {",
@@ -45238,7 +46365,7 @@
45238
46365
  "languages": [
45239
46366
  "tsx"
45240
46367
  ],
45241
- "source": "// Maintenance tickets on a flat sheet: Acknowledge, Defer… (a form of one date field, opening on tomorrow, that moves the ticket's due date), Hand over ▾ (a menu of the crews register, that moves its crew) and Close, a final state — each action saved as it is taken\n// inputs: []\nexport const TicketAction = VariantType({\n acknowledged: NullType,\n deferred: DateTimeType, // until when: a form of one date field\n handed_over: StringType, // to which crew: a register's members\n closed: NullType,\n});\n\nexport const Ticket = StructType({ title: StringType, crew: StringType, due: OptionType(DateTimeType), action: OptionType(TicketAction) });\n\nexport const Crew = StructType({ name: StringType });\n\nexport const sheetTickets = e3.record(\"sheet_tickets\", DictType(StringType, Ticket), {\n initial: new Map([\n [\"T-301\", { title: \"Spindle noise\", crew: \"day\", due: some(new Date(\"2026-11-03T00:00:00Z\")), action: none }],\n [\"T-302\", { title: \"Coolant leak\", crew: \"swing\", due: some(new Date(\"2026-11-04T00:00:00Z\")), action: some(variant(\"acknowledged\", null)) }],\n [\"T-303\", { title: \"Guard latch\", crew: \"night\", due: none, action: some(variant(\"closed\", null)) }],\n ]),\n mutations: (mutation) => ({\n // The tickets' patch door — every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\nexport const sheetCrews = e3.record(\"sheet_crews\", DictType(StringType, Crew), {\n initial: new Map([[\"day\", { name: \"Day crew\" }], [\"swing\", { name: \"Swing crew\" }], [\"night\", { name: \"Night crew\" }]]),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const tickets = $.let(Record.bind(sheetTickets));\n const crews = $.let(Data.bind(sheetCrews));\n const crewList = $.let(crews.read());\n const open = [\"acknowledged\", \"deferred\", \"handed_over\", \"closed\"] as const;\n return (\n <Box height=\"420px\">\n <Sheet\n record={tickets}\n name=\"sheetActionsTickets\"\n registers={{ crews: Sheet.register.members(crewList, { kind: \"crew\", key: (_c, k) => k, label: c => c.name }) }}\n columns={{\n title: Sheet.column.text(Ticket, { header: \"Ticket\", width: \"220px\" }),\n crew: Sheet.column.reference(Ticket, \"crews\", { header: \"Crew\", width: \"120px\", editable: false }),\n due: Sheet.column.date(Ticket, { header: \"Due\", width: \"96px\", editable: false }),\n action: Sheet.column.action(Ticket, TicketAction, {\n header: \"Action\", width: \"304px\",\n name: t => t.title,\n start: open,\n cases: {\n acknowledged: { label: \"Acknowledge\", state: \"Acknowledged\", tone: \"info\", icon: \"eye\", next: open },\n deferred: {\n label: \"Defer\", state: \"Deferred\", tone: \"warning\", icon: \"clock\", next: open,\n take: Sheet.action.form({ fields: Sheet.field.date({ label: \"Until\", precision: \"date\" }), initial: (ctx) => ctx.today.addDays(1n) }),\n summary: (until) => East.str`until ${until.printFormatted(\"DD MMM\")}`,\n updates: (until) => ({ row: Sheet.patch(Ticket, { due: some(until) }) }),\n },\n handed_over: {\n label: \"Hand over\", state: \"Handed over\", icon: \"right-left\", next: open,\n take: Sheet.action.menu({ of: \"crews\" }),\n // The crew by its name, as the Crew column shows it: the value is its key.\n summary: (crew) => crewList.get(crew, (_$2, key) => ({ name: key })).name,\n updates: (crew) => ({ row: Sheet.patch(Ticket, { crew }) }),\n },\n closed: { label: \"Close\", state: \"Closed\", tone: \"success\", icon: \"check\" },\n },\n }),\n }}\n applyMode=\"auto\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
46368
+ "source": "// Maintenance tickets on a flat sheet: Acknowledge, Defer… (a form of one date field, opening on tomorrow, that moves the ticket's due date), Hand over ▾ (a menu of the crews register, that moves its crew) and Close, a final state\n// inputs: []\nexport const TicketAction = VariantType({\n acknowledged: NullType,\n deferred: DateTimeType, // until when: a form of one date field\n handed_over: StringType, // to which crew: a register's members\n closed: NullType,\n});\n\nexport const Ticket = StructType({ title: StringType, crew: StringType, due: OptionType(DateTimeType), action: OptionType(TicketAction) });\n\nexport const Crew = StructType({ name: StringType });\n\nexport const sheetTickets = e3.record(\"sheet_tickets\", DictType(StringType, Ticket), {\n initial: new Map([\n [\"T-301\", { title: \"Spindle noise\", crew: \"day\", due: some(new Date(\"2026-11-03T00:00:00Z\")), action: none }],\n [\"T-302\", { title: \"Coolant leak\", crew: \"swing\", due: some(new Date(\"2026-11-04T00:00:00Z\")), action: some(variant(\"acknowledged\", null)) }],\n [\"T-303\", { title: \"Guard latch\", crew: \"night\", due: none, action: some(variant(\"closed\", null)) }],\n ]),\n mutations: (mutation) => ({\n // The tickets' patch door — every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\nexport const sheetCrews = e3.record(\"sheet_crews\", DictType(StringType, Crew), {\n initial: new Map([[\"day\", { name: \"Day crew\" }], [\"swing\", { name: \"Swing crew\" }], [\"night\", { name: \"Night crew\" }]]),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const tickets = $.let(Record.bind(sheetTickets));\n const crews = $.let(Data.bind(sheetCrews));\n const crewList = $.let(crews.read());\n const open = [\"acknowledged\", \"deferred\", \"handed_over\", \"closed\"] as const;\n return (\n <Box height=\"420px\">\n <Sheet\n record={tickets}\n name=\"sheetActionsTickets\"\n // The tickets come from the maintenance log: this sheet takes their actions, and adds none.\n edits={{ insertRows: false }}\n registers={{ crews: Sheet.register.members(crewList, { kind: \"crew\", key: (_c, k) => k, label: c => c.name }) }}\n columns={{\n title: Sheet.column.text(Ticket, { header: \"Ticket\", width: \"220px\" }),\n crew: Sheet.column.reference(Ticket, \"crews\", { header: \"Crew\", width: \"120px\", editable: false }),\n due: Sheet.column.date(Ticket, { header: \"Due\", width: \"96px\", editable: false }),\n action: Sheet.column.action(Ticket, TicketAction, {\n header: \"Action\", width: \"304px\",\n name: t => t.title,\n start: open,\n cases: {\n acknowledged: { label: \"Acknowledge\", state: \"Acknowledged\", tone: \"info\", icon: \"eye\", next: open },\n deferred: {\n label: \"Defer\", state: \"Deferred\", tone: \"warning\", icon: \"clock\", next: open,\n take: Sheet.action.form({ fields: Sheet.field.date({ label: \"Until\", precision: \"date\" }), initial: (ctx) => ctx.today.addDays(1n) }),\n summary: (until) => East.str`until ${until.printFormatted(\"DD MMM\")}`,\n updates: (until) => ({ row: Sheet.patch(Ticket, { due: some(until) }) }),\n },\n handed_over: {\n label: \"Hand over\", state: \"Handed over\", icon: \"right-left\", next: open,\n take: Sheet.action.menu({ of: \"crews\" }),\n // The crew by its name, as the Crew column shows it: the value is its key.\n summary: (crew) => crewList.get(crew, (_$2, key) => ({ name: key })).name,\n updates: (crew) => ({ row: Sheet.patch(Ticket, { crew }) }),\n },\n closed: { label: \"Close\", state: \"Closed\", tone: \"success\", icon: \"check\" },\n },\n }),\n }}\n />\n </Box>\n );\n }}</Reactive>\n ))"
45242
46369
  },
45243
46370
  {
45244
46371
  "id": "e3-ui:sheet-actions.examples.tsx:sheetActionsReadOnly",
@@ -45272,7 +46399,7 @@
45272
46399
  "package": "e3-ui",
45273
46400
  "file": "east-ui/packages/e3-ui/test/sheet/sheet-actions.examples.tsx",
45274
46401
  "suite": "",
45275
- "test": "Example 2's work orders in a phone's box, 390 wide or the screen's width: each action cell shows its state alone, and a tap on an Action cell turns the docked strip into its action bar — the first action full width, the rest in one line, a menu or a form opening inside the bar — while a tap on Good or Done edits it there, the inspector's field at touch size; each change saved as it is made",
46402
+ "test": "Example 2's work orders in a phone's box, 390 wide or the screen's width: each action cell shows its state alone, and a tap on an Action cell turns the docked strip into its action bar — the first action full width, the rest in one line, a menu or a form opening inside the bar — while a tap on Good or Done edits it there, the inspector's field at touch size",
45276
46403
  "keywords": [
45277
46404
  "Sheet",
45278
46405
  "Sheet.column.action",
@@ -45282,9 +46409,7 @@
45282
46409
  "touch",
45283
46410
  "action bar",
45284
46411
  "cell editor",
45285
- "Sheet.field.number",
45286
- "applyMode",
45287
- "auto"
46412
+ "Sheet.field.number"
45288
46413
  ],
45289
46414
  "imports": [
45290
46415
  "import {",
@@ -45295,7 +46420,7 @@
45295
46420
  "languages": [
45296
46421
  "tsx"
45297
46422
  ],
45298
- "source": "// Example 2's work orders in a phone's box, 390 wide or the screen's width: each action cell shows its state alone, and a tap on an Action cell turns the docked strip into its action bar — the first action full width, the rest in one line, a menu or a form opening inside the bar — while a tap on Good or Done edits it there, the inspector's field at touch size; each change saved as it is made\n// inputs: []\nexport const HoldReason = VariantType({ awaiting_parts: NullType, machine_down: NullType, quality_hold: NullType });\n\nexport const StepAlert = StructType({ changes: StringType, severity: VariantType({ low: NullType, high: NullType }) });\n\nexport const StepAction = VariantType({\n started: NullType,\n completed: NullType,\n reported: IntegerType, // the good parts counted so far\n held: HoldReason,\n alerted: StepAlert,\n verified: NullType, // written upstream by QA; never offered here\n});\n\nexport const Step = StructType({\n op: StringType, step: StringType, plan: IntegerType,\n good: OptionType(IntegerType), done: OptionType(DateTimeType),\n action: OptionType(StepAction),\n});\n\nexport const WorkOrder = StructType({ id: StringType, name: StringType, status: StringType, steps: ArrayType(Step) });\n\nexport const WorkStatus = StructType({ word: StringType, label: StringType, tone: StatusValueType });\n\nexport const sheetWorkOrders = e3.record(\"sheet_work_orders\", DictType(StringType, WorkOrder), {\n initial: new Map([\n [\"WO-1042\", { id: \"WO-1042\", name: \"Frame assembly\", status: \"in_progress\", steps: [\n { op: \"10\", step: \"Cut tube stock\", plan: 24n, good: some(24n), done: some(new Date(\"2026-11-02T08:42:00Z\")), action: some(variant(\"completed\", null)) },\n { op: \"20\", step: \"Weld frame\", plan: 24n, good: none, done: none, action: some(variant(\"started\", null)) },\n { op: \"30\", step: \"Grind welds\", plan: 24n, good: none, done: none, action: none },\n ] }],\n [\"WO-1043\", { id: \"WO-1043\", name: \"Bracket kit\", status: \"on_hold\", steps: [\n { op: \"10\", step: \"Laser cut\", plan: 120n, good: none, done: none, action: some(variant(\"held\", variant(\"machine_down\", null))) },\n { op: \"20\", step: \"Bend\", plan: 120n, good: none, done: none, action: none },\n ] }],\n [\"WO-1044\", { id: \"WO-1044\", name: \"Pump housing\", status: \"on_hold\", steps: [\n { op: \"10\", step: \"Turn blank\", plan: 8n, good: some(8n), done: some(new Date(\"2026-11-02T11:05:00Z\")), action: some(variant(\"verified\", null)) },\n { op: \"20\", step: \"Mill bore\", plan: 8n, good: none, done: none,\n action: some(variant(\"alerted\", { changes: \"Bore gauge reads 0.04 mm over\", severity: variant(\"high\", null) })) },\n ] }],\n ]),\n indexes: (index) => ({\n // The orders by status: what the rail narrows them by.\n sheet_work_orders_by_status: index.on([\"status\"]),\n }),\n mutations: (mutation) => ({\n // The orders' patch door — every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const orders = $.let(Record.bind(sheetWorkOrders));\n // One rail over the orders: its `rows` source narrows them.\n const slice = $.let(Slice.bindRecords(\"sheet.work.sheetActionsPhone\", {\n rows: {\n source: Data.bindPaged(sheetWorkOrders, { indexes: [\"sheet_work_orders_by_status\"] }),\n label: \"Orders\",\n fields: { status: { label: \"Status\", hints: [{ value: \"in_progress\", label: \"In progress\" }, { value: \"on_hold\", label: \"On hold\" }, { value: \"done\", label: \"Done\" }] } },\n },\n }));\n const statuses = $.let([\n { word: \"in_progress\", label: \"In progress\", tone: variant(\"info\", null) },\n { word: \"on_hold\", label: \"On hold\", tone: variant(\"warning\", null) },\n { word: \"done\", label: \"Done\", tone: variant(\"success\", null) },\n ], ArrayType(WorkStatus));\n // A step is finished once completed or verified.\n const finished = $.const(East.function([Step], BooleanType, (_$2, step) =>\n step.action.match({ some: (_$3, a) => a.hasTag(\"completed\").or(() => a.hasTag(\"verified\")) }, () => false)));\n return (\n <Box width=\"390px\" maxWidth=\"100%\" height=\"620px\">\n <Sheet\n slice={{ slice }}\n name=\"sheetActionsPhone\"\n group={Sheet.group(WorkOrder, \"steps\", {\n title: \"name\", sub: o => o.id, noun: { singular: \"order\", plural: \"orders\" },\n // The order's status on its band, under the Action column; the actions write it, and a status card sets it.\n cells: { action: Sheet.group.cell.enum(WorkOrder, \"statuses\", \"status\") },\n })}\n registers={{\n statuses: Sheet.register.members(statuses, { kind: \"status\", key: s => s.word, label: s => s.label, tone: s => some(s.tone) }),\n }}\n columns={{\n step: Sheet.column.text(Step, { header: \"Step\", width: \"158px\", editable: false }),\n good: Sheet.column.integer(Step, { header: \"Good\", width: \"56px\" }),\n action: Sheet.column.action(Step, StepAction, {\n header: \"Action\", width: \"304px\",\n name: s => East.str`step ${s.op}`,\n title: s => s.step,\n start: [\"started\"],\n // A step waits until the step before it is finished.\n blocked: (ctx) => ctx.index.equal(0n).ifElse(() => East.value(none, OptionType(StringType)), () =>\n ctx.rows.get(ctx.index.subtract(1n)).match({\n some: (_$2, before) => finished(before).ifElse(() => East.value(none, OptionType(StringType)), () => East.value(some(East.str`waits for ${before.op}`), OptionType(StringType))),\n }, () => East.value(some(\"waits for the step before\"), OptionType(StringType)))),\n cases: {\n started: {\n label: \"Start\", state: \"Started\", tone: \"info\", icon: \"play\",\n next: [\"completed\", \"reported\", \"held\", \"alerted\"],\n updates: () => ({ group: Sheet.patch(WorkOrder, { status: \"in_progress\" }) }),\n },\n completed: {\n label: \"Complete\", state: \"Completed\", tone: \"success\", icon: \"check\",\n summary: (_v, s) => s.good.match({ some: (_$2, g) => East.str`${g} good` }, () => \"\"),\n updates: (_v, ctx, at) => ({\n row: Sheet.patch(Step, { good: some(ctx.row.good.match({ some: (_$2, g) => g }, () => ctx.row.plan)), done: some(at) }),\n // The last step to finish finishes the order.\n group: Sheet.patch(WorkOrder, { status: ctx.rows.every((_$2, r, i) =>\n i.equal(ctx.index).or(() => r.match({ some: (_$3, s) => finished(s) }, () => false)))\n .ifElse(() => \"done\", () => \"in_progress\") }),\n }),\n },\n reported: {\n label: \"Report\", state: \"Reported\", tone: \"info\", icon: \"hashtag\",\n next: [\"completed\", \"reported\", \"held\", \"alerted\"],\n take: Sheet.action.form({\n fields: Sheet.field.number({ label: \"Good parts\", unit: \"pcs\", min: 0n }),\n initial: (ctx) => ctx.row.good.match({ some: (_$2, g) => g }, () => 0n),\n }),\n summary: (count) => East.str`${count} good`,\n updates: (count) => ({ row: Sheet.patch(Step, { good: some(count) }) }),\n },\n held: {\n label: \"Hold\", state: \"Held\", tone: \"warning\", icon: \"pause\",\n next: [\"started\"],\n take: Sheet.action.menu({ labels: { awaiting_parts: \"Awaiting parts\", machine_down: \"Machine down\", quality_hold: \"Quality hold\" } }),\n summary: (reason) => reason.match({ awaiting_parts: () => \"Awaiting parts\", machine_down: () => \"Machine down\", quality_hold: () => \"Quality hold\" }),\n updates: () => ({ group: Sheet.patch(WorkOrder, { status: \"on_hold\" }) }),\n },\n alerted: {\n label: \"Alert\", state: \"Alerted\", tone: \"danger\", icon: \"flag\",\n next: [\"started\", \"completed\"],\n take: Sheet.action.form({ fields: {\n changes: Sheet.field.text({ label: \"What changed\", help: \"What the operator saw\", placeholder: \"What the operator saw\" }),\n severity: Sheet.field.select({ help: \"High puts the order on hold\" }),\n } }),\n summary: (alert) => alert.changes,\n updates: (alert) => ({ group: Sheet.patch(WorkOrder, {\n status: alert.severity.hasTag(\"high\").ifElse(() => \"on_hold\", () => \"in_progress\"),\n }) }),\n },\n verified: {\n label: \"Verify\", state: \"Verified\", tone: \"success\",\n summary: () => \"by QA\",\n },\n },\n }),\n done: Sheet.column.date(Step, { header: \"Done\", width: \"64px\", level: () => \"time\", format: \"HH:mm\" }),\n }}\n library={[\n // The statuses an order takes: a tap sets one on the selected order, as a drop on its band does on a wider frame.\n Sheet.library.tab(statuses, { name: \"Statuses\", key: s => s.word, label: s => s.label, drop: s => Sheet.patch(WorkOrder, { status: s.word }) }),\n Sheet.library.columns(),\n ]}\n inspector\n // Good's field, as a tap on its cell edits it under the grid: counted in parts, never below none.\n fields={{ good: Sheet.field.number({ unit: \"pcs\", min: 0n, help: \"empty until reported\" }) }}\n onApply={Record.onApply(orders, { keyed: true })}\n applyMode=\"auto\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
46423
+ "source": "// Example 2's work orders in a phone's box, 390 wide or the screen's width: each action cell shows its state alone, and a tap on an Action cell turns the docked strip into its action bar — the first action full width, the rest in one line, a menu or a form opening inside the bar — while a tap on Good or Done edits it there, the inspector's field at touch size\n// inputs: []\nexport const HoldReason = VariantType({ awaiting_parts: NullType, machine_down: NullType, quality_hold: NullType });\n\nexport const StepAlert = StructType({ changes: StringType, severity: VariantType({ low: NullType, high: NullType }) });\n\nexport const StepAction = VariantType({\n started: NullType,\n completed: NullType,\n reported: IntegerType, // the good parts counted so far\n held: HoldReason,\n alerted: StepAlert,\n verified: NullType, // written upstream by QA; never offered here\n});\n\nexport const Step = StructType({\n op: StringType, step: StringType, plan: IntegerType,\n good: OptionType(IntegerType), done: OptionType(DateTimeType),\n action: OptionType(StepAction),\n});\n\nexport const WorkOrder = StructType({ id: StringType, name: StringType, status: StringType, steps: ArrayType(Step) });\n\nexport const WorkStatus = StructType({ word: StringType, label: StringType, tone: StatusValueType });\n\nexport const sheetWorkOrders = e3.record(\"sheet_work_orders\", DictType(StringType, WorkOrder), {\n initial: new Map([\n [\"WO-1042\", { id: \"WO-1042\", name: \"Frame assembly\", status: \"in_progress\", steps: [\n { op: \"10\", step: \"Cut tube stock\", plan: 24n, good: some(24n), done: some(new Date(\"2026-11-02T08:42:00Z\")), action: some(variant(\"completed\", null)) },\n { op: \"20\", step: \"Weld frame\", plan: 24n, good: none, done: none, action: some(variant(\"started\", null)) },\n { op: \"30\", step: \"Grind welds\", plan: 24n, good: none, done: none, action: none },\n ] }],\n [\"WO-1043\", { id: \"WO-1043\", name: \"Bracket kit\", status: \"on_hold\", steps: [\n { op: \"10\", step: \"Laser cut\", plan: 120n, good: none, done: none, action: some(variant(\"held\", variant(\"machine_down\", null))) },\n { op: \"20\", step: \"Bend\", plan: 120n, good: none, done: none, action: none },\n ] }],\n [\"WO-1044\", { id: \"WO-1044\", name: \"Pump housing\", status: \"on_hold\", steps: [\n { op: \"10\", step: \"Turn blank\", plan: 8n, good: some(8n), done: some(new Date(\"2026-11-02T11:05:00Z\")), action: some(variant(\"verified\", null)) },\n { op: \"20\", step: \"Mill bore\", plan: 8n, good: none, done: none,\n action: some(variant(\"alerted\", { changes: \"Bore gauge reads 0.04 mm over\", severity: variant(\"high\", null) })) },\n ] }],\n ]),\n indexes: (index) => ({\n // The orders by status: what the rail narrows them by.\n sheet_work_orders_by_status: index.on([\"status\"]),\n }),\n mutations: (mutation) => ({\n // The orders' patch door — every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const orders = $.let(Record.bind(sheetWorkOrders));\n // One rail over the orders: its `rows` source narrows them.\n const slice = $.let(Slice.bindRecords(\"sheet.work.sheetActionsPhone\", {\n rows: {\n source: Data.bindPaged(sheetWorkOrders, { indexes: [\"sheet_work_orders_by_status\"] }),\n label: \"Orders\",\n fields: { status: { label: \"Status\", hints: [{ value: \"in_progress\", label: \"In progress\" }, { value: \"on_hold\", label: \"On hold\" }, { value: \"done\", label: \"Done\" }] } },\n },\n }));\n const statuses = $.let([\n { word: \"in_progress\", label: \"In progress\", tone: variant(\"info\", null) },\n { word: \"on_hold\", label: \"On hold\", tone: variant(\"warning\", null) },\n { word: \"done\", label: \"Done\", tone: variant(\"success\", null) },\n ], ArrayType(WorkStatus));\n // A step is finished once completed or verified.\n const finished = $.const(East.function([Step], BooleanType, (_$2, step) =>\n step.action.match({ some: (_$3, a) => a.hasTag(\"completed\").or(() => a.hasTag(\"verified\")) }, () => false)));\n return (\n <Box width=\"390px\" maxWidth=\"100%\" height=\"620px\">\n <Sheet\n slice={{ slice }}\n name=\"sheetActionsPhone\"\n // The orders and their steps come from planning: this sheet takes their actions, and adds neither.\n edits={{ insertRows: false, insertGroups: false }}\n group={Sheet.group(WorkOrder, \"steps\", {\n title: \"name\", sub: o => o.id, noun: { singular: \"order\", plural: \"orders\" },\n // The order's status on its band, under the Action column; the actions write it, and a status card sets it.\n cells: { action: Sheet.group.cell.enum(WorkOrder, \"statuses\", \"status\") },\n })}\n registers={{\n statuses: Sheet.register.members(statuses, { kind: \"status\", key: s => s.word, label: s => s.label, tone: s => some(s.tone) }),\n }}\n columns={{\n step: Sheet.column.text(Step, { header: \"Step\", width: \"158px\", editable: false }),\n good: Sheet.column.integer(Step, { header: \"Good\", width: \"56px\" }),\n action: Sheet.column.action(Step, StepAction, {\n header: \"Action\", width: \"304px\",\n name: s => East.str`step ${s.op}`,\n title: s => s.step,\n start: [\"started\"],\n // A step waits until the step before it is finished.\n blocked: (ctx) => ctx.index.equal(0n).ifElse(() => East.value(none, OptionType(StringType)), () =>\n ctx.rows.get(ctx.index.subtract(1n)).match({\n some: (_$2, before) => finished(before).ifElse(() => East.value(none, OptionType(StringType)), () => East.value(some(East.str`waits for ${before.op}`), OptionType(StringType))),\n }, () => East.value(some(\"waits for the step before\"), OptionType(StringType)))),\n cases: {\n started: {\n label: \"Start\", state: \"Started\", tone: \"info\", icon: \"play\",\n next: [\"completed\", \"reported\", \"held\", \"alerted\"],\n updates: () => ({ group: Sheet.patch(WorkOrder, { status: \"in_progress\" }) }),\n },\n completed: {\n label: \"Complete\", state: \"Completed\", tone: \"success\", icon: \"check\",\n summary: (_v, s) => s.good.match({ some: (_$2, g) => East.str`${g} good` }, () => \"\"),\n updates: (_v, ctx, at) => ({\n row: Sheet.patch(Step, { good: some(ctx.row.good.match({ some: (_$2, g) => g }, () => ctx.row.plan)), done: some(at) }),\n // The last step to finish finishes the order.\n group: Sheet.patch(WorkOrder, { status: ctx.rows.every((_$2, r, i) =>\n i.equal(ctx.index).or(() => r.match({ some: (_$3, s) => finished(s) }, () => false)))\n .ifElse(() => \"done\", () => \"in_progress\") }),\n }),\n },\n reported: {\n label: \"Report\", state: \"Reported\", tone: \"info\", icon: \"hashtag\",\n next: [\"completed\", \"reported\", \"held\", \"alerted\"],\n take: Sheet.action.form({\n fields: Sheet.field.number({ label: \"Good parts\", unit: \"pcs\", min: 0n }),\n initial: (ctx) => ctx.row.good.match({ some: (_$2, g) => g }, () => 0n),\n }),\n summary: (count) => East.str`${count} good`,\n updates: (count) => ({ row: Sheet.patch(Step, { good: some(count) }) }),\n },\n held: {\n label: \"Hold\", state: \"Held\", tone: \"warning\", icon: \"pause\",\n next: [\"started\"],\n take: Sheet.action.menu({ labels: { awaiting_parts: \"Awaiting parts\", machine_down: \"Machine down\", quality_hold: \"Quality hold\" } }),\n summary: (reason) => reason.match({ awaiting_parts: () => \"Awaiting parts\", machine_down: () => \"Machine down\", quality_hold: () => \"Quality hold\" }),\n updates: () => ({ group: Sheet.patch(WorkOrder, { status: \"on_hold\" }) }),\n },\n alerted: {\n label: \"Alert\", state: \"Alerted\", tone: \"danger\", icon: \"flag\",\n next: [\"started\", \"completed\"],\n take: Sheet.action.form({ fields: {\n changes: Sheet.field.text({ label: \"What changed\", help: \"What the operator saw\", placeholder: \"What the operator saw\" }),\n severity: Sheet.field.select({ help: \"High puts the order on hold\" }),\n } }),\n summary: (alert) => alert.changes,\n updates: (alert) => ({ group: Sheet.patch(WorkOrder, {\n status: alert.severity.hasTag(\"high\").ifElse(() => \"on_hold\", () => \"in_progress\"),\n }) }),\n },\n verified: {\n label: \"Verify\", state: \"Verified\", tone: \"success\",\n summary: () => \"by QA\",\n },\n },\n }),\n done: Sheet.column.date(Step, { header: \"Done\", width: \"64px\", level: () => \"time\", format: \"HH:mm\" }),\n }}\n library={[\n // The statuses an order takes: a tap sets one on the selected order, as a drop on its band does on a wider frame.\n Sheet.library.tab(statuses, { name: \"Statuses\", key: s => s.word, label: s => s.label, drop: s => Sheet.patch(WorkOrder, { status: s.word }) }),\n Sheet.library.columns(),\n ]}\n inspector\n // Good's field, as a tap on its cell edits it under the grid: counted in parts, never below none.\n fields={{ good: Sheet.field.number({ unit: \"pcs\", min: 0n, help: \"empty until reported\" }) }}\n onApply={Record.onApply(orders, { keyed: true })}\n />\n </Box>\n );\n }}</Reactive>\n ))"
45299
46424
  },
45300
46425
  {
45301
46426
  "id": "e3-ui:sheet-actions.examples.tsx:sheetActionsPinned",
@@ -45324,7 +46449,7 @@
45324
46449
  "languages": [
45325
46450
  "tsx"
45326
46451
  ],
45327
- "source": "// Example 3's tickets in a phone's box, their title pinned at the left beside a window of one column the pager pages: `narrow` says which column stays and how many others show, and says nothing wider than 560px\n// inputs: []\nexport const TicketAction = VariantType({\n acknowledged: NullType,\n deferred: DateTimeType, // until when: a form of one date field\n handed_over: StringType, // to which crew: a register's members\n closed: NullType,\n});\n\nexport const Ticket = StructType({ title: StringType, crew: StringType, due: OptionType(DateTimeType), action: OptionType(TicketAction) });\n\nexport const Crew = StructType({ name: StringType });\n\nexport const sheetTickets = e3.record(\"sheet_tickets\", DictType(StringType, Ticket), {\n initial: new Map([\n [\"T-301\", { title: \"Spindle noise\", crew: \"day\", due: some(new Date(\"2026-11-03T00:00:00Z\")), action: none }],\n [\"T-302\", { title: \"Coolant leak\", crew: \"swing\", due: some(new Date(\"2026-11-04T00:00:00Z\")), action: some(variant(\"acknowledged\", null)) }],\n [\"T-303\", { title: \"Guard latch\", crew: \"night\", due: none, action: some(variant(\"closed\", null)) }],\n ]),\n mutations: (mutation) => ({\n // The tickets' patch door — every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\nexport const sheetCrews = e3.record(\"sheet_crews\", DictType(StringType, Crew), {\n initial: new Map([[\"day\", { name: \"Day crew\" }], [\"swing\", { name: \"Swing crew\" }], [\"night\", { name: \"Night crew\" }]]),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const tickets = $.let(Record.bind(sheetTickets));\n const crews = $.let(Data.bind(sheetCrews));\n const crewList = $.let(crews.read());\n return (\n <Box width=\"390px\" maxWidth=\"100%\" height=\"420px\">\n <Sheet\n record={tickets}\n name=\"sheetActionsPinned\"\n narrow={{ pin: \"title\", columns: 1 }}\n registers={{ crews: Sheet.register.members(crewList, { kind: \"crew\", key: (_c, k) => k, label: c => c.name }) }}\n columns={{\n title: Sheet.column.text(Ticket, { header: \"Ticket\", width: \"220px\" }),\n crew: Sheet.column.reference(Ticket, \"crews\", { header: \"Crew\", width: \"120px\", editable: false }),\n due: Sheet.column.date(Ticket, { header: \"Due\", width: \"96px\", editable: false }),\n }}\n />\n </Box>\n );\n }}</Reactive>\n ))"
46452
+ "source": "// Example 3's tickets in a phone's box, their title pinned at the left beside a window of one column the pager pages: `narrow` says which column stays and how many others show, and says nothing wider than 560px\n// inputs: []\nexport const TicketAction = VariantType({\n acknowledged: NullType,\n deferred: DateTimeType, // until when: a form of one date field\n handed_over: StringType, // to which crew: a register's members\n closed: NullType,\n});\n\nexport const Ticket = StructType({ title: StringType, crew: StringType, due: OptionType(DateTimeType), action: OptionType(TicketAction) });\n\nexport const Crew = StructType({ name: StringType });\n\nexport const sheetTickets = e3.record(\"sheet_tickets\", DictType(StringType, Ticket), {\n initial: new Map([\n [\"T-301\", { title: \"Spindle noise\", crew: \"day\", due: some(new Date(\"2026-11-03T00:00:00Z\")), action: none }],\n [\"T-302\", { title: \"Coolant leak\", crew: \"swing\", due: some(new Date(\"2026-11-04T00:00:00Z\")), action: some(variant(\"acknowledged\", null)) }],\n [\"T-303\", { title: \"Guard latch\", crew: \"night\", due: none, action: some(variant(\"closed\", null)) }],\n ]),\n mutations: (mutation) => ({\n // The tickets' patch door — every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\nexport const sheetCrews = e3.record(\"sheet_crews\", DictType(StringType, Crew), {\n initial: new Map([[\"day\", { name: \"Day crew\" }], [\"swing\", { name: \"Swing crew\" }], [\"night\", { name: \"Night crew\" }]]),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const tickets = $.let(Record.bind(sheetTickets));\n const crews = $.let(Data.bind(sheetCrews));\n const crewList = $.let(crews.read());\n return (\n <Box width=\"390px\" maxWidth=\"100%\" height=\"420px\">\n <Sheet\n record={tickets}\n name=\"sheetActionsPinned\"\n // The tickets come from the maintenance log: this sheet adds none.\n edits={{ insertRows: false }}\n narrow={{ pin: \"title\", columns: 1 }}\n registers={{ crews: Sheet.register.members(crewList, { kind: \"crew\", key: (_c, k) => k, label: c => c.name }) }}\n columns={{\n title: Sheet.column.text(Ticket, { header: \"Ticket\", width: \"220px\" }),\n crew: Sheet.column.reference(Ticket, \"crews\", { header: \"Crew\", width: \"120px\", editable: false }),\n due: Sheet.column.date(Ticket, { header: \"Due\", width: \"96px\", editable: false }),\n }}\n />\n </Box>\n );\n }}</Reactive>\n ))"
45328
46453
  },
45329
46454
  {
45330
46455
  "id": "e3-ui:sheet-link.examples.ts:sheetLinkPrint",
@@ -45748,7 +46873,7 @@
45748
46873
  "package": "e3-ui",
45749
46874
  "file": "east-ui/packages/e3-ui/test/sheet/sheet.examples.tsx",
45750
46875
  "suite": "",
45751
- "test": "A sheet over one entry's rows — the week the viewer picks, its rows in the planner's order, each week its own drafts until Save or Discard — with every column kind and its rules (a date at each row's level with its actual, an integer, a reference, an enum narrowed by an options rule with a detail, a stamped code owning its row, a set of machines in ranges), a row rule, a journal of every gesture, ids minted by a counter, and its own Details in the inspector pane, a row's quantity on a slider written back as one transaction",
46876
+ "test": "A sheet over one entry's rows — the week the viewer picks, its rows in the planner's order, each week its own drafts until Save or Discard — with every column kind and its rules (a date at each row's level with its actual, an integer, a reference, an enum narrowed by an options rule with a detail, a stamped code owning its row, a set of machines in ranges), a row rule, a journal of every gesture, ids in the host's own scheme, and its own Details in the inspector pane, a row's quantity on a slider written back as one transaction",
45752
46877
  "keywords": [
45753
46878
  "Sheet",
45754
46879
  "BuilderFrame",
@@ -45795,7 +46920,7 @@
45795
46920
  "PatchEvent",
45796
46921
  "provenance",
45797
46922
  "source",
45798
- "newRowId",
46923
+ "newKey",
45799
46924
  "newRow",
45800
46925
  "write-back"
45801
46926
  ],
@@ -45808,7 +46933,7 @@
45808
46933
  "languages": [
45809
46934
  "tsx"
45810
46935
  ],
45811
- "source": "// A sheet over one entry's rows — the week the viewer picks, its rows in the planner's order, each week its own drafts until Save or Discard — with every column kind and its rules (a date at each row's level with its actual, an integer, a reference, an enum narrowed by an options rule with a detail, a stamped code owning its row, a set of machines in ranges), a row rule, a journal of every gesture, ids minted by a counter, and its own Details in the inspector pane, a row's quantity on a slider written back as one transaction\n// inputs: []\n/** A plan row — what it is, when it starts (read at its own level) and when it\n * really started, how many, its set-ups, the site it runs at, its status, the\n * order code the ERP stamps on release, and the machines it runs on (a set\n * of codes); `id` identifies it. */\nexport const WeekRow = StructType({\n id: StringType, task: StringType, start: OptionType(DateTimeType), qty: OptionType(FloatType),\n setups: OptionType(IntegerType), site: StringType, status: StringType, code: StringType,\n level: Sheet.Types.DateLevel, started: OptionType(DateTimeType), machines: Sheet.Types.Link,\n});\n\n/** One week's plan — when it starts, and its rows in the planner's order. */\nexport const WeekPlan = StructType({ starts: DateTimeType, rows: ArrayType(WeekRow) });\n\n/** The plans, one per week, keyed 2026-W42, 2026-W43, … */\nexport const sheetWeekPlans = e3.record(\"sheet_week_plans\", DictType(StringType, WeekPlan), {\n initial: new Map([\n [\"2026-W42\", { starts: new Date(\"2026-10-12T00:00:00Z\"), rows: [\n { id: \"w42-1\", task: \"Cut the kitchen carcasses\", start: some(new Date(\"2026-10-12T00:00:00Z\")), qty: some(48.0), setups: some(2n), site: \"Machine shop\",\n status: \"PLANNED\", code: \"\", level: variant(\"day\", null), started: none,\n machines: { from: [], to: [variant(\"range\", { from: \"S101\", to: \"S103\" })] } },\n { id: \"w42-2\", task: \"Band the carcass edges\", start: some(new Date(\"2026-10-13T00:00:00Z\")), qty: some(120.0), setups: some(1n), site: \"Machine shop\",\n status: \"RELEASED\", code: \"WO-2201\", level: variant(\"day\", null), started: some(new Date(\"2026-10-13T07:30:00Z\")),\n machines: { from: [], to: [variant(\"identified\", { key: \"E201\" })] } },\n { id: \"w42-3\", task: \"Route the door panels\", start: none, qty: some(24.0), setups: none, site: \"Bench room\",\n status: \"PLANNED\", code: \"\", level: variant(\"week\", null), started: none,\n machines: { from: [], to: [] } },\n ] }],\n [\"2026-W43\", { starts: new Date(\"2026-10-19T00:00:00Z\"), rows: [\n { id: \"w43-1\", task: \"Assemble the wardrobes\", start: some(new Date(\"2026-10-19T00:00:00Z\")), qty: some(6.0), setups: none, site: \"Fitting shop\",\n status: \"PLANNED\", code: \"\", level: variant(\"day\", null), started: none,\n machines: { from: [], to: [variant(\"identified\", { key: \"A701\" })] } },\n { id: \"w43-2\", task: \"Spray the vanity doors\", start: none, qty: some(4.0), setups: none, site: \"Spray shop\",\n status: \"PLANNED\", code: \"\", level: variant(\"time\", null), started: none,\n machines: { from: [], to: [] } },\n ] }],\n ]),\n mutations: (mutation) => ({\n // The plans' patch door — every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const plans = $.let(Record.bind(sheetWeekPlans));\n // The week the viewer picked, the journal and the id counter: a viewer's own state.\n const week = $.let(State.bind([StringType], \"sheet.weeks.week\", \"2026-W42\"));\n const log = $.let(State.bind([ArrayType(StringType)], \"sheet.weeks.journal\", []));\n const counter = $.let(State.bind([IntegerType], \"sheet.weeks.counter\", 1n));\n const weeks = $.let([\"2026-W42\", \"2026-W43\", \"2026-W44\"], ArrayType(StringType));\n const pick = $.const(East.function([StringType], NullType, ($, w) => { $(week.write(w)); }));\n const StatusType = StructType({ word: StringType, tone: StatusValueType });\n const statuses = $.let([\n { word: \"PLANNED\", tone: variant(\"neutral\", null) }, { word: \"RELEASED\", tone: variant(\"info\", null) },\n { word: \"IN PROGRESS\", tone: variant(\"warning\", null) }, { word: \"COMPLETE\", tone: variant(\"success\", null) },\n ], ArrayType(StatusType));\n const sites = $.let([\"Machine shop\", \"Bench room\", \"Fitting shop\", \"Spray shop\"], ArrayType(StringType));\n const machines = $.let([\"S101\", \"S102\", \"S103\", \"E201\", \"E202\", \"R301\", \"R302\", \"R303\", \"A701\", \"A702\"], ArrayType(StringType));\n const Ctx = Sheet.Types.DraftContext(WeekRow);\n // Until a row has an order code it may only be planned or released.\n const statusOptions = $.const(East.function([Ctx], OptionType(ArrayType(StringType)), ($, ctx) => {\n const whole = $.const(none, OptionType(ArrayType(StringType)));\n const early = $.const(some([\"PLANNED\", \"RELEASED\"]), OptionType(ArrayType(StringType)));\n return ctx.row.code.match({ value: (_$2, code) => code.length().equal(0n).ifElse(() => early, () => whole) }, () => early);\n }));\n // A row is ready once its quantity is positive.\n const readyRow = $.const(East.function([Sheet.Types.Draft(WeekRow), Ctx], Sheet.Types.Readiness, ($, row) => {\n $.if(row.qty.hasTag(\"value\").and(() => row.qty.unwrap(\"value\").match({ some: (_$2, q) => q.lessEqual(0.0), none: () => false })), $ => {\n $.return(East.value(variant(\"incomplete\", [{ field: \"qty\", message: \"Quantity must be positive\" }]), Sheet.Types.Readiness));\n });\n return East.value(variant(\"ready\", null), Sheet.Types.Readiness);\n }));\n // Every gesture, journalled once with where it came from.\n const onPatch = $.const(East.function([Sheet.Types.PatchEvent(WeekRow)], NullType, ($, e) => {\n $(log.write(log.read().concat([East.str`${e.origin.getTag()} · ${e.label} · ${e.readiness.getTag()}`])));\n }));\n // The host mints a new row's id.\n const newRowId = $.const(East.function([], StringType, ($) => {\n const n = $.let(counter.read());\n $(counter.write(n.add(1n)));\n return East.str`new-${n}`;\n }));\n const newRow = $.const(East.function([Sheet.Types.NewRow], Sheet.Types.Patch(WeekRow), () => Sheet.patch(WeekRow, {\n setups: none, site: \"\", status: \"PLANNED\", code: \"\", level: variant(\"day\", null), started: none, machines: { from: [], to: [] },\n })));\n // A row's own Details: its task, and its quantity on a slider — released, the edited row goes back through `update`.\n const inspect = $.const(East.function([WeekRow, FunctionType([WeekRow], NullType)], UIComponentType, ($, row, update) => {\n const qty = $.let(row.qty.match({ none: () => 0.0, some: (_$, q) => q }));\n const setQty = $.const(East.function([FloatType], NullType, ($2, next) => {\n // East has no struct spread: the row, rebuilt with its new quantity.\n const edited = $2.const({\n id: row.id, task: row.task, start: row.start, qty: some(next), setups: row.setups, site: row.site,\n status: row.status, code: row.code, level: row.level, started: row.started, machines: row.machines,\n }, WeekRow);\n $2(update(edited));\n }));\n return (\n <VStack gap=\"3\" align=\"stretch\">\n <Text>{row.task}</Text>\n <Field.Slider label=\"Quantity\" value={qty} min={0} max={200} step={1}\n helperText=\"Released, it is one step the history undoes\" onChangeEnd={setQty} />\n </VStack>\n );\n }));\n const entries = $.let(log.read());\n return (\n <VStack gap=\"3\" align=\"stretch\">\n <SegmentGroup value={week.read()} onChange={pick} size=\"sm\"\n items={weeks.map((_$, w) => SegmentGroup.Item(w, <Text>{w}</Text>))} />\n <Box height=\"480px\">\n <Sheet\n record={plans}\n entry={{ key: week.read(), rows: \"rows\", id: \"id\" }}\n name=\"weeks\"\n inspector={inspect}\n owned={r => r.code.length().greater(0n)}\n registers={{\n statuses: Sheet.register.members(statuses, { kind: \"status\", key: s => s.word, label: s => s.word, tone: s => some(s.tone) }),\n sites: Sheet.register.members(sites, { kind: \"site\", key: s => s, label: s => s }),\n machines: Sheet.register.members(machines, { kind: \"machine\", key: m => m, label: m => m }),\n }}\n columns={{\n task: Sheet.column.text(WeekRow, { header: \"Task\", width: \"260px\" }),\n start: Sheet.column.date(WeekRow, { header: \"Start\", sub: \"at the row's level\", width: \"168px\", level: r => r.level, actual: r => r.started }),\n qty: Sheet.column.quantity(WeekRow, { header: \"Qty\", width: \"96px\" }),\n setups: Sheet.column.integer(WeekRow, { header: \"Set-ups\", width: \"72px\" }),\n site: Sheet.column.reference(WeekRow, \"sites\", { header: \"Site\", width: \"128px\" }),\n status: Sheet.column.enum(WeekRow, \"statuses\", { header: \"Status\", width: \"132px\", options: statusOptions, detail: r => r.code }),\n code: Sheet.column.stamped(WeekRow, { header: \"Order code\", sub: \"stamped on release\", owner: \"ERP\", width: \"112px\" }),\n machines: Sheet.column.set(WeekRow, \"machines\", { header: \"Machines\", sub: \"S101-03 · a run\", width: \"200px\",\n members: [{ kind: \"machine\", identified: true, ranged: true }] }),\n }}\n ready={{ row: readyRow }}\n onPatch={onPatch}\n newRow={newRow}\n newRowId={newRowId}\n />\n </Box>\n <Text.MonoLabel>{East.str`EDITS · ${entries.length()}`}</Text.MonoLabel>\n {entries.map((_$, l) => <Text textStyle=\"caption\" color=\"fg.muted\">{l}</Text>)}\n </VStack>\n );\n }}</Reactive>\n ))"
46936
+ "source": "// A sheet over one entry's rows — the week the viewer picks, its rows in the planner's order, each week its own drafts until Save or Discard — with every column kind and its rules (a date at each row's level with its actual, an integer, a reference, an enum narrowed by an options rule with a detail, a stamped code owning its row, a set of machines in ranges), a row rule, a journal of every gesture, ids in the host's own scheme, and its own Details in the inspector pane, a row's quantity on a slider written back as one transaction\n// inputs: []\n/** A plan row — what it is, when it starts (read at its own level) and when it\n * really started, how many, its set-ups, the site it runs at, its status, the\n * order code the ERP stamps on release, and the machines it runs on (a set\n * of codes); `id` identifies it. */\nexport const WeekRow = StructType({\n id: StringType, task: StringType, start: OptionType(DateTimeType), qty: OptionType(FloatType),\n setups: OptionType(IntegerType), site: StringType, status: StringType, code: StringType,\n level: Sheet.Types.DateLevel, started: OptionType(DateTimeType), machines: Sheet.Types.Link,\n});\n\n/** One week's plan — when it starts, and its rows in the planner's order. */\nexport const WeekPlan = StructType({ starts: DateTimeType, rows: ArrayType(WeekRow) });\n\n/** The plans, one per week, keyed 2026-W42, 2026-W43, … */\nexport const sheetWeekPlans = e3.record(\"sheet_week_plans\", DictType(StringType, WeekPlan), {\n initial: new Map([\n [\"2026-W42\", { starts: new Date(\"2026-10-12T00:00:00Z\"), rows: [\n { id: \"w42-1\", task: \"Cut the kitchen carcasses\", start: some(new Date(\"2026-10-12T00:00:00Z\")), qty: some(48.0), setups: some(2n), site: \"Machine shop\",\n status: \"PLANNED\", code: \"\", level: variant(\"day\", null), started: none,\n machines: { from: [], to: [variant(\"range\", { from: \"S101\", to: \"S103\" })] } },\n { id: \"w42-2\", task: \"Band the carcass edges\", start: some(new Date(\"2026-10-13T00:00:00Z\")), qty: some(120.0), setups: some(1n), site: \"Machine shop\",\n status: \"RELEASED\", code: \"WO-2201\", level: variant(\"day\", null), started: some(new Date(\"2026-10-13T07:30:00Z\")),\n machines: { from: [], to: [variant(\"identified\", { key: \"E201\" })] } },\n { id: \"w42-3\", task: \"Route the door panels\", start: none, qty: some(24.0), setups: none, site: \"Bench room\",\n status: \"PLANNED\", code: \"\", level: variant(\"week\", null), started: none,\n machines: { from: [], to: [] } },\n ] }],\n [\"2026-W43\", { starts: new Date(\"2026-10-19T00:00:00Z\"), rows: [\n { id: \"w43-1\", task: \"Assemble the wardrobes\", start: some(new Date(\"2026-10-19T00:00:00Z\")), qty: some(6.0), setups: none, site: \"Fitting shop\",\n status: \"PLANNED\", code: \"\", level: variant(\"day\", null), started: none,\n machines: { from: [], to: [variant(\"identified\", { key: \"A701\" })] } },\n { id: \"w43-2\", task: \"Spray the vanity doors\", start: none, qty: some(4.0), setups: none, site: \"Spray shop\",\n status: \"PLANNED\", code: \"\", level: variant(\"time\", null), started: none,\n machines: { from: [], to: [] } },\n ] }],\n ]),\n mutations: (mutation) => ({\n // The plans' patch door — every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const plans = $.let(Record.bind(sheetWeekPlans));\n // The week the viewer picked and the journal: a viewer's own state.\n const week = $.let(State.bind([StringType], \"sheet.weeks.week\", \"2026-W42\"));\n const log = $.let(State.bind([ArrayType(StringType)], \"sheet.weeks.journal\", []));\n const weeks = $.let([\"2026-W42\", \"2026-W43\", \"2026-W44\"], ArrayType(StringType));\n const pick = $.const(East.function([StringType], NullType, ($, w) => { $(week.write(w)); }));\n const StatusType = StructType({ word: StringType, tone: StatusValueType });\n const statuses = $.let([\n { word: \"PLANNED\", tone: variant(\"neutral\", null) }, { word: \"RELEASED\", tone: variant(\"info\", null) },\n { word: \"IN PROGRESS\", tone: variant(\"warning\", null) }, { word: \"COMPLETE\", tone: variant(\"success\", null) },\n ], ArrayType(StatusType));\n const sites = $.let([\"Machine shop\", \"Bench room\", \"Fitting shop\", \"Spray shop\"], ArrayType(StringType));\n const machines = $.let([\"S101\", \"S102\", \"S103\", \"E201\", \"E202\", \"R301\", \"R302\", \"R303\", \"A701\", \"A702\"], ArrayType(StringType));\n const Ctx = Sheet.Types.DraftContext(WeekRow);\n // Until a row has an order code it may only be planned or released.\n const statusOptions = $.const(East.function([Ctx], OptionType(ArrayType(StringType)), ($, ctx) => {\n const whole = $.const(none, OptionType(ArrayType(StringType)));\n const early = $.const(some([\"PLANNED\", \"RELEASED\"]), OptionType(ArrayType(StringType)));\n return ctx.row.code.match({ value: (_$2, code) => code.length().equal(0n).ifElse(() => early, () => whole) }, () => early);\n }));\n // A row is ready once its quantity is positive.\n const readyRow = $.const(East.function([Sheet.Types.Draft(WeekRow), Ctx], Sheet.Types.Readiness, ($, row) => {\n $.if(row.qty.hasTag(\"value\").and(() => row.qty.unwrap(\"value\").match({ some: (_$2, q) => q.lessEqual(0.0), none: () => false })), $ => {\n $.return(East.value(variant(\"incomplete\", [{ field: \"qty\", message: \"Quantity must be positive\" }]), Sheet.Types.Readiness));\n });\n return East.value(variant(\"ready\", null), Sheet.Types.Readiness);\n }));\n // Every gesture, journalled once with where it came from.\n const onPatch = $.const(East.function([Sheet.Types.PatchEvent(WeekRow)], NullType, ($, e) => {\n $(log.write(log.read().concat([East.str`${e.origin.getTag()} · ${e.label} · ${e.readiness.getTag()}`])));\n }));\n // A new row's id in the host's own scheme: given every id taken, the first new-N none of them is.\n const newKey = $.const(East.function([SetType(StringType)], StringType, ($, taken) => {\n const n = $.let(taken.size().add(1n));\n $.while(taken.has(East.str`new-${n}`), ($2) => {\n $2.assign(n, n.add(1n));\n });\n return East.str`new-${n}`;\n }));\n const newRow = $.const(East.function([Sheet.Types.NewRow], Sheet.Types.Patch(WeekRow), () => Sheet.patch(WeekRow, {\n setups: none, site: \"\", status: \"PLANNED\", code: \"\", level: variant(\"day\", null), started: none, machines: { from: [], to: [] },\n })));\n // A row's own Details: its task, and its quantity on a slider — released, the edited row goes back through `update`.\n const inspect = $.const(East.function([WeekRow, FunctionType([WeekRow], NullType)], UIComponentType, ($, row, update) => {\n const qty = $.let(row.qty.match({ none: () => 0.0, some: (_$, q) => q }));\n const setQty = $.const(East.function([FloatType], NullType, ($2, next) => {\n // East has no struct spread: the row, rebuilt with its new quantity.\n const edited = $2.const({\n id: row.id, task: row.task, start: row.start, qty: some(next), setups: row.setups, site: row.site,\n status: row.status, code: row.code, level: row.level, started: row.started, machines: row.machines,\n }, WeekRow);\n $2(update(edited));\n }));\n return (\n <VStack gap=\"3\" align=\"stretch\">\n <Text>{row.task}</Text>\n <Field.Slider label=\"Quantity\" value={qty} min={0} max={200} step={1}\n helperText=\"Released, it is one step the history undoes\" onChangeEnd={setQty} />\n </VStack>\n );\n }));\n const entries = $.let(log.read());\n return (\n <VStack gap=\"3\" align=\"stretch\">\n <SegmentGroup value={week.read()} onChange={pick} size=\"sm\"\n items={weeks.map((_$, w) => SegmentGroup.Item(w, <Text>{w}</Text>))} />\n <Box height=\"480px\">\n <Sheet\n record={plans}\n entry={{ key: week.read(), rows: \"rows\", id: \"id\" }}\n name=\"weeks\"\n inspector={inspect}\n owned={r => r.code.length().greater(0n)}\n registers={{\n statuses: Sheet.register.members(statuses, { kind: \"status\", key: s => s.word, label: s => s.word, tone: s => some(s.tone) }),\n sites: Sheet.register.members(sites, { kind: \"site\", key: s => s, label: s => s }),\n machines: Sheet.register.members(machines, { kind: \"machine\", key: m => m, label: m => m }),\n }}\n columns={{\n task: Sheet.column.text(WeekRow, { header: \"Task\", width: \"260px\" }),\n start: Sheet.column.date(WeekRow, { header: \"Start\", sub: \"at the row's level\", width: \"168px\", level: r => r.level, actual: r => r.started }),\n qty: Sheet.column.quantity(WeekRow, { header: \"Qty\", width: \"96px\" }),\n setups: Sheet.column.integer(WeekRow, { header: \"Set-ups\", width: \"72px\" }),\n site: Sheet.column.reference(WeekRow, \"sites\", { header: \"Site\", width: \"128px\" }),\n status: Sheet.column.enum(WeekRow, \"statuses\", { header: \"Status\", width: \"132px\", options: statusOptions, detail: r => r.code }),\n code: Sheet.column.stamped(WeekRow, { header: \"Order code\", sub: \"stamped on release\", owner: \"ERP\", width: \"112px\" }),\n machines: Sheet.column.set(WeekRow, \"machines\", { header: \"Machines\", sub: \"S101-03 · a run\", width: \"200px\",\n members: [{ kind: \"machine\", identified: true, ranged: true }] }),\n }}\n ready={{ row: readyRow }}\n onPatch={onPatch}\n newRow={newRow}\n newKey={newKey}\n />\n </Box>\n <Text.MonoLabel>{East.str`EDITS · ${entries.length()}`}</Text.MonoLabel>\n {entries.map((_$, l) => <Text textStyle=\"caption\" color=\"fg.muted\">{l}</Text>)}\n </VStack>\n );\n }}</Reactive>\n ))"
45812
46937
  },
45813
46938
  {
45814
46939
  "id": "e3-ui:sheet.examples.tsx:sheetWording",
@@ -45838,7 +46963,7 @@
45838
46963
  "languages": [
45839
46964
  "tsx"
45840
46965
  ],
45841
- "source": "// A workshop's weeks in its own words (#1516): `vocabulary` names what a link cell holds, a counted member, a link's halves and a date's wanted and actual, wherever the sheet says them, each keeping the sheet's word where left out.\n// inputs: []\n/** A plan row — what it is, when it starts (read at its own level) and when it\n * really started, how many, its set-ups, the site it runs at, its status, the\n * order code the ERP stamps on release, and the machines it runs on (a set\n * of codes); `id` identifies it. */\nexport const WeekRow = StructType({\n id: StringType, task: StringType, start: OptionType(DateTimeType), qty: OptionType(FloatType),\n setups: OptionType(IntegerType), site: StringType, status: StringType, code: StringType,\n level: Sheet.Types.DateLevel, started: OptionType(DateTimeType), machines: Sheet.Types.Link,\n});\n\n/** One week's plan — when it starts, and its rows in the planner's order. */\nexport const WeekPlan = StructType({ starts: DateTimeType, rows: ArrayType(WeekRow) });\n\n/** The plans, one per week, keyed 2026-W42, 2026-W43, … */\nexport const sheetWeekPlans = e3.record(\"sheet_week_plans\", DictType(StringType, WeekPlan), {\n initial: new Map([\n [\"2026-W42\", { starts: new Date(\"2026-10-12T00:00:00Z\"), rows: [\n { id: \"w42-1\", task: \"Cut the kitchen carcasses\", start: some(new Date(\"2026-10-12T00:00:00Z\")), qty: some(48.0), setups: some(2n), site: \"Machine shop\",\n status: \"PLANNED\", code: \"\", level: variant(\"day\", null), started: none,\n machines: { from: [], to: [variant(\"range\", { from: \"S101\", to: \"S103\" })] } },\n { id: \"w42-2\", task: \"Band the carcass edges\", start: some(new Date(\"2026-10-13T00:00:00Z\")), qty: some(120.0), setups: some(1n), site: \"Machine shop\",\n status: \"RELEASED\", code: \"WO-2201\", level: variant(\"day\", null), started: some(new Date(\"2026-10-13T07:30:00Z\")),\n machines: { from: [], to: [variant(\"identified\", { key: \"E201\" })] } },\n { id: \"w42-3\", task: \"Route the door panels\", start: none, qty: some(24.0), setups: none, site: \"Bench room\",\n status: \"PLANNED\", code: \"\", level: variant(\"week\", null), started: none,\n machines: { from: [], to: [] } },\n ] }],\n [\"2026-W43\", { starts: new Date(\"2026-10-19T00:00:00Z\"), rows: [\n { id: \"w43-1\", task: \"Assemble the wardrobes\", start: some(new Date(\"2026-10-19T00:00:00Z\")), qty: some(6.0), setups: none, site: \"Fitting shop\",\n status: \"PLANNED\", code: \"\", level: variant(\"day\", null), started: none,\n machines: { from: [], to: [variant(\"identified\", { key: \"A701\" })] } },\n { id: \"w43-2\", task: \"Spray the vanity doors\", start: none, qty: some(4.0), setups: none, site: \"Spray shop\",\n status: \"PLANNED\", code: \"\", level: variant(\"time\", null), started: none,\n machines: { from: [], to: [] } },\n ] }],\n ]),\n mutations: (mutation) => ({\n // The plans' patch door — every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const plans = $.let(Record.bind(sheetWeekPlans));\n // The week the viewer picked, the journal and the id counter: a viewer's own state.\n const week = $.let(State.bind([StringType], \"sheet.weeks.week\", \"2026-W42\"));\n const log = $.let(State.bind([ArrayType(StringType)], \"sheet.weeks.journal\", []));\n const counter = $.let(State.bind([IntegerType], \"sheet.weeks.counter\", 1n));\n const weeks = $.let([\"2026-W42\", \"2026-W43\", \"2026-W44\"], ArrayType(StringType));\n const pick = $.const(East.function([StringType], NullType, ($, w) => { $(week.write(w)); }));\n const StatusType = StructType({ word: StringType, tone: StatusValueType });\n const statuses = $.let([\n { word: \"PLANNED\", tone: variant(\"neutral\", null) }, { word: \"RELEASED\", tone: variant(\"info\", null) },\n { word: \"IN PROGRESS\", tone: variant(\"warning\", null) }, { word: \"COMPLETE\", tone: variant(\"success\", null) },\n ], ArrayType(StatusType));\n const sites = $.let([\"Machine shop\", \"Bench room\", \"Fitting shop\", \"Spray shop\"], ArrayType(StringType));\n const machines = $.let([\"S101\", \"S102\", \"S103\", \"E201\", \"E202\", \"R301\", \"R302\", \"R303\", \"A701\", \"A702\"], ArrayType(StringType));\n const Ctx = Sheet.Types.DraftContext(WeekRow);\n // Until a row has an order code it may only be planned or released.\n const statusOptions = $.const(East.function([Ctx], OptionType(ArrayType(StringType)), ($, ctx) => {\n const whole = $.const(none, OptionType(ArrayType(StringType)));\n const early = $.const(some([\"PLANNED\", \"RELEASED\"]), OptionType(ArrayType(StringType)));\n return ctx.row.code.match({ value: (_$2, code) => code.length().equal(0n).ifElse(() => early, () => whole) }, () => early);\n }));\n // A row is ready once its quantity is positive.\n const readyRow = $.const(East.function([Sheet.Types.Draft(WeekRow), Ctx], Sheet.Types.Readiness, ($, row) => {\n $.if(row.qty.hasTag(\"value\").and(() => row.qty.unwrap(\"value\").match({ some: (_$2, q) => q.lessEqual(0.0), none: () => false })), $ => {\n $.return(East.value(variant(\"incomplete\", [{ field: \"qty\", message: \"Quantity must be positive\" }]), Sheet.Types.Readiness));\n });\n return East.value(variant(\"ready\", null), Sheet.Types.Readiness);\n }));\n // Every gesture, journalled once with where it came from.\n const onPatch = $.const(East.function([Sheet.Types.PatchEvent(WeekRow)], NullType, ($, e) => {\n $(log.write(log.read().concat([East.str`${e.origin.getTag()} · ${e.label} · ${e.readiness.getTag()}`])));\n }));\n // The host mints a new row's id.\n const newRowId = $.const(East.function([], StringType, ($) => {\n const n = $.let(counter.read());\n $(counter.write(n.add(1n)));\n return East.str`new-${n}`;\n }));\n const newRow = $.const(East.function([Sheet.Types.NewRow], Sheet.Types.Patch(WeekRow), () => Sheet.patch(WeekRow, {\n setups: none, site: \"\", status: \"PLANNED\", code: \"\", level: variant(\"day\", null), started: none, machines: { from: [], to: [] },\n })));\n // A row's own Details: its task, and its quantity on a slider — released, the edited row goes back through `update`.\n const inspect = $.const(East.function([WeekRow, FunctionType([WeekRow], NullType)], UIComponentType, ($, row, update) => {\n const qty = $.let(row.qty.match({ none: () => 0.0, some: (_$, q) => q }));\n const setQty = $.const(East.function([FloatType], NullType, ($2, next) => {\n // East has no struct spread: the row, rebuilt with its new quantity.\n const edited = $2.const({\n id: row.id, task: row.task, start: row.start, qty: some(next), setups: row.setups, site: row.site,\n status: row.status, code: row.code, level: row.level, started: row.started, machines: row.machines,\n }, WeekRow);\n $2(update(edited));\n }));\n return (\n <VStack gap=\"3\" align=\"stretch\">\n <Text>{row.task}</Text>\n <Field.Slider label=\"Quantity\" value={qty} min={0} max={200} step={1}\n helperText=\"Released, it is one step the history undoes\" onChangeEnd={setQty} />\n </VStack>\n );\n }));\n const entries = $.let(log.read());\n return (\n <VStack gap=\"3\" align=\"stretch\">\n <SegmentGroup value={week.read()} onChange={pick} size=\"sm\"\n items={weeks.map((_$, w) => SegmentGroup.Item(w, <Text>{w}</Text>))} />\n <Box height=\"480px\">\n <Sheet\n vocabulary={{ members: \"machine\", unassigned: \"anyone free\", source: \"start bay\", destination: \"end bay\", wanted: \"promised\", actual: \"met\" }}\n record={plans}\n entry={{ key: week.read(), rows: \"rows\", id: \"id\" }}\n name=\"weeks\"\n inspector={inspect}\n owned={r => r.code.length().greater(0n)}\n registers={{\n statuses: Sheet.register.members(statuses, { kind: \"status\", key: s => s.word, label: s => s.word, tone: s => some(s.tone) }),\n sites: Sheet.register.members(sites, { kind: \"site\", key: s => s, label: s => s }),\n machines: Sheet.register.members(machines, { kind: \"machine\", key: m => m, label: m => m }),\n }}\n columns={{\n task: Sheet.column.text(WeekRow, { header: \"Task\", width: \"260px\" }),\n start: Sheet.column.date(WeekRow, { header: \"Start\", sub: \"at the row's level\", width: \"168px\", level: r => r.level, actual: r => r.started }),\n qty: Sheet.column.quantity(WeekRow, { header: \"Qty\", width: \"96px\" }),\n setups: Sheet.column.integer(WeekRow, { header: \"Set-ups\", width: \"72px\" }),\n site: Sheet.column.reference(WeekRow, \"sites\", { header: \"Site\", width: \"128px\" }),\n status: Sheet.column.enum(WeekRow, \"statuses\", { header: \"Status\", width: \"132px\", options: statusOptions, detail: r => r.code }),\n code: Sheet.column.stamped(WeekRow, { header: \"Order code\", sub: \"stamped on release\", owner: \"ERP\", width: \"112px\" }),\n machines: Sheet.column.set(WeekRow, \"machines\", { header: \"Machines\", sub: \"S101-03 · a run\", width: \"200px\",\n members: [{ kind: \"machine\", identified: true, ranged: true }] }),\n }}\n ready={{ row: readyRow }}\n onPatch={onPatch}\n newRow={newRow}\n newRowId={newRowId}\n />\n </Box>\n <Text.MonoLabel>{East.str`EDITS · ${entries.length()}`}</Text.MonoLabel>\n {entries.map((_$, l) => <Text textStyle=\"caption\" color=\"fg.muted\">{l}</Text>)}\n </VStack>\n );\n }}</Reactive>\n ))"
46966
+ "source": "// A workshop's weeks in its own words (#1516): `vocabulary` names what a link cell holds, a counted member, a link's halves and a date's wanted and actual, wherever the sheet says them, each keeping the sheet's word where left out.\n// inputs: []\n/** A plan row — what it is, when it starts (read at its own level) and when it\n * really started, how many, its set-ups, the site it runs at, its status, the\n * order code the ERP stamps on release, and the machines it runs on (a set\n * of codes); `id` identifies it. */\nexport const WeekRow = StructType({\n id: StringType, task: StringType, start: OptionType(DateTimeType), qty: OptionType(FloatType),\n setups: OptionType(IntegerType), site: StringType, status: StringType, code: StringType,\n level: Sheet.Types.DateLevel, started: OptionType(DateTimeType), machines: Sheet.Types.Link,\n});\n\n/** One week's plan — when it starts, and its rows in the planner's order. */\nexport const WeekPlan = StructType({ starts: DateTimeType, rows: ArrayType(WeekRow) });\n\n/** The plans, one per week, keyed 2026-W42, 2026-W43, … */\nexport const sheetWeekPlans = e3.record(\"sheet_week_plans\", DictType(StringType, WeekPlan), {\n initial: new Map([\n [\"2026-W42\", { starts: new Date(\"2026-10-12T00:00:00Z\"), rows: [\n { id: \"w42-1\", task: \"Cut the kitchen carcasses\", start: some(new Date(\"2026-10-12T00:00:00Z\")), qty: some(48.0), setups: some(2n), site: \"Machine shop\",\n status: \"PLANNED\", code: \"\", level: variant(\"day\", null), started: none,\n machines: { from: [], to: [variant(\"range\", { from: \"S101\", to: \"S103\" })] } },\n { id: \"w42-2\", task: \"Band the carcass edges\", start: some(new Date(\"2026-10-13T00:00:00Z\")), qty: some(120.0), setups: some(1n), site: \"Machine shop\",\n status: \"RELEASED\", code: \"WO-2201\", level: variant(\"day\", null), started: some(new Date(\"2026-10-13T07:30:00Z\")),\n machines: { from: [], to: [variant(\"identified\", { key: \"E201\" })] } },\n { id: \"w42-3\", task: \"Route the door panels\", start: none, qty: some(24.0), setups: none, site: \"Bench room\",\n status: \"PLANNED\", code: \"\", level: variant(\"week\", null), started: none,\n machines: { from: [], to: [] } },\n ] }],\n [\"2026-W43\", { starts: new Date(\"2026-10-19T00:00:00Z\"), rows: [\n { id: \"w43-1\", task: \"Assemble the wardrobes\", start: some(new Date(\"2026-10-19T00:00:00Z\")), qty: some(6.0), setups: none, site: \"Fitting shop\",\n status: \"PLANNED\", code: \"\", level: variant(\"day\", null), started: none,\n machines: { from: [], to: [variant(\"identified\", { key: \"A701\" })] } },\n { id: \"w43-2\", task: \"Spray the vanity doors\", start: none, qty: some(4.0), setups: none, site: \"Spray shop\",\n status: \"PLANNED\", code: \"\", level: variant(\"time\", null), started: none,\n machines: { from: [], to: [] } },\n ] }],\n ]),\n mutations: (mutation) => ({\n // The plans' patch door — every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const plans = $.let(Record.bind(sheetWeekPlans));\n // The week the viewer picked and the journal: a viewer's own state.\n const week = $.let(State.bind([StringType], \"sheet.weeks.week\", \"2026-W42\"));\n const log = $.let(State.bind([ArrayType(StringType)], \"sheet.weeks.journal\", []));\n const weeks = $.let([\"2026-W42\", \"2026-W43\", \"2026-W44\"], ArrayType(StringType));\n const pick = $.const(East.function([StringType], NullType, ($, w) => { $(week.write(w)); }));\n const StatusType = StructType({ word: StringType, tone: StatusValueType });\n const statuses = $.let([\n { word: \"PLANNED\", tone: variant(\"neutral\", null) }, { word: \"RELEASED\", tone: variant(\"info\", null) },\n { word: \"IN PROGRESS\", tone: variant(\"warning\", null) }, { word: \"COMPLETE\", tone: variant(\"success\", null) },\n ], ArrayType(StatusType));\n const sites = $.let([\"Machine shop\", \"Bench room\", \"Fitting shop\", \"Spray shop\"], ArrayType(StringType));\n const machines = $.let([\"S101\", \"S102\", \"S103\", \"E201\", \"E202\", \"R301\", \"R302\", \"R303\", \"A701\", \"A702\"], ArrayType(StringType));\n const Ctx = Sheet.Types.DraftContext(WeekRow);\n // Until a row has an order code it may only be planned or released.\n const statusOptions = $.const(East.function([Ctx], OptionType(ArrayType(StringType)), ($, ctx) => {\n const whole = $.const(none, OptionType(ArrayType(StringType)));\n const early = $.const(some([\"PLANNED\", \"RELEASED\"]), OptionType(ArrayType(StringType)));\n return ctx.row.code.match({ value: (_$2, code) => code.length().equal(0n).ifElse(() => early, () => whole) }, () => early);\n }));\n // A row is ready once its quantity is positive.\n const readyRow = $.const(East.function([Sheet.Types.Draft(WeekRow), Ctx], Sheet.Types.Readiness, ($, row) => {\n $.if(row.qty.hasTag(\"value\").and(() => row.qty.unwrap(\"value\").match({ some: (_$2, q) => q.lessEqual(0.0), none: () => false })), $ => {\n $.return(East.value(variant(\"incomplete\", [{ field: \"qty\", message: \"Quantity must be positive\" }]), Sheet.Types.Readiness));\n });\n return East.value(variant(\"ready\", null), Sheet.Types.Readiness);\n }));\n // Every gesture, journalled once with where it came from.\n const onPatch = $.const(East.function([Sheet.Types.PatchEvent(WeekRow)], NullType, ($, e) => {\n $(log.write(log.read().concat([East.str`${e.origin.getTag()} · ${e.label} · ${e.readiness.getTag()}`])));\n }));\n // A new row's id in the host's own scheme: given every id taken, the first new-N none of them is.\n const newKey = $.const(East.function([SetType(StringType)], StringType, ($, taken) => {\n const n = $.let(taken.size().add(1n));\n $.while(taken.has(East.str`new-${n}`), ($2) => {\n $2.assign(n, n.add(1n));\n });\n return East.str`new-${n}`;\n }));\n const newRow = $.const(East.function([Sheet.Types.NewRow], Sheet.Types.Patch(WeekRow), () => Sheet.patch(WeekRow, {\n setups: none, site: \"\", status: \"PLANNED\", code: \"\", level: variant(\"day\", null), started: none, machines: { from: [], to: [] },\n })));\n // A row's own Details: its task, and its quantity on a slider — released, the edited row goes back through `update`.\n const inspect = $.const(East.function([WeekRow, FunctionType([WeekRow], NullType)], UIComponentType, ($, row, update) => {\n const qty = $.let(row.qty.match({ none: () => 0.0, some: (_$, q) => q }));\n const setQty = $.const(East.function([FloatType], NullType, ($2, next) => {\n // East has no struct spread: the row, rebuilt with its new quantity.\n const edited = $2.const({\n id: row.id, task: row.task, start: row.start, qty: some(next), setups: row.setups, site: row.site,\n status: row.status, code: row.code, level: row.level, started: row.started, machines: row.machines,\n }, WeekRow);\n $2(update(edited));\n }));\n return (\n <VStack gap=\"3\" align=\"stretch\">\n <Text>{row.task}</Text>\n <Field.Slider label=\"Quantity\" value={qty} min={0} max={200} step={1}\n helperText=\"Released, it is one step the history undoes\" onChangeEnd={setQty} />\n </VStack>\n );\n }));\n const entries = $.let(log.read());\n return (\n <VStack gap=\"3\" align=\"stretch\">\n <SegmentGroup value={week.read()} onChange={pick} size=\"sm\"\n items={weeks.map((_$, w) => SegmentGroup.Item(w, <Text>{w}</Text>))} />\n <Box height=\"480px\">\n <Sheet\n vocabulary={{ members: \"machine\", unassigned: \"anyone free\", source: \"start bay\", destination: \"end bay\", wanted: \"promised\", actual: \"met\" }}\n record={plans}\n entry={{ key: week.read(), rows: \"rows\", id: \"id\" }}\n name=\"weeks\"\n inspector={inspect}\n owned={r => r.code.length().greater(0n)}\n registers={{\n statuses: Sheet.register.members(statuses, { kind: \"status\", key: s => s.word, label: s => s.word, tone: s => some(s.tone) }),\n sites: Sheet.register.members(sites, { kind: \"site\", key: s => s, label: s => s }),\n machines: Sheet.register.members(machines, { kind: \"machine\", key: m => m, label: m => m }),\n }}\n columns={{\n task: Sheet.column.text(WeekRow, { header: \"Task\", width: \"260px\" }),\n start: Sheet.column.date(WeekRow, { header: \"Start\", sub: \"at the row's level\", width: \"168px\", level: r => r.level, actual: r => r.started }),\n qty: Sheet.column.quantity(WeekRow, { header: \"Qty\", width: \"96px\" }),\n setups: Sheet.column.integer(WeekRow, { header: \"Set-ups\", width: \"72px\" }),\n site: Sheet.column.reference(WeekRow, \"sites\", { header: \"Site\", width: \"128px\" }),\n status: Sheet.column.enum(WeekRow, \"statuses\", { header: \"Status\", width: \"132px\", options: statusOptions, detail: r => r.code }),\n code: Sheet.column.stamped(WeekRow, { header: \"Order code\", sub: \"stamped on release\", owner: \"ERP\", width: \"112px\" }),\n machines: Sheet.column.set(WeekRow, \"machines\", { header: \"Machines\", sub: \"S101-03 · a run\", width: \"200px\",\n members: [{ kind: \"machine\", identified: true, ranged: true }] }),\n }}\n ready={{ row: readyRow }}\n onPatch={onPatch}\n newRow={newRow}\n newKey={newKey}\n />\n </Box>\n <Text.MonoLabel>{East.str`EDITS · ${entries.length()}`}</Text.MonoLabel>\n {entries.map((_$, l) => <Text textStyle=\"caption\" color=\"fg.muted\">{l}</Text>)}\n </VStack>\n );\n }}</Reactive>\n ))"
45842
46967
  },
45843
46968
  {
45844
46969
  "id": "e3-ui:sheet.examples.tsx:sheetBatches",
@@ -46029,7 +47154,7 @@
46029
47154
  "languages": [
46030
47155
  "tsx"
46031
47156
  ],
46032
- "source": "// A sheet whose inspector pane edits one field of every kind over the workshop's machines' upkeep — a number with its unit and bounds, a select of a variant's cases, a reference, a text emptied to none, tags, a checklist, a nested struct's fields under its name, a checkbox, a date and a time, Options set and cleared, and a stamped code read only — the hinted fields leading, with a row rule's issue\n// inputs: []\n/** A machine's family — the kind of machine it is. */\nexport const UpkeepFamily = VariantType({ beam_saw: NullType, edge_bander: NullType, cnc_router: NullType, spray_booth: NullType });\n\n/** One check of a service — what is checked, and whether it was done. */\nexport const UpkeepCheck = StructType({ text: StringType, done: BooleanType });\n\n/** Who supplies a machine's parts. */\nexport const UpkeepSupplier = StructType({ name: StringType, phone: StringType });\n\n/** A machine's upkeep — one field of each kind the inspector's form edits. */\nexport const MachineUpkeep = StructType({\n name: StringType, // a text column\n bay: StringType, // a reference column: a key of the bays\n hours: IntegerType, // an integer column: a number with its unit and bounds\n family: UpkeepFamily, // a select of the variant's cases\n wear: OptionType(FloatType), // a number with its unit, bounds and step, cleared to none\n crew: OptionType(StringType), // a text, emptied to none\n tickets: SetType(StringType), // tags, the tickets offered as they are typed\n checks: ArrayType(UpkeepCheck), // a checklist\n supplier: UpkeepSupplier, // a nested struct: its fields under its name\n in_service: BooleanType, // a checkbox\n guard_checked: OptionType(BooleanType), // a checkbox, cleared to none: not recorded\n serviced: DateTimeType, // a date and a time\n next_service: OptionType(DateTimeType), // a date and a time, set or cleared\n serial: StringType, // a stamped column: read only\n});\n\n/** The machines' upkeep, keyed by machine code. */\nexport const sheetMachineUpkeep = e3.record(\"sheet_machine_upkeep\", DictType(StringType, MachineUpkeep), {\n initial: new Map([\n [\"S101\", { name: \"Beam saw\", bay: \"Bay 1\", hours: 1240n, family: variant(\"beam_saw\", null), wear: some(35.5), crew: some(\"Cutting crew\"),\n tickets: new Set([\"Panel saw ticket\", \"Dust extraction\"]),\n checks: [{ text: \"Blade sharpened\", done: true }, { text: \"Fence squared\", done: true }, { text: \"Extraction cleaned\", done: false }],\n supplier: { name: \"Kestrelmoor Saw Works\", phone: \"01632 960 118\" },\n in_service: true, guard_checked: some(true),\n serviced: new Date(\"2026-09-28T07:30:00Z\"), next_service: some(new Date(\"2026-11-09T07:30:00Z\")), serial: \"BS-4410-0193\" }],\n [\"E201\", { name: \"Edge bander\", bay: \"Bay 2\", hours: 860n, family: variant(\"edge_bander\", null), wear: none, crew: none,\n tickets: new Set<string>(), checks: [], supplier: { name: \"\", phone: \"\" },\n in_service: true, guard_checked: none,\n serviced: new Date(\"2026-08-17T06:00:00Z\"), next_service: none, serial: \"EB-2207-0457\" }],\n [\"R301\", { name: \"CNC router\", bay: \"Bay 3\", hours: 2210n, family: variant(\"cnc_router\", null), wear: some(62.0), crew: some(\"Machining crew\"),\n tickets: new Set([\"Router ticket\"]),\n checks: [{ text: \"Spindle greased\", done: true }, { text: \"Bed vacuum tested\", done: false }],\n supplier: { name: \"Brindlecote Tooling\", phone: \"01632 960 342\" },\n in_service: false, guard_checked: some(false),\n serviced: new Date(\"2026-07-06T13:15:00Z\"), next_service: none, serial: \"CR-5120-0088\" }],\n [\"F401\", { name: \"Spray booth\", bay: \"Bay 4\", hours: 540n, family: variant(\"spray_booth\", null), wear: none, crew: some(\"Finishing crew\"),\n tickets: new Set([\"Spray ticket\", \"First aid\"]),\n checks: [{ text: \"Filters changed\", done: true }],\n supplier: { name: \"Fennimarsh Coatings\", phone: \"01632 960 775\" },\n in_service: true, guard_checked: some(true),\n serviced: new Date(\"2026-10-01T08:00:00Z\"), next_service: some(new Date(\"2026-12-01T08:00:00Z\")), serial: \"SB-0391-0017\" }],\n ]),\n mutations: (mutation) => ({\n // The upkeep's patch door — every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const upkeep = $.let(Record.bind(sheetMachineUpkeep));\n const bays = $.let([\"Bay 1\", \"Bay 2\", \"Bay 3\", \"Bay 4\", \"Bay 7\"], ArrayType(StringType));\n // A machine out of service needs its next service booked.\n const readyMachine = $.const(East.function([Sheet.Types.Draft(MachineUpkeep), Sheet.Types.DraftContext(MachineUpkeep)], Sheet.Types.Readiness, ($, row) => {\n const out = $.const(row.in_service.match({ value: (_$2, on) => on.not() }, () => false));\n const unbooked = $.const(row.next_service.match({ value: (_$2, next) => next.hasTag(\"none\") }, () => false));\n $.if(out.and(() => unbooked), $ => {\n $.return(East.value(variant(\"incomplete\", [{ field: \"next_service\", message: \"Out of service — book its next service\" }]), Sheet.Types.Readiness));\n });\n return East.value(variant(\"ready\", null), Sheet.Types.Readiness);\n }));\n return (\n <Box height=\"640px\">\n <Sheet\n record={upkeep}\n name=\"upkeep\"\n registers={{ bays: Sheet.register.members(bays, { kind: \"bay\", key: b => b, label: b => b }) }}\n columns={{\n name: Sheet.column.text(MachineUpkeep, { header: \"Machine\", width: \"200px\" }),\n bay: Sheet.column.reference(MachineUpkeep, \"bays\", { header: \"Bay\", width: \"96px\" }),\n hours: Sheet.column.integer(MachineUpkeep, { header: \"Hours\", sub: \"run since new\", width: \"96px\" }),\n serial: Sheet.column.stamped(MachineUpkeep, { header: \"Serial\", sub: \"on the maker's plate\", owner: \"Maker\", width: \"140px\" }),\n }}\n // The inspector pane: every field of a machine — the hinted ones first, in this order.\n inspector\n fields={{\n name: Sheet.field.text({ placeholder: \"Its name on the floor\" }),\n bay: Sheet.field.reference({ of: \"bays\", help: \"Where it stands\" }),\n hours: Sheet.field.number({ unit: \"h\", min: 0n, step: 10n }),\n family: Sheet.field.select({ labels: { beam_saw: \"Beam saw\", edge_bander: \"Edge bander\", cnc_router: \"CNC router\", spray_booth: \"Spray booth\" } }),\n wear: Sheet.field.number({ label: \"Blade wear\", unit: \"%\", min: 0, max: 100, step: 0.5 }),\n crew: Sheet.field.text({ placeholder: \"Which crew runs it\" }),\n tickets: Sheet.field.tags({ options: [\"Panel saw ticket\", \"Router ticket\", \"Spray ticket\", \"Dust extraction\", \"First aid\"] }),\n checks: Sheet.field.checklist({ help: \"Signed off at the last service\" }),\n supplier: { name: Sheet.field.text({ placeholder: \"Who supplies its parts\" }), phone: Sheet.field.text({ placeholder: \"01632 960 000\" }) },\n }}\n ready={{ row: readyMachine }}\n />\n </Box>\n );\n }}</Reactive>\n ))"
47157
+ "source": "// A sheet whose inspector pane edits one field of every kind over the workshop's machines' upkeep — a number with its unit and bounds, a select of a variant's cases, a reference, a text emptied to none, tags, a checklist, a nested struct's fields under its name, a checkbox, a date and a time, Options set and cleared, and a stamped code read only — the hinted fields leading, with a row rule's issue\n// inputs: []\n/** A machine's family — the kind of machine it is. */\nexport const UpkeepFamily = VariantType({ beam_saw: NullType, edge_bander: NullType, cnc_router: NullType, spray_booth: NullType });\n\n/** One check of a service — what is checked, and whether it was done. */\nexport const UpkeepCheck = StructType({ text: StringType, done: BooleanType });\n\n/** Who supplies a machine's parts. */\nexport const UpkeepSupplier = StructType({ name: StringType, phone: StringType });\n\n/** A machine's upkeep — one field of each kind the inspector's form edits. */\nexport const MachineUpkeep = StructType({\n name: StringType, // a text column\n bay: StringType, // a reference column: a key of the bays\n hours: IntegerType, // an integer column: a number with its unit and bounds\n family: UpkeepFamily, // a select of the variant's cases\n wear: OptionType(FloatType), // a number with its unit, bounds and step, cleared to none\n crew: OptionType(StringType), // a text, emptied to none\n tickets: SetType(StringType), // tags, the tickets offered as they are typed\n checks: ArrayType(UpkeepCheck), // a checklist\n supplier: UpkeepSupplier, // a nested struct: its fields under its name\n in_service: BooleanType, // a checkbox\n guard_checked: OptionType(BooleanType), // a checkbox, cleared to none: not recorded\n serviced: DateTimeType, // a date and a time\n next_service: OptionType(DateTimeType), // a date and a time, set or cleared\n serial: StringType, // a stamped column: read only\n});\n\n/** The machines' upkeep, keyed by machine code. */\nexport const sheetMachineUpkeep = e3.record(\"sheet_machine_upkeep\", DictType(StringType, MachineUpkeep), {\n initial: new Map([\n [\"S101\", { name: \"Beam saw\", bay: \"Bay 1\", hours: 1240n, family: variant(\"beam_saw\", null), wear: some(35.5), crew: some(\"Cutting crew\"),\n tickets: new Set([\"Panel saw ticket\", \"Dust extraction\"]),\n checks: [{ text: \"Blade sharpened\", done: true }, { text: \"Fence squared\", done: true }, { text: \"Extraction cleaned\", done: false }],\n supplier: { name: \"Kestrelmoor Saw Works\", phone: \"01632 960 118\" },\n in_service: true, guard_checked: some(true),\n serviced: new Date(\"2026-09-28T07:30:00Z\"), next_service: some(new Date(\"2026-11-09T07:30:00Z\")), serial: \"BS-4410-0193\" }],\n [\"E201\", { name: \"Edge bander\", bay: \"Bay 2\", hours: 860n, family: variant(\"edge_bander\", null), wear: none, crew: none,\n tickets: new Set<string>(), checks: [], supplier: { name: \"\", phone: \"\" },\n in_service: true, guard_checked: none,\n serviced: new Date(\"2026-08-17T06:00:00Z\"), next_service: none, serial: \"EB-2207-0457\" }],\n [\"R301\", { name: \"CNC router\", bay: \"Bay 3\", hours: 2210n, family: variant(\"cnc_router\", null), wear: some(62.0), crew: some(\"Machining crew\"),\n tickets: new Set([\"Router ticket\"]),\n checks: [{ text: \"Spindle greased\", done: true }, { text: \"Bed vacuum tested\", done: false }],\n supplier: { name: \"Brindlecote Tooling\", phone: \"01632 960 342\" },\n in_service: false, guard_checked: some(false),\n serviced: new Date(\"2026-07-06T13:15:00Z\"), next_service: none, serial: \"CR-5120-0088\" }],\n [\"F401\", { name: \"Spray booth\", bay: \"Bay 4\", hours: 540n, family: variant(\"spray_booth\", null), wear: none, crew: some(\"Finishing crew\"),\n tickets: new Set([\"Spray ticket\", \"First aid\"]),\n checks: [{ text: \"Filters changed\", done: true }],\n supplier: { name: \"Fennimarsh Coatings\", phone: \"01632 960 775\" },\n in_service: true, guard_checked: some(true),\n serviced: new Date(\"2026-10-01T08:00:00Z\"), next_service: some(new Date(\"2026-12-01T08:00:00Z\")), serial: \"SB-0391-0017\" }],\n ]),\n mutations: (mutation) => ({\n // The upkeep's patch door — every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const upkeep = $.let(Record.bind(sheetMachineUpkeep));\n const bays = $.let([\"Bay 1\", \"Bay 2\", \"Bay 3\", \"Bay 4\", \"Bay 7\"], ArrayType(StringType));\n // A machine out of service needs its next service booked.\n const readyMachine = $.const(East.function([Sheet.Types.Draft(MachineUpkeep), Sheet.Types.DraftContext(MachineUpkeep)], Sheet.Types.Readiness, ($, row) => {\n const out = $.const(row.in_service.match({ value: (_$2, on) => on.not() }, () => false));\n const unbooked = $.const(row.next_service.match({ value: (_$2, next) => next.hasTag(\"none\") }, () => false));\n $.if(out.and(() => unbooked), $ => {\n $.return(East.value(variant(\"incomplete\", [{ field: \"next_service\", message: \"Out of service — book its next service\" }]), Sheet.Types.Readiness));\n });\n return East.value(variant(\"ready\", null), Sheet.Types.Readiness);\n }));\n return (\n <Box height=\"640px\">\n <Sheet\n record={upkeep}\n name=\"upkeep\"\n registers={{ bays: Sheet.register.members(bays, { kind: \"bay\", key: b => b, label: b => b }) }}\n columns={{\n name: Sheet.column.text(MachineUpkeep, { header: \"Machine\", width: \"200px\" }),\n bay: Sheet.column.reference(MachineUpkeep, \"bays\", { header: \"Bay\", width: \"96px\" }),\n hours: Sheet.column.integer(MachineUpkeep, { header: \"Hours\", sub: \"run since new\", width: \"96px\" }),\n serial: Sheet.column.stamped(MachineUpkeep, { header: \"Serial\", sub: \"on the maker's plate\", owner: \"Maker\", width: \"140px\" }),\n }}\n // The inspector pane: every field of a machine — the hinted ones first, in this order.\n inspector\n fields={{\n name: Sheet.field.text({ placeholder: \"Its name on the floor\" }),\n bay: Sheet.field.reference({ of: \"bays\", help: \"Where it stands\" }),\n hours: Sheet.field.number({ unit: \"h\", min: 0n, step: 10n }),\n family: Sheet.field.select({ labels: { beam_saw: \"Beam saw\", edge_bander: \"Edge bander\", cnc_router: \"CNC router\", spray_booth: \"Spray booth\" } }),\n wear: Sheet.field.number({ label: \"Blade wear\", unit: \"%\", min: 0, max: 100, step: 0.5 }),\n crew: Sheet.field.text({ placeholder: \"Which crew runs it\" }),\n tickets: Sheet.field.tags({ options: [\"Panel saw ticket\", \"Router ticket\", \"Spray ticket\", \"Dust extraction\", \"First aid\"] }),\n checks: Sheet.field.checklist({ help: \"Signed off at the last service\" }),\n supplier: { name: Sheet.field.text({ placeholder: \"Who supplies its parts\" }), phone: Sheet.field.text({ placeholder: \"01632 960 000\" }) },\n }}\n ready={{ row: readyMachine }}\n // A machine's serial is its maker's: the sheet keeps the machines' upkeep, and adds none.\n edits={{ insertRows: false }}\n />\n </Box>\n );\n }}</Reactive>\n ))"
46033
47158
  },
46034
47159
  {
46035
47160
  "id": "e3-ui:sheet.examples.tsx:sheetConflicts",
@@ -46037,7 +47162,7 @@
46037
47162
  "package": "e3-ui",
46038
47163
  "file": "east-ui/packages/e3-ui/test/sheet/sheet.examples.tsx",
46039
47164
  "suite": "",
46040
- "test": "Your edits meeting someone else's save, in one window — edit a Qty or a Start, then press Someone else saves, which saves another person's change to the same jobs (every Qty 12 more, every Start a day later), so yours conflict and wait to be chosen; a Task you change combines with theirs",
47165
+ "test": "Your edits meeting someone else's save, in one window — edit a Qty or a Start, then press Someone else saves, which saves another person's change to the same jobs (every Qty 12 more, every Start a day later), so yours conflict and wait to be chosen; a Task you change combines with theirs. Someone else removes Panel cutting removes that job — changed by you, a conflict of the whole row to choose — and Someone else adds a job adds one under the next key, which the sheet's newKey gives a row of yours too: one you added meanwhile takes the key after it, and both are kept",
46041
47166
  "keywords": [
46042
47167
  "Sheet",
46043
47168
  "conflict",
@@ -46050,7 +47175,14 @@
46050
47175
  "Record.bind",
46051
47176
  "mutate",
46052
47177
  "Button",
46053
- "patch"
47178
+ "patch",
47179
+ "removed",
47180
+ "added",
47181
+ "delete",
47182
+ "insert",
47183
+ "key taken",
47184
+ "newKey",
47185
+ "renumbered"
46054
47186
  ],
46055
47187
  "imports": [
46056
47188
  "import {",
@@ -46061,7 +47193,7 @@
46061
47193
  "languages": [
46062
47194
  "tsx"
46063
47195
  ],
46064
- "source": "// Your edits meeting someone else's save, in one window — edit a Qty or a Start, then press Someone else saves, which saves another person's change to the same jobs (every Qty 12 more, every Start a day later), so yours conflict and wait to be chosen; a Task you change combines with theirs\n// inputs: []\n/** A job — what it is, when it starts and how many. */\nexport const SheetJob = StructType({ task: StringType, start: OptionType(DateTimeType), qty: OptionType(FloatType) });\n\n/** The jobs the conflicts example edits, in a record of their own, so no other example's edits meet them. */\nexport const sheetConflictJobs = e3.record(\"sheet_conflict_jobs\", DictType(StringType, SheetJob), {\n initial: new Map([\n [\"J-0001\", { task: \"Panel cutting\", start: some(new Date(\"2026-10-12T00:00:00Z\")), qty: some(48.0) }],\n [\"J-0002\", { task: \"Edge banding\", start: some(new Date(\"2026-10-13T00:00:00Z\")), qty: some(120.0) }],\n [\"J-0003\", { task: \"CNC routing\", start: some(new Date(\"2026-10-14T00:00:00Z\")), qty: some(48.0) }],\n [\"J-0004\", { task: \"Spray finish\", start: some(new Date(\"2026-10-15T00:00:00Z\")), qty: some(36.0) }],\n ]),\n mutations: (mutation) => ({\n // The jobs' patch door — every Save commits through it.\n patch: mutation.patch(),\n // Someone else's save: every job's quantity 12 more and its start a day later, its task as it was.\n elsewhere: mutation.reduce(East.function([DictType(StringType, SheetJob)], DictType(StringType, SheetJob), (_$, jobs) =>\n jobs.map((_$2, job) => ({\n task: job.task,\n start: job.start.match({\n some: (_$3, at) => East.value(some(at.addDays(1n)), OptionType(DateTimeType)),\n none: (_$3) => East.value(none, OptionType(DateTimeType)),\n }),\n qty: job.qty.match({\n some: (_$3, n) => East.value(some(n.add(12.0)), OptionType(FloatType)),\n none: (_$3) => East.value(none, OptionType(FloatType)),\n }),\n })))),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const jobs = $.let(Record.bind(sheetConflictJobs, [\"patch\"]));\n const others = $.let(Record.bind(sheetConflictJobs, [\"elsewhere\"]));\n const theirs = $.const(East.function([], NullType, ($) => { $(others.mutate.elsewhere()); }));\n return (\n <VStack gap=\"3\" align=\"stretch\">\n <HStack gap=\"3\">\n <Button variant=\"outline\" onClick={theirs} loading={others.mutate.pending()}>Someone else saves</Button>\n <Text color=\"fg.muted\">Their change: every Qty 12 more, every Start a day later</Text>\n </HStack>\n <Box height=\"560px\">\n <Sheet\n name=\"conflicts\"\n record={jobs}\n columns={{\n task: Sheet.column.text(SheetJob, { header: \"Task\", width: \"240px\" }),\n start: Sheet.column.date(SheetJob, { header: \"Start\", width: \"96px\" }),\n qty: Sheet.column.quantity(SheetJob, { header: \"Qty\", width: \"96px\" }),\n }}\n />\n </Box>\n </VStack>\n );\n }}</Reactive>\n ))"
47196
+ "source": "// Your edits meeting someone else's save, in one window — edit a Qty or a Start, then press Someone else saves, which saves another person's change to the same jobs (every Qty 12 more, every Start a day later), so yours conflict and wait to be chosen; a Task you change combines with theirs. Someone else removes Panel cutting removes that job — changed by you, a conflict of the whole row to choose — and Someone else adds a job adds one under the next key, which the sheet's newKey gives a row of yours too: one you added meanwhile takes the key after it, and both are kept\n// inputs: []\n/** A job — what it is, when it starts and how many. */\nexport const SheetJob = StructType({ task: StringType, start: OptionType(DateTimeType), qty: OptionType(FloatType) });\n\n/** The jobs the conflicts example edits, in a record of their own, so no other example's edits meet them. */\nexport const sheetConflictJobs = e3.record(\"sheet_conflict_jobs\", DictType(StringType, SheetJob), {\n initial: new Map([\n [\"J-0001\", { task: \"Panel cutting\", start: some(new Date(\"2026-10-12T00:00:00Z\")), qty: some(48.0) }],\n [\"J-0002\", { task: \"Edge banding\", start: some(new Date(\"2026-10-13T00:00:00Z\")), qty: some(120.0) }],\n [\"J-0003\", { task: \"CNC routing\", start: some(new Date(\"2026-10-14T00:00:00Z\")), qty: some(48.0) }],\n [\"J-0004\", { task: \"Spray finish\", start: some(new Date(\"2026-10-15T00:00:00Z\")), qty: some(36.0) }],\n ]),\n mutations: (mutation) => ({\n // The jobs' patch door — every Save commits through it.\n patch: mutation.patch(),\n // Someone else's save: every job's quantity 12 more and its start a day later, its task as it was.\n elsewhere: mutation.reduce(East.function([DictType(StringType, SheetJob)], DictType(StringType, SheetJob), (_$, jobs) =>\n jobs.map((_$2, job) => ({\n task: job.task,\n start: job.start.match({\n some: (_$3, at) => East.value(some(at.addDays(1n)), OptionType(DateTimeType)),\n none: (_$3) => East.value(none, OptionType(DateTimeType)),\n }),\n qty: job.qty.match({\n some: (_$3, n) => East.value(some(n.add(12.0)), OptionType(FloatType)),\n none: (_$3) => East.value(none, OptionType(FloatType)),\n }),\n })))),\n // Someone else's save: Panel cutting, J-0001, removed — where the record still holds it.\n removes: mutation.reduce(East.function([DictType(StringType, SheetJob)], DictType(StringType, SheetJob), ($, jobs) => {\n const next = $.let(jobs.copy());\n $(next.tryDelete(\"J-0001\"));\n return next;\n })),\n // Someone else's save: a job added under the next key, J-0005 — where the record holds none there.\n adds: mutation.reduce(East.function([DictType(StringType, SheetJob)], DictType(StringType, SheetJob), ($, jobs) => {\n const next = $.let(jobs.copy());\n $.if(next.has(\"J-0005\").not(), ($2) => {\n const assembly = $2.const({ task: \"Assembly\", start: some(new Date(\"2026-10-16T00:00:00Z\")), qty: some(6.0) }, SheetJob);\n $2(next.insert(\"J-0005\", assembly));\n });\n return next;\n })),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const jobs = $.let(Record.bind(sheetConflictJobs, [\"patch\"]));\n const others = $.let(Record.bind(sheetConflictJobs, [\"elsewhere\", \"removes\", \"adds\"]));\n const theirs = $.const(East.function([], NullType, ($) => { $(others.mutate.elsewhere()); }));\n const theirRemoval = $.const(East.function([], NullType, ($) => { $(others.mutate.removes()); }));\n const theirAddition = $.const(East.function([], NullType, ($) => { $(others.mutate.adds()); }));\n // A new job's key in the workshop's own scheme: given every key taken, the first J-000N none of them is.\n const newKey = $.const(East.function([SetType(StringType)], StringType, ($, taken) => {\n const n = $.let(taken.size().add(1n));\n $.while(taken.has(East.str`J-000${n}`), ($2) => {\n $2.assign(n, n.add(1n));\n });\n return East.str`J-000${n}`;\n }));\n return (\n <VStack gap=\"3\" align=\"stretch\">\n <HStack gap=\"3\" wrap=\"wrap\">\n <Button variant=\"outline\" onClick={theirs} loading={others.mutate.pending()}>Someone else saves</Button>\n <Button variant=\"outline\" onClick={theirRemoval} loading={others.mutate.pending()}>Someone else removes Panel cutting</Button>\n <Button variant=\"outline\" onClick={theirAddition} loading={others.mutate.pending()}>Someone else adds a job</Button>\n </HStack>\n <Text color=\"fg.muted\">Someone else saves: every Qty 12 more, every Start a day later. Their removal: J-0001, Panel cutting. Their addition: J-0005, Assembly.</Text>\n <Box height=\"560px\">\n <Sheet\n name=\"conflicts\"\n record={jobs}\n columns={{\n task: Sheet.column.text(SheetJob, { header: \"Task\", width: \"240px\" }),\n start: Sheet.column.date(SheetJob, { header: \"Start\", width: \"96px\" }),\n qty: Sheet.column.quantity(SheetJob, { header: \"Qty\", width: \"96px\" }),\n }}\n newKey={newKey}\n />\n </Box>\n </VStack>\n );\n }}</Reactive>\n ))"
46065
47197
  },
46066
47198
  {
46067
47199
  "id": "e3-ui:component.examples.tsx:studioComponent",