@cocoar/vue-ui 4.0.0-beta.46 → 4.0.0-beta.51

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocoar/vue-ui",
3
- "version": "4.0.0-beta.46",
3
+ "version": "4.0.0-beta.51",
4
4
  "description": "Cocoar Design System — a tablet-first Vue 3 component library with 30+ accessible, themeable components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -58,7 +58,7 @@
58
58
  "skills"
59
59
  ],
60
60
  "dependencies": {
61
- "@cocoar/vue-localization": "4.0.0-beta.46",
61
+ "@cocoar/vue-localization": "4.0.0-beta.51",
62
62
  "@fontsource/cascadia-code": "^5.2.3",
63
63
  "@fontsource/inter": "^5.2.8",
64
64
  "@fontsource/onest": "^5.3.1",
@@ -84,7 +84,7 @@
84
84
  "vue": "^3.5.32",
85
85
  "vue-router": "^5.0.4"
86
86
  },
87
- "gitHead": "cb5acac0116b4cf88473d153787d615b19fb7923",
87
+ "gitHead": "b2b2eadc5d009e0a8cbb4a90112d4c2ff7916325",
88
88
  "scripts": {
89
89
  "build": "vite build",
90
90
  "test": "vitest run",
@@ -233,6 +233,21 @@ An action is a field of its own: a select in it does not take the label, hint or
233
233
  `CoarFormField`, so give it its own name with `aria-label`. The same slots exist on
234
234
  [Text Input](./text-input.md#actions).
235
235
 
236
+ ## Exact entry (Preview) {#exact}
237
+
238
+ Leaving the field without changing its text never changes the value, also when the value has more digits than
239
+ `decimals` shows or lies outside `min` and `max`. Text that was edited is rounded and clamped: while typing, or
240
+ with `clampOnBlur` only when the field is left.
241
+
242
+ For data that must not be altered, such as configuration values, `exact` turns off the mask, rounding and clamping.
243
+ It accepts the decimal separator of the locale or a point, and no thousands separators. Other text, or more digits
244
+ than `decimals` allows, stays in the field as an error, the value does not change, and `entry-refused` reports it.
245
+ Use `:decimals="null"` to allow any number of decimals.
246
+
247
+ ```vue
248
+ <CoarNumberInput v-model="timeout" exact :decimals="null" locale="de-AT" @entry-refused="refused = $event" />
249
+ ```
250
+
236
251
  ## Accessibility
237
252
 
238
253
  ### Keyboard Navigation
@@ -275,7 +290,9 @@ These keys can be translated via [`@cocoar/vue-localization`](../foundations/loc
275
290
  | `min` | `number` | `undefined` | Minimum allowed value |
276
291
  | `max` | `number` | `undefined` | Maximum allowed value |
277
292
  | `step` | `number` | `1` | Step increment |
278
- | `decimals` | `number` | `0` | Number of decimal places |
293
+ | `decimals` | `number \| null` | `0` | Number of decimal places. `null` (Preview): as many as the value has |
294
+ | `clampOnBlur` (Preview) | `boolean` | `false` | `min` and `max` apply when the field is left, not already while typing |
295
+ | `exact` (Preview) | `boolean` | `false` | Stores the value as typed or not at all, see [Exact entry](#exact) |
279
296
  | `prefix` | `string` | `''` | Prefix text |
280
297
  | `suffix` | `string` | `''` | Suffix text (e.g. '%', 'EUR') |
281
298
  | `stepperButtons` | `'none' \| 'increment' \| 'decrement' \| 'both'` | `'none'` | Stepper button mode |
@@ -261,7 +261,8 @@ everything else:
261
261
  as generic text. **`validateSchema: false`**: the stored form (an encrypted envelope) differs from the logical
262
262
  schema (`type: "string"`), so the schema's checks are skipped at this value.
263
263
  - **`redact(pointer, value)`** masks any other value as dots, read-only and without a control, also unknown keys
264
- the schema does not describe.
264
+ the schema does not describe. It is asked for every value inside a row's value too: a redacted value deep in an
265
+ unknown object or a list masks the whole row.
265
266
 
266
267
  A missing required key is still reported where `validateSchema` is `false`: it is a check of the parent object.
267
268
 
@@ -340,6 +341,66 @@ pre {
340
341
  </style>
341
342
  ```
342
343
 
344
+ ## Values outside the schema (Preview) {#values-outside-the-schema}
345
+
346
+ A value the schema does not describe stays in the document and has a row of its own, marked "not in the schema"
347
+ and read-only. `editUnknown(pointer, value)` lets the user edit such a value as JSON where the app returns `true`,
348
+ for a legacy field or one only newer clients know. It is asked for each existing value; it never adds keys, and it
349
+ does not lift `additionalProperties: false`: validation still reports the key.
350
+
351
+ - The value changes only when the text is valid JSON and differs. Invalid text shows a message and leaves the
352
+ document as it was; Esc restores the text.
353
+ - `null`, `""`, `[]` and `{}` are written as entered, also with `presence="filled"`.
354
+ - A value that `redact` masks, or that holds a masked value, is never editable.
355
+
356
+ **Demo — `object-editor/demos/ObjectEditorUnknown.vue`**
357
+
358
+ ```vue
359
+ <template>
360
+ <div class="demo">
361
+ <CoarObjectEditor v-model="settings" :schema="schema" :edit-unknown="editUnknown" locale="en-US" />
362
+ <pre class="json">{{ JSON.stringify(settings, null, 2) }}</pre>
363
+ </div>
364
+ </template>
365
+
366
+ <script setup lang="ts">
367
+ import { ref } from 'vue';
368
+ import { CoarObjectEditor, type JsonObject, type JsonSchema, type JsonValue } from '@cocoar/vue-object-editor';
369
+ import '@cocoar/vue-object-editor/styles';
370
+
371
+ const schema: JsonSchema = {
372
+ type: 'object',
373
+ properties: {
374
+ DatabaseSettings: {
375
+ type: 'object',
376
+ title: 'Database',
377
+ properties: { Host: { type: 'string', title: 'Host' }, Port: { type: 'integer', title: 'Port' } },
378
+ },
379
+ },
380
+ };
381
+
382
+ // A legacy field and one only newer clients know: neither is in the schema.
383
+ const settings = ref<JsonObject | undefined>({
384
+ DatabaseSettings: { Host: 'db.internal', Port: 5432, UnknownLegacy: { Keep: 1 } },
385
+ FeatureFlags: ['beta-search'],
386
+ });
387
+
388
+ // The app decides per value. Here: everything except the legacy field.
389
+ const editUnknown = (pointer: string, _value: JsonValue) => pointer !== '/DatabaseSettings/UnknownLegacy';
390
+ </script>
391
+
392
+ <style scoped>
393
+ .demo {
394
+ display: grid;
395
+ gap: 12px;
396
+ }
397
+ .json {
398
+ margin: 0;
399
+ font-size: 12px;
400
+ }
401
+ </style>
402
+ ```
403
+
343
404
  ## The schema
344
405
 
345
406
  The schema is standard JSON Schema; anything that validates JSON Schema can check the data too. A few
@@ -350,10 +411,15 @@ The schema is standard JSON Schema; anything that validates JSON Schema can chec
350
411
  | `x-coar-type` | property | Id of the value type. Without it the type is recognized from the schema (`format: "date"` → date) |
351
412
  | `x-coar-order` | object | Order of its properties. Key order alone does not survive every database |
352
413
  | `x-coar-unit` | number | Unit after the value, such as `cm` |
353
- | `x-coar-decimals` | number | Decimal places; 0 for `integer`, 2 for `number` without it |
414
+ | `x-coar-decimals` | number | Fixed decimal places, for a known use such as money. Without it a `number` keeps every digit; an `integer` has none |
354
415
  | `x-coar-options` | choice | Name of an option source the app passes in `optionSources` |
355
416
  | `x-coar-suggestions` | tags | Suggested tags |
356
417
 
418
+ A **number** is stored as entered, within JavaScript number precision, and leaving a field unchanged never rewrites
419
+ it. Entry accepts the decimal separator of `locale` or a point, so `12,3456` and `12.3456` are the same value in
420
+ German. Thousands separators are not accepted: in English `12,3456` is refused with a message instead of becoming
421
+ `123456`, and so is an entry with more decimals than `x-coar-decimals` allows.
422
+
357
423
  A **choice** is `oneOf` of `{ const, title }`; several choices are an `array` with `uniqueItems` and
358
424
  `items.anyOf` of `{ const, title }`. A plain `enum` is read too.
359
425
 
@@ -662,6 +728,7 @@ a confirmation. **Allows null** writes `type: [t, "null"]`, and keeps an existin
662
728
  | `issues` | `ObjectEditorIssue[]` | `[]` | Problems the app found, shown in their rows |
663
729
  | `resolveType` | `({ schema, pointer, typeId }) => string \| undefined` | — | Chooses the type of a property, see [Sensitive values](#sensitive-values) |
664
730
  | `redact` | `(pointer, value) => boolean` | — | Masks a value as dots |
731
+ | `editUnknown` (Preview) | `(pointer, value) => boolean` | — | Edits a value the schema does not describe as JSON, see [Values outside the schema](#values-outside-the-schema) |
665
732
  | `v-model:search` | `string` | `''` | Filters rows by title, key or path, see [Search](#search) |
666
733
 
667
734
  The component exposes `issues` (every problem of the value, as `{ pointer, keyword, message? }`) and
@@ -713,6 +780,9 @@ app, set its token in the theme or style preset; the `striped` prop sets the sam
713
780
  | `coar.objectEditor.minLength` / `maxLength` | `At least {min} characters.` / `At most {max} characters.` |
714
781
  | `coar.objectEditor.formatDate` / `formatEmail` / `format` | `Not a valid date.` / `Not a valid email address.` / `Wrong format.` |
715
782
  | `coar.objectEditor.type` | `Wrong kind of value.` |
783
+ | `coar.objectEditor.invalidJson` | `Not valid JSON: the value is unchanged. Esc restores it.` |
784
+ | `coar.objectEditor.invalidNumber` | `Enter a number with one decimal separator, without thousands separators.` |
785
+ | `coar.objectEditor.invalidNumberScale` | `Enter a number with at most {count} decimal places, without thousands separators.` |
716
786
  | `coar.objectEditor.notAllowed` | `Not one of the allowed values.` |
717
787
  | `coar.objectEditor.unique` | `Each value may appear only once.` |
718
788
  | `coar.objectEditor.additional` | `Contains values the schema does not allow.` |