@porsche-design-system/components-react 4.7.0 → 4.8.0-rc.1
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/CHANGELOG.md +94 -1
- package/cjs/hooks.cjs +1 -5
- package/cjs/lib/components/checkbox.wrapper.cjs +3 -3
- package/cjs/lib/components/input-date.wrapper.cjs +3 -3
- package/cjs/lib/components/input-email.wrapper.cjs +3 -3
- package/cjs/lib/components/input-month.wrapper.cjs +3 -3
- package/cjs/lib/components/input-number.wrapper.cjs +3 -3
- package/cjs/lib/components/input-password.wrapper.cjs +3 -3
- package/cjs/lib/components/input-tel.wrapper.cjs +3 -3
- package/cjs/lib/components/input-text.wrapper.cjs +3 -3
- package/cjs/lib/components/input-time.wrapper.cjs +3 -3
- package/cjs/lib/components/input-url.wrapper.cjs +3 -3
- package/cjs/lib/components/input-week.wrapper.cjs +3 -3
- package/cjs/lib/components/multi-select.wrapper.cjs +3 -3
- package/cjs/lib/components/select.wrapper.cjs +3 -3
- package/cjs/lib/components/switch.wrapper.cjs +3 -3
- package/cjs/lib/components/textarea.wrapper.cjs +3 -3
- package/esm/hooks.d.ts +0 -3
- package/esm/hooks.mjs +2 -5
- package/esm/lib/components/checkbox.wrapper.d.ts +9 -1
- package/esm/lib/components/checkbox.wrapper.mjs +3 -3
- package/esm/lib/components/input-date.wrapper.d.ts +9 -1
- package/esm/lib/components/input-date.wrapper.mjs +3 -3
- package/esm/lib/components/input-email.wrapper.d.ts +9 -1
- package/esm/lib/components/input-email.wrapper.mjs +3 -3
- package/esm/lib/components/input-month.wrapper.d.ts +9 -1
- package/esm/lib/components/input-month.wrapper.mjs +3 -3
- package/esm/lib/components/input-number.wrapper.d.ts +9 -1
- package/esm/lib/components/input-number.wrapper.mjs +3 -3
- package/esm/lib/components/input-password.wrapper.d.ts +9 -1
- package/esm/lib/components/input-password.wrapper.mjs +3 -3
- package/esm/lib/components/input-search.wrapper.d.ts +2 -2
- package/esm/lib/components/input-tel.wrapper.d.ts +9 -1
- package/esm/lib/components/input-tel.wrapper.mjs +3 -3
- package/esm/lib/components/input-text.wrapper.d.ts +9 -1
- package/esm/lib/components/input-text.wrapper.mjs +3 -3
- package/esm/lib/components/input-time.wrapper.d.ts +9 -1
- package/esm/lib/components/input-time.wrapper.mjs +3 -3
- package/esm/lib/components/input-url.wrapper.d.ts +9 -1
- package/esm/lib/components/input-url.wrapper.mjs +3 -3
- package/esm/lib/components/input-week.wrapper.d.ts +9 -1
- package/esm/lib/components/input-week.wrapper.mjs +3 -3
- package/esm/lib/components/link-pure.wrapper.d.ts +2 -2
- package/esm/lib/components/link-tile-product.wrapper.d.ts +2 -2
- package/esm/lib/components/link.wrapper.d.ts +2 -2
- package/esm/lib/components/multi-select.wrapper.d.ts +9 -1
- package/esm/lib/components/multi-select.wrapper.mjs +3 -3
- package/esm/lib/components/select.wrapper.d.ts +9 -1
- package/esm/lib/components/select.wrapper.mjs +3 -3
- package/esm/lib/components/switch.wrapper.d.ts +9 -1
- package/esm/lib/components/switch.wrapper.mjs +3 -3
- package/esm/lib/components/textarea.wrapper.d.ts +9 -1
- package/esm/lib/components/textarea.wrapper.mjs +3 -3
- package/esm/lib/types.d.ts +22 -1
- package/package.json +2 -2
- package/skills/pds-audit-deprecations-react/SKILL.md +2 -2
- package/skills/pds-knowledge-react/SKILL.md +14 -5
- package/skills/pds-knowledge-react/references/components/p-carousel/examples/DynamicSlides.tsx +1 -0
- package/skills/pds-knowledge-react/references/components/p-carousel/examples/FocusOnCenterSlide.tsx +1 -0
- package/skills/pds-knowledge-react/references/components/p-carousel/examples/JumpToSlide.tsx +1 -0
- package/skills/pds-knowledge-react/references/components/p-checkbox/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-checkbox/p-checkbox.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-input-date/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-input-date/p-input-date.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-input-email/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-input-email/p-input-email.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-input-month/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-input-month/p-input-month.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-input-number/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-input-number/p-input-number.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-input-password/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-input-password/p-input-password.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-input-search/p-input-search.md +2 -1
- package/skills/pds-knowledge-react/references/components/p-input-tel/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-input-tel/p-input-tel.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-input-text/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-input-text/p-input-text.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-input-time/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-input-time/p-input-time.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-input-url/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-input-url/p-input-url.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-input-week/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-input-week/p-input-week.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-link/p-link.md +2 -2
- package/skills/pds-knowledge-react/references/components/p-link-pure/p-link-pure.md +2 -2
- package/skills/pds-knowledge-react/references/components/p-link-tile-product/p-link-tile-product.md +2 -2
- package/skills/pds-knowledge-react/references/components/p-multi-select/accessibility.md +22 -0
- package/skills/pds-knowledge-react/references/components/p-multi-select/p-multi-select.md +14 -2
- package/skills/pds-knowledge-react/references/components/p-pin-code/p-pin-code.md +11 -3
- package/skills/pds-knowledge-react/references/components/p-select/accessibility.md +22 -0
- package/skills/pds-knowledge-react/references/components/p-select/p-select.md +14 -2
- package/skills/pds-knowledge-react/references/components/p-switch/accessibility.md +18 -0
- package/skills/pds-knowledge-react/references/components/p-switch/p-switch.md +12 -0
- package/skills/pds-knowledge-react/references/components/p-textarea/accessibility.md +14 -0
- package/skills/pds-knowledge-react/references/components/p-textarea/p-textarea.md +12 -0
- package/skills/pds-knowledge-react/references/deprecations.md +4 -4
- package/skills/pds-knowledge-react/references/examples/patterns/feedback/dialog.md +230 -0
- package/skills/pds-knowledge-react/references/examples/patterns/feedback/inline.md +193 -0
- package/skills/pds-knowledge-react/references/examples/patterns/footer.md +250 -0
- package/skills/pds-knowledge-react/references/examples/patterns/header/overlay.md +152 -0
- package/skills/pds-knowledge-react/references/examples/patterns/header/stacked.md +122 -0
- package/skills/pds-knowledge-react/references/examples/patterns/popover/feature-tour.md +243 -0
- package/skills/pds-knowledge-react/references/examples/patterns/popover/local-market-switch.md +323 -0
- package/skills/pds-knowledge-react/references/examples/patterns/popover/priority-navigation.md +191 -0
- package/skills/pds-knowledge-react/references/examples/templates/admin-panel.md +397 -0
- package/skills/pds-knowledge-react/references/examples/templates/landing-page.md +529 -0
- package/skills/pds-knowledge-react/references/examples.md +48 -0
- package/ssr/cjs/components/dist/styles/esm/styles-entry.cjs +18 -105
- package/ssr/cjs/components/dist/utils/esm/utils-entry.cjs +78 -156
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/hooks.cjs +1 -5
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/checkbox.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/input-date.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/input-email.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/input-month.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/input-number.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/input-password.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/input-tel.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/input-text.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/input-time.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/input-url.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/input-week.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/multi-select.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/select.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/switch.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/textarea.wrapper.cjs +4 -4
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/checkbox.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/drilldown.cjs +2 -2
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-date.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-email.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-month.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-number.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-password.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-tel.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-text.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-time.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-url.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-week.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/label.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/link-pure.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/link-tile-product.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/link.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/multi-select.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/pin-code.cjs +2 -3
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/segmented-control-item.cjs +0 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/select.cjs +1 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/stepper-horizontal.cjs +0 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/switch.cjs +1 -2
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/tabs-bar.cjs +0 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/tabs.cjs +0 -1
- package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/textarea.cjs +1 -1
- package/ssr/esm/components/dist/styles/esm/styles-entry.mjs +18 -105
- package/ssr/esm/components/dist/utils/esm/utils-entry.mjs +78 -150
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/hooks.mjs +2 -5
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/checkbox.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/input-date.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/input-email.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/input-month.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/input-number.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/input-password.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/input-tel.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/input-text.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/input-time.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/input-url.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/input-week.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/multi-select.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/select.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/switch.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/textarea.wrapper.mjs +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/checkbox.mjs +2 -2
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/drilldown.mjs +3 -3
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-date.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-email.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-month.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-number.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-password.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-tel.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-text.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-time.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-url.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/input-week.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/label.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/link-pure.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/link-tile-product.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/link.mjs +1 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/multi-select.mjs +2 -2
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/pin-code.mjs +3 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/segmented-control-item.mjs +0 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/select.mjs +2 -2
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/stepper-horizontal.mjs +0 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/switch.mjs +1 -2
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/tabs-bar.mjs +0 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/tabs.mjs +0 -1
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/textarea.mjs +2 -2
- package/ssr/esm/hooks.d.ts +0 -3
- package/ssr/esm/lib/components/checkbox.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/input-date.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/input-email.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/input-month.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/input-number.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/input-password.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/input-search.wrapper.d.ts +2 -2
- package/ssr/esm/lib/components/input-tel.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/input-text.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/input-time.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/input-url.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/input-week.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/link-pure.wrapper.d.ts +2 -2
- package/ssr/esm/lib/components/link-tile-product.wrapper.d.ts +2 -2
- package/ssr/esm/lib/components/link.wrapper.d.ts +2 -2
- package/ssr/esm/lib/components/multi-select.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/select.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/switch.wrapper.d.ts +9 -1
- package/ssr/esm/lib/components/textarea.wrapper.d.ts +9 -1
- package/ssr/esm/lib/dsr-components/label.d.ts +1 -0
- package/ssr/esm/lib/dsr-components/link-pure.d.ts +1 -1
- package/ssr/esm/lib/dsr-components/link-tile-product.d.ts +1 -1
- package/ssr/esm/lib/dsr-components/link.d.ts +1 -1
- package/ssr/esm/lib/dsr-components/stepper-horizontal.d.ts +0 -1
- package/ssr/esm/lib/dsr-components/tabs-bar.d.ts +0 -1
- package/ssr/esm/lib/dsr-components/tabs.d.ts +0 -1
- package/ssr/esm/lib/types.d.ts +22 -1
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
## Integration examples
|
|
4
4
|
|
|
5
|
+
### ARIA on component host vs aria prop
|
|
6
|
+
|
|
7
|
+
#### ❌ Anti-pattern
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
<PSwitch aria-label="Dark mode" aria-description="Toggles the color theme">
|
|
11
|
+
Dark mode
|
|
12
|
+
</PSwitch>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
#### ✅ Recommended
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
<PSwitch aria={{'aria-label': 'Dark mode', 'aria-description': 'Toggles the color theme'}}>
|
|
19
|
+
Dark mode
|
|
20
|
+
</PSwitch>
|
|
21
|
+
```
|
|
22
|
+
|
|
5
23
|
### Switch without descriptive label
|
|
6
24
|
|
|
7
25
|
#### ❌ Anti-pattern
|
|
@@ -46,6 +46,15 @@ You can use native `click`, `focus`, `focusin`, `blur` and `focusout` events on
|
|
|
46
46
|
|
|
47
47
|
### ARIA enhancements
|
|
48
48
|
|
|
49
|
+
#### External **ARIA** provided by the `aria` property:
|
|
50
|
+
|
|
51
|
+
Use the `aria` property to pass supported attributes to the **native control inside the shadow DOM**. Prefer a visible slotted label for the accessible name. Use `aria-label` when the label is hidden or missing, and `aria-description` for extra context that should not replace the name. Do not use `aria-label` to replace a different visible label (WCAG 2.5.3).
|
|
52
|
+
|
|
53
|
+
| ARIA | Usage |
|
|
54
|
+
| --- | --- |
|
|
55
|
+
| `aria-label` | Defines an accessible name when the visible label is insufficient or hidden; prefer a visible `label` for most cases. |
|
|
56
|
+
| `aria-description` | Provides additional context for assistive technologies without replacing the accessible name. |
|
|
57
|
+
|
|
49
58
|
#### Internal **ARIA** that is managed by the component:
|
|
50
59
|
|
|
51
60
|
| ARIA | Usage |
|
|
@@ -62,9 +71,11 @@ The switch accessible name comes from the default slot. Provide concise, descrip
|
|
|
62
71
|
|
|
63
72
|
### Common do's and don'ts
|
|
64
73
|
|
|
74
|
+
- **Do** pass extra labelling through the `aria` prop (`aria-label`, `aria-description`).
|
|
65
75
|
- **Do** provide a clear slotted label that describes what the switch controls.
|
|
66
76
|
- **Do** use `hide-label` only when the label text remains in the slot for screen readers.
|
|
67
77
|
- **Don't** use an icon or visual state alone without descriptive label text.
|
|
78
|
+
- **Don't** add native `aria-*` attributes directly on the component host.
|
|
68
79
|
|
|
69
80
|
## Integration examples
|
|
70
81
|
|
|
@@ -77,6 +88,7 @@ See [accessibility integration examples](./accessibility.md) for paired anti-pat
|
|
|
77
88
|
| Property | Type | Default | Description |
|
|
78
89
|
| --- | --- | --- | --- |
|
|
79
90
|
| `alignLabel` | `'start'` `'end'`<br>`BreakpointCustomizable<SwitchAlignLabel>` | `'end'` | Sets the position of the slotted label relative to the switch toggle, either before (`start`) or after (`end`) it. Supports responsive breakpoint values. |
|
|
91
|
+
| `aria` | `SwitchAriaAttribute` | `undefined` | Sets additional ARIA attributes on the switch to improve accessibility for screen readers. |
|
|
80
92
|
| `checked` | `boolean` | `false` | Reflects the switch's current on/off state and allows setting the initial checked value when the component first renders. |
|
|
81
93
|
| `compact` | `boolean` | `false` | Reduces the switch size and spacing for use in dense layouts where vertical space is limited. |
|
|
82
94
|
| `disabled` | `boolean` | `false` | Prevents user interaction with the switch and blocks all click and keyboard events while it is disabled. |
|
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
## Integration examples
|
|
4
4
|
|
|
5
|
+
### ARIA on component host vs aria prop
|
|
6
|
+
|
|
7
|
+
#### ❌ Anti-pattern
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
<PTextarea name="comment" label="Comment" aria-label="Accessible name" aria-description="Additional context"></PTextarea>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
#### ✅ Recommended
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
<PTextarea name="comment" label="Comment" aria={{'aria-label': 'Accessible name', 'aria-description': 'Additional context'}}></PTextarea>
|
|
17
|
+
```
|
|
18
|
+
|
|
5
19
|
### Placeholder-only instructions for open text input
|
|
6
20
|
|
|
7
21
|
#### ❌ Anti-pattern
|
|
@@ -34,6 +34,15 @@ Instead of relying on slotted content, the `p-textarea` component offers a `valu
|
|
|
34
34
|
|
|
35
35
|
### ARIA enhancements
|
|
36
36
|
|
|
37
|
+
#### External **ARIA** provided by the `aria` property:
|
|
38
|
+
|
|
39
|
+
Use the `aria` property to pass supported attributes to the **native control inside the shadow DOM**. Prefer a visible `label` for the accessible name. Use `aria-label` when the label is hidden or insufficient, and `aria-description` for extra context that should not replace the name.
|
|
40
|
+
|
|
41
|
+
| ARIA | Usage |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| `aria-label` | Defines an accessible name when the visible label is insufficient or hidden; prefer a visible `label` for most cases. |
|
|
44
|
+
| `aria-description` | Provides additional context for assistive technologies without replacing the accessible name. |
|
|
45
|
+
|
|
37
46
|
#### Internal **ARIA** that is managed by the component:
|
|
38
47
|
|
|
39
48
|
| ARIA | Usage |
|
|
@@ -52,11 +61,13 @@ In general, avoid using the `disabled` state. Disabled elements are no longer fo
|
|
|
52
61
|
|
|
53
62
|
### Common do's and don'ts
|
|
54
63
|
|
|
64
|
+
- **Do** pass extra labelling through the `aria` prop (`aria-label`, `aria-description`).
|
|
55
65
|
- **Do** provide a descriptive label, especially for open text questions.
|
|
56
66
|
- **Do** use helper text to describe expected format, length, or sensitive content rules.
|
|
57
67
|
- **Do** surface validation with state/message so screen readers get updates.
|
|
58
68
|
- **Don't** use placeholder-only instructions.
|
|
59
69
|
- **Don't** use `hide-label` without an accessible name.
|
|
70
|
+
- **Don't** add native `aria-*` attributes directly on the component host.
|
|
60
71
|
|
|
61
72
|
## Integration examples
|
|
62
73
|
|
|
@@ -68,6 +79,7 @@ See [accessibility integration examples](./accessibility.md) for paired anti-pat
|
|
|
68
79
|
|
|
69
80
|
| Property | Type | Default | Description |
|
|
70
81
|
| --- | --- | --- | --- |
|
|
82
|
+
| `aria` | `TextareaAriaAttribute` | `undefined` | Sets additional ARIA attributes on the native textarea to improve accessibility for screen readers. |
|
|
71
83
|
| `autoComplete` | `string` | `undefined` | Provides the browser with a hint to enable text autofill suggestions for the textarea (e.g. `autocomplete='on'`). |
|
|
72
84
|
| `compact` | `boolean` | `false` | Reduces the textarea's initial height and padding for use in dense layouts where vertical space is limited. |
|
|
73
85
|
| `counter` | `boolean` | `false` | Shows a live character counter below the textarea indicating how many characters the user has typed relative to `maxLength`. |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Deprecated API
|
|
2
2
|
|
|
3
|
-
Every deprecated Porsche Design System API in `4.
|
|
3
|
+
Every deprecated Porsche Design System API in `4.8.0-rc.1`, indexed by what is deprecated rather than by which component owns it. Use it to check an existing codebase; use the component and styling references to build with the current API.
|
|
4
4
|
|
|
5
5
|
Deprecated APIs still work in this version. Each will be removed in the next major release, so usage is a compatibility risk rather than a present-day defect — except where a message says an API has no effect anymore, which means the behavior is already gone and only the declaration remains.
|
|
6
6
|
|
|
@@ -675,12 +675,12 @@ Derived from the Tailwind theme exposed by `@porsche-design-system/components-re
|
|
|
675
675
|
|
|
676
676
|
## Tokens
|
|
677
677
|
|
|
678
|
-
No deprecations in `4.
|
|
678
|
+
No deprecations in `4.8.0-rc.1`. Derived from the design-token API exposed by `@porsche-design-system/components-react/tokens`, which was checked and found to carry none — this is a verified result, not an omission.
|
|
679
679
|
|
|
680
680
|
## Icons
|
|
681
681
|
|
|
682
|
-
No deprecations in `4.
|
|
682
|
+
No deprecations in `4.8.0-rc.1`. Derived from the `p-icon` `name` values exposed by `@porsche-design-system/components-react`, which was checked and found to carry none — this is a verified result, not an omission.
|
|
683
683
|
|
|
684
684
|
## Stylesheets
|
|
685
685
|
|
|
686
|
-
No deprecations in `4.
|
|
686
|
+
No deprecations in `4.8.0-rc.1`. Derived from the global CSS exposed by `@porsche-design-system/components-react/index.css`, including `@porsche-design-system/components-react/variables.css` and `@porsche-design-system/components-react/color-scheme.css`, which was checked and found to carry none — this is a verified result, not an omission.
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# Feedback: Dialog
|
|
2
|
+
|
|
3
|
+
A trigger button opens the same rating-and-comment flow inside a dialog, keeping the page uncluttered. It can be launched from any action on the page, which makes it ideal for task-focused or space-constrained contexts where feedback should stay available but out of the way.
|
|
4
|
+
|
|
5
|
+
- **Type:** Pattern
|
|
6
|
+
- **Components:** [`p-button`](../../../components/p-button/p-button.md), [`p-heading`](../../../components/p-heading/p-heading.md), [`p-modal`](../../../components/p-modal/p-modal.md), [`p-segmented-control`](../../../components/p-segmented-control/p-segmented-control.md), [`p-text`](../../../components/p-text/p-text.md), [`p-textarea`](../../../components/p-textarea/p-textarea.md)
|
|
7
|
+
- **Conventions and stylesheet:** shared by all examples, see [examples.md](../../../examples.md)
|
|
8
|
+
|
|
9
|
+
## Markup
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<html lang="en">
|
|
13
|
+
<body>
|
|
14
|
+
<main id="main" class="grid-template gap-y-fluid-xl py-fluid-lg">
|
|
15
|
+
<section class="col-wide grid gap-fluid-md">
|
|
16
|
+
<p-heading tag="h1" size="xl">Feedback in a dialog</p-heading>
|
|
17
|
+
<p-text>
|
|
18
|
+
The page asks for permission first: the flow opens in a modal, and closing it returns focus to the button it
|
|
19
|
+
was opened from. The next visit starts fresh, because the reset waits for the closing animation.
|
|
20
|
+
</p-text>
|
|
21
|
+
</section>
|
|
22
|
+
<section
|
|
23
|
+
class="col-extended justify-self-center w-full max-w-prose grid gap-fluid-md justify-items-center"
|
|
24
|
+
aria-label="Feedback"
|
|
25
|
+
>
|
|
26
|
+
<div class="grid gap-static-xs justify-items-center">
|
|
27
|
+
<p-heading tag="h2" size="md" align="center">Your opinion matters</p-heading>
|
|
28
|
+
<p-text color="contrast-medium" align="center">Help us improve this page.</p-text>
|
|
29
|
+
</div>
|
|
30
|
+
<p-button
|
|
31
|
+
id="feedback-trigger"
|
|
32
|
+
type="button"
|
|
33
|
+
variant="secondary"
|
|
34
|
+
icon="none"
|
|
35
|
+
aria="{ 'aria-haspopup': 'dialog' }"
|
|
36
|
+
>
|
|
37
|
+
Give feedback
|
|
38
|
+
</p-button>
|
|
39
|
+
</section>
|
|
40
|
+
</main>
|
|
41
|
+
<p-modal id="feedback-modal" aria="{ 'aria-label': 'Feedback' }">
|
|
42
|
+
<div class="grid gap-fluid-md">
|
|
43
|
+
<p-heading
|
|
44
|
+
id="feedback-question"
|
|
45
|
+
class="focus-visible:outline outline-focus outline-offset-2 rounded-md"
|
|
46
|
+
tag="h2"
|
|
47
|
+
size="md"
|
|
48
|
+
align="center"
|
|
49
|
+
tabindex="-1"
|
|
50
|
+
>
|
|
51
|
+
How satisfied are you with the information shown on this page?
|
|
52
|
+
</p-heading>
|
|
53
|
+
<form id="feedback-form" class="grid gap-fluid-md justify-items-center">
|
|
54
|
+
<div class="w-full grid md:grid-cols-[auto_minmax(320px,1fr)_auto] items-center gap-static-md">
|
|
55
|
+
<p-text
|
|
56
|
+
class="max-sm:hidden row-2 md:row-auto col-1 md:col-auto justify-self-start"
|
|
57
|
+
size="sm"
|
|
58
|
+
align="start"
|
|
59
|
+
color="contrast-medium"
|
|
60
|
+
>
|
|
61
|
+
Very dissatisfied
|
|
62
|
+
</p-text>
|
|
63
|
+
<p-segmented-control
|
|
64
|
+
id="feedback-rating"
|
|
65
|
+
class="row-1 md:row-auto col-span-2 md:col-auto"
|
|
66
|
+
columns="{ base: 1, s: 5 }"
|
|
67
|
+
label="Select your satisfaction from the scale 1 (very dissatisfied) to 5 (very satisfied)"
|
|
68
|
+
hide-label="true"
|
|
69
|
+
>
|
|
70
|
+
<p-segmented-control-item value="1">
|
|
71
|
+
1
|
|
72
|
+
<span class="sm:sr-only">(very dissatisfied)</span>
|
|
73
|
+
</p-segmented-control-item>
|
|
74
|
+
<p-segmented-control-item value="2">
|
|
75
|
+
2
|
|
76
|
+
<span class="sm:sr-only">(dissatisfied)</span>
|
|
77
|
+
</p-segmented-control-item>
|
|
78
|
+
<p-segmented-control-item value="3">
|
|
79
|
+
3
|
|
80
|
+
<span class="sm:sr-only">(neutral)</span>
|
|
81
|
+
</p-segmented-control-item>
|
|
82
|
+
<p-segmented-control-item value="4">
|
|
83
|
+
4
|
|
84
|
+
<span class="sm:sr-only">(satisfied)</span>
|
|
85
|
+
</p-segmented-control-item>
|
|
86
|
+
<p-segmented-control-item value="5">
|
|
87
|
+
5
|
|
88
|
+
<span class="sm:sr-only">(very satisfied)</span>
|
|
89
|
+
</p-segmented-control-item>
|
|
90
|
+
</p-segmented-control>
|
|
91
|
+
<p-text
|
|
92
|
+
class="max-sm:hidden row-2 md:row-auto col-2 md:col-auto justify-self-end"
|
|
93
|
+
size="sm"
|
|
94
|
+
align="end"
|
|
95
|
+
color="contrast-medium"
|
|
96
|
+
>
|
|
97
|
+
Very satisfied
|
|
98
|
+
</p-text>
|
|
99
|
+
</div>
|
|
100
|
+
<p-textarea
|
|
101
|
+
id="feedback-comment"
|
|
102
|
+
class="w-full"
|
|
103
|
+
name="comment"
|
|
104
|
+
label="What two things could we do to make this page better?"
|
|
105
|
+
rows="4"
|
|
106
|
+
hidden
|
|
107
|
+
></p-textarea>
|
|
108
|
+
<p-button id="feedback-submit" type="button" hidden>Submit feedback</p-button>
|
|
109
|
+
</form>
|
|
110
|
+
<div
|
|
111
|
+
id="feedback-thanks"
|
|
112
|
+
class="grid gap-fluid-md justify-items-center"
|
|
113
|
+
aria-live="polite"
|
|
114
|
+
aria-atomic="true"
|
|
115
|
+
hidden
|
|
116
|
+
>
|
|
117
|
+
<p-heading
|
|
118
|
+
id="feedback-thanks-heading"
|
|
119
|
+
class="focus-visible:outline outline-focus outline-offset-2 rounded-md"
|
|
120
|
+
tag="h2"
|
|
121
|
+
size="md"
|
|
122
|
+
align="center"
|
|
123
|
+
tabindex="-1"
|
|
124
|
+
>
|
|
125
|
+
Thank you for your feedback
|
|
126
|
+
</p-heading>
|
|
127
|
+
<p-text align="center">Your feedback helps us continuously improve our page.</p-text>
|
|
128
|
+
<p-button id="feedback-close" type="button" variant="secondary">Close</p-button>
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
</p-modal>
|
|
132
|
+
<script type="module" src="main.js"></script>
|
|
133
|
+
</body>
|
|
134
|
+
</html>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Script
|
|
138
|
+
|
|
139
|
+
```js
|
|
140
|
+
// DO NOT USE IN PRODUCTION!
|
|
141
|
+
// EXAMPLE CODE FOR DEMONSTRATION PURPOSE ONLY.
|
|
142
|
+
|
|
143
|
+
// Behaviour of the feedback dialog pattern: whether the modal is open. The flow inside it is the script of
|
|
144
|
+
// "FeedbackForm", which also cancels a pending submission and starts over when the modal closes.
|
|
145
|
+
//
|
|
146
|
+
// "p-modal" is used in *controlled* mode – "open" is set from here, which is what lets the flow wait for the
|
|
147
|
+
// closing animation before it resets, instead of snapping back while the dialog is still visible.
|
|
148
|
+
|
|
149
|
+
const trigger = document.getElementById('feedback-trigger');
|
|
150
|
+
const modal = document.getElementById('feedback-modal');
|
|
151
|
+
const closeButton = document.getElementById('feedback-close');
|
|
152
|
+
|
|
153
|
+
const closeModal = () => {
|
|
154
|
+
modal.open = false;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
trigger.addEventListener('click', () => {
|
|
158
|
+
modal.open = true;
|
|
159
|
+
});
|
|
160
|
+
closeButton.addEventListener('click', closeModal);
|
|
161
|
+
modal.addEventListener('dismiss', closeModal);
|
|
162
|
+
|
|
163
|
+
// Behaviour of the feedback flow: which of its two steps – the question or the confirmation – is shown.
|
|
164
|
+
//
|
|
165
|
+
// No data is sent anywhere: the submission is simulated, so the flow can be reviewed end to end.
|
|
166
|
+
|
|
167
|
+
const question = document.getElementById('feedback-question');
|
|
168
|
+
const form = document.getElementById('feedback-form');
|
|
169
|
+
const rating = document.getElementById('feedback-rating');
|
|
170
|
+
const comment = document.getElementById('feedback-comment');
|
|
171
|
+
const submit = document.getElementById('feedback-submit');
|
|
172
|
+
const thanks = document.getElementById('feedback-thanks');
|
|
173
|
+
const thanksHeading = document.getElementById('feedback-thanks-heading');
|
|
174
|
+
|
|
175
|
+
// Handle of the simulated request, so dismissing the modal mid-submission can cancel it.
|
|
176
|
+
let pendingSubmission;
|
|
177
|
+
|
|
178
|
+
const cancelSubmission = () => {
|
|
179
|
+
window.clearTimeout(pendingSubmission);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
// Choosing a rating reveals the optional free-text field and the submit button.
|
|
183
|
+
rating.addEventListener('change', () => {
|
|
184
|
+
comment.hidden = false;
|
|
185
|
+
submit.hidden = false;
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// Reveal the confirmation once the "submission" has completed.
|
|
189
|
+
const showConfirmation = () => {
|
|
190
|
+
form.hidden = true;
|
|
191
|
+
question.hidden = true;
|
|
192
|
+
thanks.hidden = false;
|
|
193
|
+
submit.loading = false;
|
|
194
|
+
// Move focus to the confirmation so keyboard and screen reader users are informed.
|
|
195
|
+
thanksHeading.focus();
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
submit.addEventListener('click', () => {
|
|
199
|
+
// Simulate a short server round-trip: show a loading spinner while "submitting", then reveal the
|
|
200
|
+
// confirmation. In a real integration the request would happen here.
|
|
201
|
+
submit.loading = true;
|
|
202
|
+
pendingSubmission = window.setTimeout(showConfirmation, 1200);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
const startOver = () => {
|
|
206
|
+
cancelSubmission();
|
|
207
|
+
rating.value = '';
|
|
208
|
+
comment.value = '';
|
|
209
|
+
comment.hidden = true;
|
|
210
|
+
submit.loading = false;
|
|
211
|
+
submit.hidden = true;
|
|
212
|
+
thanks.hidden = true;
|
|
213
|
+
question.hidden = false;
|
|
214
|
+
form.hidden = false;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
// Offered by the flow shown in the page: starting over from the confirmation.
|
|
218
|
+
document.getElementById('feedback-restart')?.addEventListener('click', () => {
|
|
219
|
+
startOver();
|
|
220
|
+
// Return focus to the question so the flow is re-announced and can be repeated from the start.
|
|
221
|
+
question.focus();
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
// Shown in a modal, the flow follows it: a submission still pending when the modal is dismissed is cancelled, and
|
|
225
|
+
// the next open starts fresh. The reset waits for "motionHiddenEnd", which fires once the close animation has
|
|
226
|
+
// finished, so the content does not visibly snap back while the dialog is still on screen.
|
|
227
|
+
const enclosingModal = form.closest('p-modal');
|
|
228
|
+
enclosingModal?.addEventListener('dismiss', cancelSubmission);
|
|
229
|
+
enclosingModal?.addEventListener('motionHiddenEnd', startOver);
|
|
230
|
+
```
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# Feedback: Inline
|
|
2
|
+
|
|
3
|
+
The rating sits directly in the page flow, typically at the end of the content, and stays visible at all times. Once feedback is submitted, it shows a confirmation and offers the option to start over and give new feedback.
|
|
4
|
+
|
|
5
|
+
- **Type:** Pattern
|
|
6
|
+
- **Components:** [`p-button`](../../../components/p-button/p-button.md), [`p-heading`](../../../components/p-heading/p-heading.md), [`p-segmented-control`](../../../components/p-segmented-control/p-segmented-control.md), [`p-text`](../../../components/p-text/p-text.md), [`p-textarea`](../../../components/p-textarea/p-textarea.md)
|
|
7
|
+
- **Conventions and stylesheet:** shared by all examples, see [examples.md](../../../examples.md)
|
|
8
|
+
|
|
9
|
+
## Markup
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<html lang="en">
|
|
13
|
+
<body>
|
|
14
|
+
<main id="main" class="grid-template gap-y-fluid-xl py-fluid-lg">
|
|
15
|
+
<section class="col-wide grid gap-fluid-md">
|
|
16
|
+
<p-heading tag="h1" size="xl">Inline feedback</p-heading>
|
|
17
|
+
<p-text>
|
|
18
|
+
The feedback sits in the page, below the content it asks about. Choosing a rating reveals the optional
|
|
19
|
+
comment; submitting replaces the form with the confirmation, which offers to start over.
|
|
20
|
+
</p-text>
|
|
21
|
+
</section>
|
|
22
|
+
<section
|
|
23
|
+
class="col-extended justify-self-center w-full max-w-prose grid gap-fluid-md justify-items-center"
|
|
24
|
+
aria-label="Feedback"
|
|
25
|
+
>
|
|
26
|
+
<p-heading
|
|
27
|
+
id="feedback-question"
|
|
28
|
+
class="focus-visible:outline outline-focus outline-offset-2 rounded-md"
|
|
29
|
+
tag="h2"
|
|
30
|
+
size="md"
|
|
31
|
+
align="center"
|
|
32
|
+
tabindex="-1"
|
|
33
|
+
>
|
|
34
|
+
How satisfied are you with the information shown on this page?
|
|
35
|
+
</p-heading>
|
|
36
|
+
<form id="feedback-form" class="grid gap-fluid-md justify-items-center">
|
|
37
|
+
<div class="w-full grid md:grid-cols-[auto_minmax(320px,1fr)_auto] items-center gap-static-md">
|
|
38
|
+
<p-text
|
|
39
|
+
class="max-sm:hidden row-2 md:row-auto col-1 md:col-auto justify-self-start"
|
|
40
|
+
size="sm"
|
|
41
|
+
align="start"
|
|
42
|
+
color="contrast-medium"
|
|
43
|
+
>
|
|
44
|
+
Very dissatisfied
|
|
45
|
+
</p-text>
|
|
46
|
+
<p-segmented-control
|
|
47
|
+
id="feedback-rating"
|
|
48
|
+
class="row-1 md:row-auto col-span-2 md:col-auto"
|
|
49
|
+
columns="{ base: 1, s: 5 }"
|
|
50
|
+
label="Select your satisfaction from the scale 1 (very dissatisfied) to 5 (very satisfied)"
|
|
51
|
+
hide-label="true"
|
|
52
|
+
>
|
|
53
|
+
<p-segmented-control-item value="1">
|
|
54
|
+
1
|
|
55
|
+
<span class="sm:sr-only">(very dissatisfied)</span>
|
|
56
|
+
</p-segmented-control-item>
|
|
57
|
+
<p-segmented-control-item value="2">
|
|
58
|
+
2
|
|
59
|
+
<span class="sm:sr-only">(dissatisfied)</span>
|
|
60
|
+
</p-segmented-control-item>
|
|
61
|
+
<p-segmented-control-item value="3">
|
|
62
|
+
3
|
|
63
|
+
<span class="sm:sr-only">(neutral)</span>
|
|
64
|
+
</p-segmented-control-item>
|
|
65
|
+
<p-segmented-control-item value="4">
|
|
66
|
+
4
|
|
67
|
+
<span class="sm:sr-only">(satisfied)</span>
|
|
68
|
+
</p-segmented-control-item>
|
|
69
|
+
<p-segmented-control-item value="5">
|
|
70
|
+
5
|
|
71
|
+
<span class="sm:sr-only">(very satisfied)</span>
|
|
72
|
+
</p-segmented-control-item>
|
|
73
|
+
</p-segmented-control>
|
|
74
|
+
<p-text
|
|
75
|
+
class="max-sm:hidden row-2 md:row-auto col-2 md:col-auto justify-self-end"
|
|
76
|
+
size="sm"
|
|
77
|
+
align="end"
|
|
78
|
+
color="contrast-medium"
|
|
79
|
+
>
|
|
80
|
+
Very satisfied
|
|
81
|
+
</p-text>
|
|
82
|
+
</div>
|
|
83
|
+
<p-textarea
|
|
84
|
+
id="feedback-comment"
|
|
85
|
+
class="w-full"
|
|
86
|
+
name="comment"
|
|
87
|
+
label="What two things could we do to make this page better?"
|
|
88
|
+
rows="4"
|
|
89
|
+
hidden
|
|
90
|
+
></p-textarea>
|
|
91
|
+
<p-button id="feedback-submit" type="button" hidden>Submit feedback</p-button>
|
|
92
|
+
</form>
|
|
93
|
+
<div
|
|
94
|
+
id="feedback-thanks"
|
|
95
|
+
class="grid gap-fluid-md justify-items-center"
|
|
96
|
+
aria-live="polite"
|
|
97
|
+
aria-atomic="true"
|
|
98
|
+
hidden
|
|
99
|
+
>
|
|
100
|
+
<p-heading
|
|
101
|
+
id="feedback-thanks-heading"
|
|
102
|
+
class="focus-visible:outline outline-focus outline-offset-2 rounded-md"
|
|
103
|
+
tag="h2"
|
|
104
|
+
size="md"
|
|
105
|
+
align="center"
|
|
106
|
+
tabindex="-1"
|
|
107
|
+
>
|
|
108
|
+
Thank you for your feedback
|
|
109
|
+
</p-heading>
|
|
110
|
+
<p-text align="center">Your feedback helps us continuously improve our page.</p-text>
|
|
111
|
+
<p-button id="feedback-restart" type="button" variant="secondary" icon="refresh">Give new feedback</p-button>
|
|
112
|
+
</div>
|
|
113
|
+
</section>
|
|
114
|
+
</main>
|
|
115
|
+
<script type="module" src="main.js"></script>
|
|
116
|
+
</body>
|
|
117
|
+
</html>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Script
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
// DO NOT USE IN PRODUCTION!
|
|
124
|
+
// EXAMPLE CODE FOR DEMONSTRATION PURPOSE ONLY.
|
|
125
|
+
|
|
126
|
+
// Behaviour of the feedback flow: which of its two steps – the question or the confirmation – is shown.
|
|
127
|
+
//
|
|
128
|
+
// No data is sent anywhere: the submission is simulated, so the flow can be reviewed end to end.
|
|
129
|
+
|
|
130
|
+
const question = document.getElementById('feedback-question');
|
|
131
|
+
const form = document.getElementById('feedback-form');
|
|
132
|
+
const rating = document.getElementById('feedback-rating');
|
|
133
|
+
const comment = document.getElementById('feedback-comment');
|
|
134
|
+
const submit = document.getElementById('feedback-submit');
|
|
135
|
+
const thanks = document.getElementById('feedback-thanks');
|
|
136
|
+
const thanksHeading = document.getElementById('feedback-thanks-heading');
|
|
137
|
+
|
|
138
|
+
// Handle of the simulated request, so dismissing the modal mid-submission can cancel it.
|
|
139
|
+
let pendingSubmission;
|
|
140
|
+
|
|
141
|
+
const cancelSubmission = () => {
|
|
142
|
+
window.clearTimeout(pendingSubmission);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// Choosing a rating reveals the optional free-text field and the submit button.
|
|
146
|
+
rating.addEventListener('change', () => {
|
|
147
|
+
comment.hidden = false;
|
|
148
|
+
submit.hidden = false;
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// Reveal the confirmation once the "submission" has completed.
|
|
152
|
+
const showConfirmation = () => {
|
|
153
|
+
form.hidden = true;
|
|
154
|
+
question.hidden = true;
|
|
155
|
+
thanks.hidden = false;
|
|
156
|
+
submit.loading = false;
|
|
157
|
+
// Move focus to the confirmation so keyboard and screen reader users are informed.
|
|
158
|
+
thanksHeading.focus();
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
submit.addEventListener('click', () => {
|
|
162
|
+
// Simulate a short server round-trip: show a loading spinner while "submitting", then reveal the
|
|
163
|
+
// confirmation. In a real integration the request would happen here.
|
|
164
|
+
submit.loading = true;
|
|
165
|
+
pendingSubmission = window.setTimeout(showConfirmation, 1200);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
const startOver = () => {
|
|
169
|
+
cancelSubmission();
|
|
170
|
+
rating.value = '';
|
|
171
|
+
comment.value = '';
|
|
172
|
+
comment.hidden = true;
|
|
173
|
+
submit.loading = false;
|
|
174
|
+
submit.hidden = true;
|
|
175
|
+
thanks.hidden = true;
|
|
176
|
+
question.hidden = false;
|
|
177
|
+
form.hidden = false;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// Offered by the flow shown in the page: starting over from the confirmation.
|
|
181
|
+
document.getElementById('feedback-restart')?.addEventListener('click', () => {
|
|
182
|
+
startOver();
|
|
183
|
+
// Return focus to the question so the flow is re-announced and can be repeated from the start.
|
|
184
|
+
question.focus();
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// Shown in a modal, the flow follows it: a submission still pending when the modal is dismissed is cancelled, and
|
|
188
|
+
// the next open starts fresh. The reset waits for "motionHiddenEnd", which fires once the close animation has
|
|
189
|
+
// finished, so the content does not visibly snap back while the dialog is still on screen.
|
|
190
|
+
const enclosingModal = form.closest('p-modal');
|
|
191
|
+
enclosingModal?.addEventListener('dismiss', cancelSubmission);
|
|
192
|
+
enclosingModal?.addEventListener('motionHiddenEnd', startOver);
|
|
193
|
+
```
|