@aiaiai-pt/design-system 0.57.0 → 0.59.0

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.
@@ -203,6 +203,10 @@
203
203
  dropLabel?: string;
204
204
  /** Default section heading when no section label is declared. */
205
205
  defaultSectionLabel?: string;
206
+ /** A11y hint shown when the submit button is disabled because required
207
+ * fields are empty. Rendered as a polite `role="status"` so screen
208
+ * readers announce why the form cannot be submitted. */
209
+ requiredFieldsMessage?: string;
206
210
  }
207
211
 
208
212
  let {
@@ -239,6 +243,7 @@
239
243
  searchingLabel = "Searching…",
240
244
  dropLabel = "Drop files here or click to browse",
241
245
  defaultSectionLabel = "Details",
246
+ requiredFieldsMessage = "Fill in all required fields to submit.",
242
247
  }: Props = $props();
243
248
 
244
249
  let values = $state<Record<string, unknown>>({});
@@ -1179,7 +1184,7 @@
1179
1184
  `aria-required` that marks which fields are needed. -->
1180
1185
  {#if !canSubmit && !submitting}
1181
1186
  <p class="submit-hint" role="status">
1182
- Fill in all required fields to submit.
1187
+ {requiredFieldsMessage}
1183
1188
  </p>
1184
1189
  {/if}
1185
1190
  <Button
@@ -142,6 +142,10 @@ interface Props {
142
142
  dropLabel?: string;
143
143
  /** Default section heading when no section label is declared. */
144
144
  defaultSectionLabel?: string;
145
+ /** A11y hint shown when the submit button is disabled because required
146
+ * fields are empty. Rendered as a polite `role="status"` so screen
147
+ * readers announce why the form cannot be submitted. */
148
+ requiredFieldsMessage?: string;
145
149
  }
146
150
  declare const ActionFormRenderer: import("svelte").Component<Props, {}, "">;
147
151
  type ActionFormRenderer = ReturnType<typeof ActionFormRenderer>;
@@ -68,6 +68,10 @@
68
68
  weekLabel = 'Week',
69
69
  /** @type {string} — "Day" view toggle label */
70
70
  dayLabel = 'Day',
71
+ /** @type {string} — aria-label on the "previous" nav button */
72
+ prevAriaLabel = 'Previous',
73
+ /** @type {string} — aria-label on the "next" nav button */
74
+ nextAriaLabel = 'Next',
71
75
  /** @type {string} */
72
76
  class: className = '',
73
77
  ...rest
@@ -276,12 +280,12 @@
276
280
  <!-- Toolbar buttons blur() on click to prevent stale focus rings when user presses keys afterward -->
277
281
  <div class="calendar-toolbar">
278
282
  <div class="calendar-toolbar-left">
279
- <button type="button" class="calendar-nav-btn" onclick={(e) => { prev(); /** @type {HTMLElement} */ (e.currentTarget).blur(); }} aria-label="Previous">
283
+ <button type="button" class="calendar-nav-btn" onclick={(e) => { prev(); /** @type {HTMLElement} */ (e.currentTarget).blur(); }} aria-label={prevAriaLabel}>
280
284
  <svg viewBox="0 0 256 256" aria-hidden="true">
281
285
  <polyline points="160,208 80,128 160,48" fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" />
282
286
  </svg>
283
287
  </button>
284
- <button type="button" class="calendar-nav-btn" onclick={(e) => { next(); /** @type {HTMLElement} */ (e.currentTarget).blur(); }} aria-label="Next">
288
+ <button type="button" class="calendar-nav-btn" onclick={(e) => { next(); /** @type {HTMLElement} */ (e.currentTarget).blur(); }} aria-label={nextAriaLabel}>
285
289
  <svg viewBox="0 0 256 256" aria-hidden="true">
286
290
  <polyline points="96,48 176,128 96,208" fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" />
287
291
  </svg>
@@ -38,6 +38,8 @@ declare const Calendar: import("svelte").Component<{
38
38
  monthLabel?: string;
39
39
  weekLabel?: string;
40
40
  dayLabel?: string;
41
+ prevAriaLabel?: string;
42
+ nextAriaLabel?: string;
41
43
  class?: string;
42
44
  } & Record<string, any>, {}, "view" | "date">;
43
45
  type $$ComponentProps = {
@@ -53,6 +55,8 @@ type $$ComponentProps = {
53
55
  monthLabel?: string;
54
56
  weekLabel?: string;
55
57
  dayLabel?: string;
58
+ prevAriaLabel?: string;
59
+ nextAriaLabel?: string;
56
60
  class?: string;
57
61
  } & Record<string, any>;
58
62
  import { enUS } from 'date-fns/locale';
@@ -22,6 +22,11 @@
22
22
  {#snippet icon()}<svg>...</svg>{/snippet}
23
23
  INBOX
24
24
  </SidebarItem>
25
+
26
+ @example Collapsed with abbreviation (no icon)
27
+ <SidebarItem href="/cases" abbr="C" label="Cases">
28
+ Cases
29
+ </SidebarItem>
25
30
  -->
26
31
  <script>
27
32
  import { getContext } from 'svelte';
@@ -41,11 +46,24 @@
41
46
  icon = undefined,
42
47
  /** @type {import('svelte').Snippet | undefined} */
43
48
  children = undefined,
49
+ /** Short text shown when collapsed and no icon is given (e.g. the
50
+ * first letter of the entry). The component cannot read text out of
51
+ * the `children` snippet, so the consumer supplies it. If absent and
52
+ * there is no icon, nothing is rendered when collapsed. */
53
+ abbr = undefined,
54
+ /** Full accessible name used as `aria-label` and `title` when
55
+ * collapsed. When expanded, the visible children serve as the name
56
+ * and no `aria-label` is added. A consumer passing `abbr` should
57
+ * pass `label` so the collapsed abbreviation has a full name. */
58
+ label = undefined,
44
59
  ...rest
45
60
  } = $props();
46
61
 
47
62
  const sidebar = getContext('aiaiai-sidebar');
48
63
  const isCollapsed = $derived(sidebar?.collapsed ?? false);
64
+
65
+ /** Whether to show the abbreviation: collapsed, no icon, abbr provided. */
66
+ const showAbbr = $derived(isCollapsed && !icon && !!abbr);
49
67
  </script>
50
68
 
51
69
  {#if href && !disabled}
@@ -54,9 +72,12 @@
54
72
  class="nav-item {className}"
55
73
  class:nav-item-active={active}
56
74
  aria-current={active ? 'page' : undefined}
75
+ aria-label={isCollapsed && label ? label : undefined}
76
+ title={isCollapsed && label ? label : undefined}
57
77
  {...rest}
58
78
  >
59
79
  {#if icon}<span class="nav-icon-wrap">{@render icon()}</span>{/if}
80
+ {#if showAbbr}<span class="nav-abbr" aria-hidden="true">{abbr}</span>{/if}
60
81
  {#if !isCollapsed}
61
82
  {#if children}<span class="nav-item-label">{@render children()}</span>{/if}
62
83
  {#if badge != null}<span class="nav-badge">{badge}</span>{/if}
@@ -69,9 +90,12 @@
69
90
  class:nav-item-disabled={disabled}
70
91
  {disabled}
71
92
  aria-current={active ? 'page' : undefined}
93
+ aria-label={isCollapsed && label ? label : undefined}
94
+ title={isCollapsed && label ? label : undefined}
72
95
  {...rest}
73
96
  >
74
97
  {#if icon}<span class="nav-icon-wrap">{@render icon()}</span>{/if}
98
+ {#if showAbbr}<span class="nav-abbr" aria-hidden="true">{abbr}</span>{/if}
75
99
  {#if !isCollapsed}
76
100
  {#if children}<span class="nav-item-label">{@render children()}</span>{/if}
77
101
  {#if badge != null}<span class="nav-badge">{badge}</span>{/if}
@@ -131,6 +155,21 @@
131
155
  height: 100%;
132
156
  }
133
157
 
158
+ /* The abbreviation box matches the icon-wrap size so a column of
159
+ letters aligns with a column of icons. */
160
+ .nav-abbr {
161
+ display: flex;
162
+ flex-shrink: 0;
163
+ align-items: center;
164
+ justify-content: center;
165
+ width: var(--icon-size-sm);
166
+ height: var(--icon-size-sm);
167
+ font-family: var(--nav-item-font);
168
+ font-size: var(--nav-item-font-size);
169
+ font-weight: var(--raw-font-weight-semibold);
170
+ line-height: 1;
171
+ }
172
+
134
173
  .nav-item-label {
135
174
  white-space: nowrap;
136
175
  overflow: hidden;
@@ -27,6 +27,11 @@ type SidebarItem = {
27
27
  * {#snippet icon()}<svg>...</svg>{/snippet}
28
28
  * INBOX
29
29
  * </SidebarItem>
30
+ *
31
+ * @example Collapsed with abbreviation (no icon)
32
+ * <SidebarItem href="/cases" abbr="C" label="Cases">
33
+ * Cases
34
+ * </SidebarItem>
30
35
  */
31
36
  declare const SidebarItem: import("svelte").Component<{
32
37
  active?: boolean;
@@ -36,6 +41,8 @@ declare const SidebarItem: import("svelte").Component<{
36
41
  class?: string;
37
42
  icon?: any;
38
43
  children?: any;
44
+ abbr?: any;
45
+ label?: any;
39
46
  } & Record<string, any>, {}, "">;
40
47
  type $$ComponentProps = {
41
48
  active?: boolean;
@@ -45,4 +52,6 @@ type $$ComponentProps = {
45
52
  class?: string;
46
53
  icon?: any;
47
54
  children?: any;
55
+ abbr?: any;
56
+ label?: any;
48
57
  } & Record<string, any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiaiai-pt/design-system",
3
- "version": "0.57.0",
3
+ "version": "0.59.0",
4
4
  "description": "Design system tokens and Svelte components for aiaiai products",
5
5
  "license": "MIT",
6
6
  "type": "module",