maverick-wave-astro 1.16.0 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -147,11 +147,14 @@ their schemas; a site not yet moved has `contentmanager/sections.json`.
147
147
  `mwa-check && astro build` in the build script so a broken file stops the
148
148
  build - it knows the formats `date`, `email`, `uri` and the keywords `x-widget`,
149
149
  `x-item-title`, `x-labels`, `x-empty`, `x-not-before`, `x-groups`,
150
- `x-newest-first`, `x-translate`. Photos uploaded in the werkbank land in
151
- `public/images/uploads/`; the integration derives their sizes before the build
152
- (`maverick-wave-astro/uploads`), skips a file sharp cannot read and removes the
153
- originals from `dist/`, since they still carry EXIF and GPS. Tooling: re-export
154
- `maverick-wave-astro/eslint` and `/prettier`.
150
+ `x-newest-first`, `x-translate`, `x-show-if` (the werkbank shows a field only
151
+ while a neighbour has one of the given values) and `x-width` (`narrow` |
152
+ `medium` | `wide`: how wide a field stands next to other short ones). Photos
153
+ uploaded in the werkbank land in `public/images/uploads/`; the integration
154
+ derives their sizes before the build (`maverick-wave-astro/uploads`), skips a
155
+ file sharp cannot read and removes the originals from `dist/`, since they still
156
+ carry EXIF and GPS. Tooling: re-export `maverick-wave-astro/eslint` and
157
+ `/prettier`.
155
158
 
156
159
  Pages read sections and the texts of the code through
157
160
  `maverick-wave-astro/werkbank`:
package/bin/check.mjs CHANGED
@@ -26,6 +26,18 @@ ajv.addVocabulary([
26
26
  'x-groups',
27
27
  'x-newest-first',
28
28
  'x-translate',
29
+ // The werkbank turns it into the fields of the section a story tab hangs on.
30
+ 'x-fields',
31
+ // Only the form reads these: a field shows when a neighbour has one of the
32
+ // values, and how wide it stands next to other short fields.
33
+ 'x-show-if',
34
+ 'x-width',
35
+ 'x-empty-by',
36
+ // The werkbank fills it with the designs of the section Stories, lowers the
37
+ // maximum of the list without the larger booking, and keeps its ids.
38
+ 'x-story-design',
39
+ 'x-basic-max-items',
40
+ 'x-keep-ids',
29
41
  ]);
30
42
  // Same rule as in the werkbank: YYYY-MM-DD compares as text.
31
43
  ajv.addKeyword({
@@ -73,14 +85,42 @@ const documents = existsSync(WERKBANK)
73
85
 
74
86
  const compiled = new Map();
75
87
  const validator = schema => {
76
- if (!compiled.has(schema)) compiled.set(schema, ajv.compile(read(schema)));
88
+ if (!compiled.has(schema)) {
89
+ const json = read(schema);
90
+ compiled.set(schema, { json, validate: ajv.compile(json) });
91
+ }
77
92
  return compiled.get(schema);
78
93
  };
79
94
 
95
+ // The ids of a list with x-keep-ids stay in the file for other sections to
96
+ // point at - they are no field of the schema.
97
+ const withoutKeptIds = (schema, value) => {
98
+ if (Array.isArray(value)) {
99
+ return value.map(entry => {
100
+ const inner = withoutKeptIds(schema?.items, entry);
101
+ if (!schema?.['x-keep-ids'] || !inner || typeof inner !== 'object') {
102
+ return inner;
103
+ }
104
+ const rest = { ...inner };
105
+ delete rest._id;
106
+ return rest;
107
+ });
108
+ }
109
+ if (value && typeof value === 'object') {
110
+ return Object.fromEntries(
111
+ Object.entries(value).map(([key, inner]) => [
112
+ key,
113
+ withoutKeptIds(schema?.properties?.[key], inner),
114
+ ])
115
+ );
116
+ }
117
+ return value;
118
+ };
119
+
80
120
  let count = 0;
81
121
  for (const { name, schema, document } of documents) {
82
- const validate = validator(schema);
83
- if (validate(document)) continue;
122
+ const { json, validate } = validator(schema);
123
+ if (validate(withoutKeptIds(json, document))) continue;
84
124
  for (const error of validate.errors) {
85
125
  console.error(`${name}${error.instancePath}: ${message(error)}`);
86
126
  count++;
@@ -2,7 +2,7 @@
2
2
  // Call, directions, book - held at the bottom edge of a phone. From a tablet
3
3
  // up it steps aside unless `always` is set; while it shows, the page keeps
4
4
  // its height free. Place it last in the body, after the footer.
5
- import { config } from '../dist/config.js';
5
+ import { actionBarFloats, config } from '../dist/config.js';
6
6
  import { PACKAGE_ICONS } from '../dist/icons.js';
7
7
  import { linkTo } from '../dist/path.js';
8
8
  import Icon from './Icon.astro';
@@ -24,6 +24,7 @@ interface Props {
24
24
  // At the bottom of its own frame instead of the window, e.g. a device.
25
25
  embedded?: boolean;
26
26
  // Floats above the bottom edge as the counterpart to the header island.
27
+ // Without it, design.actionBar decides - the owner switches it in the werkbank.
27
28
  island?: boolean;
28
29
  class?: string;
29
30
  }
@@ -48,7 +49,7 @@ const {
48
49
  items,
49
50
  always = false,
50
51
  embedded = false,
51
- island = false,
52
+ island = actionBarFloats(),
52
53
  class: className,
53
54
  } = Astro.props;
54
55
  ---