bits-ui 1.5.2 → 1.6.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.
@@ -148,7 +148,6 @@ class AccordionContentState {
148
148
  constructor(opts, item) {
149
149
  this.opts = opts;
150
150
  this.item = item;
151
- this.item = item;
152
151
  this.#isMountAnimationPrevented = this.item.isActive;
153
152
  useRefById(opts);
154
153
  $effect.pre(() => {
@@ -8,6 +8,22 @@ import type { DateAndTimeSegmentObj, DateOnInvalid, DateSegmentObj, DateSegmentP
8
8
  import { type Formatter } from "../../internal/date-time/formatter.js";
9
9
  import { type Announcer } from "../../internal/date-time/announcer.js";
10
10
  export declare const DATE_FIELD_INPUT_ATTR = "data-date-field-input";
11
+ type SegmentConfig = {
12
+ min: number | ((root: DateFieldRootState) => number);
13
+ max: number | ((root: DateFieldRootState) => number);
14
+ cycle: number;
15
+ canBeZero?: boolean;
16
+ padZero?: boolean;
17
+ getAnnouncement?: (value: number, root: DateFieldRootState) => string | number;
18
+ updateLogic?: (props: {
19
+ root: DateFieldRootState;
20
+ prev: string | null;
21
+ num: number;
22
+ moveToNext: {
23
+ value: boolean;
24
+ };
25
+ }) => string | null;
26
+ };
11
27
  export type DateFieldRootStateProps = WritableBoxedValues<{
12
28
  value: DateValue | undefined;
13
29
  placeholder: DateValue;
@@ -186,46 +202,24 @@ declare class DateFieldLabelState {
186
202
  readonly onclick: (_: BitsMouseEvent) => void;
187
203
  };
188
204
  }
189
- type DateFieldDaySegmentStateProps = WithRefProps;
190
- declare class DateFieldDaySegmentState {
205
+ declare abstract class BaseNumericSegmentState {
191
206
  #private;
192
- readonly opts: DateFieldDaySegmentStateProps;
207
+ readonly opts: WithRefProps;
193
208
  readonly root: DateFieldRootState;
194
- constructor(opts: DateFieldDaySegmentStateProps, root: DateFieldRootState);
209
+ readonly announcer: Announcer;
210
+ readonly part: string;
211
+ readonly config: SegmentConfig;
212
+ constructor(opts: WithRefProps, root: DateFieldRootState, part: string, config: SegmentConfig);
195
213
  onkeydown(e: BitsKeyboardEvent): void;
196
214
  onfocusout(_: BitsFocusEvent): void;
197
- props: {
198
- "aria-invalid": "true" | undefined;
199
- "aria-disabled": "true" | "false";
200
- "aria-readonly": "true" | "false";
201
- "data-invalid": "" | undefined;
202
- "data-disabled": "" | undefined;
203
- "data-readonly": "" | undefined;
204
- "data-segment": string;
205
- id: string;
215
+ getSegmentProps(): {
206
216
  "aria-label": string;
207
217
  "aria-valuemin": number;
208
218
  "aria-valuemax": number;
209
219
  "aria-valuenow": number;
210
220
  "aria-valuetext": string;
211
- onkeydown: (e: BitsKeyboardEvent) => void;
212
- onfocusout: (_: BitsFocusEvent) => void;
213
- onclick: (e: BitsMouseEvent) => void;
214
- role: string;
215
- contenteditable: string;
216
- tabindex: number;
217
- spellcheck: boolean;
218
- inputmode: string;
219
- autocorrect: string;
220
- enterkeyhint: string;
221
- style: {
222
- caretColor: string;
223
- };
224
- } | {
225
- "aria-labelledby": string;
226
- contenteditable: string | undefined;
227
- "aria-describedby": string | undefined;
228
- tabindex: number | undefined;
221
+ };
222
+ props: {
229
223
  "aria-invalid": "true" | undefined;
230
224
  "aria-disabled": "true" | "false";
231
225
  "aria-readonly": "true" | "false";
@@ -233,116 +227,15 @@ declare class DateFieldDaySegmentState {
233
227
  "data-disabled": "" | undefined;
234
228
  "data-readonly": "" | undefined;
235
229
  "data-segment": string;
236
- id: string;
237
- "aria-label": string;
238
- "aria-valuemin": number;
239
- "aria-valuemax": number;
240
- "aria-valuenow": number;
241
- "aria-valuetext": string;
242
230
  onkeydown: (e: BitsKeyboardEvent) => void;
243
231
  onfocusout: (_: BitsFocusEvent) => void;
244
232
  onclick: (e: BitsMouseEvent) => void;
245
- role: string;
246
- spellcheck: boolean;
247
- inputmode: string;
248
- autocorrect: string;
249
- enterkeyhint: string;
250
- style: {
251
- caretColor: string;
252
- };
253
- };
254
- }
255
- type DateFieldMonthSegmentStateProps = WithRefProps;
256
- declare class DateFieldMonthSegmentState {
257
- #private;
258
- readonly opts: DateFieldMonthSegmentStateProps;
259
- readonly root: DateFieldRootState;
260
- constructor(opts: DateFieldMonthSegmentStateProps, root: DateFieldRootState);
261
- onkeydown(e: BitsKeyboardEvent): void;
262
- onfocusout(_: BitsFocusEvent): void;
263
- props: {
264
- readonly "aria-invalid": "true" | undefined;
265
- readonly "aria-disabled": "true" | "false";
266
- readonly "aria-readonly": "true" | "false";
267
- readonly "data-invalid": "" | undefined;
268
- readonly "data-disabled": "" | undefined;
269
- readonly "data-readonly": "" | undefined;
270
- readonly "data-segment": string;
271
- readonly id: string;
272
- readonly "aria-label": "month, ";
273
- readonly contenteditable: "true";
274
- readonly "aria-valuemin": 1;
275
- readonly "aria-valuemax": 12;
276
- readonly "aria-valuenow": number;
277
- readonly "aria-valuetext": string;
278
- readonly onkeydown: (e: BitsKeyboardEvent) => void;
279
- readonly onfocusout: (_: BitsFocusEvent) => void;
280
- readonly onclick: (e: BitsMouseEvent) => void;
281
- readonly role: string;
282
- readonly tabindex: number;
283
- readonly spellcheck: boolean;
284
- readonly inputmode: string;
285
- readonly autocorrect: string;
286
- readonly enterkeyhint: string;
287
- readonly style: {
288
- caretColor: string;
289
- };
290
- } | {
291
- readonly "aria-labelledby": string;
292
- readonly contenteditable: string | undefined;
293
- readonly "aria-describedby": string | undefined;
294
- readonly tabindex: number | undefined;
295
- readonly "aria-invalid": "true" | undefined;
296
- readonly "aria-disabled": "true" | "false";
297
- readonly "aria-readonly": "true" | "false";
298
- readonly "data-invalid": "" | undefined;
299
- readonly "data-disabled": "" | undefined;
300
- readonly "data-readonly": "" | undefined;
301
- readonly "data-segment": string;
302
- readonly id: string;
303
- readonly "aria-label": "month, ";
304
- readonly "aria-valuemin": 1;
305
- readonly "aria-valuemax": 12;
306
- readonly "aria-valuenow": number;
307
- readonly "aria-valuetext": string;
308
- readonly onkeydown: (e: BitsKeyboardEvent) => void;
309
- readonly onfocusout: (_: BitsFocusEvent) => void;
310
- readonly onclick: (e: BitsMouseEvent) => void;
311
- readonly role: string;
312
- readonly spellcheck: boolean;
313
- readonly inputmode: string;
314
- readonly autocorrect: string;
315
- readonly enterkeyhint: string;
316
- readonly style: {
317
- caretColor: string;
318
- };
319
- };
320
- }
321
- type DateFieldYearSegmentStateProps = WithRefProps;
322
- declare class DateFieldYearSegmentState {
323
- #private;
324
- readonly opts: DateFieldYearSegmentStateProps;
325
- readonly root: DateFieldRootState;
326
- constructor(opts: DateFieldYearSegmentStateProps, root: DateFieldRootState);
327
- onkeydown(e: BitsKeyboardEvent): void;
328
- onfocusout(_: BitsFocusEvent): void;
329
- props: {
330
- "aria-invalid": "true" | undefined;
331
- "aria-disabled": "true" | "false";
332
- "aria-readonly": "true" | "false";
333
- "data-invalid": "" | undefined;
334
- "data-disabled": "" | undefined;
335
- "data-readonly": "" | undefined;
336
- "data-segment": string;
337
- id: string;
338
233
  "aria-label": string;
339
234
  "aria-valuemin": number;
340
235
  "aria-valuemax": number;
341
236
  "aria-valuenow": number;
342
237
  "aria-valuetext": string;
343
- onkeydown: (e: BitsKeyboardEvent) => void;
344
- onclick: (e: BitsMouseEvent) => void;
345
- onfocusout: (_: BitsFocusEvent) => void;
238
+ id: string;
346
239
  role: string;
347
240
  contenteditable: string;
348
241
  tabindex: number;
@@ -365,15 +258,15 @@ declare class DateFieldYearSegmentState {
365
258
  "data-disabled": "" | undefined;
366
259
  "data-readonly": "" | undefined;
367
260
  "data-segment": string;
368
- id: string;
261
+ onkeydown: (e: BitsKeyboardEvent) => void;
262
+ onfocusout: (_: BitsFocusEvent) => void;
263
+ onclick: (e: BitsMouseEvent) => void;
369
264
  "aria-label": string;
370
265
  "aria-valuemin": number;
371
266
  "aria-valuemax": number;
372
267
  "aria-valuenow": number;
373
268
  "aria-valuetext": string;
374
- onkeydown: (e: BitsKeyboardEvent) => void;
375
- onclick: (e: BitsMouseEvent) => void;
376
- onfocusout: (_: BitsFocusEvent) => void;
269
+ id: string;
377
270
  role: string;
378
271
  spellcheck: boolean;
379
272
  inputmode: string;
@@ -384,35 +277,27 @@ declare class DateFieldYearSegmentState {
384
277
  };
385
278
  };
386
279
  }
387
- type DateFieldHourSegmentStateProps = WithRefProps;
388
- declare class DateFieldHourSegmentState {
280
+ declare class DateFieldYearSegmentState extends BaseNumericSegmentState {
389
281
  #private;
390
- readonly opts: DateFieldHourSegmentStateProps;
391
- readonly root: DateFieldRootState;
392
- constructor(opts: DateFieldHourSegmentStateProps, root: DateFieldRootState);
282
+ constructor(opts: WithRefProps, root: DateFieldRootState);
393
283
  onkeydown(e: BitsKeyboardEvent): void;
394
284
  onfocusout(_: BitsFocusEvent): void;
395
- props: {};
396
285
  }
397
- type DateFieldMinuteSegmentStateProps = WithRefProps;
398
- declare class DateFieldMinuteSegmentState {
399
- #private;
400
- readonly opts: DateFieldMinuteSegmentStateProps;
401
- readonly root: DateFieldRootState;
402
- constructor(opts: DateFieldMinuteSegmentStateProps, root: DateFieldRootState);
403
- onkeydown(e: BitsKeyboardEvent): void;
404
- onfocusout(_: BitsFocusEvent): void;
405
- props: {};
286
+ declare class DateFieldDaySegmentState extends BaseNumericSegmentState {
287
+ constructor(opts: WithRefProps, root: DateFieldRootState);
406
288
  }
407
- type DateFieldSecondSegmentStateProps = WithRefProps;
408
- declare class DateFieldSecondSegmentState {
409
- #private;
410
- readonly opts: DateFieldSecondSegmentStateProps;
411
- readonly root: DateFieldRootState;
412
- constructor(opts: DateFieldSecondSegmentStateProps, root: DateFieldRootState);
289
+ declare class DateFieldMonthSegmentState extends BaseNumericSegmentState {
290
+ constructor(opts: WithRefProps, root: DateFieldRootState);
291
+ }
292
+ declare class DateFieldHourSegmentState extends BaseNumericSegmentState {
293
+ constructor(opts: WithRefProps, root: DateFieldRootState);
413
294
  onkeydown(e: BitsKeyboardEvent): void;
414
- onfocusout(_: BitsFocusEvent): void;
415
- props: {};
295
+ }
296
+ declare class DateFieldMinuteSegmentState extends BaseNumericSegmentState {
297
+ constructor(opts: WithRefProps, root: DateFieldRootState);
298
+ }
299
+ declare class DateFieldSecondSegmentState extends BaseNumericSegmentState {
300
+ constructor(opts: WithRefProps, root: DateFieldRootState);
416
301
  }
417
302
  type DateFieldDayPeriodSegmentStateProps = WithRefProps;
418
303
  declare class DateFieldDayPeriodSegmentState {
@@ -509,9 +394,9 @@ declare class DateFieldDayLiteralSegmentState {
509
394
  };
510
395
  }
511
396
  declare class DateFieldTimeZoneSegmentState {
512
- readonly opts: DateFieldMinuteSegmentStateProps;
397
+ readonly opts: DateFieldLiteralSegmentStateProps;
513
398
  readonly root: DateFieldRootState;
514
- constructor(opts: DateFieldMinuteSegmentStateProps, root: DateFieldRootState);
399
+ constructor(opts: DateFieldLiteralSegmentStateProps, root: DateFieldRootState);
515
400
  onkeydown(e: BitsKeyboardEvent): void;
516
401
  props: {
517
402
  readonly "data-readonly": "" | undefined;
@@ -553,6 +438,6 @@ declare class DateFieldTimeZoneSegmentState {
553
438
  export declare function useDateFieldRoot(props: DateFieldRootStateProps, rangeRoot?: DateRangeFieldRootState): DateFieldRootState;
554
439
  export declare function useDateFieldInput(props: DateFieldInputStateProps): DateFieldInputState;
555
440
  export declare function useDateFieldHiddenInput(): DateFieldHiddenInputState;
556
- export declare function useDateFieldSegment(part: SegmentPart, props: WithRefProps): DateFieldDaySegmentState | DateFieldMonthSegmentState | DateFieldYearSegmentState | DateFieldHourSegmentState | DateFieldMinuteSegmentState | DateFieldSecondSegmentState | DateFieldDayPeriodSegmentState | DateFieldDayLiteralSegmentState | DateFieldTimeZoneSegmentState;
441
+ export declare function useDateFieldSegment(part: SegmentPart, props: WithRefProps): DateFieldYearSegmentState | DateFieldDaySegmentState | DateFieldMonthSegmentState | DateFieldHourSegmentState | DateFieldMinuteSegmentState | DateFieldSecondSegmentState | DateFieldDayPeriodSegmentState | DateFieldDayLiteralSegmentState | DateFieldTimeZoneSegmentState;
557
442
  export declare function useDateFieldLabel(props: DateFieldLabelStateProps): DateFieldLabelState;
558
443
  export {};