@cscfi/csc-ui 4.0.0-rc.3 → 4.0.0-rc.5

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 (50) hide show
  1. package/dist/csc-ui.js +12632 -11979
  2. package/dist/custom-elements.json +204 -28
  3. package/dist/docs/c-button/usage.md +93 -14
  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 +19 -8
  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 +107 -96
  14. package/dist/vscode.css-custom-data.json +2 -2
  15. package/dist/vscode.html-custom-data.json +88 -16
  16. package/dist/web-types.json +118 -34
  17. package/dist-types/components/c-autocomplete/CAutocomplete.vue.d.ts +2 -1
  18. package/dist-types/components/c-button/CButton.vue.d.ts +23 -5
  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 +18 -2
  25. package/dist-types/components/c-list-item/CListItem.vue.d.ts +1 -1
  26. package/dist-types/components/c-number-field/CNumberField.vue.d.ts +2 -1
  27. package/dist-types/components/c-otp-input/COtpInput.vue.d.ts +7 -0
  28. package/dist-types/components/c-radio-group/CRadioGroup.vue.d.ts +8 -0
  29. package/dist-types/components/c-select/CSelect.vue.d.ts +2 -1
  30. package/dist-types/components/c-side-navigation-item/CSideNavigationItem.vue.d.ts +1 -1
  31. package/dist-types/components/c-slider/CSlider.vue.d.ts +2 -3
  32. package/dist-types/components/c-sub-navigation-item/CSubNavigationItem.vue.d.ts +1 -1
  33. package/dist-types/components/c-switch/CSwitch.vue.d.ts +8 -0
  34. package/dist-types/components/c-text-field/CTextField.vue.d.ts +3 -2
  35. package/dist-types/components/c-text-field/injectTextFieldStyles.d.ts +1 -0
  36. package/dist-types/components/c-time-picker/CTimePicker.vue.d.ts +2 -1
  37. package/dist-types/components/c-tree-select/CTreeSelect.vue.d.ts +1 -1
  38. package/dist-types/index.d.ts +2 -2
  39. package/dist-types/registry.d.ts +7 -0
  40. package/dist-types/shared/appDefaults.d.ts +8 -1
  41. package/dist-types/shared/buttonVariant.d.ts +5 -0
  42. package/dist-types/shared/defineElement.d.ts +5 -1
  43. package/dist-types/shared/implicitSubmission.d.ts +31 -0
  44. package/dist-types/shared/useElementInternals.d.ts +7 -0
  45. package/dist-types/shared/useFormAssociation.d.ts +88 -0
  46. package/dist-types/shared/useHostStates.d.ts +5 -4
  47. package/dist-types/shared/useTypedField.d.ts +7 -0
  48. package/dist-types/shared/valueEvents.d.ts +6 -0
  49. package/dist-types/tag-name-map.d.ts +75 -28
  50. package/package.json +3 -2
@@ -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();
@@ -6,7 +6,7 @@ the button itself (the slot wins when both are given). Listen to the native
6
6
  `click` event; a disabled or loading button does not deliver it.
7
7
 
8
8
  ```vue
9
- <c-icon-button aria-label="Delete" danger @click="remove">
9
+ <c-icon-button aria-label="Delete" variant="danger" @click="remove">
10
10
  <c-icon :path="mdiDelete" />
11
11
  </c-icon-button>
12
12
  ```
@@ -22,13 +22,24 @@ the button itself (the slot wins when both are given). Listen to the native
22
22
 
23
23
  ## Appearances
24
24
 
25
- `appearance` matches `c-button`'s: `filled` (the default) primary button for
26
- the main action, then `outlined`, `ghost` (a light primary tint) and `text`
27
- (no fill) for lower emphasis. The 3.x `outlined`, `ghost` and `text` boolean
28
- attributes still work until 5.0; `appearance` wins when both are set. `danger` turns the filled button into the error
29
- role for a destructive action; it has no effect on the other appearances.
30
- `inverted` is for a fixed dark or brand-coloured backdrop: it paints the
31
- `inverse-*` family, which looks the same in both theme modes.
25
+ `appearance` matches `c-button`'s: `filled` (the default) for the main
26
+ action, then `outlined`, `ghost` (a light tint) and `text` (no fill) for lower
27
+ emphasis. The 3.x `outlined`, `ghost` and `text` boolean attributes still work
28
+ until 5.0; `appearance` wins when both are set. `inverted` is for a fixed dark
29
+ or brand-coloured backdrop: it paints the `inverse-*` family, which looks the
30
+ same in both theme modes.
31
+
32
+ ## Variants
33
+
34
+ `variant` matches `c-button`'s and colours every appearance: `primary` (the
35
+ default), `secondary`, `success`, `info`, `warning`, or `danger` for a
36
+ destructive action. The filled success, info and warning buttons draw a dark
37
+ icon, which stays visible on their lighter fills; inverted, only the filled
38
+ look shows the colour. An app can change the default with
39
+ `applyDefaults({ 'c-icon-button': { variant: 'secondary' } })`; the icon
40
+ buttons the library draws inside its own components keep `primary`. The
41
+ `danger` attribute of earlier releases still works until 5.0; `variant` wins
42
+ when both are set.
32
43
 
33
44
  ## Sizes
34
45
 
@@ -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);