@cscfi/csc-ui 4.0.0-rc.4 → 4.0.0-rc.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/csc-ui.js +11345 -10712
  2. package/dist/custom-elements.json +145 -23
  3. package/dist/docs/c-button/usage.md +63 -6
  4. package/dist/docs/c-color-picker/usage.md +2 -1
  5. package/dist/docs/c-date-picker/usage.md +2 -1
  6. package/dist/docs/c-file-upload/usage.md +3 -3
  7. package/dist/docs/c-icon-button/usage.md +1 -0
  8. package/dist/docs/c-otp-input/usage.md +4 -1
  9. package/dist/docs/c-radio-group/usage.md +3 -1
  10. package/dist/docs/c-slider/usage.md +2 -2
  11. package/dist/docs/c-text-field/usage.md +53 -1
  12. package/dist/styles/css/tailwind-theme.css +6 -0
  13. package/dist/styles/css/tokens.css +95 -88
  14. package/dist/vscode.css-custom-data.json +2 -2
  15. package/dist/vscode.html-custom-data.json +63 -15
  16. package/dist/web-types.json +85 -29
  17. package/dist-types/components/c-autocomplete/CAutocomplete.vue.d.ts +2 -1
  18. package/dist-types/components/c-button/CButton.vue.d.ts +6 -2
  19. package/dist-types/components/c-button/injectButtonStyles.d.ts +1 -0
  20. package/dist-types/components/c-button-group/CButtonGroup.vue.d.ts +8 -0
  21. package/dist-types/components/c-checkbox/CCheckbox.vue.d.ts +3 -3
  22. package/dist-types/components/c-color-picker/CColorPicker.vue.d.ts +2 -1
  23. package/dist-types/components/c-date-picker/CDatePicker.vue.d.ts +2 -1
  24. package/dist-types/components/c-icon-button/CIconButton.vue.d.ts +3 -1
  25. package/dist-types/components/c-number-field/CNumberField.vue.d.ts +2 -1
  26. package/dist-types/components/c-otp-input/COtpInput.vue.d.ts +7 -0
  27. package/dist-types/components/c-radio-group/CRadioGroup.vue.d.ts +8 -0
  28. package/dist-types/components/c-select/CSelect.vue.d.ts +2 -1
  29. package/dist-types/components/c-slider/CSlider.vue.d.ts +2 -3
  30. package/dist-types/components/c-switch/CSwitch.vue.d.ts +8 -0
  31. package/dist-types/components/c-text-field/CTextField.vue.d.ts +3 -2
  32. package/dist-types/components/c-text-field/injectTextFieldStyles.d.ts +1 -0
  33. package/dist-types/components/c-time-picker/CTimePicker.vue.d.ts +2 -1
  34. package/dist-types/components/c-tree-select/CTreeSelect.vue.d.ts +1 -1
  35. package/dist-types/registry.d.ts +7 -0
  36. package/dist-types/shared/defineElement.d.ts +5 -1
  37. package/dist-types/shared/implicitSubmission.d.ts +31 -0
  38. package/dist-types/shared/useElementInternals.d.ts +7 -0
  39. package/dist-types/shared/useFormAssociation.d.ts +88 -0
  40. package/dist-types/shared/useHostStates.d.ts +5 -4
  41. package/dist-types/shared/useTypedField.d.ts +7 -0
  42. package/dist-types/shared/valueEvents.d.ts +6 -0
  43. package/dist-types/tag-name-map.d.ts +61 -21
  44. package/package.json +3 -2
@@ -805,7 +805,7 @@
805
805
  "cssParts": [
806
806
  {
807
807
  "name": "root",
808
- "description": "The item's box: its share of the accordion frame, the lifted outline and wash while expanded, and the ring the accordion's `outlined` adds"
808
+ "description": "The item's box: its share of the accordion frame, the lifted outline and tint while expanded, and the ring the accordion's `outlined` adds"
809
809
  },
810
810
  {
811
811
  "name": "header",
@@ -936,7 +936,7 @@
936
936
  "cssParts": [
937
937
  {
938
938
  "name": "root",
939
- "description": "The tinted box carrying the type's wash, hairline border and accent edge"
939
+ "description": "The box carrying the type's tint, hairline border and accent edge"
940
940
  },
941
941
  {
942
942
  "name": "icon",
@@ -1201,7 +1201,7 @@
1201
1201
  {
1202
1202
  "fieldName": "name",
1203
1203
  "name": "name",
1204
- "description": "Input field name",
1204
+ "description": "The name the picked value submits under in a native `<form>` — one entry\nper value with `multiple`",
1205
1205
  "type": {
1206
1206
  "text": "string"
1207
1207
  },
@@ -1571,7 +1571,7 @@
1571
1571
  "kind": "field",
1572
1572
  "name": "name",
1573
1573
  "privacy": "public",
1574
- "description": "Input field name",
1574
+ "description": "The name the picked value submits under in a native `<form>` — one entry\nper value with `multiple`",
1575
1575
  "type": {
1576
1576
  "text": "string"
1577
1577
  },
@@ -2380,12 +2380,21 @@
2380
2380
  "typeAlias": "CButtonVariant",
2381
2381
  "defaultable": true
2382
2382
  }
2383
+ },
2384
+ {
2385
+ "kind": "method",
2386
+ "name": "focus",
2387
+ "privacy": "public",
2388
+ "description": "Focus its button — its link under `href`, or the slotted button — as\n`focus()` does on a native button: the element renders no box of its own to\ntake it.",
2389
+ "csc": {
2390
+ "signature": "(options?: FocusOptions): void"
2391
+ }
2383
2392
  }
2384
2393
  ],
2385
2394
  "slots": [
2386
2395
  {
2387
2396
  "name": "default",
2388
- "description": "Button label content."
2397
+ "description": "Button label content, or a slotted `<button>` (ADR-0085):\nthe page's own native button, which a password manager reading the form's\nsubmit button finds. Its own `type`, `disabled`, `name`, `value` and\n`form` apply; the element paints its look."
2389
2398
  },
2390
2399
  {
2391
2400
  "name": "icon",
@@ -2470,6 +2479,18 @@
2470
2479
  },
2471
2480
  "default": "false"
2472
2481
  },
2482
+ {
2483
+ "fieldName": "name",
2484
+ "name": "name",
2485
+ "description": "The name the active button's value submits under in a native `<form>` —\none entry per active button with `multiple`, nothing while none is active",
2486
+ "type": {
2487
+ "text": "string"
2488
+ },
2489
+ "default": "''",
2490
+ "csc": {
2491
+ "freeform": true
2492
+ }
2493
+ },
2473
2494
  {
2474
2495
  "fieldName": "required",
2475
2496
  "name": "required",
@@ -2580,6 +2601,19 @@
2580
2601
  },
2581
2602
  "default": "false"
2582
2603
  },
2604
+ {
2605
+ "kind": "field",
2606
+ "name": "name",
2607
+ "privacy": "public",
2608
+ "description": "The name the active button's value submits under in a native `<form>` —\none entry per active button with `multiple`, nothing while none is active",
2609
+ "type": {
2610
+ "text": "string"
2611
+ },
2612
+ "default": "''",
2613
+ "csc": {
2614
+ "freeform": true
2615
+ }
2616
+ },
2583
2617
  {
2584
2618
  "kind": "field",
2585
2619
  "name": "required",
@@ -3134,7 +3168,7 @@
3134
3168
  {
3135
3169
  "fieldName": "name",
3136
3170
  "name": "name",
3137
- "description": "`name` of the inner checkbox input. The component is not\nform-associated, so it does not submit with a `<form>`.",
3171
+ "description": "The name the checkbox submits under in a native `<form>` while it is\nchecked: its `true-value`, or `on` when that is `true`",
3138
3172
  "type": {
3139
3173
  "text": "string"
3140
3174
  },
@@ -3340,7 +3374,7 @@
3340
3374
  "kind": "field",
3341
3375
  "name": "name",
3342
3376
  "privacy": "public",
3343
- "description": "`name` of the inner checkbox input. The component is not\nform-associated, so it does not submit with a `<form>`.",
3377
+ "description": "The name the checkbox submits under in a native `<form>` while it is\nchecked: its `true-value`, or `on` when that is `true`",
3344
3378
  "type": {
3345
3379
  "text": "string"
3346
3380
  },
@@ -3557,7 +3591,7 @@
3557
3591
  {
3558
3592
  "fieldName": "name",
3559
3593
  "name": "name",
3560
- "description": "Input field name",
3594
+ "description": "The name the colour submits under in a native `<form>`, in the\npicker's notation",
3561
3595
  "type": {
3562
3596
  "text": "string"
3563
3597
  },
@@ -3903,7 +3937,7 @@
3903
3937
  "kind": "field",
3904
3938
  "name": "name",
3905
3939
  "privacy": "public",
3906
- "description": "Input field name",
3940
+ "description": "The name the colour submits under in a native `<form>`, in the\npicker's notation",
3907
3941
  "type": {
3908
3942
  "text": "string"
3909
3943
  },
@@ -4737,7 +4771,7 @@
4737
4771
  {
4738
4772
  "fieldName": "name",
4739
4773
  "name": "name",
4740
- "description": "Input field name",
4774
+ "description": "The name the date submits under in a native `<form>`, as its ISO text;\na `range` as one ISO 8601 interval, `start/end`",
4741
4775
  "type": {
4742
4776
  "text": "string"
4743
4777
  },
@@ -5192,7 +5226,7 @@
5192
5226
  "kind": "field",
5193
5227
  "name": "name",
5194
5228
  "privacy": "public",
5195
- "description": "Input field name",
5229
+ "description": "The name the date submits under in a native `<form>`, as its ISO text;\na `range` as one ISO 8601 interval, `start/end`",
5196
5230
  "type": {
5197
5231
  "text": "string"
5198
5232
  },
@@ -6336,6 +6370,15 @@
6336
6370
  "typeAlias": "CIconButtonVariant",
6337
6371
  "defaultable": true
6338
6372
  }
6373
+ },
6374
+ {
6375
+ "kind": "method",
6376
+ "name": "focus",
6377
+ "privacy": "public",
6378
+ "description": "Focus its button, as `focus()` does on a native button: the element renders\nno box of its own to take it.",
6379
+ "csc": {
6380
+ "signature": "(options?: FocusOptions): void"
6381
+ }
6339
6382
  }
6340
6383
  ],
6341
6384
  "slots": [
@@ -8564,7 +8607,7 @@
8564
8607
  {
8565
8608
  "fieldName": "name",
8566
8609
  "name": "name",
8567
- "description": "Name of the input",
8610
+ "description": "The name the number submits under in a native `<form>`, written as a\nplain JS number (`1234.5`)",
8568
8611
  "type": {
8569
8612
  "text": "string"
8570
8613
  },
@@ -8876,7 +8919,7 @@
8876
8919
  "kind": "field",
8877
8920
  "name": "name",
8878
8921
  "privacy": "public",
8879
- "description": "Name of the input",
8922
+ "description": "The name the number submits under in a native `<form>`, written as a\nplain JS number (`1234.5`)",
8880
8923
  "type": {
8881
8924
  "text": "string"
8882
8925
  },
@@ -9299,6 +9342,18 @@
9299
9342
  },
9300
9343
  "default": "6"
9301
9344
  },
9345
+ {
9346
+ "fieldName": "name",
9347
+ "name": "name",
9348
+ "description": "The name the code submits under in a native `<form>`, as typed so far",
9349
+ "type": {
9350
+ "text": "string"
9351
+ },
9352
+ "default": "''",
9353
+ "csc": {
9354
+ "freeform": true
9355
+ }
9356
+ },
9302
9357
  {
9303
9358
  "fieldName": "required",
9304
9359
  "name": "required",
@@ -9465,6 +9520,19 @@
9465
9520
  },
9466
9521
  "default": "6"
9467
9522
  },
9523
+ {
9524
+ "kind": "field",
9525
+ "name": "name",
9526
+ "privacy": "public",
9527
+ "description": "The name the code submits under in a native `<form>`, as typed so far",
9528
+ "type": {
9529
+ "text": "string"
9530
+ },
9531
+ "default": "''",
9532
+ "csc": {
9533
+ "freeform": true
9534
+ }
9535
+ },
9468
9536
  {
9469
9537
  "kind": "field",
9470
9538
  "name": "required",
@@ -10461,6 +10529,18 @@
10461
10529
  "freeform": true
10462
10530
  }
10463
10531
  },
10532
+ {
10533
+ "fieldName": "name",
10534
+ "name": "name",
10535
+ "description": "The name the picked radio's value submits under in a native `<form>`;\nnothing submits while no radio is picked",
10536
+ "type": {
10537
+ "text": "string"
10538
+ },
10539
+ "default": "''",
10540
+ "csc": {
10541
+ "freeform": true
10542
+ }
10543
+ },
10464
10544
  {
10465
10545
  "fieldName": "required",
10466
10546
  "name": "required",
@@ -10613,6 +10693,19 @@
10613
10693
  "freeform": true
10614
10694
  }
10615
10695
  },
10696
+ {
10697
+ "kind": "field",
10698
+ "name": "name",
10699
+ "privacy": "public",
10700
+ "description": "The name the picked radio's value submits under in a native `<form>`;\nnothing submits while no radio is picked",
10701
+ "type": {
10702
+ "text": "string"
10703
+ },
10704
+ "default": "''",
10705
+ "csc": {
10706
+ "freeform": true
10707
+ }
10708
+ },
10616
10709
  {
10617
10710
  "kind": "field",
10618
10711
  "name": "required",
@@ -10833,7 +10926,7 @@
10833
10926
  {
10834
10927
  "fieldName": "name",
10835
10928
  "name": "name",
10836
- "description": "Input field name",
10929
+ "description": "The name the picked value submits under in a native `<form>` — one entry\nper value with `multiple`",
10837
10930
  "type": {
10838
10931
  "text": "string"
10839
10932
  },
@@ -11174,7 +11267,7 @@
11174
11267
  "kind": "field",
11175
11268
  "name": "name",
11176
11269
  "privacy": "public",
11177
- "description": "Input field name",
11270
+ "description": "The name the picked value submits under in a native `<form>` — one entry\nper value with `multiple`",
11178
11271
  "type": {
11179
11272
  "text": "string"
11180
11273
  },
@@ -11793,7 +11886,7 @@
11793
11886
  {
11794
11887
  "fieldName": "name",
11795
11888
  "name": "name",
11796
- "description": "`name` of the inner range input. The component is not\nform-associated, so it does not submit with a `<form>`.",
11889
+ "description": "The name the value submits under in a native `<form>`",
11797
11890
  "type": {
11798
11891
  "text": "string"
11799
11892
  },
@@ -11967,7 +12060,7 @@
11967
12060
  "kind": "field",
11968
12061
  "name": "name",
11969
12062
  "privacy": "public",
11970
- "description": "`name` of the inner range input. The component is not\nform-associated, so it does not submit with a `<form>`.",
12063
+ "description": "The name the value submits under in a native `<form>`",
11971
12064
  "type": {
11972
12065
  "text": "string"
11973
12066
  },
@@ -12679,6 +12772,18 @@
12679
12772
  },
12680
12773
  "default": "false"
12681
12774
  },
12775
+ {
12776
+ "fieldName": "name",
12777
+ "name": "name",
12778
+ "description": "The name the switch submits under in a native `<form>` while it is on:\nits `true-value`, or `on` when that is `true`",
12779
+ "type": {
12780
+ "text": "string"
12781
+ },
12782
+ "default": "''",
12783
+ "csc": {
12784
+ "freeform": true
12785
+ }
12786
+ },
12682
12787
  {
12683
12788
  "fieldName": "required",
12684
12789
  "name": "required",
@@ -12804,6 +12909,19 @@
12804
12909
  },
12805
12910
  "default": "false"
12806
12911
  },
12912
+ {
12913
+ "kind": "field",
12914
+ "name": "name",
12915
+ "privacy": "public",
12916
+ "description": "The name the switch submits under in a native `<form>` while it is on:\nits `true-value`, or `on` when that is `true`",
12917
+ "type": {
12918
+ "text": "string"
12919
+ },
12920
+ "default": "''",
12921
+ "csc": {
12922
+ "freeform": true
12923
+ }
12924
+ },
12807
12925
  {
12808
12926
  "kind": "field",
12809
12927
  "name": "required",
@@ -13997,7 +14115,7 @@
13997
14115
  {
13998
14116
  "fieldName": "name",
13999
14117
  "name": "name",
14000
- "description": "`name` of the inner input. The component is not form-associated, so it\ndoes not submit with a `<form>`.",
14118
+ "description": "The name the text submits under in a native `<form>`",
14001
14119
  "type": {
14002
14120
  "text": "string"
14003
14121
  },
@@ -14334,7 +14452,7 @@
14334
14452
  "kind": "field",
14335
14453
  "name": "name",
14336
14454
  "privacy": "public",
14337
- "description": "`name` of the inner input. The component is not form-associated, so it\ndoes not submit with a `<form>`.",
14455
+ "description": "The name the text submits under in a native `<form>`",
14338
14456
  "type": {
14339
14457
  "text": "string"
14340
14458
  },
@@ -14490,6 +14608,10 @@
14490
14608
  }
14491
14609
  ],
14492
14610
  "slots": [
14611
+ {
14612
+ "name": "default",
14613
+ "description": "A page's own `<input>`, framed in place of the field's own so that every password manager can fill it; its native attributes are its own"
14614
+ },
14493
14615
  {
14494
14616
  "name": "pre",
14495
14617
  "description": "Content inside the field, before the input, such as an icon"
@@ -14683,7 +14805,7 @@
14683
14805
  {
14684
14806
  "fieldName": "name",
14685
14807
  "name": "name",
14686
- "description": "Input field name",
14808
+ "description": "The name the time submits under in a native `<form>`, as its ISO text;\na `range` as one ISO 8601 interval, `start/end`",
14687
14809
  "type": {
14688
14810
  "text": "string"
14689
14811
  },
@@ -15036,7 +15158,7 @@
15036
15158
  "kind": "field",
15037
15159
  "name": "name",
15038
15160
  "privacy": "public",
15039
- "description": "Input field name",
15161
+ "description": "The name the time submits under in a native `<form>`, as its ISO text;\na `range` as one ISO 8601 interval, `start/end`",
15040
15162
  "type": {
15041
15163
  "text": "string"
15042
15164
  },
@@ -15808,7 +15930,7 @@
15808
15930
  {
15809
15931
  "fieldName": "name",
15810
15932
  "name": "name",
15811
- "description": "Input field name",
15933
+ "description": "The name the picked value submits under in a native `<form>`",
15812
15934
  "type": {
15813
15935
  "text": "string"
15814
15936
  },
@@ -16149,7 +16271,7 @@
16149
16271
  "kind": "field",
16150
16272
  "name": "name",
16151
16273
  "privacy": "public",
16152
- "description": "Input field name",
16274
+ "description": "The name the picked value submits under in a native `<form>`",
16153
16275
  "type": {
16154
16276
  "text": "string"
16155
16277
  },
@@ -53,24 +53,81 @@ wins when both are set.
53
53
 
54
54
  ## In a form
55
55
 
56
- `type="submit"` submits the `<form>` around the button (validating it first,
57
- as `form.requestSubmit()` does) and `type="reset"` resets it; the default
58
- `button` does nothing to the form. A disabled or loading button, or one with
59
- an `href`, never submits.
56
+ `type="submit"` submits the button's `<form>` — the one around it, or the one
57
+ its `form` attribute names — validating it first, as `form.requestSubmit()`
58
+ does, and `type="reset"` resets it; the default `button` does nothing to the
59
+ form. A disabled or loading button, or one with an `href`, never submits,
60
+ and a disabled `<fieldset>` around the button disables it.
61
+
62
+ The fields beside it take part in the form as native controls do: each
63
+ submits its value under its `name`, `form.reset()` returns it to the value
64
+ its markup set, and a disabled `<fieldset>` disables it. Enter in a
65
+ single-line text field submits the form through its first submit button,
66
+ `c-button` included, so a loading button stops that submit too.
67
+
68
+ A form without `novalidate` is checked before it submits: a `required` field
69
+ left empty, a date or colour that is bad input, a number out of range, an
70
+ incomplete mask or a partly filled code stops the submit, and the browser
71
+ points at the field with its own message. The field's look follows only its
72
+ `invalid` prop, so an app that shows its own error messages adds `novalidate`
73
+ and checks the fields itself:
60
74
 
61
75
  ```vue
62
- <form @submit.prevent="save">
76
+ <form novalidate @submit.prevent="save">
77
+ <c-text-field v-model="name" label="Name" name="name" required />
63
78
  <c-button type="submit">Save</c-button>
64
79
  </form>
65
80
  ```
66
81
 
82
+ What each field submits under its `name`:
83
+
84
+ | Field | Submits |
85
+ | ------------------------------------------------ | ------------------------------------------------------------------------------------------- |
86
+ | Text, number, code, colour, date and time fields | Its text, `''` when empty; a number as a plain JS number (`1234.5`), never the grouped text |
87
+ | A `range` date or time picker | One ISO 8601 interval, `2026-11-01/2026-11-30`, with a side left empty while it has none |
88
+ | `c-select`, `c-autocomplete`, `c-tree-select` | The picked value (an item's `value`), `''` without one; one entry per pick with `multiple` |
89
+ | `c-checkbox`, `c-switch` | Its `true-value` while on (`on` for `true`), nothing while off |
90
+ | `c-radio-group`, `c-button-group` | The picked value, nothing without one; one entry per active button with `multiple` |
91
+ | `c-slider` | Its value |
92
+
93
+ `c-file-upload` takes no part: its upload function sends the files.
94
+
95
+ ## Slotted button
96
+
97
+ A password manager reads a form's submit button to tell what the form is
98
+ for, and cannot find the native button inside a `c-button`'s shadow root:
99
+ Proton Pass, for one, then offers no password to generate on a sign-up form.
100
+ For the submit button of a form a password manager reads — sign up, log in,
101
+ change password — write the `<button>` yourself inside the `c-button`:
102
+
103
+ ```vue
104
+ <c-button :loading="saving">
105
+ <button type="submit">Create account</button>
106
+ </c-button>
107
+ ```
108
+
109
+ The button fills the `c-button`, which paints it with its appearance,
110
+ variant, size, ripple and loading spinner, and it stays in the page, where
111
+ every password manager finds it. Its own attributes apply — `type`,
112
+ `disabled`, `name`, `value`, `form` — and it submits its form natively. The
113
+ `c-button`'s `type`, `href`, `target` and `value` are ignored, and so are
114
+ the `icon` and `description` slots (put an icon inside the button), each
115
+ with a console warning. `loading` cancels the button's clicks; set
116
+ `disabled` on the button, where assistive technology hears it.
117
+
118
+ Every other form keeps `<c-button type="submit">`.
119
+
67
120
  ## Accessibility
68
121
 
69
122
  The `root` part is a native `<button>` (or `<a>` when `href` is set), so
70
123
  focus, keyboard activation and screen-reader semantics come from the
71
- platform. When only an icon is slotted, provide an accessible name on the
124
+ platform; with a slotted button, the page's own `<button>` is the control and
125
+ `root` only paints. When only an icon is slotted, provide an accessible name on the
72
126
  host, e.g. `aria-label="Close"`.
73
127
 
128
+ The element's `focus()` focuses that control, as on a native button, so a
129
+ page can move focus to it and a menu or popover returns focus to it.
130
+
74
131
  ## Customization
75
132
 
76
133
  Restyle via CSS parts from your own stylesheet:
@@ -43,7 +43,8 @@ Text that names no colour — `blurple`, `var(--brand)` — is **bad input**: th
43
43
  text stays as the user typed it, the value becomes `null`, and the host
44
44
  exposes the `bad-input` custom state and a read-only `badInput` property. The
45
45
  component never shows an error of its own; deciding whether bad input is an
46
- error, and saying so, is the consumer's validation:
46
+ error, and saying so, is the consumer's validation, and only a `<form>`
47
+ without `novalidate` stops a submit on it:
47
48
 
48
49
  ```vue
49
50
  <c-color-picker
@@ -41,7 +41,8 @@ date outside `min` and `max` — is **bad input**: the text stays as the user
41
41
  typed it, the value becomes `null`, and the host exposes the `bad-input` custom
42
42
  state and a read-only `badInput` property. The component never shows an error
43
43
  of its own; deciding whether bad input is an error, and saying so, is the
44
- consumer's validation:
44
+ consumer's validation, and only a `<form>` without `novalidate` stops a submit
45
+ on it:
45
46
 
46
47
  ```vue
47
48
  <c-date-picker
@@ -91,9 +91,9 @@ does nothing.
91
91
  Without `manual`, there is no waiting: an upload function assigned later
92
92
  queues every `local` entry at once, and so every file added after it.
93
93
 
94
- Or leave `upload` unset and send the files with the rest of the form. The
95
- field takes no part in a native `<form>` submission; build the `FormData`
96
- from the value:
94
+ Or leave `upload` unset and send the files with the rest of the form. Unlike
95
+ the other fields, a file upload takes no part in a native `<form>`
96
+ submission; build the `FormData` from the value:
97
97
 
98
98
  ```js
99
99
  const body = new FormData();
@@ -74,6 +74,7 @@ element ids (`aria-controls`, `aria-describedby`, …) give the button the
74
74
  elements the ids name in your page. Without an `aria-label` the button is named only by
75
75
  the text in its content, which is usually nothing or the badge count; visually
76
76
  hidden slotted text also names it, and keeps naming it while `loading`.
77
+ The element's `focus()` focuses the inner button, as on a native button.
77
78
 
78
79
  To show the name to sighted users too, put the button in a `c-tooltip`'s
79
80
  `trigger` slot. The tooltip text is announced as a description, so the
@@ -58,7 +58,10 @@ is ignored. The boxes opt out of browser and password-manager autofill.
58
58
 
59
59
  The `label` prop names the group; for richer label content, put it in the
60
60
  default slot instead (the prop wins when both are set). `required` adds the
61
- required marker to the label; enforcing it is your form logic's job.
61
+ required marker to the label. A native `<form>` without `novalidate` stops a
62
+ submit on an empty required code, and on a partly filled one; elsewhere,
63
+ enforcing it is your form logic's job. The code submits under `name`; see
64
+ **In a form** on `c-button`.
62
65
 
63
66
  Validation is yours too: set `invalid` and an `error-message` explaining why.
64
67
  The boxes take the error colour and the message replaces the `hint`. While
@@ -51,7 +51,9 @@ label.
51
51
  ## Validation
52
52
 
53
53
  Validation is your job: set `invalid` and supply an `error-message`
54
- explaining why. While invalid without an `error-message`,
54
+ explaining why. In a native `<form>` the picked value submits under `name`,
55
+ and a form without `novalidate` stops a submit while a `required` group has
56
+ no pick; see **In a form** on `c-button`. While invalid without an `error-message`,
55
57
  the `hint` keeps rendering as a hint. The message area reserves its height
56
58
  (unless `hide-message`), so an error appearing at runtime doesn't shift the
57
59
  layout.
@@ -35,8 +35,8 @@ Setting `value` moves the thumb and fires nothing. Set one: the built-in
35
35
  default is `50` whatever `min` and `max` are, held within them, so a slider
36
36
  with `max="8"` and no value starts at 8.
37
37
 
38
- `name` is passed to the inner range input, but the component is not
39
- form-associated, so the value does not submit with a `<form>`.
38
+ In a native `<form>` the value submits under `name`; see **In a form** on
39
+ `c-button`.
40
40
 
41
41
  ## Value bubble and unit
42
42
 
@@ -12,6 +12,9 @@ listen for `update:value`, which fires on every keystroke:
12
12
  `change` fires when the text is committed — Enter, or leaving the field after
13
13
  an edit — so save or validate there rather than on every keystroke.
14
14
 
15
+ In a native `<form>` the text submits under `name`, and Enter submits the
16
+ form; see **In a form** on `c-button`.
17
+
15
18
  `type` maps to the native input type: `password` adds a toggle that reveals
16
19
  the text, and `number` honours `min`, `max` and `step`. Setting `rows` above
17
20
  `1` renders a textarea.
@@ -88,7 +91,8 @@ Text that leaves some token unfilled is kept as typed. The read-only
88
91
  `maskComplete` property tells whether every token is filled, and a field
89
92
  holding such partial text exposes the `incomplete` custom state. The field
90
93
  shows no error of its own; whether an incomplete value is an error is the
91
- consumer's validation:
94
+ consumer's validation, and only a `<form>` without `novalidate` stops a
95
+ submit on it:
92
96
 
93
97
  ```vue
94
98
  <c-text-field
@@ -107,3 +111,51 @@ consumer's validation:
107
111
 
108
112
  A mask applies to a single-line field of type `text`, `tel` or `search`;
109
113
  other types (and a textarea) ignore it.
114
+
115
+ ## Password managers
116
+
117
+ A password manager fills only the inputs it can see, and Safari's and
118
+ Firefox's, like several extensions, do not look inside a component's shadow
119
+ root. For a username, a password or a one-time code, write the `<input>`
120
+ yourself inside the field: it stays in the page, where every password
121
+ manager finds it, and the field frames it with its label, message and
122
+ password toggle.
123
+
124
+ ```vue
125
+ <form action="/login" method="post">
126
+ <c-text-field label="Username">
127
+ <input v-model="username" autocomplete="username" name="username" />
128
+ </c-text-field>
129
+
130
+ <c-text-field label="Password">
131
+ <input
132
+ v-model="password"
133
+ autocomplete="current-password"
134
+ name="password"
135
+ type="password"
136
+ />
137
+ </c-text-field>
138
+
139
+ <c-button>
140
+ <button type="submit">Log in</button>
141
+ </c-button>
142
+ </form>
143
+ ```
144
+
145
+ The input's own attributes apply — `type`, `name`, `autocomplete`,
146
+ `required`, `disabled`, `placeholder` and the rest — and the field's props of
147
+ those names are ignored, with a console warning. `autocomplete` tells the
148
+ manager what the input holds: `username`, `current-password`, `new-password`
149
+ (where it offers to generate one) or `one-time-code`. In a form the input
150
+ submits and validates itself.
151
+
152
+ A password manager decides what a form is for — logging in, signing up,
153
+ changing a password — partly from its submit button, which it cannot find
154
+ inside a `c-button`'s shadow root: Proton Pass then offers no password to
155
+ generate on a sign-up form, whatever the page's headings say. Write the
156
+ submit button yourself inside the `c-button`, as above: a **slotted button**,
157
+ which the `c-button` paints (see `c-button`).
158
+
159
+ The field's `value` and its value events still work, so `v-model` goes on the
160
+ field or on the input. `mask`, `rows` and `trim-whitespace` do not apply to a
161
+ slotted input.
@@ -96,6 +96,8 @@
96
96
  --color-error-subtle: var(--c-error-subtle);
97
97
  --color-error-subtle-hover: var(--c-error-subtle-hover);
98
98
  --color-on-error-subtle: var(--c-on-error-subtle);
99
+ /* Error text on a surface: lighter than the dark-mode error fill (ADR-0080). */
100
+ --color-on-surface-error: var(--c-on-surface-error);
99
101
 
100
102
  --color-link: var(--c-link);
101
103
  --color-link-hover: var(--c-link-hover);
@@ -144,6 +146,10 @@
144
146
  --color-inverse-on: var(--c-inverse-on);
145
147
  --color-inverse-primary: var(--c-inverse-primary);
146
148
  --color-inverse-error: var(--c-inverse-error);
149
+ --color-inverse-secondary: var(--c-inverse-secondary);
150
+ --color-inverse-success: var(--c-inverse-success);
151
+ --color-inverse-info: var(--c-inverse-info);
152
+ --color-inverse-warning: var(--c-inverse-warning);
147
153
 
148
154
  /* Mode-invariant overlay scrim (dims content behind modals/backdrops). */
149
155
  --color-scrim: var(--c-scrim);