@foldkit/ui 0.121.0 → 0.122.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.
@@ -70,7 +70,12 @@ export type OutMessage = typeof OutMessage.Type;
70
70
  /** Configuration for creating a dialog model with `init`. The `id` must be
71
71
  * non-empty and unique within the document: it keys the dialog element, its
72
72
  * ARIA references, and the framework's per-dialog resource cleanup, so a
73
- * duplicate or empty id breaks cleanup accounting. */
73
+ * duplicate or empty id breaks cleanup accounting.
74
+ *
75
+ * The dialog derives framework-managed ids from this `id`: `-dialog-title`,
76
+ * `-dialog-description`, and `-panel` (the animation panel). Spread
77
+ * `RenderInfo`'s `title` / `description` onto your heading and description
78
+ * elements rather than constructing those ids yourself. */
74
79
  export type InitConfig = Readonly<{
75
80
  id: string;
76
81
  isOpen?: boolean;
@@ -116,9 +121,23 @@ export declare const update: (model: Model, message: Message) => UpdateReturn;
116
121
  export declare const open: (model: Model) => UpdateReturn;
117
122
  /** Programmatically closes the dialog. */
118
123
  export declare const close: (model: Model) => UpdateReturn;
119
- /** Returns the ID used for `aria-labelledby` on the dialog. Apply this to your title element. */
124
+ /** Returns the framework-managed id the dialog's `aria-labelledby` points at,
125
+ * the `-dialog-title` suffix on `model.id`.
126
+ *
127
+ * The primary path is spreading `RenderInfo`'s `title` onto your heading
128
+ * (`h.h2([...title], [...])`), which carries this id for you. Reach for this
129
+ * helper only when you need the id as a value outside `toView`: a Command that
130
+ * calls `getElementById`, a cross-element `aria-describedby`, or a test. Do not
131
+ * hand-roll the id string. */
120
132
  export declare const titleId: (model: Model) => string;
121
- /** Returns the ID used for `aria-describedby` on the dialog. Apply this to your description element. */
133
+ /** Returns the framework-managed id the dialog's `aria-describedby` points at,
134
+ * the `-dialog-description` suffix on `model.id`.
135
+ *
136
+ * The primary path is spreading `RenderInfo`'s `description` onto your
137
+ * description element (`h.p([...description], [...])`), which carries this id
138
+ * for you. Reach for this helper only when you need the id as a value outside
139
+ * `toView`: a Command that calls `getElementById`, a cross-element
140
+ * `aria-describedby`, or a test. Do not hand-roll the id string. */
122
141
  export declare const descriptionId: (model: Model) => string;
123
142
  /** Render-time payload published to the consumer's `toView`.
124
143
  *
@@ -136,6 +155,13 @@ export declare const descriptionId: (model: Model) => string;
136
155
  * is in progress).
137
156
  * - `panel`: attributes for the panel element. Includes the panel id
138
157
  * (`${model.id}-panel`) and the Animation data attributes.
158
+ * - `title`: attributes for the accessible-name heading. Carries the
159
+ * framework-managed id the dialog's `aria-labelledby` points at. Spread
160
+ * onto your heading element (`h.h2([...title], [...])`) so labelling
161
+ * wires up without hand-rolling the id.
162
+ * - `description`: attributes for the description element. Carries the
163
+ * framework-managed id the dialog's `aria-describedby` points at. Spread
164
+ * onto your description element (`h.p([...description], [...])`).
139
165
  * - `closeButton`: attributes for an in-panel close control such as a Cancel
140
166
  * or dismiss button. Carries the `OnClick` handler that closes the
141
167
  * dialog (suppressed while a leave animation is in progress). Spread
@@ -147,6 +173,8 @@ export type RenderInfo = Readonly<{
147
173
  dialog: ReadonlyArray<ChildAttribute>;
148
174
  backdrop: ReadonlyArray<ChildAttribute>;
149
175
  panel: ReadonlyArray<ChildAttribute>;
176
+ title: ReadonlyArray<ChildAttribute>;
177
+ description: ReadonlyArray<ChildAttribute>;
150
178
  closeButton: ReadonlyArray<ChildAttribute>;
151
179
  isVisible: boolean;
152
180
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dialog/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,MAAM,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAChE,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAE1C,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,IAAI,EAGV,MAAM,cAAc,CAAA;AAwBrB,6IAA6I;AAC7I,eAAO,MAAM,KAAK;;;;;;;;;;EAMhB,CAAA;AAEF,MAAM,MAAM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,CAAC,CAAA;IACpC,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IACpC,WAAW,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IAC1C,WAAW,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IAC1C,SAAS,EAAE,OAAO,CAAA;CACnB,CAAC,CAAA;AAEF,qFAAqF;AACrF,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,MAAM,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAA;CACrC,CAAC,CAAA;AAEF;;;2EAG2E;AAC3E,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;YAPP,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI;GA0FrC,CAAA"}
@@ -186,10 +186,24 @@ export const open = (model) => update(model, RequestedOpen());
186
186
  /** Programmatically closes the dialog. */
187
187
  export const close = (model) => update(model, RequestedClose());
188
188
  // VIEW
189
- /** Returns the ID used for `aria-labelledby` on the dialog. Apply this to your title element. */
190
- export const titleId = (model) => `${model.id}-title`;
191
- /** Returns the ID used for `aria-describedby` on the dialog. Apply this to your description element. */
192
- export const descriptionId = (model) => `${model.id}-description`;
189
+ /** Returns the framework-managed id the dialog's `aria-labelledby` points at,
190
+ * the `-dialog-title` suffix on `model.id`.
191
+ *
192
+ * The primary path is spreading `RenderInfo`'s `title` onto your heading
193
+ * (`h.h2([...title], [...])`), which carries this id for you. Reach for this
194
+ * helper only when you need the id as a value outside `toView`: a Command that
195
+ * calls `getElementById`, a cross-element `aria-describedby`, or a test. Do not
196
+ * hand-roll the id string. */
197
+ export const titleId = (model) => `${model.id}-dialog-title`;
198
+ /** Returns the framework-managed id the dialog's `aria-describedby` points at,
199
+ * the `-dialog-description` suffix on `model.id`.
200
+ *
201
+ * The primary path is spreading `RenderInfo`'s `description` onto your
202
+ * description element (`h.p([...description], [...])`), which carries this id
203
+ * for you. Reach for this helper only when you need the id as a value outside
204
+ * `toView`: a Command that calls `getElementById`, a cross-element
205
+ * `aria-describedby`, or a test. Do not hand-roll the id string. */
206
+ export const descriptionId = (model) => `${model.id}-dialog-description`;
193
207
  /** Renders a headless dialog component backed by the native `<dialog>`
194
208
  * element. `ShowDialog` opens it through `Dom.showDialog`, which uses `show()`
195
209
  * (not native `showModal()`) with a high z-index, a focus trap, a
@@ -217,8 +231,8 @@ export const view = defineView((model, viewInputs) => {
217
231
  ]), M.orElse(() => []));
218
232
  const dialogAttributes = [
219
233
  h.Id(id),
220
- h.AriaLabelledBy(`${id}-title`),
221
- h.AriaDescribedBy(`${id}-description`),
234
+ h.AriaLabelledBy(titleId(model)),
235
+ h.AriaDescribedBy(descriptionId(model)),
222
236
  h.OnCancel(RequestedClose()),
223
237
  h.Open(isVisible),
224
238
  h.Style({
@@ -243,11 +257,15 @@ export const view = defineView((model, viewInputs) => {
243
257
  ...(isLeaving ? [] : [h.OnClick(RequestedClose())]),
244
258
  ];
245
259
  const panelAttributes = [h.Id(`${id}-panel`), ...animationAttributes];
260
+ const titleAttributes = [h.Id(titleId(model))];
261
+ const descriptionAttributes = [h.Id(descriptionId(model))];
246
262
  const closeButtonAttributes = isLeaving ? [] : [h.OnClick(RequestedClose())];
247
263
  return toView({
248
264
  dialog: childAttributes(dialogAttributes),
249
265
  backdrop: childAttributes(backdropAttributes),
250
266
  panel: childAttributes(panelAttributes),
267
+ title: childAttributes(titleAttributes),
268
+ description: childAttributes(descriptionAttributes),
251
269
  closeButton: childAttributes(closeButtonAttributes),
252
270
  isVisible,
253
271
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foldkit/ui",
3
- "version": "0.121.0",
3
+ "version": "0.122.0",
4
4
  "description": "Headless, accessible UI components for Foldkit",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -127,7 +127,7 @@
127
127
  "typedoc": "^0.28.19",
128
128
  "typescript": "^6.0.3",
129
129
  "vitest": "^4.1.9",
130
- "foldkit": "0.121.0"
130
+ "foldkit": "0.122.0"
131
131
  },
132
132
  "keywords": [
133
133
  "foldkit",