@cocoar/vue-ui 4.0.0-beta.44 → 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/dist/components/date-time/scrollable-calendar/CoarScrollableCalendar.vue.d.ts.map +1 -1
- package/dist/components/number-input/CoarNumberInput.vue.d.ts +15 -3
- package/dist/components/number-input/CoarNumberInput.vue.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +1515 -1449
- package/package.json +3 -3
- package/skills/cocoar-vue-ui/references/components/number-input.md +18 -1
- package/skills/cocoar-vue-ui/references/components/object-editor.md +75 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocoar/vue-ui",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
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.
|
|
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": "
|
|
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 |
|
|
@@ -244,8 +244,9 @@ pre {
|
|
|
244
244
|
/>
|
|
245
245
|
```
|
|
246
246
|
|
|
247
|
-
The editor looks up a value per path: the local one, else the base one.
|
|
248
|
-
|
|
247
|
+
The editor looks up a value per path: the local one, else the base one. A group inherits the keys it does not set;
|
|
248
|
+
a local list or map replaces the inherited one as a whole, also when it is empty, and **Reset to inherited** on the
|
|
249
|
+
list or map brings the inherited entries back. It does not merge — how layers combine is the app's rule. `origin` names the source of an inherited value; `conflict: true` shows "differs by context"
|
|
249
250
|
instead of a value that would look authoritative. To check the effective document, turn `validate` off and pass
|
|
250
251
|
the app's own `issues`: missing local keys are then no error, and the problems still appear in their rows.
|
|
251
252
|
|
|
@@ -260,7 +261,8 @@ everything else:
|
|
|
260
261
|
as generic text. **`validateSchema: false`**: the stored form (an encrypted envelope) differs from the logical
|
|
261
262
|
schema (`type: "string"`), so the schema's checks are skipped at this value.
|
|
262
263
|
- **`redact(pointer, value)`** masks any other value as dots, read-only and without a control, also unknown keys
|
|
263
|
-
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.
|
|
264
266
|
|
|
265
267
|
A missing required key is still reported where `validateSchema` is `false`: it is a check of the parent object.
|
|
266
268
|
|
|
@@ -339,6 +341,66 @@ pre {
|
|
|
339
341
|
</style>
|
|
340
342
|
```
|
|
341
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
|
+
|
|
342
404
|
## The schema
|
|
343
405
|
|
|
344
406
|
The schema is standard JSON Schema; anything that validates JSON Schema can check the data too. A few
|
|
@@ -349,10 +411,15 @@ The schema is standard JSON Schema; anything that validates JSON Schema can chec
|
|
|
349
411
|
| `x-coar-type` | property | Id of the value type. Without it the type is recognized from the schema (`format: "date"` → date) |
|
|
350
412
|
| `x-coar-order` | object | Order of its properties. Key order alone does not survive every database |
|
|
351
413
|
| `x-coar-unit` | number | Unit after the value, such as `cm` |
|
|
352
|
-
| `x-coar-decimals` | number |
|
|
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 |
|
|
353
415
|
| `x-coar-options` | choice | Name of an option source the app passes in `optionSources` |
|
|
354
416
|
| `x-coar-suggestions` | tags | Suggested tags |
|
|
355
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
|
+
|
|
356
423
|
A **choice** is `oneOf` of `{ const, title }`; several choices are an `array` with `uniqueItems` and
|
|
357
424
|
`items.anyOf` of `{ const, title }`. A plain `enum` is read too.
|
|
358
425
|
|
|
@@ -661,6 +728,7 @@ a confirmation. **Allows null** writes `type: [t, "null"]`, and keeps an existin
|
|
|
661
728
|
| `issues` | `ObjectEditorIssue[]` | `[]` | Problems the app found, shown in their rows |
|
|
662
729
|
| `resolveType` | `({ schema, pointer, typeId }) => string \| undefined` | — | Chooses the type of a property, see [Sensitive values](#sensitive-values) |
|
|
663
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) |
|
|
664
732
|
| `v-model:search` | `string` | `''` | Filters rows by title, key or path, see [Search](#search) |
|
|
665
733
|
|
|
666
734
|
The component exposes `issues` (every problem of the value, as `{ pointer, keyword, message? }`) and
|
|
@@ -712,6 +780,9 @@ app, set its token in the theme or style preset; the `striped` prop sets the sam
|
|
|
712
780
|
| `coar.objectEditor.minLength` / `maxLength` | `At least {min} characters.` / `At most {max} characters.` |
|
|
713
781
|
| `coar.objectEditor.formatDate` / `formatEmail` / `format` | `Not a valid date.` / `Not a valid email address.` / `Wrong format.` |
|
|
714
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.` |
|
|
715
786
|
| `coar.objectEditor.notAllowed` | `Not one of the allowed values.` |
|
|
716
787
|
| `coar.objectEditor.unique` | `Each value may appear only once.` |
|
|
717
788
|
| `coar.objectEditor.additional` | `Contains values the schema does not allow.` |
|