@funstack/ui 0.1.0-alpha.20 → 0.1.0-alpha.21

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 (105) hide show
  1. package/dist/alert-dialog/alert-dialog-root.mjs +2 -1
  2. package/dist/alert-dialog/alert-dialog-root.mjs.map +1 -1
  3. package/dist/avatar/avatar-context.mjs +24 -0
  4. package/dist/avatar/avatar-context.mjs.map +1 -0
  5. package/dist/avatar/avatar-fallback.d.mts +32 -0
  6. package/dist/avatar/avatar-fallback.d.mts.map +1 -0
  7. package/dist/avatar/avatar-fallback.mjs +31 -0
  8. package/dist/avatar/avatar-fallback.mjs.map +1 -0
  9. package/dist/avatar/avatar-image.d.mts +37 -0
  10. package/dist/avatar/avatar-image.d.mts.map +1 -0
  11. package/dist/avatar/avatar-image.mjs +91 -0
  12. package/dist/avatar/avatar-image.mjs.map +1 -0
  13. package/dist/avatar/avatar-root.d.mts +48 -0
  14. package/dist/avatar/avatar-root.d.mts.map +1 -0
  15. package/dist/avatar/avatar-root.mjs +81 -0
  16. package/dist/avatar/avatar-root.mjs.map +1 -0
  17. package/dist/avatar/index.d.mts +24 -0
  18. package/dist/avatar/index.d.mts.map +1 -0
  19. package/dist/avatar/index.mjs +24 -0
  20. package/dist/avatar/index.mjs.map +1 -0
  21. package/dist/dialog/dialog-close.d.mts.map +1 -1
  22. package/dist/dialog/dialog-close.mjs +14 -3
  23. package/dist/dialog/dialog-close.mjs.map +1 -1
  24. package/dist/dialog/dialog-context.mjs +7 -1
  25. package/dist/dialog/dialog-context.mjs.map +1 -1
  26. package/dist/dialog/dialog-popup.d.mts +1 -0
  27. package/dist/dialog/dialog-popup.d.mts.map +1 -1
  28. package/dist/dialog/dialog-popup.mjs +20 -2
  29. package/dist/dialog/dialog-popup.mjs.map +1 -1
  30. package/dist/dialog/dialog-root.mjs +6 -4
  31. package/dist/dialog/dialog-root.mjs.map +1 -1
  32. package/dist/docs/components/avatar.md +354 -0
  33. package/dist/docs/components/drawer.md +622 -0
  34. package/dist/docs/components/otp-field.md +501 -0
  35. package/dist/docs/components/scroll-area.md +294 -0
  36. package/dist/docs/index.md +5 -1
  37. package/dist/docs/roadmap.md +6 -0
  38. package/dist/drawer/drawer-close.d.mts +26 -0
  39. package/dist/drawer/drawer-close.d.mts.map +1 -0
  40. package/dist/drawer/drawer-close.mjs +19 -0
  41. package/dist/drawer/drawer-close.mjs.map +1 -0
  42. package/dist/drawer/drawer-description.d.mts +23 -0
  43. package/dist/drawer/drawer-description.d.mts.map +1 -0
  44. package/dist/drawer/drawer-description.mjs +18 -0
  45. package/dist/drawer/drawer-description.mjs.map +1 -0
  46. package/dist/drawer/drawer-form.d.mts +24 -0
  47. package/dist/drawer/drawer-form.d.mts.map +1 -0
  48. package/dist/drawer/drawer-form.mjs +19 -0
  49. package/dist/drawer/drawer-form.mjs.map +1 -0
  50. package/dist/drawer/drawer-popup.d.mts +77 -0
  51. package/dist/drawer/drawer-popup.d.mts.map +1 -0
  52. package/dist/drawer/drawer-popup.mjs +124 -0
  53. package/dist/drawer/drawer-popup.mjs.map +1 -0
  54. package/dist/drawer/drawer-root.d.mts +31 -0
  55. package/dist/drawer/drawer-root.d.mts.map +1 -0
  56. package/dist/drawer/drawer-root.mjs +23 -0
  57. package/dist/drawer/drawer-root.mjs.map +1 -0
  58. package/dist/drawer/drawer-swipe.d.mts +5 -0
  59. package/dist/drawer/drawer-swipe.d.mts.map +1 -0
  60. package/dist/drawer/drawer-swipe.mjs +193 -0
  61. package/dist/drawer/drawer-swipe.mjs.map +1 -0
  62. package/dist/drawer/drawer-title.d.mts +23 -0
  63. package/dist/drawer/drawer-title.d.mts.map +1 -0
  64. package/dist/drawer/drawer-title.mjs +18 -0
  65. package/dist/drawer/drawer-title.mjs.map +1 -0
  66. package/dist/drawer/drawer-trigger.d.mts +23 -0
  67. package/dist/drawer/drawer-trigger.d.mts.map +1 -0
  68. package/dist/drawer/drawer-trigger.mjs +18 -0
  69. package/dist/drawer/drawer-trigger.mjs.map +1 -0
  70. package/dist/drawer/index.d.mts +34 -0
  71. package/dist/drawer/index.d.mts.map +1 -0
  72. package/dist/drawer/index.mjs +33 -0
  73. package/dist/drawer/index.mjs.map +1 -0
  74. package/dist/index.d.mts +19 -1
  75. package/dist/index.mjs +4 -1
  76. package/dist/internal/swipe-arithmetic.mjs +75 -0
  77. package/dist/internal/swipe-arithmetic.mjs.map +1 -0
  78. package/dist/internal/swipe.mjs +169 -0
  79. package/dist/internal/swipe.mjs.map +1 -0
  80. package/dist/menu/menu-context-trigger.mjs +1 -1
  81. package/dist/menu/menu-popup.mjs +1 -1
  82. package/dist/otp-field/index.d.mts +23 -0
  83. package/dist/otp-field/index.d.mts.map +1 -0
  84. package/dist/otp-field/index.mjs +23 -0
  85. package/dist/otp-field/index.mjs.map +1 -0
  86. package/dist/otp-field/otp-field-context.mjs +13 -0
  87. package/dist/otp-field/otp-field-context.mjs.map +1 -0
  88. package/dist/otp-field/otp-field-filter.d.mts +5 -0
  89. package/dist/otp-field/otp-field-filter.d.mts.map +1 -0
  90. package/dist/otp-field/otp-field-filter.mjs +135 -0
  91. package/dist/otp-field/otp-field-filter.mjs.map +1 -0
  92. package/dist/otp-field/otp-field-input.d.mts +41 -0
  93. package/dist/otp-field/otp-field-input.d.mts.map +1 -0
  94. package/dist/otp-field/otp-field-input.mjs +177 -0
  95. package/dist/otp-field/otp-field-input.mjs.map +1 -0
  96. package/dist/otp-field/otp-field-root.d.mts +143 -0
  97. package/dist/otp-field/otp-field-root.d.mts.map +1 -0
  98. package/dist/otp-field/otp-field-root.mjs +397 -0
  99. package/dist/otp-field/otp-field-root.mjs.map +1 -0
  100. package/dist/otp-field/otp-field-slot.d.mts +52 -0
  101. package/dist/otp-field/otp-field-slot.d.mts.map +1 -0
  102. package/dist/otp-field/otp-field-slot.mjs +67 -0
  103. package/dist/otp-field/otp-field-slot.mjs.map +1 -0
  104. package/package.json +4 -1
  105. package/skills/funstack-ui-knowledge/SKILL.md +5 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/drawer/index.ts"],"sourcesContent":["// Ships the platform attribute typings (`command`, `commandfor`) with this subpath\n// (conventions 7.4). Type-only: the built JS has no import of it.\nimport \"../internal/platform-attributes.js\";\nimport { DrawerClose } from \"./drawer-close.js\";\nimport { DrawerDescription } from \"./drawer-description.js\";\nimport { DrawerForm } from \"./drawer-form.js\";\nimport { DrawerPopup } from \"./drawer-popup.js\";\nimport { DrawerRoot } from \"./drawer-root.js\";\nimport { DrawerTitle } from \"./drawer-title.js\";\nimport { DrawerTrigger } from \"./drawer-trigger.js\";\n\n/**\n * A Dialog attached to an edge of the viewport that the user can swipe back to it: `Root` (no\n * DOM) > `Trigger` + `Popup` (`dialog[data-side]`) > `Title`, `Description`, `Close`, `Form`.\n * Every part runs the code of the matching Dialog part (JS-free mode included). The Popup adds\n * `side` (default `\"bottom\"`, rendered as `data-side`; your CSS places it) and `swipeDismiss`\n * (default on): a drag toward the edge writes `data-swiping` and `--drawer-swipe-x` / `-y` /\n * `-progress`, and a release past a quarter or a flick slides the drawer out and closes it, a\n * dismissal reported to `onOpenChange`. `lightDismiss` defaults to the Root's `modal`.\n * Transition types: `fsui-drawer`, `fsui-drawer-open`, `fsui-drawer-close`.\n *\n * @see https://ui.funstack.work/components/drawer\n */\nexport const Drawer = {\n Root: DrawerRoot,\n Trigger: DrawerTrigger,\n Popup: DrawerPopup,\n Title: DrawerTitle,\n Description: DrawerDescription,\n Close: DrawerClose,\n Form: DrawerForm,\n} as const;\n\nexport type { DrawerRootProps, DrawerRootState, DrawerOpenChangeDetails } from \"./drawer-root.js\";\nexport type { DrawerTriggerProps, DrawerTriggerState } from \"./drawer-trigger.js\";\nexport type { DrawerPopupProps, DrawerPopupState, DrawerSide } from \"./drawer-popup.js\";\nexport type { DrawerTitleProps, DrawerTitleState } from \"./drawer-title.js\";\nexport type { DrawerDescriptionProps, DrawerDescriptionState } from \"./drawer-description.js\";\nexport type { DrawerCloseProps, DrawerCloseState, DrawerCloseDetails } from \"./drawer-close.js\";\nexport type { DrawerFormProps, DrawerFormState } from \"./drawer-form.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,SAAS;CACpB,MAAM;CACN,SAAS;CACT,OAAO;CACP,OAAO;CACP,aAAa;CACb,OAAO;CACP,MAAM;AACR"}
package/dist/index.d.mts CHANGED
@@ -21,6 +21,10 @@ import { AlertDialogTitleProps, AlertDialogTitleState } from "./alert-dialog/ale
21
21
  import { DialogTriggerProps, DialogTriggerState } from "./dialog/dialog-trigger.mjs";
22
22
  import { AlertDialogTriggerProps, AlertDialogTriggerState } from "./alert-dialog/alert-dialog-trigger.mjs";
23
23
  import { AlertDialog } from "./alert-dialog/index.mjs";
24
+ import { AvatarRootProps, AvatarState, AvatarStatus } from "./avatar/avatar-root.mjs";
25
+ import { AvatarFallbackProps } from "./avatar/avatar-fallback.mjs";
26
+ import { AvatarImageProps } from "./avatar/avatar-image.mjs";
27
+ import { Avatar } from "./avatar/index.mjs";
24
28
  import { Button, ButtonActionDetails, ButtonProps, ButtonState } from "./button/button.mjs";
25
29
  import "./button/index.mjs";
26
30
  import { CheckboxGroupItemProps, CheckboxGroupItemState } from "./checkbox-group/checkbox-group-item.mjs";
@@ -49,6 +53,15 @@ import { CSPProvider, CSPProviderProps } from "./csp/csp-provider.mjs";
49
53
  import { STYLE_SHA256 } from "./csp/style-hashes.mjs";
50
54
  import "./csp/index.mjs";
51
55
  import { Dialog } from "./dialog/index.mjs";
56
+ import { DrawerCloseDetails, DrawerCloseProps, DrawerCloseState } from "./drawer/drawer-close.mjs";
57
+ import { DrawerDescriptionProps, DrawerDescriptionState } from "./drawer/drawer-description.mjs";
58
+ import { DrawerFormProps, DrawerFormState } from "./drawer/drawer-form.mjs";
59
+ import { DrawerSide } from "./drawer/drawer-swipe.mjs";
60
+ import { DrawerPopupProps, DrawerPopupState } from "./drawer/drawer-popup.mjs";
61
+ import { DrawerOpenChangeDetails, DrawerRootProps, DrawerRootState } from "./drawer/drawer-root.mjs";
62
+ import { DrawerTitleProps, DrawerTitleState } from "./drawer/drawer-title.mjs";
63
+ import { DrawerTriggerProps, DrawerTriggerState } from "./drawer/drawer-trigger.mjs";
64
+ import { Drawer } from "./drawer/index.mjs";
52
65
  import { FieldErrorValue, FieldValidity, FormErrors } from "./internal/form/validity.mjs";
53
66
  import { FieldState } from "./internal/form/field-context.mjs";
54
67
  import { FieldControlProps } from "./field/field-control.mjs";
@@ -149,6 +162,11 @@ import { NumberFieldButtonState, NumberFieldDecrementProps, NumberFieldIncrement
149
162
  import { NumberFieldInputProps } from "./number-field/number-field-input.mjs";
150
163
  import { NumberFieldLabelProps } from "./number-field/number-field-label.mjs";
151
164
  import { NumberField } from "./number-field/index.mjs";
165
+ import { OTPFieldCharset } from "./otp-field/otp-field-filter.mjs";
166
+ import { OTPFieldCompleteDetails, OTPFieldRootProps, OTPFieldState, OTPFieldValueChangeDetails } from "./otp-field/otp-field-root.mjs";
167
+ import { OTPFieldInputProps } from "./otp-field/otp-field-input.mjs";
168
+ import { OTPFieldSlotProps, OTPFieldSlotState } from "./otp-field/otp-field-slot.mjs";
169
+ import { OTPField } from "./otp-field/index.mjs";
152
170
  import { ProgressRootProps, ProgressState } from "./progress/progress-root.mjs";
153
171
  import { ProgressIndicatorProps } from "./progress/progress-indicator.mjs";
154
172
  import { ProgressLabelProps } from "./progress/progress-label.mjs";
@@ -162,4 +180,4 @@ import { MeterLabelProps } from "./meter/meter-label.mjs";
162
180
  import { MeterTrackProps } from "./meter/meter-track.mjs";
163
181
  import { MeterValueProps } from "./meter/meter-value.mjs";
164
182
  import { Meter } from "./meter/index.mjs";
165
- export { Accordion, type AccordionItemProps, type AccordionItemState, type AccordionPanelProps, type AccordionPanelState, type AccordionRootExclusiveProps, type AccordionRootMultipleProps, type AccordionRootProps, type AccordionRootState, type AccordionTriggerProps, type AccordionTriggerState, type AccordionValueChangeDetails, type Action, type ActionDetails, AlertDialog, type AlertDialogActionDetails, type AlertDialogActionProps, type AlertDialogActionState, type AlertDialogCancelDetails, type AlertDialogCancelProps, type AlertDialogCancelState, type AlertDialogDescriptionProps, type AlertDialogDescriptionState, type AlertDialogFormProps, type AlertDialogFormState, type AlertDialogOpenChangeDetails, type AlertDialogPopupProps, type AlertDialogPopupState, type AlertDialogRootProps, type AlertDialogRootState, type AlertDialogTitleProps, type AlertDialogTitleState, type AlertDialogTriggerProps, type AlertDialogTriggerState, Button, type ButtonActionDetails, type ButtonProps, type ButtonState, CSPProvider, type CSPProviderProps, type ChangeAction, type ChangeReason, Checkbox, type CheckboxCheckedChangeDetails, CheckboxGroup, type CheckboxGroupItemProps, type CheckboxGroupItemState, type CheckboxGroupLabelProps, type CheckboxGroupParentProps, type CheckboxGroupParentState, type CheckboxGroupRootProps, type CheckboxGroupRootState, type CheckboxGroupValueChangeDetails, type CheckboxProps, type CheckboxState, Collapsible, type CollapsibleOpenChangeDetails, type CollapsiblePanelProps, type CollapsiblePanelState, type CollapsibleRootProps, type CollapsibleRootState, type CollapsibleTriggerProps, type CollapsibleTriggerState, Combobox, type ComboboxChipProps, type ComboboxChipRemoveProps, type ComboboxChipRemoveState, type ComboboxChipState, type ComboboxChipsProps, type ComboboxChipsState, type ComboboxClearProps, type ComboboxClearState, type ComboboxEmptyProps, type ComboboxEmptyState, type ComboboxGroupLabelProps, type ComboboxGroupLabelState, type ComboboxGroupProps, type ComboboxGroupState, type ComboboxInputProps, type ComboboxInputState, type ComboboxInputValueChangeDetails, type ComboboxLabelProps, type ComboboxLabelState, type ComboboxListProps, type ComboboxListState, type ComboboxMultipleProps, type ComboboxMultipleRootState, type ComboboxMultipleValueChangeDetails, type ComboboxOpenChangeDetails, type ComboboxOptionProps, type ComboboxOptionState, type ComboboxPopupProps, type ComboboxPopupState, type ComboboxRootProps, type ComboboxRootState, type ComboboxSingleProps, type ComboboxStatusProps, type ComboboxStatusState, type ComboboxTriggerProps, type ComboboxTriggerState, type ComboboxValueChangeDetails, Dialog, type DialogCloseDetails, type DialogCloseProps, type DialogCloseState, type DialogDescriptionProps, type DialogDescriptionState, type DialogFormProps, type DialogFormState, type DialogOpenChangeDetails, type DialogPopupProps, type DialogPopupState, type DialogRootProps, type DialogRootState, type DialogTitleProps, type DialogTitleState, type DialogTriggerProps, type DialogTriggerState, Field, type FieldControlProps, type FieldDescriptionProps, type FieldErrorProps, type FieldErrorValue, type FieldLabelProps, type FieldRootProps, type FieldState, type FieldValidate, type FieldValidity, Form, type FormErrors, type FormRootProps, type FormRootState, type FormSubmitProps, type FormSubmitState, HoverCard, type HoverCardAlign, type HoverCardOpenChangeDetails, type HoverCardPopupProps, type HoverCardPopupState, type HoverCardRootProps, type HoverCardRootState, type HoverCardSide, type HoverCardTriggerProps, type HoverCardTriggerState, Menu, type MenuAlign, type MenuCheckboxItemProps, type MenuCheckboxItemState, type MenuContextTriggerProps, type MenuContextTriggerState, type MenuGroupLabelProps, type MenuGroupLabelState, type MenuGroupProps, type MenuGroupState, type MenuItemDetails, type MenuItemProps, type MenuItemState, type MenuOpenChangeDetails, type MenuPopupProps, type MenuPopupState, type MenuRadioGroupProps, type MenuRadioGroupState, type MenuRadioItemProps, type MenuRadioItemState, type MenuRootProps, type MenuRootState, type MenuSeparatorProps, type MenuSeparatorState, type MenuSide, type MenuSubmenuTriggerProps, type MenuSubmenuTriggerState, type MenuTriggerProps, type MenuTriggerState, Meter, type MeterIndicatorProps, type MeterLabelProps, type MeterRegion, type MeterRootProps, type MeterState, type MeterTrackProps, type MeterValueProps, MultiSelect, type MultiSelectEmptyProps, type MultiSelectEmptyState, type MultiSelectGroupLabelProps, type MultiSelectGroupLabelState, type MultiSelectGroupProps, type MultiSelectGroupState, type MultiSelectLabelProps, type MultiSelectLabelState, type MultiSelectListProps, type MultiSelectListState, type MultiSelectOpenChangeDetails, type MultiSelectOptionProps, type MultiSelectOptionState, type MultiSelectPopupProps, type MultiSelectPopupState, type MultiSelectRootProps, type MultiSelectRootState, type MultiSelectStatusProps, type MultiSelectStatusState, type MultiSelectTriggerProps, type MultiSelectTriggerState, type MultiSelectValueChangeDetails, type MultiSelectValueProps, type MultiSelectValueState, NumberField, type NumberFieldButtonState, type NumberFieldDecrementProps, type NumberFieldIncrementProps, type NumberFieldInputProps, type NumberFieldLabelProps, type NumberFieldRootProps, type NumberFieldState, type NumberFieldValueChangeDetails, Popover, type PopoverAlign, type PopoverCloseProps, type PopoverCloseState, type PopoverDescriptionProps, type PopoverDescriptionState, type PopoverOpenChangeDetails, type PopoverPopupProps, type PopoverPopupState, type PopoverRootProps, type PopoverRootState, type PopoverSide, type PopoverTitleProps, type PopoverTitleState, type PopoverTriggerProps, type PopoverTriggerState, Progress, type ProgressIndicatorProps, type ProgressLabelProps, type ProgressRootProps, type ProgressState, type ProgressTrackProps, type ProgressValueProps, RadioGroup, type RadioGroupItemProps, type RadioGroupItemState, type RadioGroupLabelProps, type RadioGroupRootProps, type RadioGroupRootState, type RadioGroupValueChangeDetails, type RenderProp, STYLE_SHA256, Select, type SelectGroupLabelProps, type SelectGroupProps, type SelectOptionProps, type SelectOptionState, type SelectRootProps, type SelectRootState, type SelectSeparatorProps, type SelectTriggerProps, type SelectValueChangeDetails, type SelectValueProps, Separator, type SeparatorOrientation, type SeparatorProps, type SeparatorState, Slider, type SliderIndicatorProps, type SliderIndicatorState, type SliderLabelProps, type SliderOrientation, type SliderRootProps, type SliderRootState, type SliderThumbProps, type SliderThumbState, type SliderTrackProps, type SliderTrackState, type SliderValue, type SliderValueChangeDetails, type SliderValueCommitDetails, type SliderValueProps, type SliderValueState, type StateValue, Switch, type SwitchCheckedChangeDetails, type SwitchProps, type SwitchState, Tabs, type TabsActivationMode, type TabsIndicatorProps, type TabsIndicatorState, type TabsListProps, type TabsListState, type TabsOrientation, type TabsPanelProps, type TabsPanelState, type TabsRootProps, type TabsRootState, type TabsTabProps, type TabsTabState, type TabsValueChangeDetails, Toast, type ToastActionDetails, type ToastActionOptions, type ToastActionProps, type ToastActionState, type ToastCloseDetails, type ToastCloseProps, type ToastCloseState, type ToastDescriptionProps, type ToastItem, type ToastManager, type ToastOptions, type ToastPriority, type ToastPromiseOptions, type ToastRootProps, type ToastRootState, type ToastTitleProps, type ToastViewportProps, type ToastViewportState, Toggle, ToggleGroup, type ToggleGroupExclusiveProps, type ToggleGroupItemProps, type ToggleGroupItemState, type ToggleGroupMultipleProps, type ToggleGroupOrientation, type ToggleGroupRootProps, type ToggleGroupRootState, type ToggleGroupValueChangeDetails, type TogglePressedChangeDetails, type ToggleProps, type ToggleState, Toolbar, type ToolbarOrientation, type ToolbarRootProps, type ToolbarRootState, type ToolbarSeparatorProps, type ToolbarSeparatorState, Tooltip, type TooltipAlign, type TooltipArrowProps, type TooltipArrowState, type TooltipPopupProps, type TooltipPopupState, type TooltipProvides, type TooltipRootProps, type TooltipRootState, type TooltipSide, type TooltipTriggerProps, type TooltipTriggerState, type UrgentChangeHandler, type UrgentHandler, type WhilePending, createToastManager, toast };
183
+ export { Accordion, type AccordionItemProps, type AccordionItemState, type AccordionPanelProps, type AccordionPanelState, type AccordionRootExclusiveProps, type AccordionRootMultipleProps, type AccordionRootProps, type AccordionRootState, type AccordionTriggerProps, type AccordionTriggerState, type AccordionValueChangeDetails, type Action, type ActionDetails, AlertDialog, type AlertDialogActionDetails, type AlertDialogActionProps, type AlertDialogActionState, type AlertDialogCancelDetails, type AlertDialogCancelProps, type AlertDialogCancelState, type AlertDialogDescriptionProps, type AlertDialogDescriptionState, type AlertDialogFormProps, type AlertDialogFormState, type AlertDialogOpenChangeDetails, type AlertDialogPopupProps, type AlertDialogPopupState, type AlertDialogRootProps, type AlertDialogRootState, type AlertDialogTitleProps, type AlertDialogTitleState, type AlertDialogTriggerProps, type AlertDialogTriggerState, Avatar, type AvatarFallbackProps, type AvatarImageProps, type AvatarRootProps, type AvatarState, type AvatarStatus, Button, type ButtonActionDetails, type ButtonProps, type ButtonState, CSPProvider, type CSPProviderProps, type ChangeAction, type ChangeReason, Checkbox, type CheckboxCheckedChangeDetails, CheckboxGroup, type CheckboxGroupItemProps, type CheckboxGroupItemState, type CheckboxGroupLabelProps, type CheckboxGroupParentProps, type CheckboxGroupParentState, type CheckboxGroupRootProps, type CheckboxGroupRootState, type CheckboxGroupValueChangeDetails, type CheckboxProps, type CheckboxState, Collapsible, type CollapsibleOpenChangeDetails, type CollapsiblePanelProps, type CollapsiblePanelState, type CollapsibleRootProps, type CollapsibleRootState, type CollapsibleTriggerProps, type CollapsibleTriggerState, Combobox, type ComboboxChipProps, type ComboboxChipRemoveProps, type ComboboxChipRemoveState, type ComboboxChipState, type ComboboxChipsProps, type ComboboxChipsState, type ComboboxClearProps, type ComboboxClearState, type ComboboxEmptyProps, type ComboboxEmptyState, type ComboboxGroupLabelProps, type ComboboxGroupLabelState, type ComboboxGroupProps, type ComboboxGroupState, type ComboboxInputProps, type ComboboxInputState, type ComboboxInputValueChangeDetails, type ComboboxLabelProps, type ComboboxLabelState, type ComboboxListProps, type ComboboxListState, type ComboboxMultipleProps, type ComboboxMultipleRootState, type ComboboxMultipleValueChangeDetails, type ComboboxOpenChangeDetails, type ComboboxOptionProps, type ComboboxOptionState, type ComboboxPopupProps, type ComboboxPopupState, type ComboboxRootProps, type ComboboxRootState, type ComboboxSingleProps, type ComboboxStatusProps, type ComboboxStatusState, type ComboboxTriggerProps, type ComboboxTriggerState, type ComboboxValueChangeDetails, Dialog, type DialogCloseDetails, type DialogCloseProps, type DialogCloseState, type DialogDescriptionProps, type DialogDescriptionState, type DialogFormProps, type DialogFormState, type DialogOpenChangeDetails, type DialogPopupProps, type DialogPopupState, type DialogRootProps, type DialogRootState, type DialogTitleProps, type DialogTitleState, type DialogTriggerProps, type DialogTriggerState, Drawer, type DrawerCloseDetails, type DrawerCloseProps, type DrawerCloseState, type DrawerDescriptionProps, type DrawerDescriptionState, type DrawerFormProps, type DrawerFormState, type DrawerOpenChangeDetails, type DrawerPopupProps, type DrawerPopupState, type DrawerRootProps, type DrawerRootState, type DrawerSide, type DrawerTitleProps, type DrawerTitleState, type DrawerTriggerProps, type DrawerTriggerState, Field, type FieldControlProps, type FieldDescriptionProps, type FieldErrorProps, type FieldErrorValue, type FieldLabelProps, type FieldRootProps, type FieldState, type FieldValidate, type FieldValidity, Form, type FormErrors, type FormRootProps, type FormRootState, type FormSubmitProps, type FormSubmitState, HoverCard, type HoverCardAlign, type HoverCardOpenChangeDetails, type HoverCardPopupProps, type HoverCardPopupState, type HoverCardRootProps, type HoverCardRootState, type HoverCardSide, type HoverCardTriggerProps, type HoverCardTriggerState, Menu, type MenuAlign, type MenuCheckboxItemProps, type MenuCheckboxItemState, type MenuContextTriggerProps, type MenuContextTriggerState, type MenuGroupLabelProps, type MenuGroupLabelState, type MenuGroupProps, type MenuGroupState, type MenuItemDetails, type MenuItemProps, type MenuItemState, type MenuOpenChangeDetails, type MenuPopupProps, type MenuPopupState, type MenuRadioGroupProps, type MenuRadioGroupState, type MenuRadioItemProps, type MenuRadioItemState, type MenuRootProps, type MenuRootState, type MenuSeparatorProps, type MenuSeparatorState, type MenuSide, type MenuSubmenuTriggerProps, type MenuSubmenuTriggerState, type MenuTriggerProps, type MenuTriggerState, Meter, type MeterIndicatorProps, type MeterLabelProps, type MeterRegion, type MeterRootProps, type MeterState, type MeterTrackProps, type MeterValueProps, MultiSelect, type MultiSelectEmptyProps, type MultiSelectEmptyState, type MultiSelectGroupLabelProps, type MultiSelectGroupLabelState, type MultiSelectGroupProps, type MultiSelectGroupState, type MultiSelectLabelProps, type MultiSelectLabelState, type MultiSelectListProps, type MultiSelectListState, type MultiSelectOpenChangeDetails, type MultiSelectOptionProps, type MultiSelectOptionState, type MultiSelectPopupProps, type MultiSelectPopupState, type MultiSelectRootProps, type MultiSelectRootState, type MultiSelectStatusProps, type MultiSelectStatusState, type MultiSelectTriggerProps, type MultiSelectTriggerState, type MultiSelectValueChangeDetails, type MultiSelectValueProps, type MultiSelectValueState, NumberField, type NumberFieldButtonState, type NumberFieldDecrementProps, type NumberFieldIncrementProps, type NumberFieldInputProps, type NumberFieldLabelProps, type NumberFieldRootProps, type NumberFieldState, type NumberFieldValueChangeDetails, OTPField, type OTPFieldCharset, type OTPFieldCompleteDetails, type OTPFieldInputProps, type OTPFieldRootProps, type OTPFieldSlotProps, type OTPFieldSlotState, type OTPFieldState, type OTPFieldValueChangeDetails, Popover, type PopoverAlign, type PopoverCloseProps, type PopoverCloseState, type PopoverDescriptionProps, type PopoverDescriptionState, type PopoverOpenChangeDetails, type PopoverPopupProps, type PopoverPopupState, type PopoverRootProps, type PopoverRootState, type PopoverSide, type PopoverTitleProps, type PopoverTitleState, type PopoverTriggerProps, type PopoverTriggerState, Progress, type ProgressIndicatorProps, type ProgressLabelProps, type ProgressRootProps, type ProgressState, type ProgressTrackProps, type ProgressValueProps, RadioGroup, type RadioGroupItemProps, type RadioGroupItemState, type RadioGroupLabelProps, type RadioGroupRootProps, type RadioGroupRootState, type RadioGroupValueChangeDetails, type RenderProp, STYLE_SHA256, Select, type SelectGroupLabelProps, type SelectGroupProps, type SelectOptionProps, type SelectOptionState, type SelectRootProps, type SelectRootState, type SelectSeparatorProps, type SelectTriggerProps, type SelectValueChangeDetails, type SelectValueProps, Separator, type SeparatorOrientation, type SeparatorProps, type SeparatorState, Slider, type SliderIndicatorProps, type SliderIndicatorState, type SliderLabelProps, type SliderOrientation, type SliderRootProps, type SliderRootState, type SliderThumbProps, type SliderThumbState, type SliderTrackProps, type SliderTrackState, type SliderValue, type SliderValueChangeDetails, type SliderValueCommitDetails, type SliderValueProps, type SliderValueState, type StateValue, Switch, type SwitchCheckedChangeDetails, type SwitchProps, type SwitchState, Tabs, type TabsActivationMode, type TabsIndicatorProps, type TabsIndicatorState, type TabsListProps, type TabsListState, type TabsOrientation, type TabsPanelProps, type TabsPanelState, type TabsRootProps, type TabsRootState, type TabsTabProps, type TabsTabState, type TabsValueChangeDetails, Toast, type ToastActionDetails, type ToastActionOptions, type ToastActionProps, type ToastActionState, type ToastCloseDetails, type ToastCloseProps, type ToastCloseState, type ToastDescriptionProps, type ToastItem, type ToastManager, type ToastOptions, type ToastPriority, type ToastPromiseOptions, type ToastRootProps, type ToastRootState, type ToastTitleProps, type ToastViewportProps, type ToastViewportState, Toggle, ToggleGroup, type ToggleGroupExclusiveProps, type ToggleGroupItemProps, type ToggleGroupItemState, type ToggleGroupMultipleProps, type ToggleGroupOrientation, type ToggleGroupRootProps, type ToggleGroupRootState, type ToggleGroupValueChangeDetails, type TogglePressedChangeDetails, type ToggleProps, type ToggleState, Toolbar, type ToolbarOrientation, type ToolbarRootProps, type ToolbarRootState, type ToolbarSeparatorProps, type ToolbarSeparatorState, Tooltip, type TooltipAlign, type TooltipArrowProps, type TooltipArrowState, type TooltipPopupProps, type TooltipPopupState, type TooltipProvides, type TooltipRootProps, type TooltipRootState, type TooltipSide, type TooltipTriggerProps, type TooltipTriggerState, type UrgentChangeHandler, type UrgentHandler, type WhilePending, createToastManager, toast };
package/dist/index.mjs CHANGED
@@ -12,6 +12,7 @@ import { Switch } from "./switch/switch.mjs";
12
12
  import { Checkbox } from "./checkbox/checkbox.mjs";
13
13
  import { Dialog } from "./dialog/index.mjs";
14
14
  import { AlertDialog } from "./alert-dialog/index.mjs";
15
+ import { Drawer } from "./drawer/index.mjs";
15
16
  import { Popover } from "./popover/index.mjs";
16
17
  import { Menu } from "./menu/index.mjs";
17
18
  import { RadioGroup } from "./radio-group/index.mjs";
@@ -23,10 +24,12 @@ import { createToastManager, toast } from "./toast/toast.mjs";
23
24
  import { Toast } from "./toast/index.mjs";
24
25
  import { Slider } from "./slider/index.mjs";
25
26
  import { NumberField } from "./number-field/index.mjs";
27
+ import { OTPField } from "./otp-field/index.mjs";
26
28
  import { Field } from "./field/index.mjs";
27
29
  import { Form } from "./form/index.mjs";
28
30
  import { Progress } from "./progress/index.mjs";
29
31
  import { Meter } from "./meter/index.mjs";
32
+ import { Avatar } from "./avatar/index.mjs";
30
33
  import { CSPProvider } from "./csp/csp-provider.mjs";
31
34
  import { STYLE_SHA256 } from "./csp/style-hashes.mjs";
32
- export { Accordion, AlertDialog, Button, CSPProvider, Checkbox, CheckboxGroup, Collapsible, Combobox, Dialog, Field, Form, HoverCard, Menu, Meter, MultiSelect, NumberField, Popover, Progress, RadioGroup, STYLE_SHA256, Select, Separator, Slider, Switch, Tabs, Toast, Toggle, ToggleGroup, Toolbar, Tooltip, createToastManager, toast };
35
+ export { Accordion, AlertDialog, Avatar, Button, CSPProvider, Checkbox, CheckboxGroup, Collapsible, Combobox, Dialog, Drawer, Field, Form, HoverCard, Menu, Meter, MultiSelect, NumberField, OTPField, Popover, Progress, RadioGroup, STYLE_SHA256, Select, Separator, Slider, Switch, Tabs, Toast, Toggle, ToggleGroup, Toolbar, Tooltip, createToastManager, toast };
@@ -0,0 +1,75 @@
1
+ /** A release at least this fraction of the extent toward the edge dismisses. */
2
+ const SWIPE_DISMISS_FRACTION = .25;
3
+ /** A release at least this fast toward the edge dismisses, in px/ms. */
4
+ const SWIPE_FLICK_VELOCITY = .5;
5
+ /** The unit vector of a direction. */
6
+ function swipeVector(direction) {
7
+ switch (direction) {
8
+ case "up": return [0, -1];
9
+ case "down": return [0, 1];
10
+ case "left": return [-1, 0];
11
+ case "right": return [1, 0];
12
+ }
13
+ }
14
+ /**
15
+ * The signed distance a movement `(dx, dy)` covers toward the edge: positive toward it,
16
+ * negative away from it.
17
+ */
18
+ function towardEdge(dx, dy, direction) {
19
+ const [x, y] = swipeVector(direction);
20
+ return dx * x + dy * y;
21
+ }
22
+ /**
23
+ * What a press that has moved `(dx, dy)` from where it went down is: `"wait"` while it is
24
+ * within the slop; once past it, `"start"` when it moved more along the axis than across it
25
+ * and toward the edge, else `"drop"` (the first move in another direction drops the press for
26
+ * good).
27
+ */
28
+ function classifyPress(dx, dy, direction) {
29
+ if (Math.hypot(dx, dy) < 6) return "wait";
30
+ const along = towardEdge(dx, dy, direction);
31
+ const [x] = swipeVector(direction);
32
+ return along > 0 && along > (x === 0 ? Math.abs(dx) : Math.abs(dy)) ? "start" : "drop";
33
+ }
34
+ /** The offset written while dragging: the distance toward the edge, never below 0. */
35
+ function swipeOffset(toward) {
36
+ return Math.max(0, toward);
37
+ }
38
+ /** The offset as a physical vector in px (`--drawer-swipe-x` / `-y`). */
39
+ function swipeTranslation(offset, direction) {
40
+ const [x, y] = swipeVector(direction);
41
+ return [offset * x + 0, offset * y + 0];
42
+ }
43
+ /** `offset / extent`, clamped to [0, 1]; 0 for an empty extent. */
44
+ function swipeProgress(offset, extent) {
45
+ if (!(extent > 0)) return 0;
46
+ return Math.min(1, Math.max(0, offset / extent));
47
+ }
48
+ /**
49
+ * The velocity toward the edge at the release (px/ms, negative when moving back): from the
50
+ * oldest sample within `SWIPE_VELOCITY_WINDOW` of the last one to the last one. 0 when the
51
+ * pointer did not move in that window (held still before the release) or there is one sample.
52
+ */
53
+ function releaseVelocity(samples) {
54
+ const last = samples.at(-1);
55
+ if (last === void 0) return 0;
56
+ const first = samples.find((sample) => last.time - sample.time <= 100);
57
+ if (first === void 0 || first === last) return 0;
58
+ const elapsed = last.time - first.time;
59
+ if (elapsed <= 0) return 0;
60
+ return (last.toward - first.toward) / elapsed;
61
+ }
62
+ /**
63
+ * The decision at the release: `"dismiss"` when the offset is at least a quarter of the extent
64
+ * or the release is a flick toward the edge, **but** `"return"` when the pointer was moving
65
+ * back; otherwise `"return"`.
66
+ */
67
+ function releaseOutcome(offset, extent, velocity) {
68
+ if (velocity < -.1) return "return";
69
+ if (velocity >= .5) return "dismiss";
70
+ return extent > 0 && offset >= extent * .25 ? "dismiss" : "return";
71
+ }
72
+ //#endregion
73
+ export { SWIPE_DISMISS_FRACTION, SWIPE_FLICK_VELOCITY, classifyPress, releaseOutcome, releaseVelocity, swipeOffset, swipeProgress, swipeTranslation, swipeVector, towardEdge };
74
+
75
+ //# sourceMappingURL=swipe-arithmetic.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swipe-arithmetic.mjs","names":[],"sources":["../../src/internal/swipe-arithmetic.ts"],"sourcesContent":["// The arithmetic of a swipe toward an edge (design/components/drawer.md 4.1): when a press\n// becomes a drag, how far it has gone toward the edge, its release velocity and the dismiss /\n// return decision. Pure functions, no DOM; the tracker (`swipe.ts`) feeds them. No directive\n// (conventions 7.1).\n\n/** The physical direction a swipe dismisses toward. */\nexport type SwipeDirection = \"up\" | \"down\" | \"left\" | \"right\";\n\n/** How far a press must move before it is a drag or is dropped, in px. */\nexport const SWIPE_SLOP = 6;\n/** A release at least this fraction of the extent toward the edge dismisses. */\nexport const SWIPE_DISMISS_FRACTION = 0.25;\n/** A release at least this fast toward the edge dismisses, in px/ms. */\nexport const SWIPE_FLICK_VELOCITY = 0.5;\n/** A release moving back faster than this (away from the edge) returns, in px/ms. */\nexport const SWIPE_REVERSAL_VELOCITY = 0.1;\n/** The release velocity is measured over this much of the gesture's end, in ms. */\nexport const SWIPE_VELOCITY_WINDOW = 100;\n\n/** The unit vector of a direction. */\nexport function swipeVector(direction: SwipeDirection): readonly [x: number, y: number] {\n switch (direction) {\n case \"up\":\n return [0, -1];\n case \"down\":\n return [0, 1];\n case \"left\":\n return [-1, 0];\n case \"right\":\n return [1, 0];\n }\n}\n\n/**\n * The signed distance a movement `(dx, dy)` covers toward the edge: positive toward it,\n * negative away from it.\n */\nexport function towardEdge(dx: number, dy: number, direction: SwipeDirection): number {\n const [x, y] = swipeVector(direction);\n return dx * x + dy * y;\n}\n\n/**\n * What a press that has moved `(dx, dy)` from where it went down is: `\"wait\"` while it is\n * within the slop; once past it, `\"start\"` when it moved more along the axis than across it\n * and toward the edge, else `\"drop\"` (the first move in another direction drops the press for\n * good).\n */\nexport function classifyPress(\n dx: number,\n dy: number,\n direction: SwipeDirection,\n): \"wait\" | \"start\" | \"drop\" {\n if (Math.hypot(dx, dy) < SWIPE_SLOP) return \"wait\";\n const along = towardEdge(dx, dy, direction);\n const [x] = swipeVector(direction);\n const across = x === 0 ? Math.abs(dx) : Math.abs(dy);\n return along > 0 && along > across ? \"start\" : \"drop\";\n}\n\n/** The offset written while dragging: the distance toward the edge, never below 0. */\nexport function swipeOffset(toward: number): number {\n return Math.max(0, toward);\n}\n\n/** The offset as a physical vector in px (`--drawer-swipe-x` / `-y`). */\nexport function swipeTranslation(\n offset: number,\n direction: SwipeDirection,\n): readonly [x: number, y: number] {\n const [x, y] = swipeVector(direction);\n // `+ 0` turns a `-0` into `0`.\n return [offset * x + 0, offset * y + 0];\n}\n\n/** `offset / extent`, clamped to [0, 1]; 0 for an empty extent. */\nexport function swipeProgress(offset: number, extent: number): number {\n if (!(extent > 0)) return 0;\n return Math.min(1, Math.max(0, offset / extent));\n}\n\n/** One point of the gesture: a time (ms) and the signed distance toward the edge. */\nexport interface SwipeSample {\n readonly time: number;\n readonly toward: number;\n}\n\n/**\n * The velocity toward the edge at the release (px/ms, negative when moving back): from the\n * oldest sample within `SWIPE_VELOCITY_WINDOW` of the last one to the last one. 0 when the\n * pointer did not move in that window (held still before the release) or there is one sample.\n */\nexport function releaseVelocity(samples: readonly SwipeSample[]): number {\n const last = samples.at(-1);\n if (last === undefined) return 0;\n const first = samples.find((sample) => last.time - sample.time <= SWIPE_VELOCITY_WINDOW);\n if (first === undefined || first === last) return 0;\n const elapsed = last.time - first.time;\n if (elapsed <= 0) return 0;\n return (last.toward - first.toward) / elapsed;\n}\n\n/**\n * The decision at the release: `\"dismiss\"` when the offset is at least a quarter of the extent\n * or the release is a flick toward the edge, **but** `\"return\"` when the pointer was moving\n * back; otherwise `\"return\"`.\n */\nexport function releaseOutcome(\n offset: number,\n extent: number,\n velocity: number,\n): \"dismiss\" | \"return\" {\n if (velocity < -SWIPE_REVERSAL_VELOCITY) return \"return\";\n if (velocity >= SWIPE_FLICK_VELOCITY) return \"dismiss\";\n return extent > 0 && offset >= extent * SWIPE_DISMISS_FRACTION ? \"dismiss\" : \"return\";\n}\n"],"mappings":";AAWA,MAAa,yBAAyB;;AAEtC,MAAa,uBAAuB;;AAOpC,SAAgB,YAAY,WAA4D;CACtF,QAAQ,WAAR;EACE,KAAK,MACH,OAAO,CAAC,GAAG,EAAE;EACf,KAAK,QACH,OAAO,CAAC,GAAG,CAAC;EACd,KAAK,QACH,OAAO,CAAC,IAAI,CAAC;EACf,KAAK,SACH,OAAO,CAAC,GAAG,CAAC;CAChB;AACF;;;;;AAMA,SAAgB,WAAW,IAAY,IAAY,WAAmC;CACpF,MAAM,CAAC,GAAG,KAAK,YAAY,SAAS;CACpC,OAAO,KAAK,IAAI,KAAK;AACvB;;;;;;;AAQA,SAAgB,cACd,IACA,IACA,WAC2B;CAC3B,IAAI,KAAK,MAAM,IAAI,EAAE,IAAA,GAAgB,OAAO;CAC5C,MAAM,QAAQ,WAAW,IAAI,IAAI,SAAS;CAC1C,MAAM,CAAC,KAAK,YAAY,SAAS;CAEjC,OAAO,QAAQ,KAAK,SADL,MAAM,IAAI,KAAK,IAAI,EAAE,IAAI,KAAK,IAAI,EAAE,KACd,UAAU;AACjD;;AAGA,SAAgB,YAAY,QAAwB;CAClD,OAAO,KAAK,IAAI,GAAG,MAAM;AAC3B;;AAGA,SAAgB,iBACd,QACA,WACiC;CACjC,MAAM,CAAC,GAAG,KAAK,YAAY,SAAS;CAEpC,OAAO,CAAC,SAAS,IAAI,GAAG,SAAS,IAAI,CAAC;AACxC;;AAGA,SAAgB,cAAc,QAAgB,QAAwB;CACpE,IAAI,EAAE,SAAS,IAAI,OAAO;CAC1B,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,SAAS,MAAM,CAAC;AACjD;;;;;;AAaA,SAAgB,gBAAgB,SAAyC;CACvE,MAAM,OAAO,QAAQ,GAAG,EAAE;CAC1B,IAAI,SAAS,KAAA,GAAW,OAAO;CAC/B,MAAM,QAAQ,QAAQ,MAAM,WAAW,KAAK,OAAO,OAAO,QAAA,GAA6B;CACvF,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM,OAAO;CAClD,MAAM,UAAU,KAAK,OAAO,MAAM;CAClC,IAAI,WAAW,GAAG,OAAO;CACzB,QAAQ,KAAK,SAAS,MAAM,UAAU;AACxC;;;;;;AAOA,SAAgB,eACd,QACA,QACA,UACsB;CACtB,IAAI,WAAW,KAA0B,OAAO;CAChD,IAAI,YAAA,IAAkC,OAAO;CAC7C,OAAO,SAAS,KAAK,UAAU,SAAA,MAAkC,YAAY;AAC/E"}
@@ -0,0 +1,169 @@
1
+ import { classifyPress, releaseOutcome, releaseVelocity, swipeOffset, swipeProgress, towardEdge } from "./swipe-arithmetic.mjs";
2
+ import { capturePointer } from "./pointer-capture.mjs";
3
+ //#region src/internal/swipe.ts
4
+ /** The document's selection when it is not collapsed, else `null`. */
5
+ function selectionOf(doc) {
6
+ const selection = doc.getSelection();
7
+ if (selection === null || selection.isCollapsed) return null;
8
+ const { anchorNode, anchorOffset, focusNode, focusOffset } = selection;
9
+ return {
10
+ anchorNode,
11
+ anchorOffset,
12
+ focusNode,
13
+ focusOffset
14
+ };
15
+ }
16
+ /** Whether the press made a text selection: one exists now and it is not the one it found. */
17
+ function selectedSincePress(doc, before) {
18
+ const now = selectionOf(doc);
19
+ if (now === null) return false;
20
+ return before === null || now.anchorNode !== before.anchorNode || now.anchorOffset !== before.anchorOffset || now.focusNode !== before.focusNode || now.focusOffset !== before.focusOffset;
21
+ }
22
+ /**
23
+ * Tracks swipes on `element`. A primary press the caller accepts is only recorded: no capture,
24
+ * no `preventDefault()`, so a tap, a click and a text selection are untouched. When it has
25
+ * moved `SWIPE_SLOP` px, more along the axis than across and toward the edge, it becomes a drag
26
+ * (the pointer is captured on `element`) unless the press's `pointerdown` was
27
+ * `defaultPrevented` (read then, so a handler that ran after the capture-phase listener
28
+ * counts), another element took the pointer's capture, or a mouse press made a text selection.
29
+ * A first move in another direction drops the press.
30
+ */
31
+ function trackSwipe(element, options) {
32
+ const doc = element.ownerDocument;
33
+ let press = null;
34
+ const detachPress = () => {
35
+ doc.removeEventListener("pointermove", onMove, true);
36
+ doc.removeEventListener("pointerup", onUp, true);
37
+ doc.removeEventListener("pointercancel", onCancel, true);
38
+ doc.removeEventListener("gotpointercapture", onGotCapture, true);
39
+ element.removeEventListener("lostpointercapture", onLostCapture);
40
+ };
41
+ /** Forget the press; release the capture of a drag that did not end with the button. */
42
+ const clear = () => {
43
+ const current = press;
44
+ press = null;
45
+ detachPress();
46
+ if (current?.dragging) {
47
+ const id = current.event.pointerId;
48
+ try {
49
+ if (element.hasPointerCapture(id)) element.releasePointerCapture(id);
50
+ } catch {}
51
+ }
52
+ };
53
+ const finish = (outcome, event) => {
54
+ const current = press;
55
+ if (current === null || !current.dragging) {
56
+ clear();
57
+ return;
58
+ }
59
+ const { offset, extent } = current;
60
+ clear();
61
+ options.end({
62
+ outcome,
63
+ event,
64
+ offset,
65
+ extent
66
+ });
67
+ };
68
+ const onDown = (event) => {
69
+ if (press !== null) {
70
+ if (event.isPrimary && event.pointerId !== press.event.pointerId) finish("cancel", event);
71
+ else return;
72
+ }
73
+ if (!event.isPrimary || event.button !== 0) return;
74
+ const direction = options.press(event);
75
+ if (direction === null) return;
76
+ press = {
77
+ event,
78
+ direction,
79
+ selection: event.pointerType === "mouse" ? selectionOf(doc) : null,
80
+ capturedElsewhere: false,
81
+ dragging: false,
82
+ extent: 0,
83
+ offset: 0,
84
+ samples: [{
85
+ time: event.timeStamp,
86
+ toward: 0
87
+ }]
88
+ };
89
+ doc.addEventListener("pointermove", onMove, true);
90
+ doc.addEventListener("pointerup", onUp, true);
91
+ doc.addEventListener("pointercancel", onCancel, true);
92
+ doc.addEventListener("gotpointercapture", onGotCapture, true);
93
+ };
94
+ const onGotCapture = (event) => {
95
+ const current = press;
96
+ if (current === null || current.dragging) return;
97
+ if (event.pointerId !== current.event.pointerId) return;
98
+ const target = event.target;
99
+ if (target === element) return;
100
+ if (current.event.pointerType !== "mouse" && target === current.event.target) return;
101
+ current.capturedElsewhere = true;
102
+ };
103
+ /** The press becomes a drag, or is dropped (`false`). */
104
+ const tryStart = (current, event) => {
105
+ if (current.event.defaultPrevented || current.capturedElsewhere) return false;
106
+ if (current.event.pointerType === "mouse" && selectedSincePress(doc, current.selection)) return false;
107
+ if (!capturePointer(element, current.event.pointerId)) return false;
108
+ current.dragging = true;
109
+ current.extent = options.extent();
110
+ element.addEventListener("lostpointercapture", onLostCapture);
111
+ options.start(event);
112
+ return true;
113
+ };
114
+ const follow = (current, event) => {
115
+ const toward = towardEdge(event.clientX - current.event.clientX, event.clientY - current.event.clientY, current.direction);
116
+ current.samples.push({
117
+ time: event.timeStamp,
118
+ toward
119
+ });
120
+ current.offset = swipeOffset(toward);
121
+ if (current.event.pointerType === "mouse" && selectedSincePress(doc, current.selection)) doc.getSelection()?.removeAllRanges();
122
+ options.move(current.offset, swipeProgress(current.offset, current.extent), event);
123
+ };
124
+ const onMove = (event) => {
125
+ const current = press;
126
+ if (current === null || event.pointerId !== current.event.pointerId) return;
127
+ if (!current.dragging) {
128
+ const verdict = classifyPress(event.clientX - current.event.clientX, event.clientY - current.event.clientY, current.direction);
129
+ if (verdict === "wait") return;
130
+ if (verdict === "drop" || !tryStart(current, event)) {
131
+ clear();
132
+ return;
133
+ }
134
+ }
135
+ follow(current, event);
136
+ };
137
+ const onUp = (event) => {
138
+ const current = press;
139
+ if (current === null || event.pointerId !== current.event.pointerId) return;
140
+ if (!current.dragging) {
141
+ clear();
142
+ return;
143
+ }
144
+ follow(current, event);
145
+ const velocity = releaseVelocity(current.samples);
146
+ finish(releaseOutcome(current.offset, current.extent, velocity), event);
147
+ };
148
+ const onCancel = (event) => {
149
+ if (press === null || event.pointerId !== press.event.pointerId) return;
150
+ finish("cancel", event);
151
+ };
152
+ const onLostCapture = (event) => {
153
+ if (press === null || event.pointerId !== press.event.pointerId) return;
154
+ finish("cancel", event);
155
+ };
156
+ element.addEventListener("pointerdown", onDown, true);
157
+ return {
158
+ dragging: () => press?.dragging ?? false,
159
+ cancel: clear,
160
+ dispose: () => {
161
+ clear();
162
+ element.removeEventListener("pointerdown", onDown, true);
163
+ }
164
+ };
165
+ }
166
+ //#endregion
167
+ export { trackSwipe };
168
+
169
+ //# sourceMappingURL=swipe.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swipe.mjs","names":[],"sources":["../../src/internal/swipe.ts"],"sourcesContent":["// The swipe tracker (design/components/drawer.md 4.1, 9): Pointer Events bookkeeping for a drag\n// of an element toward one of its edges, for mouse, pen and touch alike. It knows nothing of\n// dialogs: the caller says which presses are candidates, which way the edge is and how far it\n// is, and gets `start`, `move(offset)` and `end` callbacks. Drawer uses it; Toast's reserved\n// swipe (toast.md 9.2) is meant to. No directive: DOM listeners only (conventions 7.1).\nimport { capturePointer } from \"./pointer-capture.js\";\nimport {\n classifyPress,\n releaseOutcome,\n releaseVelocity,\n swipeOffset,\n swipeProgress,\n towardEdge,\n} from \"./swipe-arithmetic.js\";\nimport type { SwipeDirection, SwipeSample } from \"./swipe-arithmetic.js\";\n\n/** How a gesture that started ended. */\nexport interface SwipeEnd {\n /**\n * `\"dismiss\"`: released past the threshold or with a flick toward the edge. `\"return\"`:\n * released short of it, or moving back. `\"cancel\"`: the browser took the pointer\n * (`pointercancel`), the capture was lost, or another primary press came.\n */\n readonly outcome: \"dismiss\" | \"return\" | \"cancel\";\n /** The `pointerup`, the `pointercancel` or `lostpointercapture`, or the new press. */\n readonly event: Event;\n /** The offset reached, px. */\n readonly offset: number;\n /** The extent measured at the start, px. */\n readonly extent: number;\n}\n\nexport interface SwipeTrackerOptions {\n /**\n * Whether a primary-button press can become a swipe, at the `pointerdown` (capture phase on\n * the element). Return the direction of the edge, or `null` for a press that is not a\n * candidate.\n */\n readonly press: (event: PointerEvent) => SwipeDirection | null;\n /**\n * The distance (px) that takes the element fully off its edge, measured once when the drag\n * starts, before the first `move`.\n */\n readonly extent: () => number;\n /** The drag started (the pointer is captured); `move` follows at once with the first offset. */\n readonly start: (event: PointerEvent) => void;\n /** The offset toward the edge (px, never below 0) and its fraction of the extent. */\n readonly move: (offset: number, progress: number, event: PointerEvent) => void;\n /** The drag ended. Not called for `cancel()` or `dispose()`. */\n readonly end: (end: SwipeEnd) => void;\n}\n\nexport interface SwipeTracker {\n /** Whether a drag is in progress (between `start` and `end`). */\n readonly dragging: () => boolean;\n /** Drop the press or the drag without calling `end` (the caller ends it its own way). */\n readonly cancel: () => void;\n /** Remove every listener. */\n readonly dispose: () => void;\n}\n\ninterface Press {\n readonly event: PointerEvent;\n readonly direction: SwipeDirection;\n readonly selection: SelectionSnapshot | null;\n /** Another element took the pointer's capture after the press (a slider thumb, a map). */\n capturedElsewhere: boolean;\n dragging: boolean;\n extent: number;\n offset: number;\n samples: SwipeSample[];\n}\n\ninterface SelectionSnapshot {\n readonly anchorNode: Node | null;\n readonly anchorOffset: number;\n readonly focusNode: Node | null;\n readonly focusOffset: number;\n}\n\n/** The document's selection when it is not collapsed, else `null`. */\nfunction selectionOf(doc: Document): SelectionSnapshot | null {\n const selection = doc.getSelection();\n if (selection === null || selection.isCollapsed) return null;\n const { anchorNode, anchorOffset, focusNode, focusOffset } = selection;\n return { anchorNode, anchorOffset, focusNode, focusOffset };\n}\n\n/** Whether the press made a text selection: one exists now and it is not the one it found. */\nfunction selectedSincePress(doc: Document, before: SelectionSnapshot | null): boolean {\n const now = selectionOf(doc);\n if (now === null) return false;\n return (\n before === null ||\n now.anchorNode !== before.anchorNode ||\n now.anchorOffset !== before.anchorOffset ||\n now.focusNode !== before.focusNode ||\n now.focusOffset !== before.focusOffset\n );\n}\n\n/**\n * Tracks swipes on `element`. A primary press the caller accepts is only recorded: no capture,\n * no `preventDefault()`, so a tap, a click and a text selection are untouched. When it has\n * moved `SWIPE_SLOP` px, more along the axis than across and toward the edge, it becomes a drag\n * (the pointer is captured on `element`) unless the press's `pointerdown` was\n * `defaultPrevented` (read then, so a handler that ran after the capture-phase listener\n * counts), another element took the pointer's capture, or a mouse press made a text selection.\n * A first move in another direction drops the press.\n */\nexport function trackSwipe(element: HTMLElement, options: SwipeTrackerOptions): SwipeTracker {\n const doc = element.ownerDocument;\n let press: Press | null = null;\n\n const detachPress = (): void => {\n doc.removeEventListener(\"pointermove\", onMove, true);\n doc.removeEventListener(\"pointerup\", onUp, true);\n doc.removeEventListener(\"pointercancel\", onCancel, true);\n doc.removeEventListener(\"gotpointercapture\", onGotCapture, true);\n element.removeEventListener(\"lostpointercapture\", onLostCapture);\n };\n\n /** Forget the press; release the capture of a drag that did not end with the button. */\n const clear = (): void => {\n const current = press;\n press = null;\n detachPress();\n if (current?.dragging) {\n const id = current.event.pointerId;\n try {\n if (element.hasPointerCapture(id)) element.releasePointerCapture(id);\n } catch {\n // Not an active pointer any more.\n }\n }\n };\n\n const finish = (outcome: SwipeEnd[\"outcome\"], event: Event): void => {\n const current = press;\n if (current === null || !current.dragging) {\n clear();\n return;\n }\n const { offset, extent } = current;\n clear();\n options.end({ outcome, event, offset, extent });\n };\n\n const onDown = (event: PointerEvent): void => {\n if (press !== null) {\n // A second primary press (another pointer type) ends what the first one did.\n if (event.isPrimary && event.pointerId !== press.event.pointerId) finish(\"cancel\", event);\n else return;\n }\n if (!event.isPrimary || event.button !== 0) return;\n const direction = options.press(event);\n if (direction === null) return;\n press = {\n event,\n direction,\n selection: event.pointerType === \"mouse\" ? selectionOf(doc) : null,\n capturedElsewhere: false,\n dragging: false,\n extent: 0,\n offset: 0,\n // The motion starts at the press: an engine may coalesce a flick's moves into the one\n // `pointermove` that starts the drag, and the velocity must still see the whole flick.\n samples: [{ time: event.timeStamp, toward: 0 }],\n };\n doc.addEventListener(\"pointermove\", onMove, true);\n doc.addEventListener(\"pointerup\", onUp, true);\n doc.addEventListener(\"pointercancel\", onCancel, true);\n doc.addEventListener(\"gotpointercapture\", onGotCapture, true);\n };\n\n const onGotCapture = (event: Event): void => {\n const current = press;\n if (current === null || current.dragging) return;\n if ((event as PointerEvent).pointerId !== current.event.pointerId) return;\n const target = event.target;\n if (target === element) return;\n // Touch and pen capture the pointer to the pressed element implicitly (Pointer Events 3).\n if (current.event.pointerType !== \"mouse\" && target === current.event.target) return;\n current.capturedElsewhere = true;\n };\n\n /** The press becomes a drag, or is dropped (`false`). */\n const tryStart = (current: Press, event: PointerEvent): boolean => {\n if (current.event.defaultPrevented || current.capturedElsewhere) return false;\n if (current.event.pointerType === \"mouse\" && selectedSincePress(doc, current.selection)) {\n return false;\n }\n if (!capturePointer(element, current.event.pointerId)) return false;\n current.dragging = true;\n current.extent = options.extent();\n element.addEventListener(\"lostpointercapture\", onLostCapture);\n options.start(event);\n return true;\n };\n\n const follow = (current: Press, event: PointerEvent): void => {\n const toward = towardEdge(\n event.clientX - current.event.clientX,\n event.clientY - current.event.clientY,\n current.direction,\n );\n current.samples.push({ time: event.timeStamp, toward });\n current.offset = swipeOffset(toward);\n // Firefox keeps extending the text selection of the press under pointer capture: a drag\n // moves, it does not select (Chromium selects nothing once captured).\n if (current.event.pointerType === \"mouse\" && selectedSincePress(doc, current.selection)) {\n doc.getSelection()?.removeAllRanges();\n }\n options.move(current.offset, swipeProgress(current.offset, current.extent), event);\n };\n\n const onMove = (event: PointerEvent): void => {\n const current = press;\n if (current === null || event.pointerId !== current.event.pointerId) return;\n if (!current.dragging) {\n const verdict = classifyPress(\n event.clientX - current.event.clientX,\n event.clientY - current.event.clientY,\n current.direction,\n );\n if (verdict === \"wait\") return;\n if (verdict === \"drop\" || !tryStart(current, event)) {\n clear();\n return;\n }\n }\n follow(current, event);\n };\n\n const onUp = (event: PointerEvent): void => {\n const current = press;\n if (current === null || event.pointerId !== current.event.pointerId) return;\n if (!current.dragging) {\n clear();\n return;\n }\n // The release position is the gesture's last (an engine may coalesce the final move into\n // the `pointerup`).\n follow(current, event);\n const velocity = releaseVelocity(current.samples);\n finish(releaseOutcome(current.offset, current.extent, velocity), event);\n };\n\n const onCancel = (event: PointerEvent): void => {\n if (press === null || event.pointerId !== press.event.pointerId) return;\n finish(\"cancel\", event);\n };\n\n const onLostCapture = (event: PointerEvent): void => {\n if (press === null || event.pointerId !== press.event.pointerId) return;\n // The `pointerup` comes first (it releases the capture after its dispatch), so this is a\n // capture taken away mid-drag.\n finish(\"cancel\", event);\n };\n\n element.addEventListener(\"pointerdown\", onDown, true);\n\n return {\n dragging: () => press?.dragging ?? false,\n cancel: clear,\n dispose: () => {\n clear();\n element.removeEventListener(\"pointerdown\", onDown, true);\n },\n };\n}\n"],"mappings":"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"}
@@ -3,9 +3,9 @@ import { dataAttr } from "../internal/data-attr.mjs";
3
3
  import { useDevWarning } from "../internal/use-dev-warning.mjs";
4
4
  import { resolveStateValue } from "../internal/render-element.mjs";
5
5
  import { useRender } from "../internal/use-render.mjs";
6
+ import { capturePointer } from "../internal/pointer-capture.mjs";
6
7
  import { MenuRegionContext, claimPress, isPressClaimed, markHandled, useMenuContext } from "./menu-context.mjs";
7
8
  import { isEditableTarget } from "./menu-dom.mjs";
8
- import { capturePointer } from "../internal/pointer-capture.mjs";
9
9
  import { armClickSwallow, guardTouch, isTouchLike, startDrag } from "./menu-gestures.mjs";
10
10
  import { useCallback, useEffect, useRef } from "react";
11
11
  import { jsx } from "react/jsx-runtime";
@@ -12,9 +12,9 @@ import { CSPContext } from "../internal/csp-context.mjs";
12
12
  import { FSUI_PRECEDENCE } from "../internal/shipped-styles.mjs";
13
13
  import { listenInvokerPresses } from "../internal/overlay/invokers.mjs";
14
14
  import { usePopoverPopup } from "../internal/overlay/use-popover-popup.mjs";
15
+ import { capturePointer } from "../internal/pointer-capture.mjs";
15
16
  import { MenuListContext, claimPress, useMenuContext } from "./menu-context.mjs";
16
17
  import { edgeItem } from "./menu-dom.mjs";
17
- import { capturePointer } from "../internal/pointer-capture.mjs";
18
18
  import { scheduleHoverClose } from "./menu-hover.mjs";
19
19
  import { listenOutside } from "./menu-outside.mjs";
20
20
  import { MENU_POINT_HREF, MENU_POINT_RULES, pointStyle } from "./menu-point.mjs";
@@ -0,0 +1,23 @@
1
+ import { OTPFieldCharset } from "./otp-field-filter.mjs";
2
+ import { OTPFieldCompleteDetails, OTPFieldRoot, OTPFieldRootProps, OTPFieldState, OTPFieldValueChangeDetails } from "./otp-field-root.mjs";
3
+ import { OTPFieldInput, OTPFieldInputProps } from "./otp-field-input.mjs";
4
+ import { OTPFieldSlot, OTPFieldSlotProps, OTPFieldSlotState } from "./otp-field-slot.mjs";
5
+ //#region src/otp-field/index.d.ts
6
+ /**
7
+ * OTPField: a field for a short code the user received elsewhere (an SMS or email code, an
8
+ * authenticator's digits, a PIN). `Root` (`div`, owns the text) > `Input` (the one
9
+ * `<input autocomplete="one-time-code">`, covering the Root with transparent text) + `Slot`s
10
+ * (`aria-hidden` spans that draw one character each, `data-filled`, `data-active`). The text is
11
+ * urgent (`value` / `defaultValue` / `onValueChange`); a complete code runs `completeAction` in the
12
+ * Root's transition with `data-pending`, and `submitOnComplete` submits the Input's form.
13
+ *
14
+ * @see https://ui.funstack.work/components/otp-field
15
+ */
16
+ export declare const OTPField: {
17
+ readonly Root: typeof OTPFieldRoot;
18
+ readonly Input: typeof OTPFieldInput;
19
+ readonly Slot: typeof OTPFieldSlot;
20
+ };
21
+ //#endregion
22
+ export type { OTPFieldCharset, OTPFieldCompleteDetails, OTPFieldInputProps, OTPFieldRootProps, OTPFieldSlotProps, OTPFieldSlotState, OTPFieldState, OTPFieldValueChangeDetails };
23
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/otp-field/index.ts"],"mappings":";;;;;;;;;;;;;;;qBAca;WACX,aAAI;WACJ,cAAK;WACL,aAAI"}
@@ -0,0 +1,23 @@
1
+ import { OTPFieldInput } from "./otp-field-input.mjs";
2
+ import { OTPFieldRoot } from "./otp-field-root.mjs";
3
+ import { OTPFieldSlot } from "./otp-field-slot.mjs";
4
+ //#region src/otp-field/index.ts
5
+ /**
6
+ * OTPField: a field for a short code the user received elsewhere (an SMS or email code, an
7
+ * authenticator's digits, a PIN). `Root` (`div`, owns the text) > `Input` (the one
8
+ * `<input autocomplete="one-time-code">`, covering the Root with transparent text) + `Slot`s
9
+ * (`aria-hidden` spans that draw one character each, `data-filled`, `data-active`). The text is
10
+ * urgent (`value` / `defaultValue` / `onValueChange`); a complete code runs `completeAction` in the
11
+ * Root's transition with `data-pending`, and `submitOnComplete` submits the Input's form.
12
+ *
13
+ * @see https://ui.funstack.work/components/otp-field
14
+ */
15
+ const OTPField = {
16
+ Root: OTPFieldRoot,
17
+ Input: OTPFieldInput,
18
+ Slot: OTPFieldSlot
19
+ };
20
+ //#endregion
21
+ export { OTPField };
22
+
23
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/otp-field/index.ts"],"sourcesContent":["import { OTPFieldInput } from \"./otp-field-input.js\";\nimport { OTPFieldRoot } from \"./otp-field-root.js\";\nimport { OTPFieldSlot } from \"./otp-field-slot.js\";\n\n/**\n * OTPField: a field for a short code the user received elsewhere (an SMS or email code, an\n * authenticator's digits, a PIN). `Root` (`div`, owns the text) > `Input` (the one\n * `<input autocomplete=\"one-time-code\">`, covering the Root with transparent text) + `Slot`s\n * (`aria-hidden` spans that draw one character each, `data-filled`, `data-active`). The text is\n * urgent (`value` / `defaultValue` / `onValueChange`); a complete code runs `completeAction` in the\n * Root's transition with `data-pending`, and `submitOnComplete` submits the Input's form.\n *\n * @see https://ui.funstack.work/components/otp-field\n */\nexport const OTPField = {\n Root: OTPFieldRoot,\n Input: OTPFieldInput,\n Slot: OTPFieldSlot,\n} as const;\n\nexport type {\n OTPFieldRootProps,\n OTPFieldState,\n OTPFieldValueChangeDetails,\n OTPFieldCompleteDetails,\n} from \"./otp-field-root.js\";\nexport type { OTPFieldInputProps } from \"./otp-field-input.js\";\nexport type { OTPFieldSlotProps, OTPFieldSlotState } from \"./otp-field-slot.js\";\nexport type { OTPFieldCharset } from \"./otp-field-filter.js\";\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAa,WAAW;CACtB,MAAM;CACN,OAAO;CACP,MAAM;AACR"}
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import { createContext, use } from "react";
3
+ //#region src/otp-field/otp-field-context.ts
4
+ const OTPFieldContext = createContext(null);
5
+ function useOTPFieldContext(part) {
6
+ const context = use(OTPFieldContext);
7
+ if (context === null) throw new Error(`${part} must be rendered inside an OTPField.Root.`);
8
+ return context;
9
+ }
10
+ //#endregion
11
+ export { OTPFieldContext, useOTPFieldContext };
12
+
13
+ //# sourceMappingURL=otp-field-context.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otp-field-context.mjs","names":[],"sources":["../../src/otp-field/otp-field-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport type { ChangeEvent, RefObject } from \"react\";\nimport type { OTPFieldCharset } from \"./otp-field-filter.js\";\nimport type { OTPFieldState } from \"./otp-field-root.js\";\n\nexport interface OTPFieldContextValue {\n /** The state every part's function props receive. */\n readonly state: OTPFieldState;\n readonly charset: OTPFieldCharset;\n /** Own `name` ?? the Field's. */\n readonly name: string | undefined;\n readonly form: string | undefined;\n /** Own `required` || the Field's. */\n readonly required: boolean;\n /** Inside a `Field.Root`: whether an error is shown. `undefined` outside a Field. */\n readonly fieldInvalid: boolean | undefined;\n /** The text the Input renders: the raw text while a composition is open, else the value. */\n readonly inputText: string;\n /** The active slots, `[from, to)` (design 4.3). */\n readonly active: readonly [from: number, to: number];\n readonly experimentalWebOTP: boolean;\n /** The Input element. */\n readonly inputRef: RefObject<HTMLInputElement | null>;\n /** The Input's `onChange`: the filter of design 4.1. */\n readonly change: (event: ChangeEvent<HTMLInputElement>) => void;\n /** The Input's native listeners (installed by the Input on its element). */\n readonly beforeInput: (event: InputEvent) => void;\n readonly compositionStart: () => void;\n readonly compositionEnd: (event: CompositionEvent) => void;\n readonly selectionChanged: () => void;\n readonly blurred: () => void;\n readonly click: (event: MouseEvent) => void;\n /** The Input's mount: adopts text typed, autofilled or restored before hydration (design 9). */\n readonly inputMounted: () => void;\n /** A WebOTP credential's code (design 8). */\n readonly webOTPCode: (code: string) => void;\n /** The pending WebOTP request, aborted when the code is completed by hand. */\n readonly webOTPAbort: RefObject<AbortController | null>;\n /** A completion happened: no WebOTP request starts any more (design 8). */\n readonly webOTPDone: RefObject<boolean>;\n /** Registers a Slot's element under its index; returns the cleanup. */\n readonly registerSlot: (index: number, element: HTMLElement) => () => void;\n}\n\nexport const OTPFieldContext = createContext<OTPFieldContextValue | null>(null);\n\nexport function useOTPFieldContext(part: string): OTPFieldContextValue {\n const context = use(OTPFieldContext);\n if (context === null) throw new Error(`${part} must be rendered inside an OTPField.Root.`);\n return context;\n}\n"],"mappings":";;;AA6CA,MAAa,kBAAkB,cAA2C,IAAI;AAE9E,SAAgB,mBAAmB,MAAoC;CACrE,MAAM,UAAU,IAAI,eAAe;CACnC,IAAI,YAAY,MAAM,MAAM,IAAI,MAAM,GAAG,KAAK,2CAA2C;CACzF,OAAO;AACT"}
@@ -0,0 +1,5 @@
1
+ //#region src/otp-field/otp-field-filter.d.ts
2
+ /** Which characters a code may contain (design/components/otp-field.md 3). */
3
+ export type OTPFieldCharset = "numeric" | "alphanumeric" | "alphabetic";
4
+ //#endregion
5
+ //# sourceMappingURL=otp-field-filter.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otp-field-filter.d.mts","names":[],"sources":["../../src/otp-field/otp-field-filter.ts"],"mappings":";;YAIY"}